From 83678fffe02287ea75eae4085d30d4de1adeb17f Mon Sep 17 00:00:00 2001 From: Lois Rilo Date: Tue, 23 Feb 2021 15:59:09 +0100 Subject: [PATCH 01/43] [13.0][ADD] ddmrp_warning --- ddmrp_warning/README.rst | 84 ++++ ddmrp_warning/__init__.py | 1 + ddmrp_warning/__manifest__.py | 24 + .../data/ddmrp_warning_definition_data.xml | 36 ++ ddmrp_warning/data/ir_cron.xml | 23 + ddmrp_warning/models/__init__.py | 3 + .../models/ddmrp_warning_definition.py | 33 ++ ddmrp_warning/models/ddmrp_warning_item.py | 23 + ddmrp_warning/models/stock_buffer.py | 66 +++ ddmrp_warning/readme/CONTRIBUTORS.rst | 1 + ddmrp_warning/readme/DESCRIPTION.rst | 3 + ddmrp_warning/readme/USAGE.rst | 5 + ddmrp_warning/security/ir.model.access.csv | 5 + ddmrp_warning/static/description/icon.png | Bin 0 -> 7006 bytes ddmrp_warning/static/description/index.html | 431 ++++++++++++++++++ ddmrp_warning/tests/__init__.py | 1 + ddmrp_warning/tests/test_ddmrp_warning.py | 48 ++ ddmrp_warning/views/ddmrp_buffer_view.xml | 51 +++ .../views/ddmrp_warning_definition_views.xml | 71 +++ .../views/ddmrp_warning_item_views.xml | 72 +++ 20 files changed, 981 insertions(+) create mode 100644 ddmrp_warning/README.rst create mode 100644 ddmrp_warning/__init__.py create mode 100644 ddmrp_warning/__manifest__.py create mode 100644 ddmrp_warning/data/ddmrp_warning_definition_data.xml create mode 100644 ddmrp_warning/data/ir_cron.xml create mode 100644 ddmrp_warning/models/__init__.py create mode 100644 ddmrp_warning/models/ddmrp_warning_definition.py create mode 100644 ddmrp_warning/models/ddmrp_warning_item.py create mode 100644 ddmrp_warning/models/stock_buffer.py create mode 100644 ddmrp_warning/readme/CONTRIBUTORS.rst create mode 100644 ddmrp_warning/readme/DESCRIPTION.rst create mode 100644 ddmrp_warning/readme/USAGE.rst create mode 100644 ddmrp_warning/security/ir.model.access.csv create mode 100644 ddmrp_warning/static/description/icon.png create mode 100644 ddmrp_warning/static/description/index.html create mode 100644 ddmrp_warning/tests/__init__.py create mode 100644 ddmrp_warning/tests/test_ddmrp_warning.py create mode 100644 ddmrp_warning/views/ddmrp_buffer_view.xml create mode 100644 ddmrp_warning/views/ddmrp_warning_definition_views.xml create mode 100644 ddmrp_warning/views/ddmrp_warning_item_views.xml diff --git a/ddmrp_warning/README.rst b/ddmrp_warning/README.rst new file mode 100644 index 000000000..95206c5e0 --- /dev/null +++ b/ddmrp_warning/README.rst @@ -0,0 +1,84 @@ +============= +DDMRP Warning +============= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-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%2Fddmrp-lightgray.png?logo=github + :target: https://github.com/OCA/ddmrp/tree/13.0/ddmrp_warning + :alt: OCA/ddmrp +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/ddmrp-13-0/ddmrp-13-0-ddmrp_warning + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/255/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Adds configuration warnings on stock buffers based on different definitions. +This modules include some basic warnings but you can create your own based on +your environment. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module you can proceed as follows: + +#. Use the filter *Has Warnings* in stock buffers. +#. In a buffer form view go to the *Warnings* tab and check the active warnings. +#. Fix the issues, and click on *Refresh Warnings*. + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* Lois Rilo Antelo + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/ddmrp `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/ddmrp_warning/__init__.py b/ddmrp_warning/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/ddmrp_warning/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/ddmrp_warning/__manifest__.py b/ddmrp_warning/__manifest__.py new file mode 100644 index 000000000..e0f2ad5f3 --- /dev/null +++ b/ddmrp_warning/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2021 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +{ + "name": "DDMRP Warning", + "version": "13.0.1.0.0", + "summary": "Adds configuration warnings on stock buffers.", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "development_status": "Beta", + "maintainers": ["LoisRForgeFlow"], + "website": "https://github.com/OCA/ddmrp", + "category": "Warehouse Management", + "depends": ["ddmrp"], + "data": [ + "security/ir.model.access.csv", + "views/ddmrp_buffer_view.xml", + "views/ddmrp_warning_definition_views.xml", + "views/ddmrp_warning_item_views.xml", + "data/ir_cron.xml", + "data/ddmrp_warning_definition_data.xml", + ], + "license": "LGPL-3", + "installable": True, +} diff --git a/ddmrp_warning/data/ddmrp_warning_definition_data.xml b/ddmrp_warning/data/ddmrp_warning_definition_data.xml new file mode 100644 index 000000000..d15632a72 --- /dev/null +++ b/ddmrp_warning/data/ddmrp_warning_definition_data.xml @@ -0,0 +1,36 @@ + + + + Spike horizon is smaller than DLT + buffer.order_spike_horizon < buffer.dlt + 3_high + + + Quantity multiple bigger than MOQ + buffer.minimum_order_quantity < buffer.qty_multiple + 2_mid + + + Minimum Procure Batch bigger than MOQ + buffer.minimum_order_quantity < buffer.procure_min_qty + 2_mid + + + ADU is zero + buffer.adu == 0.0 + 1_low + + diff --git a/ddmrp_warning/data/ir_cron.xml b/ddmrp_warning/data/ir_cron.xml new file mode 100644 index 000000000..88c49c289 --- /dev/null +++ b/ddmrp_warning/data/ir_cron.xml @@ -0,0 +1,23 @@ + + + + DDMRP Buffer Warning calculation + code + + 1 + days + -1 + 5 + + + + model.cron_generate_ddmrp_warnings(True) + + diff --git a/ddmrp_warning/models/__init__.py b/ddmrp_warning/models/__init__.py new file mode 100644 index 000000000..b25b0adfe --- /dev/null +++ b/ddmrp_warning/models/__init__.py @@ -0,0 +1,3 @@ +from . import ddmrp_warning_definition +from . import ddmrp_warning_item +from . import stock_buffer diff --git a/ddmrp_warning/models/ddmrp_warning_definition.py b/ddmrp_warning/models/ddmrp_warning_definition.py new file mode 100644 index 000000000..93673ef1a --- /dev/null +++ b/ddmrp_warning/models/ddmrp_warning_definition.py @@ -0,0 +1,33 @@ +# Copyright 2021 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import _, fields, models +from odoo.exceptions import UserError +from odoo.tools.safe_eval import safe_eval + + +class DdmrpWarningDefinition(models.Model): + _name = "ddmrp.warning.definition" + _description = "DDMRP Warning Definition" + + name = fields.Char(string="Description",) + python_code = fields.Text( + string="Warning Expression", + help="Write Python code that defines when this warning should " + "raise. The result of executing the expression must be " + "a boolean.", + default="""# Available locals:\n# - buffer: A buffer record\nTrue""", + ) + severity = fields.Selection( + selection=[("1_low", "Low"), ("2_mid", "Medium"), ("3_high", "High")], + default="mid", + ) + active = fields.Boolean(default=True) + + def evaluate_definition(self, buffer): + self.ensure_one() + try: + res = safe_eval(self.python_code, globals_dict={"buffer": buffer}) + except Exception as error: + raise UserError(_("Error evaluating %s.\n %s") % (self._name, error)) + return res diff --git a/ddmrp_warning/models/ddmrp_warning_item.py b/ddmrp_warning/models/ddmrp_warning_item.py new file mode 100644 index 000000000..188b7db9a --- /dev/null +++ b/ddmrp_warning/models/ddmrp_warning_item.py @@ -0,0 +1,23 @@ +# Copyright 2021 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import fields, models + + +class DdmrpWarningItem(models.Model): + _name = "ddmrp.warning.item" + _description = "DDMRP Warning Item" + _order = "severity desc, id" + + warning_definition_id = fields.Many2one(comodel_name="ddmrp.warning.definition",) + buffer_id = fields.Many2one(comodel_name="stock.buffer",) + name = fields.Char(compute="_compute_name",) + severity = fields.Selection( + related="warning_definition_id.severity", store=True, readonly=True, + ) + + def _compute_name(self): + for rec in self: + rec.name = "{} in {}".format( + rec.warning_definition_id.display_name, rec.buffer_id.display_name, + ) diff --git a/ddmrp_warning/models/stock_buffer.py b/ddmrp_warning/models/stock_buffer.py new file mode 100644 index 000000000..0cbad3d51 --- /dev/null +++ b/ddmrp_warning/models/stock_buffer.py @@ -0,0 +1,66 @@ +# Copyright 2021 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +import logging +import threading + +from odoo import api, fields, models +from odoo.tools.misc import split_every + +_logger = logging.getLogger(__name__) + + +class Buffer(models.Model): + _inherit = "stock.buffer" + + ddmrp_warning_item_ids = fields.One2many( + comodel_name="ddmrp.warning.item", inverse_name="buffer_id", readonly=True, + ) + + def _generate_ddmrp_warnings(self): + definitions = self.env["ddmrp.warning.definition"].search([]) + item_model = self.env["ddmrp.warning.item"] + for rec in self: + for d in definitions: + existing = item_model.search( + [("buffer_id", "=", rec.id), ("warning_definition_id", "=", d.id)] + ) + warning_raised = d.evaluate_definition(rec) + if warning_raised and not existing: + item_model.create( + {"buffer_id": rec.id, "warning_definition_id": d.id} + ) + elif not warning_raised and existing: + existing.unlink() + + def action_generate_warnings(self): + self._generate_ddmrp_warnings() + return True + + @api.model + def cron_generate_ddmrp_warnings(self, automatic=False): + auto_commit = not getattr(threading.currentThread(), "testing", False) + buffer_ids = self.search([]).ids + i = 0 + j = len(buffer_ids) + for buffer_chunk_ids in split_every(self.CRON_DDMRP_CHUNKS, buffer_ids): + for b in self.browse(buffer_chunk_ids).exists(): + try: + i += 1 + _logger.debug( + "ddmrp cron_generate_ddmrp_warnings: {}. ({}/{})".format( + b.name, i, j + ) + ) + if automatic: + with self.env.cr.savepoint(): + b._generate_ddmrp_warnings() + else: + b._generate_ddmrp_warnings() + except Exception: + _logger.exception("Fail to compute Warnings for buffer %s", b.name) + if not automatic: + raise + if auto_commit: + self._cr.commit() # pylint: disable=E8102 + return True diff --git a/ddmrp_warning/readme/CONTRIBUTORS.rst b/ddmrp_warning/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..611afb02f --- /dev/null +++ b/ddmrp_warning/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Lois Rilo Antelo diff --git a/ddmrp_warning/readme/DESCRIPTION.rst b/ddmrp_warning/readme/DESCRIPTION.rst new file mode 100644 index 000000000..df390fdd1 --- /dev/null +++ b/ddmrp_warning/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +Adds configuration warnings on stock buffers based on different definitions. +This modules include some basic warnings but you can create your own based on +your environment. diff --git a/ddmrp_warning/readme/USAGE.rst b/ddmrp_warning/readme/USAGE.rst new file mode 100644 index 000000000..346326e43 --- /dev/null +++ b/ddmrp_warning/readme/USAGE.rst @@ -0,0 +1,5 @@ +To use this module you can proceed as follows: + +#. Use the filter *Has Warnings* in stock buffers. +#. In a buffer form view go to the *Warnings* tab and check the active warnings. +#. Fix the issues, and click on *Refresh Warnings*. diff --git a/ddmrp_warning/security/ir.model.access.csv b/ddmrp_warning/security/ir.model.access.csv new file mode 100644 index 000000000..7898f34f4 --- /dev/null +++ b/ddmrp_warning/security/ir.model.access.csv @@ -0,0 +1,5 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +ddmrp_warning_definition_user,ddmrp.warning.definition.user,model_ddmrp_warning_definition,stock.group_stock_user,1,0,0,0 +ddmrp_warning_definition_manager,ddmrp.warning.definition.manager,model_ddmrp_warning_definition,stock.group_stock_manager,1,1,1,1 +ddmrp_warning_item_user,ddmrp.warning.item.user,model_ddmrp_warning_item,stock.group_stock_user,1,0,1,1 +ddmrp_warning_item_manager,ddmrp.warning.item.manager,model_ddmrp_warning_item,stock.group_stock_manager,1,1,1,1 diff --git a/ddmrp_warning/static/description/icon.png b/ddmrp_warning/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..b911602f4249dfb221995681bc0b91bf90499c3f GIT binary patch literal 7006 zcmV-k8=>ThP)g0$j{;%QO2fh}0)X>A<4?Zw#jn1jvwrFH&rht>)=sT8u8*VSgTNvq z(!~OkGB*LlFd?RLCXFzNjf*lM5jlo5V46JHjvr}20udWykPNZQ2zJtQOc}wDb(6r6 zsiUeN5rG*dPg1c(o*G25J&{~SZ4((rF=ez26)vOvVRJBAiab@iP(GG0GuD^uD6NjK z!XNqkBVYLHIeOxWCrZ_wi&vZ8+N~nBaiDT0sf>lkonMcrC^-c&1qTcP(tzYvhHRad z1K4q_t5dr{8Q98S70#5|#DyJ~EQhn@EGOL6X_p~UXI%L;RAkB-fPg6og>6O)LakH$ zXKbP|*YLmsT~w5<@>}2Igc&Qd&6(dj@n?s;wXubNY+&tH2FYg8G-aw;6MxmuQFa<^ zInQbqO&XJ#NXk%ou#P~Y3sTptZ~|)`L7k!`4EfJWugb+%nN3{SaqaR*n{p`J)oGU@ zQDJc<<@I z_8PqYbq+YR6KL!X+I6th=>?pm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&sv zXgtruIJM>ue3KSswD zEcT$$g~kqV4~<=}Bw-mH2~{R5GNCy`MO`OhtK+|e8 z>pgv&crMUH9DEdnM&}jK*(o%oatQ|x?Ze2}2y8NY0Zo$5UPH5XbA8!kLQgmRBtgU4 z2no;tvC!Dfxb=j{(U}z*uS9ZyJK`AFlsivovg?G@Su`}QW(x~f7Nm35ZSw7UuGSxF%V{8$z zR2Bo=a-|IT0xz|49xR?6nFp3^t;$!s1X#SUSgqWb`;I^aA|LwfTe-V{e4(1uPlIGh zq&~A70#= + + + + + +DDMRP Warning + + + +
+

