From 4e3091d49ef1361da3025aef61faddf0e6ae533e Mon Sep 17 00:00:00 2001 From: Bhavesh Odedra Date: Tue, 27 Feb 2018 22:25:41 +0530 Subject: [PATCH] [MIG] stock_orderpoint_manual_procurement_uom: Migration to 11.0 --- .../README.rst | 3 +- .../__init__.py | 1 - .../__manifest__.py | 4 +-- .../models/__init__.py | 1 - .../models/stock_warehouse_orderpoint.py | 7 ++--- .../tests/__init__.py | 1 - ...est_stock_orderpoint_manual_procurement.py | 30 +++++++++++++------ .../wizards/__init__.py | 1 - .../wizards/make_procurement_orderpoint.py | 1 - 9 files changed, 26 insertions(+), 23 deletions(-) diff --git a/stock_orderpoint_manual_procurement_uom/README.rst b/stock_orderpoint_manual_procurement_uom/README.rst index 3b52a3dcb..4a3ecb35f 100644 --- a/stock_orderpoint_manual_procurement_uom/README.rst +++ b/stock_orderpoint_manual_procurement_uom/README.rst @@ -17,7 +17,7 @@ measure indicated in the reordering rule. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/153/10.0 + :target: https://runbot.odoo-community.org/runbot/153/11.0 Bug Tracker =========== @@ -39,6 +39,7 @@ Contributors ------------ * Lois Rilo Antelo +* Bhavesh Odedra Maintainer ---------- diff --git a/stock_orderpoint_manual_procurement_uom/__init__.py b/stock_orderpoint_manual_procurement_uom/__init__.py index fbe944470..e1e144406 100644 --- a/stock_orderpoint_manual_procurement_uom/__init__.py +++ b/stock_orderpoint_manual_procurement_uom/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import models diff --git a/stock_orderpoint_manual_procurement_uom/__manifest__.py b/stock_orderpoint_manual_procurement_uom/__manifest__.py index c253712c0..641fa2ea9 100644 --- a/stock_orderpoint_manual_procurement_uom/__manifest__.py +++ b/stock_orderpoint_manual_procurement_uom/__manifest__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2018 Eficent Business and IT Consulting Services S.L. # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). @@ -6,7 +5,7 @@ "name": "Stock Orderpoint Manual Procurement UoM", "summary": "Glue module for stock_orderpoint_uom and " "stock_orderpoint_manual_procurement", - "version": "10.0.1.0.0", + "version": "11.0.1.0.0", "author": "Eficent, " "Odoo Community Association (OCA)", "website": "https://github.com/OCA/stock-logistics-warehouse", @@ -19,5 +18,4 @@ "license": "AGPL-3", 'installable': True, 'application': False, - 'auto-install': True, } diff --git a/stock_orderpoint_manual_procurement_uom/models/__init__.py b/stock_orderpoint_manual_procurement_uom/models/__init__.py index 6654fecb0..14b7c7a48 100644 --- a/stock_orderpoint_manual_procurement_uom/models/__init__.py +++ b/stock_orderpoint_manual_procurement_uom/models/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import stock_warehouse_orderpoint diff --git a/stock_orderpoint_manual_procurement_uom/models/stock_warehouse_orderpoint.py b/stock_orderpoint_manual_procurement_uom/models/stock_warehouse_orderpoint.py index bd0499452..82f04be16 100644 --- a/stock_orderpoint_manual_procurement_uom/models/stock_warehouse_orderpoint.py +++ b/stock_orderpoint_manual_procurement_uom/models/stock_warehouse_orderpoint.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2018 Eficent Business and IT Consulting Services S.L. # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). @@ -11,12 +10,10 @@ class StockWarehouseOrderpoint(models.Model): @api.multi def _get_procure_recommended_qty(self, virtual_qty, op_qtys): - procure_recommended_qty = \ + product_qty = \ super(StockWarehouseOrderpoint, self)._get_procure_recommended_qty( virtual_qty, op_qtys) if self.procure_uom_id: product_qty = self.product_id.uom_id._compute_quantity( - procure_recommended_qty, self.procure_uom_id) - else: - product_qty = procure_recommended_qty + product_qty, self.procure_uom_id) return product_qty diff --git a/stock_orderpoint_manual_procurement_uom/tests/__init__.py b/stock_orderpoint_manual_procurement_uom/tests/__init__.py index 87fd3dfb9..7d9283684 100644 --- a/stock_orderpoint_manual_procurement_uom/tests/__init__.py +++ b/stock_orderpoint_manual_procurement_uom/tests/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import test_stock_orderpoint_manual_procurement diff --git a/stock_orderpoint_manual_procurement_uom/tests/test_stock_orderpoint_manual_procurement.py b/stock_orderpoint_manual_procurement_uom/tests/test_stock_orderpoint_manual_procurement.py index 62c4634dc..ea920773c 100644 --- a/stock_orderpoint_manual_procurement_uom/tests/test_stock_orderpoint_manual_procurement.py +++ b/stock_orderpoint_manual_procurement_uom/tests/test_stock_orderpoint_manual_procurement.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2018 Eficent Business and IT Consulting Services S.L. # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). @@ -13,6 +12,10 @@ class TestStockWarehouseOrderpoint(common.TransactionCase): # Refs self.group_stock_manager = self.env.ref('stock.group_stock_manager') + self.group_purchase_manager = self.env.ref( + 'purchase.group_purchase_manager') + self.vendor = self.env.ref( + 'stock_orderpoint_manual_procurement.product_supplierinfo_product_7') # noqa self.group_change_procure_qty = self.env.ref( 'stock_orderpoint_manual_procurement.' 'group_change_orderpoint_procure_qty') @@ -21,6 +24,8 @@ class TestStockWarehouseOrderpoint(common.TransactionCase): # Get required Model self.reordering_rule_model = self.env['stock.warehouse.orderpoint'] self.product_model = self.env['product.product'] + self.purchase_model = self.env['purchase.order'] + self.purchase_line_model = self.env['purchase.order.line'] self.user_model = self.env['res.users'] self.product_ctg_model = self.env['product.category'] self.stock_change_model = self.env['stock.change.product.qty'] @@ -30,7 +35,8 @@ class TestStockWarehouseOrderpoint(common.TransactionCase): # Create users self.user = self._create_user('user_1', [self.group_stock_manager, - self.group_change_procure_qty], + self.group_change_procure_qty, + self.group_purchase_manager], self.company1) # Get required Model data self.product_uom = self.env.ref('product.product_uom_unit') @@ -68,7 +74,6 @@ class TestStockWarehouseOrderpoint(common.TransactionCase): """Create a Product Category.""" product_ctg = self.product_ctg_model.create({ 'name': 'test_product_ctg', - 'type': 'normal', }) return product_ctg @@ -79,6 +84,7 @@ class TestStockWarehouseOrderpoint(common.TransactionCase): 'categ_id': self.product_ctg.id, 'type': 'product', 'uom_id': self.product_uom.id, + 'variant_seller_ids': [(6, 0, [self.vendor.id])], }) return product @@ -122,12 +128,18 @@ class TestStockWarehouseOrderpoint(common.TransactionCase): # Create Manual Procurement from order-point procured quantity self.create_orderpoint_procurement() + # As per route configuration, it will create Purchase order # Assert that Procurement is created with the desired quantity - self.assertTrue(self.reorder.procurement_ids) + purchase = self.purchase_model.search( + [('origin', 'ilike', self.reorder.name)]) + self.assertEquals(len(purchase), 1) + purchase_line = self.purchase_line_model.search( + [('orderpoint_id', '=', self.reorder.id), + ('order_id', '=', purchase.id)]) + self.assertEquals(len(purchase_line), 1) self.assertEqual(self.reorder.product_id.id, - self.reorder.procurement_ids.product_id.id) - self.assertEqual(self.reorder.name, - self.reorder.procurement_ids.origin) + purchase_line.product_id.id) + self.assertEqual(self.reorder.name, purchase.origin) self.assertNotEqual(self.reorder.procure_recommended_qty, - self.reorder.procurement_ids.product_qty) - self.assertEqual(self.reorder.procurement_ids.product_qty, 40) + purchase_line.product_qty) + self.assertEqual(purchase_line.product_qty, 40) diff --git a/stock_orderpoint_manual_procurement_uom/wizards/__init__.py b/stock_orderpoint_manual_procurement_uom/wizards/__init__.py index aa5d94a56..79fe40f10 100644 --- a/stock_orderpoint_manual_procurement_uom/wizards/__init__.py +++ b/stock_orderpoint_manual_procurement_uom/wizards/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import make_procurement_orderpoint diff --git a/stock_orderpoint_manual_procurement_uom/wizards/make_procurement_orderpoint.py b/stock_orderpoint_manual_procurement_uom/wizards/make_procurement_orderpoint.py index 04de14f8d..d97ad2207 100644 --- a/stock_orderpoint_manual_procurement_uom/wizards/make_procurement_orderpoint.py +++ b/stock_orderpoint_manual_procurement_uom/wizards/make_procurement_orderpoint.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2018 Eficent Business and IT Consulting Services S.L. # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).