Skip to content

Commit

Permalink
[IMP] stock_move_line_lock_qty_done: prevent test cases from other mo…
Browse files Browse the repository at this point in the history
…dules from failing
  • Loading branch information
AungKoKoLin1997 committed Nov 25, 2024
1 parent ff4ac9b commit 101a2bf
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 10 deletions.
9 changes: 7 additions & 2 deletions stock_move_line_lock_qty_done/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand All @@ -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 restrict the ability to modify the done quantity for validated stock moves.

Bug Tracker
===========

Expand All @@ -64,6 +66,9 @@ Contributors
~~~~~~~~~~~~

* Souheil Bejaoui <[email protected]>
* `Quartile <https://www.quartile.co>`_:

* Aung Ko Ko Lin

Maintainers
~~~~~~~~~~~
Expand Down
6 changes: 4 additions & 2 deletions stock_move_line_lock_qty_done/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
}
2 changes: 2 additions & 0 deletions stock_move_line_lock_qty_done/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from . import res_company
from . import res_config_settings
from . import stock_move_line
14 changes: 14 additions & 0 deletions stock_move_line_lock_qty_done/models/res_company.py
Original file line number Diff line number Diff line change
@@ -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.",
)
16 changes: 16 additions & 0 deletions stock_move_line_lock_qty_done/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -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.",
)
2 changes: 1 addition & 1 deletion stock_move_line_lock_qty_done/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions stock_move_line_lock_qty_done/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -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 restrict the ability to modify the done quantity for validated stock moves.
3 changes: 3 additions & 0 deletions stock_move_line_lock_qty_done/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
* Souheil Bejaoui <[email protected]>
* `Quartile <https://www.quartile.co>`_:

* Aung Ko Ko Lin
4 changes: 2 additions & 2 deletions stock_move_line_lock_qty_done/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 7 additions & 3 deletions stock_move_line_lock_qty_done/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -370,8 +369,8 @@ <h1 class="title">Lock Done Quantity Changes in Stock Moves</h1>
!! source digest: sha256:ddd0e3ea97313eb20b471c05dc1b1a8d0bf84fcfcf8367f9049daa3cb0ec3fc6
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_move_line_lock_qty_done"><img alt="OCA/stock-logistics-workflow" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-stock_move_line_lock_qty_done"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-workflow&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module limits the capability to modify the done quantity for stock moves
once they have been validated.</p>
<p>This module can limit the ability to modify the done quantity of stock moves once they are validated,
configurable per company through the settings.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
Expand All @@ -389,6 +388,7 @@ <h1 class="title">Lock Done Quantity Changes in Stock Moves</h1>
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>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”</p>
<p>Enable the ‘Limit Updates to Done Quantity After Validation’ option under ‘Inventory &gt; Settings’ to restrict the ability to modify the done quantity for validated stock moves.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
Expand All @@ -410,6 +410,10 @@ <h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li>Souheil Bejaoui &lt;<a class="reference external" href="mailto:souheil.bejaoui&#64;acsone.eu">souheil.bejaoui&#64;acsone.eu</a>&gt;</li>
<li><a class="reference external" href="https://www.quartile.co">Quartile</a>:<ul>
<li>Aung Ko Ko Lin</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
23 changes: 23 additions & 0 deletions stock_move_line_lock_qty_done/views/res_config_settings_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_stock_config_settings" model="ir.ui.view">
<field name="name">res.config.settings</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="stock.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@id='warning_info']" position="after">
<div class="col-12 col-lg-6 o_setting_box" id="lock_qty_done">
<div class="o_setting_left_pane">
<field name="lock_qty_done" />
</div>
<div class="o_setting_right_pane">
<label for="lock_qty_done" />
<div class="text-muted">
Only users in the 'Can Edit Done Quantity for Done Stock Moves' group are allowed to edit the 'done' quantity for validated transfer.
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>

0 comments on commit 101a2bf

Please sign in to comment.