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 ba4bd44
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 4 deletions.
6 changes: 6 additions & 0 deletions stock_move_line_lock_qty_done/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ 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"


If necessary, update the "Limit Updates to Done Quantity After Validation" under "Inventory > Settings" to enable or disable limits the capability to modify the done quantity for validated stock moves (enabled by default).

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

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

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

* Aung Ko Ko Lin

Maintainers
~~~~~~~~~~~
Expand Down
7 changes: 5 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,9 @@
"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",
],
"demo": ["demo/demo_company.xml"],
}
5 changes: 5 additions & 0 deletions stock_move_line_lock_qty_done/demo/demo_company.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<function model="res.company" name="write">
<value model="res.company" search="[]" />
<value eval="{'lock_qty_done': False}" />
</function>
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
15 changes: 15 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,15 @@
# 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(
default=True,
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
3 changes: 3 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,5 @@
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"


If necessary, update the "Limit Updates to Done Quantity After Validation" under "Inventory > Settings" to enable or disable limits the capability to modify the done quantity for validated stock moves (enabled by default).
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
6 changes: 5 additions & 1 deletion 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 @@ -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>If necessary, update the “Limit Updates to Done Quantity After Validation” under “Inventory &gt; Settings” to enable or disable limits the capability to modify the done quantity for validated stock moves (enabled by default).</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 ba4bd44

Please sign in to comment.