diff --git a/stock_scrap_tier_validation/models/__init__.py b/stock_scrap_tier_validation/models/__init__.py index 90448d34afbf..db6df331b792 100644 --- a/stock_scrap_tier_validation/models/__init__.py +++ b/stock_scrap_tier_validation/models/__init__.py @@ -1,5 +1,6 @@ # Copyright 2023 Jarsa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import stock_picking from . import stock_scrap from . import tier_definition diff --git a/stock_scrap_tier_validation/models/stock_picking.py b/stock_scrap_tier_validation/models/stock_picking.py new file mode 100644 index 000000000000..87d717293854 --- /dev/null +++ b/stock_scrap_tier_validation/models/stock_picking.py @@ -0,0 +1,25 @@ +# Copyright 2024 360ERP () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class StockPicking(models.Model): + _inherit = "stock.picking" + + def button_scrap(self): + """Fix compatibility with stock_scrap_tier_validation. + + The way that super opens the scrap form in a popup window prevents + the tier validation UI elements from being effective. The record is + only saved when closing the popup. Given that it's only possible to + check if the record needs validation after saving, the popup will + always raise the 'validation required' error which blocks saving it. + + As a workaround, we open the unsaved scrap record in the main window + so that it can be saved first and then be requested validation for + in the usual way. + """ + action = super().button_scrap() + action.pop("target") + return action diff --git a/stock_scrap_tier_validation/static/description/index.html b/stock_scrap_tier_validation/static/description/index.html index 9dc4cfe36945..0ba3ae2e6a49 100644 --- a/stock_scrap_tier_validation/static/description/index.html +++ b/stock_scrap_tier_validation/static/description/index.html @@ -8,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z 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. @@ -274,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* 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 } @@ -300,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -446,7 +447,9 @@

Contributors

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +Odoo Community Association +

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.

diff --git a/stock_scrap_tier_validation/tests/test_tier_validation.py b/stock_scrap_tier_validation/tests/test_tier_validation.py index 65bf283beb16..50c5daabf3b0 100644 --- a/stock_scrap_tier_validation/tests/test_tier_validation.py +++ b/stock_scrap_tier_validation/tests/test_tier_validation.py @@ -64,3 +64,9 @@ def test_validation_stock_scrap(self): scrap.with_user(self.test_user_1).validate_tier() scrap.action_validate() self.assertEqual(scrap.state, "done") + + def test_stock_picking_scrap(self): + """Scrapping from picking does not open in a popup""" + picking = self.env["stock.picking"].search([], limit=1) + action = picking.button_scrap() + self.assertFalse(action.get("target")) diff --git a/stock_scrap_tier_validation/views/stock_scrap_view.xml b/stock_scrap_tier_validation/views/stock_scrap_view.xml index 882efd3f7d1b..aa54585fb2ca 100644 --- a/stock_scrap_tier_validation/views/stock_scrap_view.xml +++ b/stock_scrap_tier_validation/views/stock_scrap_view.xml @@ -21,4 +21,40 @@ + + + + stock.scrap + + + +
+ +
+ +