Skip to content
Snippets Groups Projects
Commit 3bcf43b0 authored by Divyesh Makwana's avatar Divyesh Makwana
Browse files

[ADD] product : Override create method in order to check 'Min margin' and 'Max margin'.

bzr revid: mdi@tinyerp.com-20120924121542-0031rv1ozrxlvc9a
parent 8957669d
Branches
Tags
No related merge requests found
......@@ -434,13 +434,22 @@ class product_pricelist_item(osv.osv):
if prod[0]['code']:
return {'value': {'name': prod[0]['code']}}
return {}
def write(self, cr, uid, ids, vals, context=None):
name = self.browse(cr, uid, ids, context=context)[0].name
def create(self, cr, uid, vals, context=None):
name = vals.get('name', '')
price_min_margin = vals.get('price_min_margin', 0.0)
price_max_margin = vals.get('price_max_margin', 0.0)
if price_min_margin > price_max_margin:
raise osv.except_osv(_('Warning!'), _('Minimum margin must be lower than maximum margin in \'%s\' pricelist rule !.') % (name))
return super(product_pricelist_item, self).create(cr, uid, vals, context=context)
def write(self, cr, uid, ids, vals, context=None):
price_min_margin = vals.get('price_min_margin', 0.0)
price_max_margin = vals.get('price_max_margin', 0.0)
for rule in self.browse(cr, uid, ids, context=context):
name = rule.name
if price_min_margin > price_max_margin:
raise osv.except_osv(_('Warning!'), _('Minimum margin must be lower than maximum margin in \'%s\' pricelist rule !.') % (name))
return super(product_pricelist_item, self).write(cr, uid, ids, vals, context=context)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment