Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1583 Zobrazení
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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
3
čvc 25
3863
0
kvě 25
731
2
bře 24
1932
1
lis 22
2976
0
srp 22
1764