-
-
Notifications
You must be signed in to change notification settings - Fork 721
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] stock_inventory_discrepancy: add system parameter configuration…
… for enabling discrepancy check
- Loading branch information
1 parent
1b6ab0b
commit d85c615
Showing
11 changed files
with
107 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
9
stock_inventory_discrepancy/demo/demo_ir_config_parameter.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright 2024 Quartile Limited | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
inventory_discrepancy_enable = fields.Boolean( | ||
string="Inventory Discrepancy Control", | ||
help="Block validation of the inventory adjustment if discrepancy exceeds " | ||
"the threshold.", | ||
) | ||
|
||
@api.model | ||
def get_values(self): | ||
res = super(ResConfigSettings, self).get_values() | ||
param = self.env["ir.config_parameter"].sudo() | ||
inventory_discrepancy_enable = ( | ||
param.get_param( | ||
"stock_inventory_discrepancy.inventory_discrepancy_enable", default="0" | ||
) | ||
== "1" | ||
) | ||
res.update( | ||
inventory_discrepancy_enable=inventory_discrepancy_enable, | ||
) | ||
return res | ||
|
||
# pylint: disable=missing-return | ||
def set_values(self): | ||
super(ResConfigSettings, self).set_values() | ||
param = self.env["ir.config_parameter"].sudo() | ||
param.set_param( | ||
"stock_inventory_discrepancy.inventory_discrepancy_enable", | ||
"1" if self.inventory_discrepancy_enable else "0", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
stock_inventory_discrepancy/views/res_config_settings_view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record id="view_stock_config_settings" model="ir.ui.view"> | ||
<field name="name">res.config.settings - inventory_discrepancy</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="inventory_discrepancy_enable" | ||
> | ||
<div class="o_setting_left_pane"> | ||
<field name="inventory_discrepancy_enable" /> | ||
</div> | ||
<div class="o_setting_right_pane"> | ||
<label for="inventory_discrepancy_enable" /> | ||
<div class="text-muted"> | ||
Block validation of the inventory adjustment if discrepancy exceeds the threshold. | ||
</div> | ||
</div> | ||
</div> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |