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

How to change form field value on onchange event

By
Claudio Ponziani
on 11/18/15, 2:53 AM 449 views

I have a problem related to set data on a form on a onchange event. On saleorderline i want to set the quantity automatically when I change the product. But I have linked product to a one2many ean13 codes that have information about the quantity. So I redefine the search of the product searching on the other table linked to the products containing the quantity information, but when i type the code of the products in the onchange I have only the product_id and lost the code_id linked to the search field so I cannot retrive te quantity information. Do you have an idea how I can have in the onchange other information about the id passed???

I post the code of the onchange, the parameter ean13_id would be an ean13_id and not a product_id, or I would have to add a parameter about the code typed to search the product.

    def ean13_id_change_with_wh(self, cr, uid, ids, ean13_id, context=None):
if context is None:
context = {}
res = {}
ean_obj = self.pool.get('product.ean13').browse(cr, uid, ean13_id, context)
if ean13_id:
res = {
'value':{
'product_id':ean_obj.product_id,
'product_uom_qty':ean_obj.quantity
}
}
return res

my friend plz did you put the onchange in yyou xml and plz print to me what did you get in ean_obj = self.pool.get('product.ean13').browse(cr, uid, ean13_id, context)

Drees Far
on 11/18/15, 4:15 AM

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: 11/18/15, 2:53 AM
Seen: 449 times
Last updated: 11/18/15, 4:15 AM