diff --git a/stock_move_line_lock_qty_done/README.rst b/stock_move_line_lock_qty_done/README.rst index c92cb1be2b94..d8b214bb9eff 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 efeb12af09a2..794a98b42f5d 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 431f51c27470..515a3a6a8f5c 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 000000000000..c54fe29a1248 --- /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 000000000000..000d70ffe315 --- /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 f48172f00d93..54ab08776ffa 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 70cec83f6e60..fd3f50c2ebac 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 50e6298db563..6f1f7741fda7 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 837e74981bb8..a88265c275b8 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 86e848c3ce27..76ae8dff96b1 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 8b494312a456..cd5c58cd478e 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 000000000000..e661b9744b62 --- /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 + + + +
+
+ +
+
+
+
+
+
+
+