Skip to content

Commit

Permalink
Merge PR #19 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Nov 8, 2024
2 parents 7e91497 + 922c2a5 commit de81c72
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
7 changes: 6 additions & 1 deletion stock_weighing/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
"website": "https://github.com/OCA/stock-weighing",
"license": "AGPL-3",
"category": "Inventory",
"depends": ["stock", "web_filter_header_button", "web_widget_numeric_step"],
"depends": [
"stock",
"web_filter_header_button",
"web_widget_numeric_step",
"web_ir_actions_act_multi",
],
"data": [
"security/ir.model.access.csv",
"views/start_screen_banner.xml",
Expand Down
25 changes: 23 additions & 2 deletions stock_weighing/wizards/weighing_wizard.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Copyright 2024 Tecnativa - David Vidal
# Copyright 2024 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import _, api, fields, models
from odoo.exceptions import UserError
from odoo.tools.misc import clean_context

from odoo.addons.web.controllers.main import clean_action


class StockMoveWeightWizard(models.TransientModel):
_name = "weighing.wizard"
Expand Down Expand Up @@ -127,15 +130,33 @@ def record_weight(self):
# Unlock the operation
selected_line.move_id.action_unlock_weigh_operation()
self.weight = 0.0
action_list = []
other_action = False
if self.print_label:
action = selected_line.action_print_weight_record_label()
if not self.env.context.get("reload_wizard_action", False):
# If we want to keep the wizard open for multiple weighing, we do not
# need to close the wizard after printing a label.
action["close_on_report_download"] = True
return action
clean_action(action, self.env)
action_list.append(action)
if self.env.context.get("reload_wizard_action", False):
return self.reload_action_wizard()
other_action = self.reload_action_wizard()
clean_action(other_action, self.env)
return self._actions_after_record_weight(action_list, other_action=other_action)

@api.model
def _actions_after_record_weight(self, actions, other_action=False):
"""Print and return action window and no break workflow allowing print with
multi-thread option"""
action_list = []
if other_action:
action_list = actions + [other_action]
else:
action_list = actions + [
{"type": "ir.actions.act_window_close"},
]
return {"type": "ir.actions.act_multi", "actions": action_list}

def action_close(self):
"""Close but unlock the operation"""
Expand Down

0 comments on commit de81c72

Please sign in to comment.