diff --git a/addons/sale_stock/tests/__init__.py b/addons/sale_stock/tests/__init__.py index 017499f740f..43ad813d2c3 100644 --- a/addons/sale_stock/tests/__init__.py +++ b/addons/sale_stock/tests/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. + from . import test_anglo_saxon_valuation from . import test_anglo_saxon_valuation_reconciliation from . import test_sale_stock diff --git a/addons/sale_stock/tests/test_anglo_saxon_valuation_reconciliation.py b/addons/sale_stock/tests/test_anglo_saxon_valuation_reconciliation.py index 381d0bde32b..372cb0c72b1 100644 --- a/addons/sale_stock/tests/test_anglo_saxon_valuation_reconciliation.py +++ b/addons/sale_stock/tests/test_anglo_saxon_valuation_reconciliation.py @@ -13,14 +13,14 @@ class TestValuationReconciliation(ValuationReconciliationTestCase): def setUp(self): super(TestValuationReconciliation, self).setUp() self.account_receivable = self.env['account.account'].create({ - 'code': 'X1111', + 'code': 'X1111 - Test Sale Stock', 'name': 'Sale - Test Receivable Account', 'user_type_id': self.env.ref('account.data_account_type_receivable').id, 'reconcile': True }) self.account_income = self.env['account.account'].create({ - 'code': 'X1112', + 'code': 'X1112 - Test Sale Stock', 'name': 'Sale - Test Account', 'user_type_id': self.env.ref('account.data_account_type_direct_costs').id }) diff --git a/addons/sale_stock/tests/test_sale_order_dates.py b/addons/sale_stock/tests/test_sale_order_dates.py index fd826fc877e..55d4f991a20 100644 --- a/addons/sale_stock/tests/test_sale_order_dates.py +++ b/addons/sale_stock/tests/test_sale_order_dates.py @@ -36,7 +36,7 @@ class TestSaleExpectedDate(common.TransactionCase): self.env['stock.quant']._update_available_quantity(product_B, self.env.ref('stock.stock_location_stock'), 10) self.env['stock.quant']._update_available_quantity(product_C, self.env.ref('stock.stock_location_stock'), 10) sale_order = self.env['sale.order'].create({ - 'partner_id': self.ref('base.res_partner_3'), + 'partner_id': self.env['res.partner'].create({'name': 'A Customer'}).id, 'picking_policy': 'direct', 'order_line': [ (0, 0, {'name': product_A.name, 'product_id': product_A.id, 'customer_lead': product_A.sale_delay, 'product_uom_qty': 5}), @@ -90,7 +90,19 @@ class TestSaleExpectedDate(common.TransactionCase): # In order to test the Commitment Date feature in Sales Orders in Odoo, # I copy a demo Sales Order with committed Date on 2010-07-12 - new_order = self.env.ref('sale.sale_order_6').copy({'commitment_date': '2010-07-12'}) + new_order = self.env['sale.order'].create({ + 'partner_id': self.env['res.partner'].create({'name': 'A Partner'}).id, + 'order_line': [(0, 0, { + 'name': "A product", + 'product_id': self.env['product.product'].create({ + 'name': 'A product', + 'type': 'product', + }).id, + 'product_uom_qty': 1, + 'price_unit': 750, + })], + 'commitment_date': '2010-07-12', + }) # I confirm the Sales Order. new_order.action_confirm() # I verify that the Procurements and Stock Moves have been generated with the correct date diff --git a/addons/sale_stock/tests/test_sale_stock.py b/addons/sale_stock/tests/test_sale_stock.py index a21b60951a9..6d5eaf6c753 100644 --- a/addons/sale_stock/tests/test_sale_stock.py +++ b/addons/sale_stock/tests/test_sale_stock.py @@ -9,13 +9,14 @@ from odoo.tests import Form, tagged @tagged('post_install', '-at_install') class TestSaleStock(TestSale): + def _get_new_sale_order(self, amount=10.0): """ Creates and returns a sale order with one default order line. :param float amount: quantity of product for the order line (10 by default) """ - partner = self.env.ref('base.res_partner_1') - product = self.env.ref('product.product_delivery_01') + partner = self.partner + product = self.products['prod_del'] sale_order_vals = { 'partner_id': partner.id, 'partner_invoice_id': partner.id, @@ -121,10 +122,15 @@ class TestSaleStock(TestSale): self.assertFalse(self.so.order_line.sorted()[0].product_updatable) self.assertTrue(self.so.picking_ids, 'Sale Stock: no picking created for "invoice on order" storable products') # let's do an invoice for a deposit of 5% + + advance_product = self.env['product.product'].create({ + 'name': 'Deposit', + 'type': 'service', + }) adv_wiz = self.env['sale.advance.payment.inv'].with_context(active_ids=[self.so.id]).create({ 'advance_payment_method': 'percentage', 'amount': 5.0, - 'product_id': self.env.ref('sale.advance_product_0').id, + 'product_id': advance_product.id, }) act = adv_wiz.with_context(open_invoices=True).create_invoices() inv = self.env['account.move'].browse(act['res_id']) @@ -151,8 +157,7 @@ class TestSaleStock(TestSale): of the picking. Check that a refund invoice is well generated. """ # intial so - self.partner = self.env.ref('base.res_partner_1') - self.product = self.env.ref('product.product_delivery_01') + self.product = self.products['prod_del'] so_vals = { 'partner_id': self.partner.id, 'partner_invoice_id': self.partner.id, @@ -223,8 +228,7 @@ class TestSaleStock(TestSale): the SO is set on 'done', the SO should be fully invoiced. """ # intial so - self.partner = self.env.ref('base.res_partner_1') - self.product = self.env.ref('product.product_delivery_01') + self.product = self.products['prod_del'] so_vals = { 'partner_id': self.partner.id, 'partner_invoice_id': self.partner.id, @@ -276,6 +280,7 @@ class TestSaleStock(TestSale): item1 = self.products['prod_order'] # consumable item1.type = 'consu' item2 = self.products['prod_del'] # storable + item2.type = 'product' # storable self.so = self.env['sale.order'].create({ 'partner_id': self.partner.id, @@ -342,7 +347,9 @@ class TestSaleStock(TestSale): """ # sell two products item1 = self.products['prod_order'] # consumable + item1.type = 'consu' # consumable item2 = self.products['prod_del'] # storable + item2.type = 'product' # storable self.env['stock.quant']._update_available_quantity(item2, self.env.ref('stock.stock_location_stock'), 2) self.so = self.env['sale.order'].create({ @@ -378,7 +385,7 @@ class TestSaleStock(TestSale): """ item1 = self.products['prod_order'] partner1 = self.partner.id - partner2 = self.env.ref('base.res_partner_2').id + partner2 = self.env['res.partner'].create({'name': 'Another Test Partner'}) so1 = self.env['sale.order'].create({ 'partner_id': partner1, 'order_line': [(0, 0, { @@ -399,7 +406,7 @@ class TestSaleStock(TestSale): so1.action_confirm() self.assertEqual(len(so1.picking_ids), 2) picking2 = so1.picking_ids.filtered(lambda p: p.state != 'cancel') - self.assertEqual(picking2.partner_id.id, partner2) + self.assertEqual(picking2.partner_id.id, partner2.id) def test_06_uom(self): """ Sell a dozen of products stocked in units. Check that the quantities on the sale order @@ -628,6 +635,7 @@ class TestSaleStock(TestSale): self.env['stock.quant']._update_reserved_quantity(item1, warehouse1.lot_stock_id, 3) warehouse2 = self.env['stock.warehouse'].create({ 'partner_id': self.env.ref('base.main_partner').id, + 'name': 'Zizizatestwarehouse', 'code': 'Test', }) self.env['stock.quant']._update_available_quantity(item1, warehouse2.lot_stock_id, 5) diff --git a/addons/sale_stock/tests/test_sale_stock_lead_time.py b/addons/sale_stock/tests/test_sale_stock_lead_time.py index fbf6080059d..253e2309d3b 100644 --- a/addons/sale_stock/tests/test_sale_stock_lead_time.py +++ b/addons/sale_stock/tests/test_sale_stock_lead_time.py @@ -9,12 +9,12 @@ from odoo.addons.stock.tests.common2 import TestStockCommon class TestSaleStockLeadTime(TestStockCommon): - def setUp(self): - super(TestSaleStockLeadTime, self).setUp() + @classmethod + def setUpClass(cls): + super(TestSaleStockLeadTime, cls).setUpClass() # Update the product_1 with type and Customer Lead Time - self.product_1.write({'type': 'product', - 'sale_delay': 5.0}) + cls.product_1.write({'type': 'product', 'sale_delay': 5.0}) def test_00_product_company_level_delays(self): """ In order to check schedule date, set product's Customer Lead Time