[IMP] mrp_subproduct: added onchange method for product_uom field in mrp.subproduct object
bzr revid: cha@tinyerp.com-20121003111335-qyu7e0683gj3zt3o
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
from osv import fields
|
||||
from osv import osv
|
||||
import decimal_precision as dp
|
||||
from tools.translate import _
|
||||
|
||||
class mrp_subproduct(osv.osv):
|
||||
_name = 'mrp.subproduct'
|
||||
@@ -51,6 +52,17 @@ class mrp_subproduct(osv.osv):
|
||||
return {'value': v}
|
||||
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
|
||||
|
||||
mrp_subproduct()
|
||||
|
||||
class mrp_bom(osv.osv):
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
<field name="sub_products">
|
||||
<tree string="sub products" editable="top">
|
||||
<field name="product_id" on_change="onchange_product_id(product_id)"/>
|
||||
<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="product_qty"/>
|
||||
<field name="subproduct_type"/>
|
||||
</tree>
|
||||
<form string="Sub Products">
|
||||
<field name="product_id" on_change="onchange_product_id(product_id)"/>
|
||||
<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="product_qty"/>
|
||||
<field name="subproduct_type"/>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user