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
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
2
Trả lời
2501
Lượt xem
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?
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký