From dff06328569f48d91b9917831e6c8b27b7cf148c Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Fri, 8 Nov 2024 10:28:45 +0000 Subject: [PATCH] [IMP] stock_move_line_lock_qty_done: prevent test cases from other modules from failing --- stock_move_line_lock_qty_done/README.rst | 9 ++++++-- stock_move_line_lock_qty_done/__manifest__.py | 6 +++-- .../models/__init__.py | 2 ++ .../models/res_company.py | 14 +++++++++++ .../models/res_config_settings.py | 16 +++++++++++++ .../models/stock_move_line.py | 2 +- .../readme/CONFIGURE.rst | 2 ++ .../readme/CONTRIBUTORS.rst | 3 +++ .../readme/DESCRIPTION.rst | 4 ++-- .../static/description/index.html | 10 +++++--- .../test_stock_move_line_lock_qty_done.py | 1 + .../views/res_config_settings_views.xml | 23 +++++++++++++++++++ 12 files changed, 82 insertions(+), 10 deletions(-) create mode 100644 stock_move_line_lock_qty_done/models/res_company.py create mode 100644 stock_move_line_lock_qty_done/models/res_config_settings.py create mode 100644 stock_move_line_lock_qty_done/views/res_config_settings_views.xml diff --git a/stock_move_line_lock_qty_done/README.rst b/stock_move_line_lock_qty_done/README.rst index c92cb1be2b9..d8b214bb9ef 100644 --- a/stock_move_line_lock_qty_done/README.rst +++ b/stock_move_line_lock_qty_done/README.rst @@ -28,8 +28,8 @@ Lock Done Quantity Changes in Stock Moves |badge1| |badge2| |badge3| |badge4| |badge5| -This module limits the capability to modify the done quantity for stock moves -once they have been validated. +This module can limit the ability to modify the done quantity of stock moves once they are validated, +configurable per company through the settings. **Table of contents** @@ -42,6 +42,8 @@ Configuration To configure this module, you need to add the users allowed to edit the done quntity for done moves to the group "Can edit done quantity for done stock moves" +Enable the 'Limit Updates to Done Quantity After Validation' option under 'Inventory > Settings' to enable the restriction of modifying the done quantity for validated stock moves. + Bug Tracker =========== @@ -64,6 +66,9 @@ Contributors ~~~~~~~~~~~~ * Souheil Bejaoui +* `Quartile `_: + + * Aung Ko Ko Lin Maintainers ~~~~~~~~~~~ diff --git a/stock_move_line_lock_qty_done/__manifest__.py b/stock_move_line_lock_qty_done/__manifest__.py index efeb12af09a..794a98b42f5 100644 --- a/stock_move_line_lock_qty_done/__manifest__.py +++ b/stock_move_line_lock_qty_done/__manifest__.py @@ -9,6 +9,8 @@ "author": "ACSONE SA/NV, Odoo Community Association (OCA)", "website": "https://github.com/OCA/stock-logistics-workflow", "depends": ["stock"], - "data": ["security/res_groups.xml"], - "demo": [], + "data": [ + "security/res_groups.xml", + "views/res_config_settings_views.xml", + ], } diff --git a/stock_move_line_lock_qty_done/models/__init__.py b/stock_move_line_lock_qty_done/models/__init__.py index 431f51c2747..515a3a6a8f5 100644 --- a/stock_move_line_lock_qty_done/models/__init__.py +++ b/stock_move_line_lock_qty_done/models/__init__.py @@ -1 +1,3 @@ +from . import res_company +from . import res_config_settings from . import stock_move_line diff --git a/stock_move_line_lock_qty_done/models/res_company.py b/stock_move_line_lock_qty_done/models/res_company.py new file mode 100644 index 00000000000..c54fe29a124 --- /dev/null +++ b/stock_move_line_lock_qty_done/models/res_company.py @@ -0,0 +1,14 @@ +# Copyright 2024 Quartile +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class ResCompany(models.Model): + _inherit = "res.company" + + lock_qty_done = fields.Boolean( + string="Limit Updates to Done Quantity After Validation", + help="Only users in the 'Can Edit Done Quantity for Done Stock Moves' group" + " are allowed to edit the 'done' quantity for validated transfer.", + ) diff --git a/stock_move_line_lock_qty_done/models/res_config_settings.py b/stock_move_line_lock_qty_done/models/res_config_settings.py new file mode 100644 index 00000000000..000d70ffe31 --- /dev/null +++ b/stock_move_line_lock_qty_done/models/res_config_settings.py @@ -0,0 +1,16 @@ +# Copyright 2024 Quartile +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + lock_qty_done = fields.Boolean( + related="company_id.lock_qty_done", + readonly=False, + string="Limit Updates to Done Quantity After Validation", + help="Only users in the 'Can Edit Done Quantity for Done Stock Moves' group" + " are allowed to edit the 'done' quantity for validated transfer.", + ) diff --git a/stock_move_line_lock_qty_done/models/stock_move_line.py b/stock_move_line_lock_qty_done/models/stock_move_line.py index f48172f00d9..54ab08776ff 100644 --- a/stock_move_line_lock_qty_done/models/stock_move_line.py +++ b/stock_move_line_lock_qty_done/models/stock_move_line.py @@ -16,7 +16,7 @@ def _check_qty_done_change_allowed(self, vals): "stock_move_line_lock_qty_done.group_stock_move_can_edit_done_qty" ) for rec in self: - if rec.state != "done": + if rec.state != "done" or not rec.company_id.lock_qty_done: continue if rec.is_locked: raise UserError( diff --git a/stock_move_line_lock_qty_done/readme/CONFIGURE.rst b/stock_move_line_lock_qty_done/readme/CONFIGURE.rst index 70cec83f6e6..fd3f50c2eba 100644 --- a/stock_move_line_lock_qty_done/readme/CONFIGURE.rst +++ b/stock_move_line_lock_qty_done/readme/CONFIGURE.rst @@ -1,2 +1,4 @@ To configure this module, you need to add the users allowed to edit the done quntity for done moves to the group "Can edit done quantity for done stock moves" + +Enable the 'Limit Updates to Done Quantity After Validation' option under 'Inventory > Settings' to enable the restriction of modifying the done quantity for validated stock moves. diff --git a/stock_move_line_lock_qty_done/readme/CONTRIBUTORS.rst b/stock_move_line_lock_qty_done/readme/CONTRIBUTORS.rst index 50e6298db56..6f1f7741fda 100644 --- a/stock_move_line_lock_qty_done/readme/CONTRIBUTORS.rst +++ b/stock_move_line_lock_qty_done/readme/CONTRIBUTORS.rst @@ -1 +1,4 @@ * Souheil Bejaoui +* `Quartile `_: + + * Aung Ko Ko Lin diff --git a/stock_move_line_lock_qty_done/readme/DESCRIPTION.rst b/stock_move_line_lock_qty_done/readme/DESCRIPTION.rst index 837e74981bb..a88265c275b 100644 --- a/stock_move_line_lock_qty_done/readme/DESCRIPTION.rst +++ b/stock_move_line_lock_qty_done/readme/DESCRIPTION.rst @@ -1,2 +1,2 @@ -This module limits the capability to modify the done quantity for stock moves -once they have been validated. +This module can limit the ability to modify the done quantity of stock moves once they are validated, +configurable per company through the settings. diff --git a/stock_move_line_lock_qty_done/static/description/index.html b/stock_move_line_lock_qty_done/static/description/index.html index 86e848c3ce2..76ae8dff96b 100644 --- a/stock_move_line_lock_qty_done/static/description/index.html +++ b/stock_move_line_lock_qty_done/static/description/index.html @@ -1,4 +1,3 @@ - @@ -370,8 +369,8 @@

