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
- Contabilità
- Magazzino
- PoS
- Project
- MRP
La domanda è stata contrassegnata
2
Risposte
2506
Visualizzazioni
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?
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!
Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!
Registrati