DDMRP Warning

+ + +

Beta License: LGPL-3 OCA/ddmrp Translate me on Weblate Try me on Runbot

+

Adds configuration warnings on stock buffers based on different definitions. +This modules include some basic warnings but you can create your own based on +your environment.

+

Table of contents

+ +
+

Usage

+

To use this module you can proceed as follows:

+
    +
  1. Use the filter Has Warnings in stock buffers.
  2. +
  3. In a buffer form view go to the Warnings tab and check the active warnings.
  4. +
  5. Fix the issues, and click on Refresh Warnings.
  6. +
+
+
+

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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/ddmrp project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/ddmrp_warning/tests/__init__.py b/ddmrp_warning/tests/__init__.py new file mode 100644 index 000000000..025c8b021 --- /dev/null +++ b/ddmrp_warning/tests/__init__.py @@ -0,0 +1 @@ +from . import test_ddmrp_warning diff --git a/ddmrp_warning/tests/test_ddmrp_warning.py b/ddmrp_warning/tests/test_ddmrp_warning.py new file mode 100644 index 000000000..9f272f44e --- /dev/null +++ b/ddmrp_warning/tests/test_ddmrp_warning.py @@ -0,0 +1,48 @@ +# Copyright 2021 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo.addons.ddmrp.tests.common import TestDdmrpCommon + + +class TestDDMRPWarning(TestDdmrpCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.warning_item_model = cls.env["ddmrp.warning.item"] + cls.spike_warning = cls.env.ref( + "ddmrp_warning.ddmrp_warning_definition_dlt_and_spike_horizon" + ) + + cls.buffer_warnings = cls.bufferModel.create( + { + "buffer_profile_id": cls.buffer_profile_mmm.id, + "product_id": cls.productA.id, + "location_id": cls.location_shelf1.id, + "warehouse_id": cls.warehouse.id, + "qty_multiple": 1.0, + "adu_calculation_method": cls.adu_fixed.id, + "adu_fixed": 5.0, + "lead_days": 10.0, + "order_spike_horizon": 0.0, + } + ) + + @classmethod + def _refresh_involved_buffers(cls): + cls.buffer_warnings.invalidate_cache() + cls.buffer_warnings.cron_actions() + cls.buffer_warnings._generate_ddmrp_warnings() + + def test_01_buffer_with_warnings(self): + self._refresh_involved_buffers() + self.assertTrue(self.buffer_warnings.ddmrp_warning_item_ids) + prev_count = len(self.buffer_warnings.ddmrp_warning_item_ids) + spike_warning_item = self.buffer_warnings.ddmrp_warning_item_ids.filtered( + lambda w: w.warning_definition_id == self.spike_warning + ) + self.assertTrue(spike_warning_item) + # Fix issue: + self.buffer_warnings.write({"order_spike_horizon": 10.0}) + self._refresh_involved_buffers() + new_count = len(self.buffer_warnings.ddmrp_warning_item_ids) + self.assertEqual(prev_count - new_count, 1) diff --git a/ddmrp_warning/views/ddmrp_buffer_view.xml b/ddmrp_warning/views/ddmrp_buffer_view.xml new file mode 100644 index 000000000..e1983c1fd --- /dev/null +++ b/ddmrp_warning/views/ddmrp_buffer_view.xml @@ -0,0 +1,51 @@ + + + + + stock.buffer.form + stock.buffer + + + + +