summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorLaurent Smet <las@odoo.com>2020-07-14 11:57:57 +0000
committerLaurent Smet <las@odoo.com>2020-07-16 07:27:10 +0000
commite936437dcf6ab24772a0e052c46f83f90b39eb17 (patch)
tree804855c72b7f1ed68fc6bfd5ee83a8d74fd5bffb /addons
parent3849b154f2e5cc029627b080d6409e7863b70068 (diff)
[IMP] stock_landed_costs: Remove dependency to AccountTestCommon
l10n runbot builds are all failing when running at least one test depending of AccountTestCommon because it: - doesn't create a sandboxed testing environnement to manage the multi-currency, multi-company, the default company's currency, the exchange rates... - doesn't setup a testing user then all tests are done using the superuser. - doesn't provide a fully setup chart of accounts: exchange difference journal is not set, accounts have bad types, etc... - is run sometimes at-install. --task: 2296213
Diffstat (limited to 'addons')
-rw-r--r--addons/stock_landed_costs/tests/common.py81
-rw-r--r--addons/stock_landed_costs/tests/test_stock_landed_costs.py18
-rw-r--r--addons/stock_landed_costs/tests/test_stock_landed_costs_purchase.py15
-rw-r--r--addons/stock_landed_costs/tests/test_stock_landed_costs_rounding.py16
-rw-r--r--addons/stock_landed_costs/tests/test_stockvaluationlayer.py1
5 files changed, 55 insertions, 76 deletions
diff --git a/addons/stock_landed_costs/tests/common.py b/addons/stock_landed_costs/tests/common.py
index 52b540fe64c..39f514f126f 100644
--- a/addons/stock_landed_costs/tests/common.py
+++ b/addons/stock_landed_costs/tests/common.py
@@ -1,70 +1,49 @@
# -*- coding: utf-8 -*-
-from odoo import tools
-from odoo.addons.account.tests.common import AccountTestCommon
-from odoo.modules.module import get_module_resource
+from odoo.addons.account.tests.common import AccountTestInvoicingCommon
-class TestStockLandedCostsCommon(AccountTestCommon):
+class TestStockLandedCostsCommon(AccountTestInvoicingCommon):
+
+ @classmethod
+ def setUpClass(cls, chart_template_ref=None):
+ super().setUpClass(chart_template_ref=chart_template_ref)
- def setUp(self):
- super(TestStockLandedCostsCommon, self).setUp()
# Objects
- self.Product = self.env['product.product']
- self.Picking = self.env['stock.picking']
- self.Move = self.env['stock.move']
- self.LandedCost = self.env['stock.landed.cost']
- self.CostLine = self.env['stock.landed.cost.lines']
+ cls.Product = cls.env['product.product']
+ cls.Picking = cls.env['stock.picking']
+ cls.Move = cls.env['stock.move']
+ cls.LandedCost = cls.env['stock.landed.cost']
+ cls.CostLine = cls.env['stock.landed.cost.lines']
# References
- self.supplier_id = self.env['res.partner'].create({'name': 'My Test Supplier'}).id
- self.customer_id = self.env['res.partner'].create({'name': 'My Test Customer'}).id
- self.picking_type_in_id = self.ref('stock.picking_type_in')
- self.picking_type_out_id = self.ref('stock.picking_type_out')
- self.supplier_location_id = self.ref('stock.stock_location_suppliers')
- self.stock_location_id = self.ref('stock.stock_location_stock')
- self.customer_location_id = self.ref('stock.stock_location_customers')
- self.categ_all = self.env.ref('product.product_category_all')
- # Create account
- self.default_account = self.env['account.account'].create({
- 'name': "Purchased Stocks",
- 'code': "X1101",
- 'user_type_id': self.env['account.account.type'].create({
- 'name': 'Expenses',
- 'type': 'other',
- 'internal_group': 'liability'}).id,
- 'reconcile': True})
- self.expenses_journal = self.env['account.journal'].create({
- 'name': 'Expenses - Test',
- 'code': 'TEXJ',
- 'type': 'purchase',
- 'default_debit_account_id': self.default_account.id,
- 'default_credit_account_id': self.default_account.id})
+ cls.warehouse = cls.env['stock.warehouse'].search([('company_id', '=', cls.env.company.id)], limit=1)
+ cls.supplier_id = cls.env['res.partner'].create({'name': 'My Test Supplier'}).id
+ cls.customer_id = cls.env['res.partner'].create({'name': 'My Test Customer'}).id
+ cls.supplier_location_id = cls.env.ref('stock.stock_location_suppliers').id
+ cls.customer_location_id = cls.env.ref('stock.stock_location_customers').id
+ cls.categ_all = cls.env.ref('product.product_category_all')
+ cls.expenses_journal = cls.company_data['default_journal_purchase']
# Create product refrigerator & oven
- self.product_refrigerator = self.Product.create({
+ cls.product_refrigerator = cls.Product.create({
'name': 'Refrigerator',
'type': 'product',
'standard_price': 1.0,
'weight': 10,
'volume': 1,
- 'categ_id': self.categ_all.id})
- self.product_refrigerator.categ_id.property_cost_method = 'fifo'
- self.product_refrigerator.categ_id.property_valuation = 'real_time'
- self.product_oven = self.Product.create({
+ 'categ_id': cls.categ_all.id})
+ cls.product_refrigerator.categ_id.property_cost_method = 'fifo'
+ cls.product_refrigerator.categ_id.property_valuation = 'real_time'
+ cls.product_oven = cls.Product.create({
'name': 'Microwave Oven',
'type': 'product',
'standard_price': 1.0,
'weight': 20,
'volume': 1.5,
- 'categ_id': self.categ_all.id})
- self.product_oven.categ_id.property_cost_method = 'fifo'
- self.product_oven.categ_id.property_valuation = 'real_time'
+ 'categ_id': cls.categ_all.id})
+ cls.product_oven.categ_id.property_cost_method = 'fifo'
+ cls.product_oven.categ_id.property_valuation = 'real_time'
# Create service type product 1.Labour 2.Brokerage 3.Transportation 4.Packaging
- self.landed_cost = self._create_services('Landed Cost')
- self.brokerage_quantity = self._create_services('Brokerage Cost')
- self.transportation_weight = self._create_services('Transportation Cost')
- self.packaging_volume = self._create_services('Packaging Cost')
-
- def _create_services(self, name):
- return self.Product.create({
- 'name': name,
- 'type': 'service'})
+ cls.landed_cost = cls.Product.create({'name': 'Landed Cost', 'type': 'service'})
+ cls.brokerage_quantity = cls.Product.create({'name': 'Brokerage Cost', 'type': 'service'})
+ cls.transportation_weight = cls.Product.create({'name': 'Transportation Cost', 'type': 'service'})
+ cls.packaging_volume = cls.Product.create({'name': 'Packaging Cost', 'type': 'service'})
diff --git a/addons/stock_landed_costs/tests/test_stock_landed_costs.py b/addons/stock_landed_costs/tests/test_stock_landed_costs.py
index 1021b652c6f..f07bedd6829 100644
--- a/addons/stock_landed_costs/tests/test_stock_landed_costs.py
+++ b/addons/stock_landed_costs/tests/test_stock_landed_costs.py
@@ -8,7 +8,7 @@ from odoo.tests import tagged
@tagged('post_install', '-at_install')
-class TestStockLandedCosts(TestStockLandedCostsCommon, StockAccountTestCommon):
+class TestStockLandedCosts(TestStockLandedCostsCommon):
def test_stock_landed_costs(self):
# In order to test the landed costs feature of stock,
@@ -22,8 +22,8 @@ class TestStockLandedCosts(TestStockLandedCostsCommon, StockAccountTestCommon):
'volume': 1,
})
product_landed_cost_1.product_tmpl_id.categ_id.property_cost_method = 'fifo'
- product_landed_cost_1.product_tmpl_id.categ_id.property_stock_account_input_categ_id = self.o_expense
- product_landed_cost_1.product_tmpl_id.categ_id.property_stock_account_output_categ_id = self.o_income
+ product_landed_cost_1.product_tmpl_id.categ_id.property_stock_account_input_categ_id = self.company_data['default_account_expense']
+ product_landed_cost_1.product_tmpl_id.categ_id.property_stock_account_output_categ_id = self.company_data['default_account_revenue']
product_landed_cost_2 = self.env['product.product'].create({
'name': "LC product 2",
@@ -31,8 +31,8 @@ class TestStockLandedCosts(TestStockLandedCostsCommon, StockAccountTestCommon):
'volume': 1.5,
})
product_landed_cost_2.product_tmpl_id.categ_id.property_cost_method = 'fifo'
- product_landed_cost_2.product_tmpl_id.categ_id.property_stock_account_input_categ_id = self.o_expense
- product_landed_cost_2.product_tmpl_id.categ_id.property_stock_account_output_categ_id = self.o_income
+ product_landed_cost_2.product_tmpl_id.categ_id.property_stock_account_input_categ_id = self.company_data['default_account_expense']
+ product_landed_cost_2.product_tmpl_id.categ_id.property_stock_account_output_categ_id = self.company_data['default_account_revenue']
self.assertEqual(product_landed_cost_1.value_svl, 0)
self.assertEqual(product_landed_cost_1.quantity_svl, 0)
@@ -44,12 +44,12 @@ class TestStockLandedCosts(TestStockLandedCostsCommon, StockAccountTestCommon):
# I create 2 picking moving those products
vals = dict(picking_default_vals, **{
'name': 'LC_pick_1',
- 'picking_type_id': self.ref('stock.picking_type_out'),
+ 'picking_type_id': self.warehouse.out_type_id.id,
'move_lines': [(0, 0, {
'product_id': product_landed_cost_1.id,
'product_uom_qty': 5,
'product_uom': self.ref('uom.product_uom_unit'),
- 'location_id': self.ref('stock.stock_location_stock'),
+ 'location_id': self.warehouse.lot_stock_id.id,
'location_dest_id': self.ref('stock.stock_location_customers'),
})],
})
@@ -69,12 +69,12 @@ class TestStockLandedCosts(TestStockLandedCostsCommon, StockAccountTestCommon):
vals = dict(picking_default_vals, **{
'name': 'LC_pick_2',
- 'picking_type_id': self.ref('stock.picking_type_out'),
+ 'picking_type_id': self.warehouse.out_type_id.id,
'move_lines': [(0, 0, {
'product_id': product_landed_cost_2.id,
'product_uom_qty': 10,
'product_uom': self.ref('uom.product_uom_unit'),
- 'location_id': self.ref('stock.stock_location_stock'),
+ 'location_id': self.warehouse.lot_stock_id.id,
'location_dest_id': self.ref('stock.stock_location_customers'),
})],
})
diff --git a/addons/stock_landed_costs/tests/test_stock_landed_costs_purchase.py b/addons/stock_landed_costs/tests/test_stock_landed_costs_purchase.py
index 47e5e8b188d..c9e88a4d695 100644
--- a/addons/stock_landed_costs/tests/test_stock_landed_costs_purchase.py
+++ b/addons/stock_landed_costs/tests/test_stock_landed_costs_purchase.py
@@ -16,9 +16,9 @@ class TestLandedCosts(TestStockLandedCostsCommon):
# Create picking incoming shipment
self.picking_in = self.Picking.create({
'partner_id': self.supplier_id,
- 'picking_type_id': self.picking_type_in_id,
+ 'picking_type_id': self.warehouse.in_type_id.id,
'location_id': self.supplier_location_id,
- 'location_dest_id': self.stock_location_id})
+ 'location_dest_id': self.warehouse.lot_stock_id.id})
self.Move.create({
'name': self.product_refrigerator.name,
'product_id': self.product_refrigerator.id,
@@ -26,7 +26,7 @@ class TestLandedCosts(TestStockLandedCostsCommon):
'product_uom': self.product_refrigerator.uom_id.id,
'picking_id': self.picking_in.id,
'location_id': self.supplier_location_id,
- 'location_dest_id': self.stock_location_id})
+ 'location_dest_id': self.warehouse.lot_stock_id.id})
self.Move.create({
'name': self.product_oven.name,
'product_id': self.product_oven.id,
@@ -34,12 +34,12 @@ class TestLandedCosts(TestStockLandedCostsCommon):
'product_uom': self.product_oven.uom_id.id,
'picking_id': self.picking_in.id,
'location_id': self.supplier_location_id,
- 'location_dest_id': self.stock_location_id})
+ 'location_dest_id': self.warehouse.lot_stock_id.id})
# Create picking outgoing shipment
self.picking_out = self.Picking.create({
'partner_id': self.customer_id,
- 'picking_type_id': self.picking_type_out_id,
- 'location_id': self.stock_location_id,
+ 'picking_type_id': self.warehouse.out_type_id.id,
+ 'location_id': self.warehouse.lot_stock_id.id,
'location_dest_id': self.customer_location_id})
self.Move.create({
'name': self.product_refrigerator.name,
@@ -47,7 +47,7 @@ class TestLandedCosts(TestStockLandedCostsCommon):
'product_uom_qty': 2,
'product_uom': self.product_refrigerator.uom_id.id,
'picking_id': self.picking_out.id,
- 'location_id': self.stock_location_id,
+ 'location_id': self.warehouse.lot_stock_id.id,
'location_dest_id': self.customer_location_id})
self.stock_input_account, self.stock_output_account, self.stock_valuation_account, self.expense_account, self.stock_journal = _create_accounting_data(self.env)
self.categ_all.write({
@@ -309,7 +309,6 @@ class TestLandedCostsWithPurchaseAndInv(TestStockValuationLCCommon):
self.env.company.anglo_saxon_accounting = True
self.product1.product_tmpl_id.categ_id.property_cost_method = 'fifo'
self.product1.product_tmpl_id.categ_id.property_valuation = 'real_time'
- self.product1.product_tmpl_id.invoice_policy = 'delivery'
self.price_diff_account = self.env['account.account'].create({
'name': 'price diff account',
'code': 'price diff account',
diff --git a/addons/stock_landed_costs/tests/test_stock_landed_costs_rounding.py b/addons/stock_landed_costs/tests/test_stock_landed_costs_rounding.py
index 9f4a6af49bc..2cfcb7b1b75 100644
--- a/addons/stock_landed_costs/tests/test_stock_landed_costs_rounding.py
+++ b/addons/stock_landed_costs/tests/test_stock_landed_costs_rounding.py
@@ -26,8 +26,8 @@ class TestStockLandedCostsRounding(TestStockLandedCostsCommon, StockAccountTestC
'uom_id': product_uom_unit_round_1.id,
})
product_landed_cost_3.product_tmpl_id.categ_id.property_cost_method = 'fifo'
- product_landed_cost_3.product_tmpl_id.categ_id.property_stock_account_input_categ_id = self.o_expense
- product_landed_cost_3.product_tmpl_id.categ_id.property_stock_account_output_categ_id = self.o_income
+ product_landed_cost_3.product_tmpl_id.categ_id.property_stock_account_input_categ_id = self.company_data['default_account_expense']
+ product_landed_cost_3.product_tmpl_id.categ_id.property_stock_account_output_categ_id = self.company_data['default_account_revenue']
product_landed_cost_4 = self.env['product.product'].create({
'name': "LC product 4",
@@ -35,21 +35,21 @@ class TestStockLandedCostsRounding(TestStockLandedCostsCommon, StockAccountTestC
})
product_landed_cost_4.product_tmpl_id.categ_id.property_cost_method = 'fifo'
product_landed_cost_4.product_tmpl_id.categ_id.property_valuation = 'real_time'
- product_landed_cost_4.product_tmpl_id.categ_id.property_stock_account_input_categ_id = self.o_expense
- product_landed_cost_4.product_tmpl_id.categ_id.property_stock_account_output_categ_id = self.o_income
+ product_landed_cost_4.product_tmpl_id.categ_id.property_stock_account_input_categ_id = self.company_data['default_account_expense']
+ product_landed_cost_4.product_tmpl_id.categ_id.property_stock_account_output_categ_id = self.company_data['default_account_revenue']
picking_default_vals = self.env['stock.picking'].default_get(list(self.env['stock.picking'].fields_get()))
# I create 2 pickings moving those products
vals = dict(picking_default_vals, **{
'name': 'LC_pick_3',
- 'picking_type_id': self.ref('stock.picking_type_in'),
+ 'picking_type_id': self.warehouse.in_type_id.id,
'move_lines': [(0, 0, {
'product_id': product_landed_cost_3.id,
'product_uom_qty': 13,
'product_uom': product_uom_unit_round_1.id,
'location_id': self.ref('stock.stock_location_customers'),
- 'location_dest_id': self.ref('stock.stock_location_stock'),
+ 'location_dest_id': self.warehouse.lot_stock_id.id,
})],
})
picking_landed_cost_3 = self.env['stock.picking'].new(vals)
@@ -61,13 +61,13 @@ class TestStockLandedCostsRounding(TestStockLandedCostsCommon, StockAccountTestC
vals = dict(picking_default_vals, **{
'name': 'LC_pick_4',
- 'picking_type_id': self.ref('stock.picking_type_in'),
+ 'picking_type_id': self.warehouse.in_type_id.id,
'move_lines': [(0, 0, {
'product_id': product_landed_cost_4.id,
'product_uom_qty': 1,
'product_uom': self.ref('uom.product_uom_dozen'),
'location_id': self.ref('stock.stock_location_customers'),
- 'location_dest_id': self.ref('stock.stock_location_stock'),
+ 'location_dest_id': self.warehouse.lot_stock_id.id,
'price_unit': 17.00 / 12.00,
})],
})
diff --git a/addons/stock_landed_costs/tests/test_stockvaluationlayer.py b/addons/stock_landed_costs/tests/test_stockvaluationlayer.py
index b0f0d37c0dc..770c05aa274 100644
--- a/addons/stock_landed_costs/tests/test_stockvaluationlayer.py
+++ b/addons/stock_landed_costs/tests/test_stockvaluationlayer.py
@@ -10,6 +10,7 @@ from odoo.addons.stock_account.tests.common import StockAccountTestCommon
class TestStockValuationLCCommon(TestStockValuationCommon, StockAccountTestCommon):
+
@classmethod
def setUpClass(cls):
super(TestStockValuationLCCommon, cls).setUpClass()