Skip to content

Commit

Permalink
[IMP] stock_inventory_discrepancy: add system parameter configuration…
Browse files Browse the repository at this point in the history
… for enabling discrepancy check
  • Loading branch information
AungKoKoLin1997 committed Mar 20, 2024
1 parent 8c475dc commit 0a89a0e
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion stock_inventory_discrepancy/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Stock Inventory Discrepancy
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:49949b52008fb335a36237b047619ef422c8377d3f70a291232c58658eb31ebd
!! source digest: sha256:0b89a2335bf4b193b3e2d426b5f2bbedc0706413791591a477317311d092e61c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 2 additions & 0 deletions stock_inventory_discrepancy/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
"data": [
"security/stock_inventory_discrepancy_security.xml",
"security/ir.model.access.csv",
"data/ir_config_parameter.xml",
"views/stock_quant_view.xml",
"views/stock_warehouse_view.xml",
"views/stock_location_view.xml",
"wizards/confirm_discrepancy_wiz.xml",
],
"demo": ["demo/demo_ir_config_parameter.xml"],
"license": "AGPL-3",
"post_load": "post_load_hook",
"installable": True,
Expand Down
10 changes: 10 additions & 0 deletions stock_inventory_discrepancy/data/ir_config_parameter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<!-- System Parameter for Enabling Inventory Discrepancy -->
<record id="param_inventory_discrepancy_enable" model="ir.config_parameter">
<field
name="key"
>stock_inventory_discrepancy.inventory_discrepancy_enable</field>
<field name="value">1</field> <!-- Enable by default -->
</record>
</odoo>
9 changes: 9 additions & 0 deletions stock_inventory_discrepancy/demo/demo_ir_config_parameter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="param_inventory_discrepancy_enable" model="ir.config_parameter">
<field
name="key"
>stock_inventory_discrepancy.inventory_discrepancy_enable</field>
<field name="value">0</field> <!-- Disable for tests case -->
</record>
</odoo>
7 changes: 7 additions & 0 deletions stock_inventory_discrepancy/models/stock_quant.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ def _compute_has_over_discrepancy(self):
def action_apply_inventory(self):
if self.env.context.get("skip_exceeded_discrepancy", False):
return super().action_apply_inventory()
inventory_discrepancy_enable = (
self.env["ir.config_parameter"]
.sudo()
.get_param("stock_inventory_discrepancy.inventory_discrepancy_enable")
)
if inventory_discrepancy_enable == "0":
return super().action_apply_inventory()
over_discrepancy = self.filtered(lambda r: r.has_over_discrepancy)
if over_discrepancy:
action = self.env["ir.actions.act_window"]._for_xml_id(
Expand Down
2 changes: 1 addition & 1 deletion stock_inventory_discrepancy/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Stock Inventory Discrepancy</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:49949b52008fb335a36237b047619ef422c8377d3f70a291232c58658eb31ebd
!! source digest: sha256:0b89a2335bf4b193b3e2d426b5f2bbedc0706413791591a477317311d092e61c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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-warehouse/tree/16.0/stock_inventory_discrepancy"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-16-0/stock-logistics-warehouse-16-0-stock_inventory_discrepancy"><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-warehouse&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>Adds the capability to show the discrepancy of every line in an inventory and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
class TestInventoryDiscrepancy(TransactionCase):
def setUp(self):
super().setUp()
# Enable the configuration using ir.config_parameter
self.env["ir.config_parameter"].sudo().set_param(
"stock_inventory_discrepancy.inventory_discrepancy_enable", "1"
)
self.obj_location = self.env["stock.location"]
self.obj_product = self.env["product.product"]
self.obj_warehouse = self.env["stock.warehouse"]
Expand Down

0 comments on commit 0a89a0e

Please sign in to comment.