Odoo Help


Help about onchange decorator in V9

on 3/2/16, 4:49 AM 1,165 views

Hi, i have to migrate a custom module from V8 to V9.

I have to remove the onchange of the field product_id in my view to put it on my model:

Before : (i show you only the line with my error)


def product_id_change(self,cr,uid,ids, pricelist, product, qty=0,uom=False, qty_uos=0, uos=False, name='', partner_id=False,lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None):

context = context or {}

Now, i try this :



def product_id_change(self):

context = self.context or {}

But when i try to add an item in a quotation (sales), i've this error :

File "/usr/local/lib/python2.7/dist-packages/odoo-9.0c-py2.7.egg/openerp/addons/BHC_Ingram_WIPv9/sale.py", line 106, in product_id_change context = self.context or {} AttributeError: 'sale.order.line' object has no attribute 'context'

Thanks in advance for help.

What exactly this api.onchange should do?

Lucas Huber
on 3/2/16, 9:30 AM


on 3/2/16, 9:42 AM
On 3/2/16, 5:14 AM

Ok, instead this line :

context = self.context or {}

It's that :

context = self._context or {}

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 3/2/16, 4:49 AM
Seen: 1165 times
Last updated: 3/2/16, 9:42 AM