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.

1

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

By
Achref Mhadhbi
on 6/17/15, 2:38 PM 533 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"/>

</tree>

</field>

</page>

Please I need your Help

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

 

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