-
-
Notifications
You must be signed in to change notification settings - Fork 723
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by pedrobaeza
- Loading branch information
Showing
41 changed files
with
4,250 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
setup/stock_inventory_discrepancy/odoo/addons/stock_inventory_discrepancy
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 @@ | ||
../../../../stock_inventory_discrepancy |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
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,110 @@ | ||
=========================== | ||
Stock Inventory Discrepancy | ||
=========================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:0efdc09fe825f32b12c7add6f17e5a2d37dc61eb02dbbfe7fb521868339981ae | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github | ||
:target: https://github.com/OCA/stock-logistics-warehouse/tree/15.0/stock_inventory_discrepancy | ||
:alt: OCA/stock-logistics-warehouse | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-15-0/stock-logistics-warehouse-15-0-stock_inventory_discrepancy | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&target_branch=15.0 | ||
:alt: Try me on Runboat | ||
|
||
|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. | ||
|
||
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 | ||
threshold now. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
#. Go to "Inventory > Warehouse Management" > Warehouses" or to "Inventory > | ||
Warehouse Management" > Locations". | ||
#. Modify the "Maximum Discrepancy Rate Threshold" either in a Warehouse or | ||
in a location. If set to 0.0 in both the threshold is disabled. | ||
|
||
Usage | ||
===== | ||
|
||
If you configured a "Maximum Discrepancy Rate Threshold". | ||
|
||
#. When validating an Inventory Adjustment if some line exceed the Discrepancy | ||
Threshold the system will set the inventory's state to 'Pending to Approve' | ||
and show the quantity of lines that exceed the threshold. | ||
#. If both WH and location thresholds are configured, the location one has | ||
preference. | ||
#. The user with "Validate All inventory Adjustments" rights can force the | ||
validation of an inventory pending to approve. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_inventory_discrepancy%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* ForgeFlow | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Lois Rilo <[email protected]> | ||
* Andreas Dian Sukarno Putro <[email protected]> | ||
* Bhavesh Odedra <[email protected]> | ||
* Héctor Villarreal <[email protected]> | ||
* `Tecnativa <https://www.tecnativa.com>`_: | ||
|
||
* Ernesto Tejeda | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
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. | ||
|
||
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/15.0/stock_inventory_discrepancy>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
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,5 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import models | ||
from . import wizards | ||
from .hooks import post_load_hook |
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 @@ | ||
# Copyright 2017-2020 ForgeFlow S.L. (http://www.forgeflow.com) | ||
# Copyright 2023 Tecnativa - Carolina Fernandez | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Stock Inventory Discrepancy", | ||
"summary": "Adds the capability to show the discrepancy of every line in " | ||
"an inventory and to block the inventory validation when the " | ||
"discrepancy is over a user defined threshold.", | ||
"version": "16.0.1.0.0", | ||
"author": "ForgeFlow, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/stock-logistics-warehouse", | ||
"category": "Warehouse", | ||
"depends": ["stock"], | ||
"data": [ | ||
"security/stock_inventory_discrepancy_security.xml", | ||
"security/ir.model.access.csv", | ||
"views/stock_quant_view.xml", | ||
"views/stock_warehouse_view.xml", | ||
"views/stock_location_view.xml", | ||
"wizards/confirm_discrepancy_wiz.xml", | ||
], | ||
"license": "AGPL-3", | ||
"post_load": "post_load_hook", | ||
"installable": True, | ||
"application": False, | ||
} |
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,76 @@ | ||
# Copyright 2019 ForgeFlow S.L. | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
|
||
|
||
from odoo import _, fields | ||
from odoo.exceptions import UserError | ||
from odoo.tools.float_utils import float_compare | ||
|
||
from odoo.addons.stock.models.stock_quant import StockQuant | ||
|
||
|
||
def post_load_hook(): | ||
def _apply_inventory_discrepancy(self): | ||
"""Override method to avoid inline group validation""" | ||
move_vals = [] | ||
# START HOOK: - Allow specific group to validate inventory | ||
# - Allow validate on pending status | ||
if ( | ||
not self.user_has_groups("stock.group_stock_manager") | ||
and not self.user_has_groups( | ||
"stock_inventory_discrepancy.group_stock_inventory_validation" | ||
) | ||
and not self.user_has_groups( | ||
"stock_inventory_discrepancy.group_stock_inventory_validation_always" | ||
) | ||
): | ||
raise UserError( | ||
_("Only a stock manager can validate an inventory adjustment.") | ||
) | ||
# Allow to write last_inventory_date on stock.location | ||
self = self.sudo() | ||
# END HOOK | ||
for quant in self: | ||
# Create and validate a move so that the quant matches its `inventory_quantity`. | ||
if ( | ||
float_compare( | ||
quant.inventory_diff_quantity, | ||
0, | ||
precision_rounding=quant.product_uom_id.rounding, | ||
) | ||
> 0 | ||
): | ||
move_vals.append( | ||
quant._get_inventory_move_values( | ||
quant.inventory_diff_quantity, | ||
quant.product_id.with_company( | ||
quant.company_id | ||
).property_stock_inventory, | ||
quant.location_id, | ||
) | ||
) | ||
else: | ||
move_vals.append( | ||
quant._get_inventory_move_values( | ||
-quant.inventory_diff_quantity, | ||
quant.location_id, | ||
quant.product_id.with_company( | ||
quant.company_id | ||
).property_stock_inventory, | ||
out=True, | ||
) | ||
) | ||
moves = ( | ||
self.env["stock.move"].with_context(inventory_mode=False).create(move_vals) | ||
) | ||
moves._action_done() | ||
self.location_id.write({"last_inventory_date": fields.Date.today()}) | ||
date_by_location = { | ||
loc: loc._get_next_inventory_date() for loc in self.mapped("location_id") | ||
} | ||
for quant in self: | ||
quant.inventory_date = date_by_location[quant.location_id] | ||
self.write({"inventory_quantity": 0, "user_id": False}) | ||
self.write({"inventory_diff_quantity": 0}) | ||
|
||
StockQuant._patch_method("_apply_inventory", _apply_inventory_discrepancy) |
Oops, something went wrong.