Skip to Content
Menu
This question has been flagged
2 Replies
696 Views

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

Avatar
Discard
Best Answer

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

Hope it helps, Thanks

Avatar
Discard
Best Answer

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

Avatar
Discard