Odoo Help


Method on_change_product(product_id) dosn't change when I choose a product between product_id and product_uom

Achref Mhadhbi
on 6/17/15, 2:38 PM 988 views

class Product(models.Model):

_name = 'operation.product'

product_id = fields.Many2one('product.product', string="Product")

product_qty = fields.Float(digits=(6, 2), help="Quantity")

product_uom= fields.Many2one('product.uom', string ="Unit of Measure",required=True)

def onchange_product_id(self, cr, uid, ids, product_id, context=None):

""" Changes UoM if product_id changes.

@param product_id: Changed product_id

@return: Dictionary of changed values


res = {}

if product_id:

prod = self.pool.get('product.product').browse(cr, uid, product_id, context=context)

res['value'] = {

'product_uom': prod.uom_id.id


return res

view: operation.xml

class Dailyreport(models.Model):

_name = 'operation.dailyreport'

name = fields.Char(required=True)

product_ids = fields.One2many('operation.product','product_id',string="Article")

<page string="Received">

<field name="product_ids">

<tree string="Products">

<field name="product_id" on_change="onchange_product_id(product_id)"/>

<field name="product_uom" />

<field name="product_qty"/>




Please I need your Help

Maurice Agée
On 9/5/15, 12:08 PM


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: 6/17/15, 2:38 PM
Seen: 988 times
Last updated: 9/10/15, 10:05 AM