Odoo Help

Welcome!

This community 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.

0

Help about onchange decorator in V9

By
Tatorus
on 3/2/16, 4:49 AM 568 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)

@api.v7

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 :

@api.multi

@api.onchange('product_id')

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

http://odoo-new-api-guide-line.readthedocs.org/en/latest/decorator.html#api-onchange

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

Ok, instead this line :

context = self.context or {}

It's that :

context = self._context or {}

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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