Merge PR #1966 into 16.0

Signed-off-by rousseldenis
This commit is contained in:
OCA-git-bot
2024-12-11 09:27:43 +00:00
11 changed files with 78 additions and 16 deletions

View File

@@ -28,9 +28,9 @@ Stock Inventory Discrepancy
|badge1| |badge2| |badge3| |badge4| |badge5|
Adds the capability to show the discrepancy of every line in an inventory and
to block the inventory validation (setting it as 'Pending to Approve') when the
discrepancy is greater than an user defined threshold.
This module adds the capability to show discrepancies for each line in an inventory and
to block inventory validation (setting it as 'Pending to Approve') when the discrepancy
exceeds a user-defined threshold. This is configurable per company through the settings.
Only new group "Validate All inventory Adjustments" will be able to force the
validation of those blocked inventories. By default, Stock manager will belong
@@ -45,6 +45,7 @@ threshold now.
Configuration
=============
#. Go to "Inventory > Settings" and select the 'Inventory Discrepancy Control' option to block the inventory validation. This should be done for each company.
#. Go to "Inventory > Warehouse Management" > Warehouses" or to "Inventory >
Warehouse Management" > Locations".
#. Modify the "Maximum Discrepancy Rate Threshold" either in a Warehouse or

View File

@@ -17,6 +17,7 @@
"views/stock_quant_view.xml",
"views/stock_warehouse_view.xml",
"views/stock_location_view.xml",
"views/res_config_settings_view.xml",
"wizards/confirm_discrepancy_wiz.xml",
],
"license": "AGPL-3",

View File

@@ -1,5 +1,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import res_company
from . import res_config_settings
from . import stock_quant
from . import stock_warehouse
from . import stock_location

View File

@@ -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"
inventory_discrepancy_enable = fields.Boolean(
string="Inventory Discrepancy Control",
help="Block validation of the inventory adjustment if discrepancy exceeds "
"the threshold.",
)

View File

@@ -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"
inventory_discrepancy_enable = fields.Boolean(
related="company_id.inventory_discrepancy_enable",
readonly=False,
string="Inventory Discrepancy Control",
help="Block validation of the inventory adjustment if discrepancy exceeds "
"the threshold.",
)

View File

@@ -76,6 +76,8 @@ class StockQuant(models.Model):
def action_apply_inventory(self):
if self.env.context.get("skip_exceeded_discrepancy", False):
return super().action_apply_inventory()
if not self.env.company.inventory_discrepancy_enable:
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(

View File

@@ -1,3 +1,4 @@
#. Go to "Inventory > Settings" and select the 'Inventory Discrepancy Control' option to block the inventory validation. This should be done for each company.
#. Go to "Inventory > Warehouse Management" > Warehouses" or to "Inventory >
Warehouse Management" > Locations".
#. Modify the "Maximum Discrepancy Rate Threshold" either in a Warehouse or

View File

@@ -1,6 +1,6 @@
Adds the capability to show the discrepancy of every line in an inventory and
to block the inventory validation (setting it as 'Pending to Approve') when the
discrepancy is greater than an user defined threshold.
This module adds the capability to show discrepancies for each line in an inventory and
to block inventory validation (setting it as 'Pending to Approve') when the discrepancy
exceeds a user-defined threshold. This is configurable per company through the settings.
Only new group "Validate All inventory Adjustments" will be able to force the
validation of those blocked inventories. By default, Stock manager will belong

View File

@@ -8,11 +8,10 @@
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
@@ -275,7 +274,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -301,7 +300,7 @@ span.option {
span.pre {
white-space: pre }
span.problematic, pre.problematic {
span.problematic {
color: red }
span.section-subtitle {
@@ -370,9 +369,9 @@ ul.auto-toc {
!! source digest: sha256:f641b413629bafcfd49b92f193419c1f3b79b143737dd5c7bad281002266fdd8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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
to block the inventory validation (setting it as Pending to Approve) when the
discrepancy is greater than an user defined threshold.</p>
<p>This module adds the capability to show discrepancies for each line in an inventory and
to block inventory validation (setting it as Pending to Approve) when the discrepancy
exceeds a user-defined threshold. This is configurable per company through the settings.</p>
<p>Only new group “Validate All inventory Adjustments” will be able to force the
validation of those blocked inventories. By default, Stock manager will belong
to this group. In addition, Stock Users can validate inventories under the
@@ -394,6 +393,7 @@ threshold now.</p>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<ol class="arabic simple">
<li>Go to “Inventory &gt; Settings” and select the Inventory Discrepancy Control option to block the inventory validation. This should be done for each company.</li>
<li>Go to “Inventory &gt; Warehouse Management” &gt; Warehouses” or to “Inventory &gt;
Warehouse Management” &gt; Locations”.</li>
<li>Modify the “Maximum Discrepancy Rate Threshold” either in a Warehouse or
@@ -446,9 +446,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>

View File

@@ -10,6 +10,7 @@ from odoo.tests.common import TransactionCase, tagged
class TestInventoryDiscrepancy(TransactionCase):
def setUp(self):
super().setUp()
self.env.company.inventory_discrepancy_enable = True
self.obj_location = self.env["stock.location"]
self.obj_product = self.env["product.product"]
self.obj_warehouse = self.env["stock.warehouse"]

View File

@@ -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>