From 9c943b7726ab91e839b4f347ca2e07ce3229ed16 Mon Sep 17 00:00:00 2001 From: Bhavesh Odedra Date: Tue, 27 Feb 2018 21:08:34 +0530 Subject: [PATCH] [MIG] stock_orderpoint_manual_procurement: Migration to 11.0 --- .../README.rst | 9 +-- .../__init__.py | 1 - .../__manifest__.py | 9 ++- .../demo/product.xml | 10 +++ .../models/__init__.py | 1 - .../models/stock_warehouse_orderpoint.py | 12 ++-- ...orderpoint_manual_procurement_security.xml | 2 +- .../tests/__init__.py | 1 - ...est_stock_orderpoint_manual_procurement.py | 30 ++++++--- .../views/procurement_order_view.xml | 17 ----- .../views/stock_warehouse_orderpoint_view.xml | 9 +-- .../wizards/__init__.py | 1 - .../wizards/make_procurement_orderpoint.py | 67 ++++++++----------- .../make_procurement_orderpoint_view.xml | 21 ++---- 14 files changed, 81 insertions(+), 109 deletions(-) create mode 100644 stock_orderpoint_manual_procurement/demo/product.xml delete mode 100644 stock_orderpoint_manual_procurement/views/procurement_order_view.xml diff --git a/stock_orderpoint_manual_procurement/README.rst b/stock_orderpoint_manual_procurement/README.rst index 00a8809c4..f7c253e3e 100644 --- a/stock_orderpoint_manual_procurement/README.rst +++ b/stock_orderpoint_manual_procurement/README.rst @@ -19,16 +19,16 @@ procurements from reordering rules', under 'Settings / Users / Users'. Usage ===== -Go to 'Inventory > Inventory Control > Reordering Rules' and review the -quantity recommended to be procured. You can now start the procurement for a -single or a list of reordering rules. +Go to 'Inventory > Master Data > Reordering Rules' and review the quantity +recommended to be procured. You can now start the procurement for a single or a +list of reordering rules. The recommended quantity to procure is adjusted to the procurement unit of 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 =========== @@ -51,6 +51,7 @@ Contributors * Jordi Ballester Alomar * Lois Rilo Antelo +* Bhavesh Odedra Maintainer ---------- diff --git a/stock_orderpoint_manual_procurement/__init__.py b/stock_orderpoint_manual_procurement/__init__.py index fbe944470..e1e144406 100644 --- a/stock_orderpoint_manual_procurement/__init__.py +++ b/stock_orderpoint_manual_procurement/__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/__manifest__.py b/stock_orderpoint_manual_procurement/__manifest__.py index fa9e47c4b..e3da69981 100644 --- a/stock_orderpoint_manual_procurement/__manifest__.py +++ b/stock_orderpoint_manual_procurement/__manifest__.py @@ -1,23 +1,26 @@ -# -*- coding: utf-8 -*- # Copyright 2016-17 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). + { "name": "Stock Orderpoint Manual Procurement", "summary": "Allows to create procurement orders from orderpoints instead " "of relying only on the scheduler.", - "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", "category": "Warehouse Management", "depends": [ "stock", + "purchase", + ], + "demo": [ + "demo/product.xml", ], "data": [ "security/stock_orderpoint_manual_procurement_security.xml", "wizards/make_procurement_orderpoint_view.xml", - "views/procurement_order_view.xml", "views/stock_warehouse_orderpoint_view.xml", ], "license": "AGPL-3", diff --git a/stock_orderpoint_manual_procurement/demo/product.xml b/stock_orderpoint_manual_procurement/demo/product.xml new file mode 100644 index 000000000..a2831566c --- /dev/null +++ b/stock_orderpoint_manual_procurement/demo/product.xml @@ -0,0 +1,10 @@ + + + + + + 3 + 1 + 72 + + diff --git a/stock_orderpoint_manual_procurement/models/__init__.py b/stock_orderpoint_manual_procurement/models/__init__.py index 6654fecb0..14b7c7a48 100644 --- a/stock_orderpoint_manual_procurement/models/__init__.py +++ b/stock_orderpoint_manual_procurement/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/models/stock_warehouse_orderpoint.py b/stock_orderpoint_manual_procurement/models/stock_warehouse_orderpoint.py index 6dd0ffe0d..eeb675e1f 100644 --- a/stock_orderpoint_manual_procurement/models/stock_warehouse_orderpoint.py +++ b/stock_orderpoint_manual_procurement/models/stock_warehouse_orderpoint.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2016-17 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). @@ -52,13 +51,14 @@ class StockWarehouseOrderpoint(models.Model): @api.multi @api.depends("product_min_qty", "product_id", "qty_multiple") def _compute_procure_recommended(self): - op_qtys = self.subtract_procurements_from_orderpoints() + op_qtys = self._quantity_in_progress() for op in self: - op.procure_recommended_date = op._get_date_planned( - datetime.today()) + qty = 0.0 virtual_qty = op.with_context( location=op.location_id.id).product_id.virtual_available if float_compare(virtual_qty, op.product_min_qty, precision_rounding=op.product_uom.rounding) < 0: - op.procure_recommended_qty = op._get_procure_recommended_qty( - virtual_qty, op_qtys) + qty = op._get_procure_recommended_qty(virtual_qty, op_qtys) + op.procure_recommended_qty = qty + op.procure_recommended_date = op._get_date_planned( + qty, datetime.today()) diff --git a/stock_orderpoint_manual_procurement/security/stock_orderpoint_manual_procurement_security.xml b/stock_orderpoint_manual_procurement/security/stock_orderpoint_manual_procurement_security.xml index 0e43bcafe..766864865 100644 --- a/stock_orderpoint_manual_procurement/security/stock_orderpoint_manual_procurement_security.xml +++ b/stock_orderpoint_manual_procurement/security/stock_orderpoint_manual_procurement_security.xml @@ -1,4 +1,4 @@ - + diff --git a/stock_orderpoint_manual_procurement/tests/__init__.py b/stock_orderpoint_manual_procurement/tests/__init__.py index 87fd3dfb9..7d9283684 100644 --- a/stock_orderpoint_manual_procurement/tests/__init__.py +++ b/stock_orderpoint_manual_procurement/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/tests/test_stock_orderpoint_manual_procurement.py b/stock_orderpoint_manual_procurement/tests/test_stock_orderpoint_manual_procurement.py index 90973a5ec..7627c15a7 100644 --- a/stock_orderpoint_manual_procurement/tests/test_stock_orderpoint_manual_procurement.py +++ b/stock_orderpoint_manual_procurement/tests/test_stock_orderpoint_manual_procurement.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2016-17 Eficent Business and IT Consulting Services S.L. # (http://www.eficent.com) # Copyright 2016 Serpent Consulting Services Pvt. Ltd. @@ -14,6 +13,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') @@ -22,6 +25,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'] @@ -31,7 +36,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 @@ -121,13 +127,15 @@ 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) - 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 = 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.assertNotEqual(self.reorder.procure_recommended_qty, - self.reorder.procurement_ids.product_qty) - self.assertEqual(self.reorder.procurement_ids.product_qty, - 480.0) + purchase_line.product_qty) + self.assertEqual(purchase_line.product_qty, 480.0) diff --git a/stock_orderpoint_manual_procurement/views/procurement_order_view.xml b/stock_orderpoint_manual_procurement/views/procurement_order_view.xml deleted file mode 100644 index 07ea9284d..000000000 --- a/stock_orderpoint_manual_procurement/views/procurement_order_view.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - procurement.order.select - procurement.order - - - - - - - - - - diff --git a/stock_orderpoint_manual_procurement/views/stock_warehouse_orderpoint_view.xml b/stock_orderpoint_manual_procurement/views/stock_warehouse_orderpoint_view.xml index 64f5d0591..bce429370 100644 --- a/stock_orderpoint_manual_procurement/views/stock_warehouse_orderpoint_view.xml +++ b/stock_orderpoint_manual_procurement/views/stock_warehouse_orderpoint_view.xml @@ -1,4 +1,4 @@ - + @@ -8,18 +8,11 @@ ref="stock.view_warehouse_orderpoint_tree"/> -