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:
- 客戶關係
- e-Commerce
- 會計
- 庫存
- PoS
- Project
- MRP
此問題已被標幟
2
回覆
2495
瀏覽次數
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?