[IMP] average yml test

bzr revid: jco@openerp.com-20130515081110-1w54knruk110jli7
This commit is contained in:
Josse Colpaert
2013-05-15 10:11:10 +02:00
parent 55d4dd6a7a
commit 6d0289e7b7
4 changed files with 7 additions and 6 deletions
+1 -1
View File
@@ -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',
+2 -3
View File
@@ -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
-
+3 -1
View File
@@ -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
+1 -1
View File
@@ -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'}