diff --git a/addons/mrp_subproduct/mrp_subproduct.py b/addons/mrp_subproduct/mrp_subproduct.py index bacdeb2c675..87a9fc6fdd7 100644 --- a/addons/mrp_subproduct/mrp_subproduct.py +++ b/addons/mrp_subproduct/mrp_subproduct.py @@ -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): diff --git a/addons/mrp_subproduct/mrp_subproduct_view.xml b/addons/mrp_subproduct/mrp_subproduct_view.xml index 94da87ef0de..b9e8fcc41ed 100644 --- a/addons/mrp_subproduct/mrp_subproduct_view.xml +++ b/addons/mrp_subproduct/mrp_subproduct_view.xml @@ -11,13 +11,13 @@ - +
- +