summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2019-06-28 11:55:50 +0000
committerChristophe Simonis <chs@odoo.com>2019-07-04 19:45:25 +0200
commit6cf09b9a3c06d6212c8e14668e034fc7f851e902 (patch)
treefd65c9ec9ace4355c9a205d8819c0d9ebd4f902b
parent1debaa89f14cf662c43744b5cefb476f10eb8a93 (diff)
[FIX] purchase: correct average cost tests
Correctly forward-port baf1580be44eab39f901d153f73546d4a4709588 by backporting 38eb5346c75fb97f215d59d208978cbc27a82b6e.
-rw-r--r--addons/purchase/tests/test_stockvaluation.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/addons/purchase/tests/test_stockvaluation.py b/addons/purchase/tests/test_stockvaluation.py
index 8eeedf1353f..da97af804d1 100644
--- a/addons/purchase/tests/test_stockvaluation.py
+++ b/addons/purchase/tests/test_stockvaluation.py
@@ -812,7 +812,7 @@ class TestStockValuationWithCOA(AccountingTestCase):
.write({'quantity_done': 1.0}))
picking.button_validate()
- # 1 Units received at rate 0.7 = 42.86
+ # 1 Unit received at rate 0.7 = 42.86
self.assertAlmostEqual(product_avg.standard_price, 42.86)
today = date_invoice
@@ -898,7 +898,7 @@ class TestStockValuationWithCOA(AccountingTestCase):
'purchase_method': 'purchase',
'cost_method': 'average',
'name': 'AVG',
- 'standard_price': 60,
+ 'standard_price': 0,
'property_account_creditor_price_difference': self.price_diff_account.id
}).product_variant_id
product_avg.invoice_policy = 'order'
@@ -945,13 +945,12 @@ class TestStockValuationWithCOA(AccountingTestCase):
'company_id': company.id,
})
- # To allow testing validation of PO
+ # To allow testing validation of PO and Delivery
+ today = date_po
def _today(*args, **kwargs):
- return date_po
- # To allow testing validation of Delivery
- delivery_now = date_delivery
+ return today
def _now(*args, **kwargs):
- return delivery_now + ' 01:00:00'
+ return today + ' 01:00:00'
patchers = [
patch('odoo.fields.Date.context_today', _today),
@@ -980,6 +979,7 @@ class TestStockValuationWithCOA(AccountingTestCase):
line_product_avg = po.order_line.filtered(lambda l: l.product_id == product_avg)
+ today = date_delivery
picking = po.picking_ids
(picking.move_lines
.filtered(lambda l: l.purchase_line_id == line_product_avg)
@@ -987,7 +987,10 @@ class TestStockValuationWithCOA(AccountingTestCase):
picking.button_validate()
picking.action_done() # Create Backorder
+ # 5 Units received at rate 0.7 = 42.86
+ self.assertAlmostEqual(product_avg.standard_price, 42.86)
+ today = date_invoice
inv = self.env['account.invoice'].create({
'type': 'in_invoice',
'date_invoice': date_invoice,
@@ -1010,13 +1013,16 @@ class TestStockValuationWithCOA(AccountingTestCase):
inv.action_invoice_open()
+ today = date_delivery1
backorder_picking = self.env['stock.picking'].search([('backorder_id', '=', picking.id)])
- delivery_now = date_delivery1
(backorder_picking.move_lines
.filtered(lambda l: l.purchase_line_id == line_product_avg)
.write({'quantity_done': 5.0}))
backorder_picking.button_validate()
+ # 5 Units received at rate 0.7 (42.86) + 5 Units received at rate 0.8 (37.50) = 40.18
+ self.assertAlmostEqual(product_avg.standard_price, 40.18)
+ today = date_invoice1
inv1 = self.env['account.invoice'].create({
'type': 'in_invoice',
'date_invoice': date_invoice1,