how to change the following code into odoo 11
def onchange_grade_chemical(self, cr, uid, ids, grade, context=None):
product_grade_obj = self.pool.get('production.product_grade')
ls = []
bo_id = product_grade_obj.search(cr, uid, [('id','=',grade)])
for li in product_grade_obj.browse(cr, uid, bo_id):
for line in li.chemical_line_ids:
result = {'standard_from':line.standard_from,'standard_to':line.standard_to,'name':line.name.id,'sequence':line.sequence}
ls.append(result)
if grade:
return {'value': {'rutile_chemical_line_ids':ls}}
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
2067
Views
Hi,
The following should work (untested as I do not have the field definitions etc):
@api.onchange('your_field') def onchange_grade_chemical(self): product_grade_obj = self.env['product.product_grade'] ls = [] bo_id = product_grade_obj.search([('id','=',grade)]) for li in bo_id: for line in li.chemical_line_ids: result = {'standard_from': line.standard_from, 'standard_to':line.standard_to, 'name':line.name.id, 'sequence':line.sequence} ls.append(result) if grade: return {'value': {'rutile_chemical_line_ids':ls}}
You basically have to remove all cr statements and slightly change the code, from self.pool.get to self.env[] for example.
I've noticed that you've posted more of these before if I'm not mistaking. Don't forget that the official help forums are made to help people, not to do their development for them.
Best of luck.
Regards,
Yenthe
I've noticed that you've posted more of these before if I'm not mistaking. Don't forget that the official help forums are made to help people, not to do their development for them.
Best of luck.
Regards,
Yenthe
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 | |
---|---|---|---|---|
|
2
Jul 24
|
941 | ||
|
1
Jun 24
|
3563 | ||
|
4
Apr 24
|
25378 | ||
|
1
Oct 23
|
8590 | ||
|
1
Oct 23
|
97 |