From d86cc61f08b76b0127458487dc7ff3c5c7a1801a Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Mon, 24 Sep 2012 13:01:26 +0530 Subject: [PATCH] [ADD] product : Added warning message on onchange of min/max margin value. bzr revid: mdi@tinyerp.com-20120924073126-ejkeieiz81zc1udo --- addons/product/pricelist.py | 13 +++++++++++++ addons/product/pricelist_view.xml | 10 +++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) 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 @@ - - + +