How to write domain filter onchange function for one2many field.
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
1
Reply
4646
Views
dear Giezel Esteves,
for v7:
def on_change_company_id(self, cr, uid, ids, company_id=False, context=None): res= {} currency_id= False company_journal_ids= [] if company_id: company_journal_obj= self.pool.get('company.journal.configuration') company_journal_ids= company_journal_obj.search(cr, uid, [('company_id','=',company_id)], context=context) res= {'domain':{'company_ids':[('id','in',company_journal_ids)]}} return res |
<field name="company_id" on_change="on_change_company_id(company_id)"/> <field name="company_ids"/> |
on v8:
@api.multi @api.onchange('company_id') def on_change_company_id(self): res= {} company_list= [] if self.company_id: company_journal_obj= self.env['company.journal.configuration'] company_journal_ids=company_journal_obj.search([('company_id','=', self.company_id.id)]) for record in company_journal_ids: company_list.append(record.id) res= {'domain':{'company_ids':[('id','in',company_list)]}} return res |
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
0
Sep 23
|
498 | ||
|
0
Sep 23
|
451 | ||
|
2
Feb 23
|
9254 | ||
|
6
Oct 23
|
19285 | ||
|
3
Mar 24
|
7695 |