From d723d91f288ee670d2b51b23358a031db613de78 Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Fri, 8 Feb 2019 10:31:57 +0100 Subject: [PATCH] [10.0][FIX] purchase_packaging: Improve tests In order to avoid conflicts with using of mrp demo data, creating product in test. --- purchase_packaging/__manifest__.py | 2 +- .../tests/test_procurement_order.py | 41 ++++++++++++------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/purchase_packaging/__manifest__.py b/purchase_packaging/__manifest__.py index e22635bae..5444b02f1 100644 --- a/purchase_packaging/__manifest__.py +++ b/purchase_packaging/__manifest__.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Purchase Packaging", - "version": "10.0.1.0.5", + "version": "10.0.1.0.6", "author": 'ACSONE SA/NV, ' 'Odoo Community Association (OCA)', "category": "Warehouse", diff --git a/purchase_packaging/tests/test_procurement_order.py b/purchase_packaging/tests/test_procurement_order.py index 50decf41a..be443b311 100644 --- a/purchase_packaging/tests/test_procurement_order.py +++ b/purchase_packaging/tests/test_procurement_order.py @@ -13,9 +13,20 @@ class TestProcurementOrder(common.TransactionCase): * product_product_3 (uom is product_uom_unit) """ super(TestProcurementOrder, self).setUp() + product_obj = self.env['product.product'] + # Create new product + vals = { + 'name': 'Product Purchase Pack Test', + 'categ_id': self.env.ref('product.product_category_5').id, + 'list_price': 30.0, + 'standard_price': 20.0, + 'type': 'product', + 'uom_id': self.env.ref('product.product_uom_unit').id, + + } + self.product_test = product_obj.create(vals) self.product_packaging_3 = self.env['product.packaging'].create({ - 'product_tmpl_id': self.env.ref( - 'product.product_product_3').product_tmpl_id.id, + 'product_tmpl_id': self.product_test.product_tmpl_id.id, 'uom_id': self.env.ref('product.product_uom_dozen').id, 'name': 'Packaging Dozen' }) @@ -40,7 +51,7 @@ class TestProcurementOrder(common.TransactionCase): # On supplierinfo set min_qty as 0 # Create procurement line with rule buy and quantity 17 # run procurement - self.env.ref('product.product_product_3').route_ids = [( + self.product_test.route_ids = [( 4, self.env.ref("purchase.route_warehouse0_buy").id)] self.env.ref('product.product_uom_unit').rounding = 1 procurement_obj = self.env['procurement.order'] @@ -51,7 +62,7 @@ class TestProcurementOrder(common.TransactionCase): proc1 = procurement_obj.create( {'name': 'test_procurement', 'location_id': self.env.ref('stock.stock_location_stock').id, - 'product_id': self.env.ref('product.product_product_3').id, + 'product_id': self.product_test.id, 'product_qty': 17, 'product_uom': self.env.ref('product.product_uom_unit').id}) procurement_obj.run_scheduler() @@ -77,7 +88,7 @@ class TestProcurementOrder(common.TransactionCase): proc1 = procurement_obj.create( {'name': 'test_procurement', 'location_id': self.env.ref('stock.stock_location_stock').id, - 'product_id': self.env.ref('product.product_product_3').id, + 'product_id': self.product_test.id, 'product_qty': 1, 'product_uom': self.env.ref('product.product_uom_dozen').id}) procurement_obj.run_scheduler() @@ -106,7 +117,7 @@ class TestProcurementOrder(common.TransactionCase): proc1 = procurement_obj.create( {'name': 'test_procurement', 'location_id': self.env.ref('stock.stock_location_stock').id, - 'product_id': self.env.ref('product.product_product_3').id, + 'product_id': self.product_test.id, 'product_qty': 17, 'product_uom': self.env.ref('product.product_uom_unit').id}) procurement_obj.run_scheduler() @@ -132,7 +143,7 @@ class TestProcurementOrder(common.TransactionCase): proc1 = procurement_obj.create( {'name': 'test_procurement', 'location_id': self.env.ref('stock.stock_location_stock').id, - 'product_id': self.env.ref('product.product_product_3').id, + 'product_id': self.product_test.id, 'product_qty': 1, 'product_uom': self.env.ref('product.product_uom_dozen').id}) procurement_obj.run_scheduler() @@ -161,7 +172,7 @@ class TestProcurementOrder(common.TransactionCase): proc1 = procurement_obj.create( {'name': 'test_procurement', 'location_id': self.env.ref('stock.stock_location_stock').id, - 'product_id': self.env.ref('product.product_product_3').id, + 'product_id': self.product_test.id, 'product_qty': 17, 'product_uom': self.env.ref('product.product_uom_unit').id}) procurement_obj.run_scheduler() @@ -188,7 +199,7 @@ class TestProcurementOrder(common.TransactionCase): proc1 = procurement_obj.create( {'name': 'test_procurement', 'location_id': self.env.ref('stock.stock_location_stock').id, - 'product_id': self.env.ref('product.product_product_3').id, + 'product_id': self.product_test.id, 'product_qty': 1, 'product_uom': self.env.ref('product.product_uom_dozen').id}) procurement_obj.run_scheduler() @@ -217,7 +228,7 @@ class TestProcurementOrder(common.TransactionCase): proc1 = procurement_obj.create( {'name': 'test_procurement', 'location_id': self.env.ref('stock.stock_location_stock').id, - 'product_id': self.env.ref('product.product_product_3').id, + 'product_id': self.product_test.id, 'product_qty': 17, 'product_uom': self.env.ref('product.product_uom_unit').id}) procurement_obj.run_scheduler() @@ -245,7 +256,7 @@ class TestProcurementOrder(common.TransactionCase): proc1 = procurement_obj.create( {'name': 'test_procurement', 'location_id': self.env.ref('stock.stock_location_stock').id, - 'product_id': self.env.ref('product.product_product_3').id, + 'product_id': self.product_test.id, 'product_qty': 1, 'product_uom': self.env.ref('product.product_uom_dozen').id}) procurement_obj.run_scheduler() @@ -275,7 +286,7 @@ class TestProcurementOrder(common.TransactionCase): # Change the stock minimum to 13 PC # The purchase quantity should increase up to 24 warehouse = self.env.ref('stock.warehouse0') - product = self.env.ref('product.product_product_3') + product = self.product_test product.route_ids = [( 4, self.env.ref("purchase.route_warehouse0_buy").id)] self.env.ref('product.product_uom_dozen').rounding = 1 @@ -331,7 +342,7 @@ class TestProcurementOrder(common.TransactionCase): # Change the stock minimum to 13 PC # A new purchase should be generated warehouse = self.env.ref('stock.warehouse0') - product = self.env.ref('product.product_product_3') + product = self.product_test product.route_ids = [( 4, self.env.ref("purchase.route_warehouse0_buy").id)] self.env.ref('product.product_uom_dozen').rounding = 1 @@ -390,7 +401,7 @@ class TestProcurementOrder(common.TransactionCase): # Change the stock minimum to 13 PC # A new purchase should be generated warehouse = self.env.ref('stock.warehouse0') - product = self.env.ref('product.product_product_3') + product = self.product_test product.route_ids = [( 4, self.env.ref("purchase.route_warehouse0_buy").id)] self.env.ref('product.product_uom_dozen').rounding = 1 @@ -449,7 +460,7 @@ class TestProcurementOrder(common.TransactionCase): # Change the stock minimum to 13 PC # A new purchase should be generated warehouse = self.env.ref('stock.warehouse0') - product = self.env.ref('product.product_product_3') + product = self.product_test product.route_ids = [( 4, self.env.ref("purchase.route_warehouse0_buy").id)] self.env.ref('product.product_uom_dozen').rounding = 1