Skip to content

Commit

Permalink
[IMP] stock_weighing: Do not break workflow to record weight is user …
Browse files Browse the repository at this point in the history
…wants to print labels

TT51483
  • Loading branch information
sergio-teruel committed Oct 30, 2024
1 parent 965a7d0 commit f45c415
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 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
11 changes: 4 additions & 7 deletions stock_weighing/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z 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.
Expand Down Expand Up @@ -275,7 +274,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* 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 }
Expand All @@ -301,7 +300,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -499,9 +498,7 @@ <h2><a class="toc-backref" href="#toc-entry-9">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-10">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
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 = []

Check warning on line 133 in stock_weighing/wizards/weighing_wizard.py

View check run for this annotation

Codecov / codecov/patch

stock_weighing/wizards/weighing_wizard.py#L133

Added line #L133 was not covered by tests
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)

Check warning on line 141 in stock_weighing/wizards/weighing_wizard.py

View check run for this annotation

Codecov / codecov/patch

stock_weighing/wizards/weighing_wizard.py#L140-L141

Added lines #L140 - L141 were not covered by tests
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)

Check warning on line 145 in stock_weighing/wizards/weighing_wizard.py

View check run for this annotation

Codecov / codecov/patch

stock_weighing/wizards/weighing_wizard.py#L143-L145

Added lines #L143 - L145 were not covered by tests

@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 = []

Check warning on line 151 in stock_weighing/wizards/weighing_wizard.py

View check run for this annotation

Codecov / codecov/patch

stock_weighing/wizards/weighing_wizard.py#L151

Added line #L151 was not covered by tests
if other_action:
action_list = actions + [other_action]

Check warning on line 153 in stock_weighing/wizards/weighing_wizard.py

View check run for this annotation

Codecov / codecov/patch

stock_weighing/wizards/weighing_wizard.py#L153

Added line #L153 was not covered by tests
else:
action_list = actions + [

Check warning on line 155 in stock_weighing/wizards/weighing_wizard.py

View check run for this annotation

Codecov / codecov/patch

stock_weighing/wizards/weighing_wizard.py#L155

Added line #L155 was not covered by tests
{"type": "ir.actions.act_window_close"},
{"type": "ir.actions.client", "tag": "reload"},
]
return {"type": "ir.actions.act_multi", "actions": action_list}

Check warning on line 159 in stock_weighing/wizards/weighing_wizard.py

View check run for this annotation

Codecov / codecov/patch

stock_weighing/wizards/weighing_wizard.py#L159

Added line #L159 was not covered by tests

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

0 comments on commit f45c415

Please sign in to comment.