Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
3 Ответы
5126 Представления
For the time off app we should be able to dynamically filter the company in the time off type list. I have worked with an Onchange function which also works perfectly. The problem is only when I open the form that domain should not apply yet. There is no list of items to see as long as I set employee field for example. This is not a problem for the managers, but it is for the employee who wants to request leave. He now does not see a list, which must also be filtered by company. Here's my code:
@api.onchange('employee_id')
def _onchange_employee_id(self):
for rec in self:
return {'domain': {'holiday_status_id': [('valid', '=', True),
('company_id', '=', rec.employee_id.company_id.id)]}}
@api.onchange('mode_company_id')
def _onchange_mode_company_id(self):
for rec in self:
return {'domain': {'holiday_status_id': [('valid', '=', True),
('company_id', '=', rec.mode_company_id.id)]}}

@api.onchange('department_id')
def _onchange_department_id(self):
for rec in self:
return {'domain': {'holiday_status_id': [('valid', '=', True),
('company_id', '=', rec.department_id.company_id.id)]}}


Аватар
Отменить
Лучший ответ

You can follow this: https://youtu.be/XGqXEL2qQmE

Hope it helps,

Thanks

Аватар
Отменить
Лучший ответ

Returning a domain using onchange method has been deprecated in Odoo 14.


You can use the new way as mentioned in the below link:

https://github.com/odoo/odoo/pull/41918#issuecomment-824946980

Аватар
Отменить
Лучший ответ

Hello Indira.

Try using this code.

@api.onchange('holiday_status_id')
def _onchange_employee_id(self):
    return {'domain': {'holiday_status_id': [('valid', '=', True),('company_id','=',self.employee_id.company_id.id)]}}


Аватар
Отменить
Related Posts Ответы Просмотры Активность
0
февр. 25
18
1
сент. 19
4251
0
мар. 15
3693
2
мар. 15
6666
1
мар. 15
3573