From 18360d80cf8fe7ec461532f9a48f35ccb8cee788 Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Tue, 14 Jul 2020 12:04:15 +0000 Subject: [PATCH] [IMP] delivery: 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. closes odoo/odoo#54444 --task: 2296213 Related: odoo/enterprise#11833 Signed-off-by: Quentin De Paoli (qdp) --- .../tests/test_delivery_stock_move.py | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/addons/delivery/tests/test_delivery_stock_move.py b/addons/delivery/tests/test_delivery_stock_move.py index 5ac27283553..d39f98b1cb7 100644 --- a/addons/delivery/tests/test_delivery_stock_move.py +++ b/addons/delivery/tests/test_delivery_stock_move.py @@ -1,39 +1,41 @@ # -*- coding: utf-8 -*- -from odoo.addons.account.tests.common import AccountTestCommon +from odoo.addons.account.tests.common import AccountTestInvoicingCommon from odoo.tests import tagged, Form @tagged('post_install', '-at_install') -class StockMoveInvoice(AccountTestCommon): +class StockMoveInvoice(AccountTestInvoicingCommon): - def setUp(self): - super(StockMoveInvoice, self).setUp() - self.ProductProduct = self.env['product.product'] - self.SaleOrder = self.env['sale.order'] - self.AccountJournal = self.env['account.journal'] + @classmethod + def setUpClass(cls, chart_template_ref=None): + super().setUpClass(chart_template_ref=chart_template_ref) - self.partner_18 = self.env['res.partner'].create({'name': 'My Test Customer'}) - self.pricelist_id = self.env.ref('product.list0') - self.product_11 = self.env['product.product'].create({'name': 'A product to deliver'}) - self.product_cable_management_box = self.env['product.product'].create({ + cls.ProductProduct = cls.env['product.product'] + cls.SaleOrder = cls.env['sale.order'] + cls.AccountJournal = cls.env['account.journal'] + + cls.partner_18 = cls.env['res.partner'].create({'name': 'My Test Customer'}) + cls.pricelist_id = cls.env.ref('product.list0') + cls.product_11 = cls.env['product.product'].create({'name': 'A product to deliver'}) + cls.product_cable_management_box = cls.env['product.product'].create({ 'name': 'Another product to deliver', 'weight': 1.0, 'invoice_policy': 'order', }) - self.product_uom_unit = self.env.ref('uom.product_uom_unit') - self.product_delivery_normal = self.env['product.product'].create({ + cls.product_uom_unit = cls.env.ref('uom.product_uom_unit') + cls.product_delivery_normal = cls.env['product.product'].create({ 'name': 'Normal Delivery Charges', 'invoice_policy': 'order', 'type': 'service', 'list_price': 10.0, - 'categ_id': self.env.ref('delivery.product_category_deliveries').id, + 'categ_id': cls.env.ref('delivery.product_category_deliveries').id, }) - self.normal_delivery = self.env['delivery.carrier'].create({ + cls.normal_delivery = cls.env['delivery.carrier'].create({ 'name': 'Normal Delivery Charges', 'fixed_price': 10, 'delivery_type': 'fixed', - 'product_id': self.product_delivery_normal.id, + 'product_id': cls.product_delivery_normal.id, }) def test_01_delivery_stock_move(self):