diff --git a/addons/product/pricelist.py b/addons/product/pricelist.py index 9b37dc0fe07..02b2605d8cf 100644 --- a/addons/product/pricelist.py +++ b/addons/product/pricelist.py @@ -437,6 +437,19 @@ class product_pricelist_item(osv.osv): if prod[0]['code']: return {'value': {'name': prod[0]['code']}} return {} + + def onchange_margin(self, cr, uid, ids, price_min_margin, price_max_margin, context=None): + res = {'value': {}} + if not price_min_margin and not price_max_margin: + return res + if price_min_margin > price_max_margin: + res['warning'] = {'title': _('Warning!'), 'message': _('Minimum Margin must be lower than Maximum Margin !.')} + pricelist_rule = self.browse(cr, uid, ids, context=context)[0] + min_margin = pricelist_rule.price_min_margin + max_margin = pricelist_rule.price_max_margin + res['value'].update({'price_min_margin': min_margin, 'price_max_margin': max_margin}) + return res + product_pricelist_item() diff --git a/addons/product/pricelist_view.xml b/addons/product/pricelist_view.xml index dc120660c43..7dcdeae15e8 100644 --- a/addons/product/pricelist_view.xml +++ b/addons/product/pricelist_view.xml @@ -20,7 +20,11 @@ - + + + + + @@ -103,8 +107,8 @@ - - + +