Skip to content

Commit 922c2a5

Browse files
committed
[IMP] stock_weighing: Do not break workflow to record weight is user wants to print labels
TT51483
1 parent 965a7d0 commit 922c2a5

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

stock_weighing/__manifest__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
"website": "https://github.com/OCA/stock-weighing",
99
"license": "AGPL-3",
1010
"category": "Inventory",
11-
"depends": ["stock", "web_filter_header_button", "web_widget_numeric_step"],
11+
"depends": [
12+
"stock",
13+
"web_filter_header_button",
14+
"web_widget_numeric_step",
15+
"web_ir_actions_act_multi",
16+
],
1217
"data": [
1318
"security/ir.model.access.csv",
1419
"views/start_screen_banner.xml",

stock_weighing/wizards/weighing_wizard.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# Copyright 2024 Tecnativa - David Vidal
2+
# Copyright 2024 Tecnativa - Sergio Teruel
23
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
34
from odoo import _, api, fields, models
45
from odoo.exceptions import UserError
56
from odoo.tools.misc import clean_context
67

8+
from odoo.addons.web.controllers.main import clean_action
9+
710

811
class StockMoveWeightWizard(models.TransientModel):
912
_name = "weighing.wizard"
@@ -127,15 +130,33 @@ def record_weight(self):
127130
# Unlock the operation
128131
selected_line.move_id.action_unlock_weigh_operation()
129132
self.weight = 0.0
133+
action_list = []
134+
other_action = False
130135
if self.print_label:
131136
action = selected_line.action_print_weight_record_label()
132137
if not self.env.context.get("reload_wizard_action", False):
133138
# If we want to keep the wizard open for multiple weighing, we do not
134139
# need to close the wizard after printing a label.
135140
action["close_on_report_download"] = True
136-
return action
141+
clean_action(action, self.env)
142+
action_list.append(action)
137143
if self.env.context.get("reload_wizard_action", False):
138-
return self.reload_action_wizard()
144+
other_action = self.reload_action_wizard()
145+
clean_action(other_action, self.env)
146+
return self._actions_after_record_weight(action_list, other_action=other_action)
147+
148+
@api.model
149+
def _actions_after_record_weight(self, actions, other_action=False):
150+
"""Print and return action window and no break workflow allowing print with
151+
multi-thread option"""
152+
action_list = []
153+
if other_action:
154+
action_list = actions + [other_action]
155+
else:
156+
action_list = actions + [
157+
{"type": "ir.actions.act_window_close"},
158+
]
159+
return {"type": "ir.actions.act_multi", "actions": action_list}
139160

140161
def action_close(self):
141162
"""Close but unlock the operation"""

0 commit comments

Comments
 (0)