diff --git a/stock_exception/README.rst b/stock_exception/README.rst
index 237b4864f566..75bdee9915e4 100644
--- a/stock_exception/README.rst
+++ b/stock_exception/README.rst
@@ -7,7 +7,7 @@ Stock Exception
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- !! source digest: sha256:f159cd4bbfb0c69257c594fa55feda897a680f3c04dcbd8dde3b5c87eabc615d
+ !! source digest: sha256:9b8183c2a60002050aaae57962c63dba0c1d30762d8cc7f0f8273f52c62135a3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -17,13 +17,13 @@ Stock Exception
: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/14.0/stock_exception
+ :target: https://github.com/OCA/stock-logistics-warehouse/tree/16.0/stock_exception
: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-14-0/stock-logistics-warehouse-14-0-stock_exception
+ :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-16-0/stock-logistics-warehouse-16-0-stock_exception
: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=14.0
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&target_branch=16.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -46,7 +46,7 @@ Bug Tracker
Bugs are tracked on `GitHub 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 `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -76,6 +76,6 @@ 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 `_ project on GitHub.
+This module is part of the `OCA/stock-logistics-warehouse `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/stock_exception/__manifest__.py b/stock_exception/__manifest__.py
index 92c677f17191..59854cdf4e2d 100644
--- a/stock_exception/__manifest__.py
+++ b/stock_exception/__manifest__.py
@@ -4,7 +4,7 @@
{
"name": "Stock Exception",
"summary": "Custom exceptions on stock picking",
- "version": "14.0.1.0.2",
+ "version": "16.0.1.0.0",
"category": "Generic Modules/Warehouse Management",
"author": "Ecosoft, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-warehouse",
@@ -15,6 +15,7 @@
"data/stock_exception_data.xml",
"wizard/stock_exception_confirm_view.xml",
"views/stock_view.xml",
+ "views/exception_rule_views.xml",
],
"installable": True,
}
diff --git a/stock_exception/i18n/es.po b/stock_exception/i18n/es.po
new file mode 100644
index 000000000000..e9cb6ef3c1a2
--- /dev/null
+++ b/stock_exception/i18n/es.po
@@ -0,0 +1,31 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * stock_exception
+#
+# Translators:
+# Matias Velazquez
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 15.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2022-06-28 22:06+0000\n"
+"PO-Revision-Date: 2023-09-03 00:15+0000\n"
+"Last-Translator: Matias Velazquez \n"
+"Language-Team: \n"
+"Language: es\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: nplurals=2; plural=n != 1;\n"
+"X-Generator: Weblate 4.17\n"
+
+#. module: stock_exception
+#: model:ir.model.fields,field_description:stock_exception.field_exception_rule__check_on_confirm
+msgid "Check On Confirm"
+msgstr "Chequear al Confirmar"
+
+#. module: stock_exception
+#: model:ir.model.fields,field_description:stock_exception.field_exception_rule__check_on_validate
+msgid "Check On Validate"
+msgstr "Chequear al Validar"
diff --git a/stock_exception/models/exception_rule.py b/stock_exception/models/exception_rule.py
index f47aa828cd6e..cd4a28911d56 100644
--- a/stock_exception/models/exception_rule.py
+++ b/stock_exception/models/exception_rule.py
@@ -15,3 +15,5 @@ class ExceptionRule(models.Model):
],
ondelete={"stock.picking": "cascade", "stock.move": "cascade"},
)
+ check_on_validate = fields.Boolean(default=False)
+ check_on_confirm = fields.Boolean(default=False)
diff --git a/stock_exception/models/stock.py b/stock_exception/models/stock.py
index 0ea351d08833..b9150c90dfd4 100644
--- a/stock_exception/models/stock.py
+++ b/stock_exception/models/stock.py
@@ -2,6 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
from odoo import api, models
+from odoo.exceptions import ValidationError
class StockPicking(models.Model):
@@ -20,11 +21,11 @@ def _reverse_field(self):
def detect_exceptions(self):
all_exceptions = super().detect_exceptions()
- moves = self.mapped("move_lines")
+ moves = self.mapped("move_ids")
all_exceptions += moves.detect_exceptions()
return all_exceptions
- @api.constrains("ignore_exception", "move_lines", "state")
+ @api.constrains("ignore_exception", "move_ids", "state")
def stock_check_exception(self):
pickings = self.filtered(
lambda s: s.state in ["waiting", "confirmed", "assigned"]
@@ -32,17 +33,37 @@ def stock_check_exception(self):
if pickings:
pickings._check_exception()
- @api.onchange("move_lines")
+ @api.onchange("move_ids")
def onchange_ignore_exception(self):
if self.state in ["waiting", "confirmed", "assigned"]:
self.ignore_exception = False
def action_confirm(self):
- if self.detect_exceptions() and not self.ignore_exception:
- return self._popup_exceptions()
+ for rec in self:
+ if rec.detect_exceptions() and not rec.ignore_exception:
+ return rec._popup_exceptions()
return super().action_confirm()
+ def button_validate(self):
+ for rec in self:
+ if rec.detect_exceptions() and not rec.ignore_exception:
+ if rec.exception_ids.check_on_validate:
+ raise ValidationError("\n".join(rec.exception_ids.mapped("name")))
+ return super().button_validate()
+
@api.model
def _get_popup_action(self):
action = self.env.ref("stock_exception.action_stock_exception_confirm")
return action
+
+ def _check_exception(self):
+ if not self.env.context.get("check_exception", True):
+ return True
+ exception_ids = self.detect_exceptions()
+ if exception_ids and self.env.context.get("raise_exception", True):
+ exceptions = self.env["exception.rule"].browse(exception_ids)
+ for picking in exceptions.picking_ids:
+ if exceptions.check_on_confirm == True and picking.state == 'assigned':
+ raise ValidationError("\n".join(exceptions.mapped("name")))
+ if exceptions.check_on_validate == True and picking.state == 'done':
+ raise ValidationError("\n".join(exceptions.mapped("name")))
diff --git a/stock_exception/static/description/index.html b/stock_exception/static/description/index.html
index c5d72ca7b479..706b49df8709 100644
--- a/stock_exception/static/description/index.html
+++ b/stock_exception/static/description/index.html
@@ -367,9 +367,9 @@ Stock Exception
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!! source digest: sha256:f159cd4bbfb0c69257c594fa55feda897a680f3c04dcbd8dde3b5c87eabc615d
+!! source digest: sha256:9b8183c2a60002050aaae57962c63dba0c1d30762d8cc7f0f8273f52c62135a3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
This module allows you attach several customizable exceptions to your
stock picking in a way that you can filter pickings by exceptions type and fix them.
This is especially useful in an scenario for mass stock picking import, because it’s likely some pickings have
@@ -392,7 +392,7 @@
Bugs are tracked on GitHub 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.
+feedback.
Do not contact contributors directly about support or help with technical issues.
diff --git a/stock_exception/views/exception_rule_views.xml b/stock_exception/views/exception_rule_views.xml
new file mode 100644
index 000000000000..0ba548cca5c7
--- /dev/null
+++ b/stock_exception/views/exception_rule_views.xml
@@ -0,0 +1,14 @@
+
+
+
+ exception.rule.form
+ exception.rule
+
+
+
+
+
+
+
+
+