Hello,
I want to use domain on field:
[('partner_id', '=', partner id)] <- when partner_id filed is set;
[] <- when partner_id field is empty
How to archive this?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
2
Replies
2230
Views
Hi, Grzegorz
You can achieve your requirement using "onchange" decorator in Odoo. Like below example
@api.onchange('partner_id')
def _onchange_partner_id(self):
res = {'domain': {'partner_id': []}}
if self.partner_id:
res['domain']['partner_id'] = [('partner_id', '=', partner_id.id)]
return res
Feel free to ask in case you have any confusion related to the above code.
Thanks,
Ashish Singh (Team Lead)
Webkul Software Private Limited
Thanks for the answer.
This will work only when partner_id is updated, not in existing records with partner_id set earlier.
Any way to trigger this dynamic domain code every time when form view is loaded?
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up