[ADD] product : Added warning message on onchange of min/max margin value.

bzr revid: mdi@tinyerp.com-20120924073126-ejkeieiz81zc1udo
This commit is contained in:
Divyesh Makwana (Open ERP) 2012-09-24 13:01:26 +05:30
parent 779ec69dba
commit d86cc61f08
2 changed files with 20 additions and 3 deletions

View File

@ -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()

View File

@ -20,7 +20,11 @@
<field name="date_end"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
</group>
<field name="items_id"/>
<notebook>
<page string="Rules">
<field name="items_id"/>
</page>
</notebook>
</form>
</field>
</record>
@ -103,8 +107,8 @@
<field name="price_surcharge" nolabel="1"/>
<newline/>
<field name="price_round" string="Rounding Method"/>
<field name="price_min_margin" string="Min. Margin"/>
<field name="price_max_margin" string="Max. Margin"/>
<field name="price_min_margin" string="Min. Margin" on_change="onchange_margin(price_min_margin, price_max_margin)"/>
<field name="price_max_margin" string="Max. Margin" on_change="onchange_margin(price_min_margin, price_max_margin)"/>
</group>
</form>