[IMP] mrp: added onchange method for product_uom field
bzr revid: cha@tinyerp.com-20121003103608-1uuh3t9mw7i2scif
This commit is contained in:
parent
2d3d478784
commit
bb4b253dfd
|
@ -274,6 +274,17 @@ class mrp_bom(osv.osv):
|
||||||
return {'value': {'name': prod.name, 'product_uom': prod.uom_id.id}}
|
return {'value': {'name': prod.name, 'product_uom': prod.uom_id.id}}
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
def onchange_uom(self, cr, uid, ids, product_id, product_uom, context=None):
|
||||||
|
res = {'value':{}}
|
||||||
|
if not product_uom or not product_id:
|
||||||
|
return res
|
||||||
|
product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
|
||||||
|
uom = self.pool.get('product.uom').browse(cr, uid, product_uom, context=context)
|
||||||
|
if uom.category_id.id != product.uom_id.category_id.id:
|
||||||
|
res['warning'] = {'title': _('Warning'), 'message': _('Selected Unit of Measure does not belong to the same category as the product Unit of Measure.')}
|
||||||
|
res['value'].update({'product_uom': product.uom_id.id})
|
||||||
|
return res
|
||||||
|
|
||||||
def _bom_find(self, cr, uid, product_id, product_uom, properties=None):
|
def _bom_find(self, cr, uid, product_id, product_uom, properties=None):
|
||||||
""" Finds BoM for particular product and product uom.
|
""" Finds BoM for particular product and product uom.
|
||||||
@param product_id: Selected product.
|
@param product_id: Selected product.
|
||||||
|
|
|
@ -351,7 +351,7 @@
|
||||||
<label for="product_qty" string="Quantity"/>
|
<label for="product_qty" string="Quantity"/>
|
||||||
<div>
|
<div>
|
||||||
<field name="product_qty" class="oe_inline"/>
|
<field name="product_qty" class="oe_inline"/>
|
||||||
<field name="product_uom" class="oe_inline" groups="product.group_uom"/>
|
<field name="product_uom" class="oe_inline" on_change="onchange_uom(product_id, product_uom)" groups="product.group_uom"/>
|
||||||
</div>
|
</div>
|
||||||
<label for="product_uos_qty" groups="product.group_uos"/>
|
<label for="product_uos_qty" groups="product.group_uos"/>
|
||||||
<div groups="product.group_uos" >
|
<div groups="product.group_uos" >
|
||||||
|
@ -382,7 +382,7 @@
|
||||||
<tree string="Components" editable="bottom">
|
<tree string="Components" editable="bottom">
|
||||||
<field name="product_id" on_change="onchange_product_id(product_id, name)"/>
|
<field name="product_id" on_change="onchange_product_id(product_id, name)"/>
|
||||||
<field name="product_qty"/>
|
<field name="product_qty"/>
|
||||||
<field name="product_uom" groups="product.group_uom"/>
|
<field name="product_uom" on_change="onchange_uom(product_id, product_uom)" groups="product.group_uom"/>
|
||||||
<field name="name" invisible="1"/>
|
<field name="name" invisible="1"/>
|
||||||
<field name="date_start"/>
|
<field name="date_start"/>
|
||||||
<field name="date_stop"/>
|
<field name="date_stop"/>
|
||||||
|
|
Loading…
Reference in New Issue