تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
3864 أدوات العرض
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


الصورة الرمزية
إهمال
أفضل إجابة

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

Hope it helps,

Thanks

الصورة الرمزية
إهمال
أفضل إجابة

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
6009
0
نوفمبر 23
1044
4
نوفمبر 23
2768
2
ديسمبر 21
6104
1
مايو 21
3655