-
-
Notifications
You must be signed in to change notification settings - Fork 644
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
878 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
setup/stock_restrict_lot_update/odoo/addons/stock_restrict_lot_update
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_restrict_lot_update |
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,109 @@ | ||
========================= | ||
Stock Restrict Lot Domain | ||
========================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:b96c96e54deba74197f2baff98dd875f8fcec856b81fbc1e55a27a7a50d63bd5 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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--workflow-lightgray.png?logo=github | ||
:target: https://github.com/OCA/stock-logistics-workflow/tree/14.0/stock_restrict_lot_update | ||
:alt: OCA/stock-logistics-workflow | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-14-0/stock-logistics-workflow-14-0-stock_restrict_lot_update | ||
: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-workflow&target_branch=14.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module builds on `stock_restrict_lot` and exposes the field | ||
`restrict_lot_id` of `stock.move`, allowing the user to update or | ||
even remove the lot restriction if the product does not fall within | ||
a domain. | ||
|
||
The domain can be updated in the settings of each individual company. | ||
|
||
Any change to `restrict_lot_id` is propagated to linked stock moves, | ||
but only forwards, not backwards. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
Go to Settings > Inventory > Enforce lot restrictions | ||
|
||
Set a domain for the products for which lot restriction on stock moves should apply (empty domain: all products) | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-workflow/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-workflow/issues/new?body=module:%20stock_restrict_lot_update%0Aversion:%2014.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 | ||
~~~~~~~ | ||
|
||
* Ooops404 | ||
* PyTech SRL | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Ooops404 | ||
|
||
* Francesco Foresti [email protected] | ||
|
||
* PyTech SRL | ||
|
||
* Alessandro Uffreduzzi <[email protected]> | ||
|
||
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. | ||
|
||
.. |maintainer-aleuffre| image:: https://github.com/aleuffre.png?size=40px | ||
:target: https://github.com/aleuffre | ||
:alt: aleuffre | ||
.. |maintainer-renda-dev| image:: https://github.com/renda-dev.png?size=40px | ||
:target: https://github.com/renda-dev | ||
:alt: renda-dev | ||
|
||
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-aleuffre| |maintainer-renda-dev| | ||
|
||
This module is part of the `OCA/stock-logistics-workflow <https://github.com/OCA/stock-logistics-workflow/tree/14.0/stock_restrict_lot_update>`_ 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 @@ | ||
from . import models |
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,18 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "Stock Restrict Lot Domain", | ||
"summary": "Only apply lot restriction on products in a domain", | ||
"version": "14.0.1.0.0", | ||
"category": "Warehouse Management", | ||
"website": "https://github.com/OCA/stock-logistics-workflow", | ||
"author": "Ooops404, PyTech SRL, Odoo Community Association (OCA)", | ||
"maintainers": ["aleuffre", "renda-dev"], | ||
"license": "AGPL-3", | ||
"installable": True, | ||
"depends": ["stock_restrict_lot"], | ||
"data": [ | ||
"views/stock_picking_views.xml", | ||
"views/res_config_settings_views.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,3 @@ | ||
from . import res_company | ||
from . import res_config_settings | ||
from . import stock_move |
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,15 @@ | ||
# Copyright 2023 Ooops404 | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import fields, models | ||
|
||
|
||
class ResCompany(models.Model): | ||
_inherit = "res.company" | ||
|
||
enforce_lot_restriction_product_domain = fields.Char( | ||
default="[]", | ||
string="Enforce lot restrictions", | ||
help="Lot restriction of stock movements cannot be changed " | ||
"for products in this domain.\n if empty, lot restrictions " | ||
"cannot be changed for any product.", | ||
) |
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,12 @@ | ||
# Copyright 2023 Ooops404 | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
enforce_lot_restriction_product_domain = fields.Char( | ||
related="company_id.enforce_lot_restriction_product_domain", | ||
readonly=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,38 @@ | ||
# Copyright 2023 Ooops404 | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, fields, models | ||
from odoo.tools.safe_eval import safe_eval | ||
|
||
|
||
class StockMove(models.Model): | ||
_inherit = "stock.move" | ||
|
||
change_restrict_lot = fields.Boolean( | ||
compute="_compute_change_restrict_lot", | ||
help="If the product is in the domain", | ||
) | ||
|
||
@api.depends("product_id", "company_id") | ||
def _compute_change_restrict_lot(self): | ||
for move in self: | ||
product_domain = safe_eval( | ||
move.sudo().company_id.enforce_lot_restriction_product_domain | ||
) | ||
# if product is not in the enforcement domain, user can change the lot | ||
move.change_restrict_lot = not move.product_id.filtered_domain( | ||
product_domain | ||
) | ||
|
||
def write(self, vals): | ||
""" | ||
Propagate changes to restrict_lot_id to all | ||
destination moves - recursively. | ||
""" | ||
res = super().write(vals) | ||
if "restrict_lot_id" in vals: | ||
related_moves = self.mapped("move_dest_ids") | ||
if related_moves: | ||
related_moves.write({"restrict_lot_id": vals["restrict_lot_id"]}) | ||
self._action_assign() | ||
return res |
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,7 @@ | ||
* Ooops404 | ||
|
||
* Francesco Foresti [email protected] | ||
|
||
* PyTech SRL | ||
|
||
* Alessandro Uffreduzzi <[email protected]> |
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 @@ | ||
This module builds on `stock_restrict_lot` and exposes the field | ||
`restrict_lot_id` of `stock.move`, allowing the user to update or | ||
even remove the lot restriction if the product does not fall within | ||
a domain. | ||
|
||
The domain can be updated in the settings of each individual company. | ||
|
||
Any change to `restrict_lot_id` is propagated to linked stock moves, | ||
but only forwards, not backwards. |
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,3 @@ | ||
Go to Settings > Inventory > Enforce lot restrictions | ||
|
||
Set a domain for the products for which lot restriction on stock moves should apply (empty domain: all products) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.