"""
onchange handler of product_uom.
"""
- if context is None:
- context = {}
- context = dict(context, uom_change=True)
if not uom_id:
return {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'notes': notes or'', 'product_uom' : uom_id or False}}
return self.onchange_product_id(cr, uid, ids, pricelist_id, product_id, qty, uom_id,
"""
onchange handler of product_id.
- :param dict context: 'uom_change' key in context override default onchange
- behaviour which force product's UoM, allowing to
- specify an 'uom_id' of the same category as product's
- UoM (ex: set when called from product_uom's onchange).
+ :param dict context: 'force_product_uom' key in context override
+ default onchange behaviour to force using the UoM
+ defined on the provided product
"""
if context is None:
context = {}
# - check that uom and product uom belong to the same category
product_uom_po_id = product.uom_po_id.id
- if not uom_id or not context.get('uom_change'):
+ if not uom_id or context.get('force_product_uom'):
uom_id = product_uom_po_id
if product.uom_id.category_id.id != product_uom.browse(cr, uid, uom_id, context=context).category_id.id:
<form string="Purchase Order Line">
<notebook colspan="4">
<page string="Order Line">
- <field name="product_id" colspan="4" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,context)" required="1"/>
+ <field name="product_id" colspan="4" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,context)" required="1" context="{'force_product_uom': True}"/>
<field name="product_qty" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,context)"/>
<field name="product_uom" on_change="onchange_product_uom(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,context)"/>
<field colspan="4" name="name"/>
"""
onchange handler for product_id.
- :param dict context: 'uom_change' key in context override default onchange
- behaviour which force product's UoM, allowing to
- specify an 'uom_id' of the same category as product's
- UoM (ex: set when called from product_uom's onchange).
-
+ :param dict context: 'force_product_uom' key in context override
+ default onchange behaviour to force using the UoM
+ defined on the provided product
"""
if context is None:
context = {}
uom2 = False
if uom:
uom2 = product_uom_obj.browse(cr, uid, uom, context=context)
- if product_obj.uom_id.category_id.id != uom2.category_id.id or not context.get('uom_change',False):
+ if product_obj.uom_id.category_id.id != uom2.category_id.id or context.get('force_product_uom'):
uom = False
uom2 = False
if uos:
if context is None:
context = {}
lang = lang or context.get('lang',False)
- context = dict(context, uom_change=True)
res = self.product_id_change(cursor, user, ids, pricelist, product,
qty=qty, uom=uom, qty_uos=qty_uos, uos=uos, name=name,
partner_id=partner_id, lang=lang, update_tax=update_tax,
<page string="Order Line">
<group colspan="4" col="5">
<field colspan="3"
- context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'shop':parent.shop_id, 'uom':product_uom}"
+ context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'shop':parent.shop_id, 'uom':product_uom, 'force_product_uom': True}"
name="product_id"
on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, False, True, parent.date_order, product_packaging, parent.fiscal_position, False, context)"/>
<field name="name"/>