[FIX]: product/purchase: Fixed wrong calculation of product qty and amount in purchas line if supplier UOM is different

lp bug: https://launchpad.net/bugs/423124 fixed

bzr revid: rpa@tinyerp.com-20101208123338-absetujv1l31ce9k
This commit is contained in:
rpa (Open ERP) 2010-12-08 18:03:38 +05:30
parent b1f8aa98da
commit 2f32807ce6
2 changed files with 8 additions and 5 deletions

View File

@ -159,7 +159,7 @@ class product_uom(osv.osv):
return price
amount = price * from_unit.factor
if to_uom_id:
amount = amount / to_unit.factor
amount = amount / to_unit.factor_inv
return amount
def onchange_type(self, cursor, user, ids, value):

View File

@ -647,7 +647,7 @@ class purchase_order_line(osv.osv):
'notes': notes or'', 'product_uom' : uom or False}, 'domain':{'product_uom':[]}}
prod= self.pool.get('product.product').browse(cr, uid, product)
product_uom_pool = self.pool.get('product.uom')
lang=False
if partner_id:
lang=self.pool.get('res.partner').read(cr, uid, partner_id, ['lang'])['lang']
@ -668,15 +668,18 @@ class purchase_order_line(osv.osv):
for s in prod.seller_ids:
if s.name.id == partner_id:
seller_delay = s.delay
temp_qty = s.qty # supplier _qty assigned to temp
temp_qty = s.min_qty # supplier _qty assigned to temp
if s.product_uom:
qty = product_uom_pool._compute_qty(cr, uid, s.product_uom.id, s.min_qty, to_uom_id=prod_uom_po)
uom = prod_uom_po
if qty < temp_qty: # If the supplier quantity is greater than entered from user, set minimal.
qty = temp_qty
if price_unit:
price = price_unit
else:
price = self.pool.get('product.pricelist').price_get(cr,uid,[pricelist],
product, qty or 1.0, partner_id, {
'uom': uom,
product, 1.0, partner_id, {
'uom': prod_uom_po,
'date': date_order,
})[pricelist]
dt = (datetime.now() + relativedelta(days=int(seller_delay) or 0.0)).strftime('%Y-%m-%d %H:%M:%S')