Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
887 มุมมอง

Hello,

 I have a model like this:

class MyClass(models.Model):
_name = 'my.class'

product_id = fields.Many2one(string='Product', comodel_name='product.product')
picking_id = fields.Many2one(string='Picking', comodel_name='stock.picking')

@onchange('product_id')
def _change_product(self):
return {'domain': {'product_id': [('id', 'in', [ml.id for ml in self.picking_id.move_lines])] if self.picking_id else []}}

This works fine, after changing the product_id of the mMyClass instance. However I would like to have a pre-load correct domain and I don't know how to do it.

Thanks in advance.

Boris

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi, you can follow this: https://youtu.be/f3mq5fHRPT0

Hope it helps, Thanks

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,
You can use the web_domain field by OCA, see how to use the app here:  Return Dynamic Domain For Field In Odoo

Thanks

อวตาร
ละทิ้ง