Lock Done Quantity Changes in Stock Moves

!! source digest: sha256:ddd0e3ea97313eb20b471c05dc1b1a8d0bf84fcfcf8367f9049daa3cb0ec3fc6 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/stock-logistics-workflow Translate me on Weblate Try me on Runboat

-

This module limits the capability to modify the done quantity for stock moves -once they have been validated.

+

This module can limit the ability to modify the done quantity of stock moves once they are validated, +configurable per company through the settings.

Table of contents

    @@ -389,6 +388,7 @@

    Lock Done Quantity Changes in Stock Moves

    Configuration

    To configure this module, you need to add the users allowed to edit the done quntity for done moves to the group “Can edit done quantity for done stock moves”

    +

    Enable the ‘Limit Updates to Done Quantity After Validation’ option under ‘Inventory > Settings’ to enable the restriction of modifying the done quantity for validated stock moves.

Bug Tracker

@@ -410,6 +410,10 @@

Authors

Contributors

diff --git a/stock_move_line_lock_qty_done/tests/test_stock_move_line_lock_qty_done.py b/stock_move_line_lock_qty_done/tests/test_stock_move_line_lock_qty_done.py index 8b494312a45..cd5c58cd478 100644 --- a/stock_move_line_lock_qty_done/tests/test_stock_move_line_lock_qty_done.py +++ b/stock_move_line_lock_qty_done/tests/test_stock_move_line_lock_qty_done.py @@ -13,6 +13,7 @@ def setUpClass(cls): [("state", "=", "assigned")], limit=1 ) cls.move_line = cls.assigned_picking.move_line_ids[0] + cls.env.company.sudo().lock_qty_done = True def test_0(self): self.assertEqual(self.assigned_picking.state, "assigned") diff --git a/stock_move_line_lock_qty_done/views/res_config_settings_views.xml b/stock_move_line_lock_qty_done/views/res_config_settings_views.xml new file mode 100644 index 00000000000..e661b9744b6 --- /dev/null +++ b/stock_move_line_lock_qty_done/views/res_config_settings_views.xml @@ -0,0 +1,23 @@ + + + + res.config.settings + res.config.settings + + + +
+
+ +
+
+
+
+
+
+
+