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
1860
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