From 16d2aff657925296cd2d97202bbf0d7ab9e2400b Mon Sep 17 00:00:00 2001 From: Lois Rilo Date: Mon, 5 Aug 2019 13:53:12 +0200 Subject: [PATCH] [12.0][MIG] mrp_multi_level: * You can know integrate with different forecasting mechanisms. As a consequence integration with stock_demand_estimate is moved to a new module (mrp_multi_level_estimate). * As agreed by the authors, the module is re-licensed to LGPL-3. --- mrp_multi_level/README.rst | 27 +- mrp_multi_level/__manifest__.py | 11 +- mrp_multi_level/demo/initial_on_hand_demo.xml | 8 +- mrp_multi_level/demo/mrp_bom_demo.xml | 22 +- mrp_multi_level/demo/product_product_demo.xml | 28 +- .../migrations/11.0.2.0.0/post-migration.py | 2 +- mrp_multi_level/models/mrp_area.py | 3 +- mrp_multi_level/models/mrp_inventory.py | 10 +- mrp_multi_level/models/mrp_move.py | 6 +- mrp_multi_level/models/mrp_planned_order.py | 8 +- mrp_multi_level/models/product_mrp_area.py | 17 +- mrp_multi_level/models/product_product.py | 2 +- mrp_multi_level/models/product_template.py | 2 +- mrp_multi_level/models/stock_location.py | 2 +- mrp_multi_level/readme/DESCRIPTION.rst | 3 +- mrp_multi_level/readme/HISTORY.rst | 8 + mrp_multi_level/static/description/index.html | 102 ++--- mrp_multi_level/tests/__init__.py | 1 - mrp_multi_level/tests/common.py | 284 ++++++++++++++ mrp_multi_level/tests/test_mrp_multi_level.py | 360 +----------------- mrp_multi_level/views/mrp_inventory_views.xml | 19 +- .../views/product_mrp_area_views.xml | 1 - .../wizards/mrp_inventory_procure.py | 5 +- .../wizards/mrp_inventory_procure_views.xml | 2 +- mrp_multi_level/wizards/mrp_multi_level.py | 77 +--- 25 files changed, 473 insertions(+), 537 deletions(-) create mode 100644 mrp_multi_level/tests/common.py diff --git a/mrp_multi_level/README.rst b/mrp_multi_level/README.rst index 3169902c2..f45bdc7df 100644 --- a/mrp_multi_level/README.rst +++ b/mrp_multi_level/README.rst @@ -10,17 +10,17 @@ MRP Multi Level .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status :alt: Beta -.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github - :target: https://github.com/OCA/manufacture/tree/11.0/mrp_multi_level + :target: https://github.com/OCA/manufacture/tree/12.0/mrp_multi_level :alt: OCA/manufacture .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/manufacture-11-0/manufacture-11-0-mrp_multi_level + :target: https://translation.odoo-community.org/projects/manufacture-12-0/manufacture-12-0-mrp_multi_level :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/129/11.0 + :target: https://runbot.odoo-community.org/runbot/129/12.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -36,11 +36,12 @@ Key Features ------------ * MRP parameters set by product variant MRP area pairs. -* Integration with `Stock Demand Estimates `_ system. * Cron job to calculate the MRP demand. * Manually calculate the MRP demand. * Confirm the calculated MRP demand and create PO's, or MO's. * Able to see the products for which action is needed throught Planned Orders. +* Integration with `Stock Demand Estimates `_ system. + Note: You need to install `mrp_multi_level_estimate module `_. **Table of contents** @@ -81,6 +82,14 @@ To launch replenishment orders (moves, purchases, production orders...): Changelog ========= +12.0.1.0.0 (2019-08-05) +~~~~~~~~~~~~~~~~~~~~~~~ + +* [MIG] Migration to v12: + + * Estimates as a forecasting mechanism is moved to a new module + (mrp_multi_level_estimate). + 11.0.3.0.0 (2019-05-22) ~~~~~~~~~~~~~~~~~~~~~~~ @@ -138,7 +147,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -182,6 +191,6 @@ Current `maintainers `__: |maintainer-jbeficent| |maintainer-lreficent| -This module is part of the `OCA/manufacture `_ project on GitHub. +This module is part of the `OCA/manufacture `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mrp_multi_level/__manifest__.py b/mrp_multi_level/__manifest__.py index 9dbbadab5..63d5b4aa7 100644 --- a/mrp_multi_level/__manifest__.py +++ b/mrp_multi_level/__manifest__.py @@ -1,11 +1,12 @@ # Copyright 2016 Ucamco - Wim Audenaert # Copyright 2016-19 Eficent Business and IT Consulting Services S.L. -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + { 'name': 'MRP Multi Level', - 'version': '11.0.3.1.1', + 'version': '12.0.1.0.0', 'development_status': 'Beta', - 'license': 'AGPL-3', + 'license': 'LGPL-3', 'author': 'Ucamco, ' 'Eficent, ' 'Odoo Community Association (OCA)', @@ -15,9 +16,7 @@ 'category': 'Manufacturing', 'depends': [ 'mrp', - 'stock', - 'purchase', - 'stock_demand_estimate', + 'purchase_stock', 'mrp_warehouse_calendar', ], 'data': [ diff --git a/mrp_multi_level/demo/initial_on_hand_demo.xml b/mrp_multi_level/demo/initial_on_hand_demo.xml index 2edf4c4b7..000bd9f8e 100644 --- a/mrp_multi_level/demo/initial_on_hand_demo.xml +++ b/mrp_multi_level/demo/initial_on_hand_demo.xml @@ -6,26 +6,26 @@ - + 10 - + 20 - + 15 - + diff --git a/mrp_multi_level/demo/mrp_bom_demo.xml b/mrp_multi_level/demo/mrp_bom_demo.xml index 1b1e9f7b5..9eec23de1 100644 --- a/mrp_multi_level/demo/mrp_bom_demo.xml +++ b/mrp_multi_level/demo/mrp_bom_demo.xml @@ -4,20 +4,20 @@ - + 5 2 - + 5 3 - + 5 @@ -26,20 +26,20 @@ - + 5 2 - + 5 3 - + 5 @@ -47,20 +47,20 @@ - + 5 3 - + 5 2 - + 5 @@ -68,13 +68,13 @@ - + 5 3 - + 5 diff --git a/mrp_multi_level/demo/product_product_demo.xml b/mrp_multi_level/demo/product_product_demo.xml index 358d70978..78d90ca8f 100644 --- a/mrp_multi_level/demo/product_product_demo.xml +++ b/mrp_multi_level/demo/product_product_demo.xml @@ -4,8 +4,8 @@ FP-1 product - - + + 2 @@ -14,8 +14,8 @@ FP-2 product - - + + 1 @@ -24,8 +24,8 @@ SF-1 product - - + + 1 @@ -33,8 +33,8 @@ SF-2 product - - + + 3 @@ -43,17 +43,17 @@ PP-1 product - - - + + + PP-2 product - - - + + + diff --git a/mrp_multi_level/migrations/11.0.2.0.0/post-migration.py b/mrp_multi_level/migrations/11.0.2.0.0/post-migration.py index 6bf508127..afd5d1925 100644 --- a/mrp_multi_level/migrations/11.0.2.0.0/post-migration.py +++ b/mrp_multi_level/migrations/11.0.2.0.0/post-migration.py @@ -1,5 +1,5 @@ # Copyright 2019 Eficent Business and IT Consulting Services, S.L. -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). import logging from odoo import api, SUPERUSER_ID diff --git a/mrp_multi_level/models/mrp_area.py b/mrp_multi_level/models/mrp_area.py index 2b7c9c60c..ea8183869 100644 --- a/mrp_multi_level/models/mrp_area.py +++ b/mrp_multi_level/models/mrp_area.py @@ -2,13 +2,14 @@ # © 2016-19 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar # - Lois Rilo Antelo -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from odoo import api, fields, models class MrpArea(models.Model): _name = 'mrp.area' + _description = "MRP Area" name = fields.Char(required=True) warehouse_id = fields.Many2one( diff --git a/mrp_multi_level/models/mrp_inventory.py b/mrp_multi_level/models/mrp_inventory.py index be68f3a5f..edbc61340 100644 --- a/mrp_multi_level/models/mrp_inventory.py +++ b/mrp_multi_level/models/mrp_inventory.py @@ -2,7 +2,7 @@ # Copyright 2016-19 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar # - Lois Rilo Antelo -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from odoo import api, fields, models @@ -34,7 +34,7 @@ class MrpInventory(models.Model): store=True, ) uom_id = fields.Many2one( - comodel_name='product.uom', string='Product UoM', + comodel_name='uom.uom', string='Product UoM', compute='_compute_uom_id', ) date = fields.Date(string='Date') @@ -84,9 +84,11 @@ class MrpInventory(models.Model): for rec in self.filtered(lambda r: r.date): delay = rec.product_mrp_area_id.mrp_lead_time if delay and rec.mrp_area_id.calendar_id: - dt_date = fields.Datetime.from_string(rec.date) + dt_date = fields.Datetime.to_datetime(rec.date) + # dt_date is at the beginning of the day (00:00), + # so we can subtract the delay straight forward. order_release_date = rec.mrp_area_id.calendar_id.plan_days( - -delay - 1, dt_date).date() + -delay, dt_date).date() else: order_release_date = fields.Date.from_string( rec.date) - timedelta(days=delay) diff --git a/mrp_multi_level/models/mrp_move.py b/mrp_multi_level/models/mrp_move.py index 0813b6462..91f825279 100644 --- a/mrp_multi_level/models/mrp_move.py +++ b/mrp_multi_level/models/mrp_move.py @@ -1,19 +1,21 @@ # © 2016 Ucamco - Wim Audenaert # © 2016-18 Eficent Business and IT Consulting Services S.L. -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from odoo import models, fields class MrpMove(models.Model): _name = 'mrp.move' + _description = "MRP Move" _order = 'product_mrp_area_id, mrp_date, mrp_type desc, id' # TODO: too many indexes... product_mrp_area_id = fields.Many2one( comodel_name="product.mrp.area", - string="Product", index=True, + string="Product MRP Area", + index=True, required=True, ) mrp_area_id = fields.Many2one( diff --git a/mrp_multi_level/models/mrp_planned_order.py b/mrp_multi_level/models/mrp_planned_order.py index 9c303e3fc..1eea070b9 100644 --- a/mrp_multi_level/models/mrp_planned_order.py +++ b/mrp_multi_level/models/mrp_planned_order.py @@ -1,6 +1,6 @@ # Copyright 2019 Eficent Business and IT Consulting Services S.L. # - Lois Rilo Antelo -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from odoo import models, fields @@ -13,7 +13,7 @@ class MrpPlannedOrder(models.Model): name = fields.Char(string="Description") product_mrp_area_id = fields.Many2one( comodel_name="product.mrp.area", - string="Product", + string="Product MRP Area", index=True, required=True, ) @@ -52,7 +52,9 @@ class MrpPlannedOrder(models.Model): mrp_action = fields.Selection( selection=[("manufacture", "Manufacturing Order"), ("buy", "Purchase Order"), - ("move", "Transfer"), + ('pull', 'Pull From'), + ('push', 'Push To'), + ('pull_push', 'Pull & Push'), ("none", "None")], string="Action", ) diff --git a/mrp_multi_level/models/product_mrp_area.py b/mrp_multi_level/models/product_mrp_area.py index ff6d153e0..84ac8e65b 100644 --- a/mrp_multi_level/models/product_mrp_area.py +++ b/mrp_multi_level/models/product_mrp_area.py @@ -2,7 +2,7 @@ # Copyright 2016-19 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar # - Lois Rilo Antelo -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from math import ceil @@ -80,11 +80,12 @@ class ProductMRPArea(models.Model): selection=[('buy', 'Buy'), ('none', 'Undefined'), ('manufacture', 'Produce'), - ('move', 'Transfer')], + ('pull', 'Pull From'), + ('push', 'Push To'), + ('pull_push', 'Pull & Push')], string='Supply Method', compute='_compute_supply_method', ) - qty_available = fields.Float( string="Quantity Available", compute="_compute_qty_available", @@ -99,10 +100,7 @@ class ProductMRPArea(models.Model): inverse_name="product_mrp_area_id", readonly=True, ) - group_estimate_days = fields.Integer( - string="Group Days of Estimates", - default=1, - ) + _sql_constraints = [ ('product_mrp_area_uniq', 'unique(product_id, mrp_area_id)', 'The product/MRP Area parameters combination must be unique.'), @@ -111,13 +109,12 @@ class ProductMRPArea(models.Model): @api.multi @api.constrains( "mrp_minimum_order_qty", "mrp_maximum_order_qty", "mrp_qty_multiple", - "mrp_minimum_stock", "mrp_nbr_days", "group_estimate_days", + "mrp_minimum_stock", "mrp_nbr_days", ) def _check_negatives(self): values = self.read([ "mrp_minimum_order_qty", "mrp_maximum_order_qty", - "mrp_qty_multiple", - "mrp_minimum_stock", "mrp_nbr_days", "group_estimate_days", + "mrp_qty_multiple", "mrp_minimum_stock", "mrp_nbr_days", ]) for rec in values: if any(v < 0 for v in rec.values()): diff --git a/mrp_multi_level/models/product_product.py b/mrp_multi_level/models/product_product.py index 1f003bf11..b52802067 100644 --- a/mrp_multi_level/models/product_product.py +++ b/mrp_multi_level/models/product_product.py @@ -1,6 +1,6 @@ # Copyright 2016 Ucamco - Wim Audenaert # Copyright 2016-18 Eficent Business and IT Consulting Services S.L. -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). import ast from odoo import api, fields, models diff --git a/mrp_multi_level/models/product_template.py b/mrp_multi_level/models/product_template.py index ed4ccaead..bcea26a27 100644 --- a/mrp_multi_level/models/product_template.py +++ b/mrp_multi_level/models/product_template.py @@ -1,5 +1,5 @@ # Copyright 2018 Eficent Business and IT Consulting Services S.L. -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). import ast from odoo import api, fields, models diff --git a/mrp_multi_level/models/stock_location.py b/mrp_multi_level/models/stock_location.py index c9d656256..3c574443c 100644 --- a/mrp_multi_level/models/stock_location.py +++ b/mrp_multi_level/models/stock_location.py @@ -1,7 +1,7 @@ # © 2016 Ucamco - Wim Audenaert # © 2016 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from odoo import fields, models diff --git a/mrp_multi_level/readme/DESCRIPTION.rst b/mrp_multi_level/readme/DESCRIPTION.rst index 3da52486c..07e004779 100644 --- a/mrp_multi_level/readme/DESCRIPTION.rst +++ b/mrp_multi_level/readme/DESCRIPTION.rst @@ -9,8 +9,9 @@ Key Features ------------ * MRP parameters set by product variant MRP area pairs. -* Integration with `Stock Demand Estimates `_ system. * Cron job to calculate the MRP demand. * Manually calculate the MRP demand. * Confirm the calculated MRP demand and create PO's, or MO's. * Able to see the products for which action is needed throught Planned Orders. +* Integration with `Stock Demand Estimates `_ system. + Note: You need to install `mrp_multi_level_estimate module `_. diff --git a/mrp_multi_level/readme/HISTORY.rst b/mrp_multi_level/readme/HISTORY.rst index 670a421e9..c1596d26c 100644 --- a/mrp_multi_level/readme/HISTORY.rst +++ b/mrp_multi_level/readme/HISTORY.rst @@ -1,3 +1,11 @@ +12.0.1.0.0 (2019-08-05) +~~~~~~~~~~~~~~~~~~~~~~~ + +* [MIG] Migration to v12: + + * Estimates as a forecasting mechanism is moved to a new module + (mrp_multi_level_estimate). + 11.0.3.0.0 (2019-05-22) ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/mrp_multi_level/static/description/index.html b/mrp_multi_level/static/description/index.html index 245c3662b..cc15dc5bd 100644 --- a/mrp_multi_level/static/description/index.html +++ b/mrp_multi_level/static/description/index.html @@ -3,7 +3,7 @@ - + MRP Multi Level