File tree 4 files changed +68
-0
lines changed
stock_scrap_tier_validation
4 files changed +68
-0
lines changed Original file line number Diff line number Diff line change 1
1
# Copyright 2023 Jarsa
2
2
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3
3
4
+ from . import stock_picking
4
5
from . import stock_scrap
5
6
from . import tier_definition
Original file line number Diff line number Diff line change
1
+ # Copyright 2024 360ERP (<https://www.360erp.com>)
2
+ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3
+
4
+ from odoo import models
5
+
6
+
7
+ class StockPicking (models .Model ):
8
+ _inherit = "stock.picking"
9
+
10
+ def button_scrap (self ):
11
+ """Fix compatibility with stock_scrap_tier_validation.
12
+
13
+ The way that super opens the scrap form in a popup window prevents
14
+ the tier validation UI elements from being effective. The record is
15
+ only saved when closing the popup. Given that it's only possible to
16
+ check if the record needs validation after saving, the popup will
17
+ always raise the 'validation required' error which blocks saving it.
18
+
19
+ As a workaround, we open the unsaved scrap record in the main window
20
+ so that it can be saved first and then be requested validation for
21
+ in the usual way.
22
+ """
23
+ action = super ().button_scrap ()
24
+ action .pop ("target" )
25
+ return action
Original file line number Diff line number Diff line change @@ -64,3 +64,9 @@ def test_validation_stock_scrap(self):
64
64
scrap .with_user (self .test_user_1 ).validate_tier ()
65
65
scrap .action_validate ()
66
66
self .assertEqual (scrap .state , "done" )
67
+
68
+ def test_stock_picking_scrap (self ):
69
+ """Scrapping from picking does not open in a popup"""
70
+ picking = self .env ["stock.picking" ].search ([], limit = 1 )
71
+ action = picking .button_scrap ()
72
+ self .assertFalse (action .get ("target" ))
Original file line number Diff line number Diff line change 21
21
</xpath >
22
22
</field >
23
23
</record >
24
+ <!--
25
+ Boost this minimal view with sheet and header tags,
26
+ for compatibility with base_tier_validation's automatic
27
+ view manipulation.
28
+ -->
29
+ <record id =" stock_scrap_form_view2" model =" ir.ui.view" >
30
+ <field name =" inherit_id" ref =" stock.stock_scrap_form_view2" />
31
+ <field name =" model" >stock.scrap</field >
32
+ <field name =" priority" eval =" 999" />
33
+ <field name =" arch" type =" xml" >
34
+ <xpath expr =" /form/group" position =" before" >
35
+ <header >
36
+ <!-- Include some buttons from the primary form -->
37
+ <button
38
+ name =" action_validate"
39
+ attrs =" {'invisible': [('state', '!=', 'draft')]}"
40
+ string =" Validate"
41
+ type =" object"
42
+ class =" oe_highlight"
43
+ context =" {'not_unlink_on_discard': True}"
44
+ data-hotkey =" v"
45
+ />
46
+ <field
47
+ name =" state"
48
+ widget =" statusbar"
49
+ statusbar_visible =" draft,done"
50
+ />
51
+ </header >
52
+ <sheet />
53
+ <footer position =" replace" />
54
+ </xpath >
55
+ <sheet position =" inside" >
56
+ <xpath expr =" /form/group" position =" move" />
57
+ </sheet >
58
+ </field >
59
+ </record >
24
60
</odoo >
You can’t perform that action at this time.
0 commit comments