Fix stock compute and average price compute
- Use the default uom of the product to compute stock if there is no uom in the context - Convert the price unit to the default uom to compute the average price bzr revid: ced-ff75ae14a470a9ced8ee6a429ff98ec8138bd195
This commit is contained in:
parent
e0d3880e16
commit
5f51130955
|
@ -144,15 +144,20 @@ class stock_location(osv.osv):
|
|||
return result
|
||||
|
||||
def _product_get_multi_location(self, cr, uid, ids, product_ids=False, context={}, states=['done'], what=('in', 'out')):
|
||||
product_obj = self.pool.get('product.product')
|
||||
states_str = ','.join(map(lambda s: "'%s'" % s, states))
|
||||
if not product_ids:
|
||||
product_ids = self.pool.get('product.product').search(cr, uid, [])
|
||||
product_ids = product_obj.search(cr, uid, [])
|
||||
res = {}
|
||||
for id in product_ids:
|
||||
res[id] = 0.0
|
||||
if not ids:
|
||||
return res
|
||||
|
||||
|
||||
product2uom = {}
|
||||
for product in product_obj.browse(cr, uid, product_ids, context=context):
|
||||
product2uom[product.id] = product.uom_id.id
|
||||
|
||||
prod_ids_str = ','.join(map(str, product_ids))
|
||||
location_ids_str = ','.join(map(str, ids))
|
||||
results = []
|
||||
|
@ -184,11 +189,11 @@ class stock_location(osv.osv):
|
|||
uom_obj = self.pool.get('product.uom')
|
||||
for amount, prod_id, prod_uom in results:
|
||||
amount = uom_obj._compute_qty(cr, uid, prod_uom, amount,
|
||||
context.get('uom', False))
|
||||
context.get('uom', product2uom[prod_id]))
|
||||
res[prod_id] += amount
|
||||
for amount, prod_id, prod_uom in results2:
|
||||
amount = uom_obj._compute_qty(cr, uid, prod_uom, amount,
|
||||
context.get('uom', False))
|
||||
context.get('uom', product2uom[prod_id]))
|
||||
res[prod_id] -= amount
|
||||
return res
|
||||
|
||||
|
|
|
@ -137,6 +137,8 @@ def _do_split(self, cr, uid, data, context):
|
|||
if qty > 0:
|
||||
new_price = currency_obj.compute(cr, uid, currency,
|
||||
user.company_id.currency_id.id, price)
|
||||
new_price = uom_obj._compute_price(cr, uid, uom, new_price,
|
||||
product.uom_id.id)
|
||||
new_std_price = ((product.standard_price * product.qty_available)\
|
||||
+ (new_price * qty))/(product.qty_available + qty)
|
||||
|
||||
|
|
Loading…
Reference in New Issue