Skip to Content
Menu
This question has been flagged
709 Views
I have this model and method in odoo

class stock_transfer_details_items(models.TransientModel):
_inherit = 'stock.transfer_details_items'
 
lot_id = fields.Many2one('stock.production.lot', Lot/Serial Number')
q_auth = fields.Boolean(related='lot_id.q_auth', string="Quality Auth.")
needs_auth = fields.Boolean(related='product_id.needs_quality_auth')
 
@api.onchange("needs_auth")
def _onchange_NQA_domain(self):
domain = {'domain': {'lot_id': [('product_id', '=', rec.product_id.id)]}}
if rec.needs_auth:
domain = {'domain': {'lot_id': [('q_auth', '!=', False), ('product_id', '=', rec.product_id.id)]}}
return domain

All this code is working ok. My problem is that I need to apply this domain when the wizard opens. `@api.depends` means that the value changes depending on the value of needs_auth but it actually don't work if I don't interact with the checkbox of needs_auth. I want to apply the domain when the view is open and not interact with the needs_auth field, because the user will not be allow to interact.
Avatar
Discard
Related Posts Replies Views Activity
2
Mar 24
574
0
Feb 24
1202
1
Nov 22
1769
0
Aug 22
1054
1
Jul 22
2725