diff --git a/addons/purchase/__openerp__.py b/addons/purchase/__openerp__.py index c8fe369a559..27fecb4c1bc 100644 --- a/addons/purchase/__openerp__.py +++ b/addons/purchase/__openerp__.py @@ -79,7 +79,7 @@ Dashboard / Reports for Purchase Management will include: 'test/ui/delete_order.yml', 'test/average_price.yml', 'test/fifo_price.yml', - 'test/lifo_price.yml' + 'test/lifo_price.yml', ], 'demo': [ 'purchase_order_demo.yml', diff --git a/addons/purchase/test/average_price.yml b/addons/purchase/test/average_price.yml index 02298c4a863..678d2135b04 100644 --- a/addons/purchase/test/average_price.yml +++ b/addons/purchase/test/average_price.yml @@ -64,7 +64,7 @@ Check the standard price of the product (average icecream). - !python {model: product.product}: | - product = self.browse(cr, uid, ref("product_average_icecream") + product = self.browse(cr, uid, ref("product_average_icecream")) assert product.qty_available == 10.0, 'Wrong quantity in stock after first reception' assert product.standard_price == 60.0, 'Standard price should be the price of the first reception!' - @@ -78,8 +78,7 @@ Check the standard price TODO the error message if the assert fails is wrong - !python {model: product.product}: | - assert self.browse(cr, uid, ref("product_average_icecream")).standard_price == 75.0, - 'After second reception, the standard price should be the weighted average of the 2 receptions' + assert self.browse(cr, uid, ref("product_average_icecream")).standard_price == 75.0, 'After second reception, the standard price should be the weighted average of the 2 receptions' - Create picking to send some goods - diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 5cd4cd9f203..6d2f3ad7c97 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2718,11 +2718,13 @@ class stock_move(osv.osv): new_price = uom_obj._compute_price(cr, uid, product.uom_id.id, product.standard_price, product_uom) self.write(cr, uid, move.id, {'price_unit': new_price}, context=ctx) elif product.cost_method == 'average': - if product_avail[product.id] >= 0.0: + if product_avail[product.id] >= 0.0: #Could put > instead amount_unit = product.standard_price move_product_price = uom_obj._compute_price(cr, uid, product_uom, move.price_unit, product.uom_id.id) new_std_price = ((amount_unit * product_avail[product.id])\ + (move_product_price * product_uom_qty))/(product_avail[product.id] + product_uom_qty) + else: + new_std_price = move.price_unit product_obj.write(cr, uid, [product.id], {'standard_price': new_std_price}, context=ctx) product_avail[product.id] += product.qty_available diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py index cbb3e7b5981..b471b5e64b0 100644 --- a/addons/stock/wizard/stock_partial_picking.py +++ b/addons/stock/wizard/stock_partial_picking.py @@ -218,7 +218,7 @@ class stock_partial_picking(osv.osv_memory): currency_obj = self.pool.get("res.currency") new_price = currency_obj.compute(cr, uid, wizard_line.currency.id, company.currency_id.id, wizard_line.cost, round=False) - partial_data['move%s' % (wizard_line.move_id.id)].update(product_price=wizard_line.cost,) + partial_data['move%s' % (wizard_line.move_id.id)].update(product_price=new_price,) stock_picking.do_partial(cr, uid, [partial.picking_id.id], partial_data, context=context) return {'type': 'ir.actions.act_window_close'}