Hello, I need to know how I could define a domain according to the value of another field in the form
these are the two domains you would need to activate one or the other depending on the value of another field x_availability
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello, I need to know how I could define a domain according to the value of another field in the form
these are the two domains you would need to activate one or the other depending on the value of another field x_availability
Hi,
You can define a domain according to the value of
another field in the form view by using the dynamic domain, you can
refer to the following code for how to use a dynamic domain.
field_1 = fields.Many2many('project.task.type')field_2 = fields.Many2one('project.task.type', domain="[('id', 'in', stage_ids)]")
@api.onchange('project_id')
def _onchange_project_id(self):
data = []
for rec in self.env['project.task.type'].search([]):
if self.project_id.id in rec.project_ids.ids:
data.append(rec.id)
self.field_1 = data
in the above code, the value for the field field_2 will be shown based on the value field_1.
Hope it helps
Создайте аккаунт сегодня, чтобы получить доступ к эксклюзивным функциям и стать частью нашего замечательного сообщества!
Регистрация| Похожие посты | Ответы | Просмотры | Активность | |
|---|---|---|---|---|
|
3
мая 24
|
7188 | |||
|
0
нояб. 23
|
1645 | |||
|
4
нояб. 23
|
3840 | |||
|
2
дек. 21
|
6996 | |||
|
lock fields in a view
Решено
|
1
мая 21
|
4212 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.