Modified product_id_change for warning message according to packaging
bzr revid: ruchakpatel@gmail.com-20080916085119-pdfdf1bbdj253jyc
This commit is contained in:
parent
e6dc1ae86d
commit
e7ca515716
|
@ -770,10 +770,10 @@ class sale_order_line(osv.osv):
|
||||||
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
|
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
|
||||||
uom=False, qty_uos=0, uos=False, name='', partner_id=False,
|
uom=False, qty_uos=0, uos=False, name='', partner_id=False,
|
||||||
lang=False, update_tax=True, date_order=False, packaging=False):
|
lang=False, update_tax=True, date_order=False, packaging=False):
|
||||||
|
warning={}
|
||||||
product_uom_obj = self.pool.get('product.uom')
|
product_uom_obj = self.pool.get('product.uom')
|
||||||
partner_obj = self.pool.get('res.partner')
|
partner_obj = self.pool.get('res.partner')
|
||||||
product_obj = self.pool.get('product.product')
|
product_obj = self.pool.get('product.product')
|
||||||
|
|
||||||
if partner_id:
|
if partner_id:
|
||||||
lang = partner_obj.browse(cr, uid, partner_id).lang
|
lang = partner_obj.browse(cr, uid, partner_id).lang
|
||||||
context = {'lang': lang, 'partner_id': partner_id}
|
context = {'lang': lang, 'partner_id': partner_id}
|
||||||
|
@ -792,7 +792,17 @@ class sale_order_line(osv.osv):
|
||||||
default_uom = product_obj.uom_id and product_obj.uom_id.id
|
default_uom = product_obj.uom_id and product_obj.uom_id.id
|
||||||
pack = self.pool.get('product.packaging').browse(cr, uid, packaging, context)
|
pack = self.pool.get('product.packaging').browse(cr, uid, packaging, context)
|
||||||
q = product_uom_obj._compute_qty(cr, uid, uom, pack.qty, default_uom)
|
q = product_uom_obj._compute_qty(cr, uid, uom, pack.qty, default_uom)
|
||||||
qty = qty - qty % q + q
|
# qty = qty - qty % q + q
|
||||||
|
if not (qty % q) == 0 :
|
||||||
|
ean = pack.ean
|
||||||
|
qty_pack = pack.qty
|
||||||
|
type_ul = pack.ul
|
||||||
|
warn_msg = "You selected a quantity of %d Units.\nBut it's not compatible with the selected packaging.\nHere is a proposition of quantities according to the packaging: " % (qty)
|
||||||
|
warn_msg = warn_msg + "\n\nEAN: " + str(ean) + " Quantiny: " + str(qty_pack) + " Type of ul: " + str(type_ul.name)
|
||||||
|
warning={
|
||||||
|
'title':'Packing Information !',
|
||||||
|
'message': warn_msg
|
||||||
|
}
|
||||||
result['product_uom_qty'] = qty
|
result['product_uom_qty'] = qty
|
||||||
|
|
||||||
if uom:
|
if uom:
|
||||||
|
@ -864,7 +874,7 @@ class sale_order_line(osv.osv):
|
||||||
# Round the quantity up
|
# Round the quantity up
|
||||||
|
|
||||||
# get unit price
|
# get unit price
|
||||||
warning={}
|
|
||||||
if not pricelist:
|
if not pricelist:
|
||||||
warning={
|
warning={
|
||||||
'title':'No Pricelist !',
|
'title':'No Pricelist !',
|
||||||
|
@ -888,7 +898,6 @@ class sale_order_line(osv.osv):
|
||||||
else:
|
else:
|
||||||
result.update({'price_unit': price})
|
result.update({'price_unit': price})
|
||||||
|
|
||||||
|
|
||||||
return {'value': result, 'domain': domain,'warning':warning}
|
return {'value': result, 'domain': domain,'warning':warning}
|
||||||
|
|
||||||
def product_uom_change(self, cursor, user, ids, pricelist, product, qty=0,
|
def product_uom_change(self, cursor, user, ids, pricelist, product, qty=0,
|
||||||
|
|
Loading…
Reference in New Issue