Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 70 additions & 1 deletion shopfloor/actions/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def confirm_location_changed(self, from_location, to_location):
return {
"message_type": "warning",
"body": _(
"Confirm location change from %(location_from)s to " "%(location_to)s?"
"Confirm location change from %(location_from)s to %(location_to)s?"
)
% dict(location_from=from_location.name, location_to=to_location.name),
}
Expand Down Expand Up @@ -278,6 +278,9 @@ def _wrong_record_msg(self, model_name):
def wrong_record(self, record):
return {"message_type": "error", "body": self._wrong_record_msg(record._name)}

def wrong_bin(self):
return {"message_type": "error", "body": _("Wrong bin")}

def no_lot_for_barcode(self, barcode):
return {
"message_type": "error",
Expand Down Expand Up @@ -538,6 +541,15 @@ def multiple_picks_found_select_manually(self):
"body": _("Several transfers found, please select a transfer manually."),
}

def multiple_picks_found_scan_pack_or_select_manually(self):
return {
"message_type": "error",
"body": _(
"Several transfers found, please scan a package"
" or select a transfer manually."
),
}

def no_transfer_for_packaging(self):
return {
"message_type": "error",
Expand Down Expand Up @@ -1031,3 +1043,60 @@ def reserved_for_other_picking_type(self, picking):
"message_type": "error",
"body": body,
}

def negative_quantity_not_allowed(self):
return {
"body": _("Negative quantity not allowed."),
"message_type": "error",
}

def products_processed_as_raw_products(self):
return {
"message_type": "success",
"body": _("Product(s) processed as raw product(s)"),
}

def packaging_changed_on_package(self, pack):
return {
"message_type": "success",
"body": _("Packaging changed on package %s", pack.name),
}

def remaining_raw_product_not_packed(self):
return {
"message_type": "warning",
"body": _("Remaining raw product not packed, proceed anyway?"),
}

def no_more_batch_todo(self):
return {
"message_type": "info",
"body": _("No more work to do, please create a new batch transfer"),
}

def batch_cannot_be_selected(self):
return {
"message_type": "warning",
"body": _("This batch cannot be selected."),
}

def destination_bin_not_empty(self, bin_package):
return {
"message_type": "error",
"body": _(
"The destination bin %s is not empty, please take another.",
bin_package.name,
),
}

def package_cancelled(self):
return {"message_type": "success", "body": _("Package cancelled")}

def line_cancelled(self):
return {"message_type": "success", "body": _("Line cancelled")}

def location_cant_be_moved_at_once(self):
return {
"message_type": "error",
"body": _("This location content can't be moved at once."),
}
38 changes: 9 additions & 29 deletions shopfloor/services/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from werkzeug.exceptions import BadRequest

from odoo import _, fields
from odoo import fields

from odoo.addons.base_rest.components.service import to_int
from odoo.addons.component.core import Component
Expand Down Expand Up @@ -248,13 +248,7 @@ def _select_document_from_location(self, location, **kw):
pickings = lines.mapped("picking_id")
if len(pickings) > 1:
return self._response_for_select_document(
message={
"message_type": "error",
"body": _(
"Several transfers found, please scan a package"
" or select a transfer manually."
),
}
message=self.msg_store.multiple_picks_found_scan_pack_or_select_manually()
)
# Keep track of what has been initially scan, and forward it through kwargs
kwargs = {**kw, "current_state": "select_document"}
Expand Down Expand Up @@ -846,10 +840,7 @@ def _change_line_qty(
for move_line in move_lines:
qty_done = quantity_func(move_line)
if qty_done < 0:
message = {
"body": _("Negative quantity not allowed."),
"message_type": "error",
}
message = self.msg_store.negative_quantity_not_allowed()
else:
new_line = self.env["stock.move.line"]
if qty_done > 0:
Expand Down Expand Up @@ -1296,10 +1287,7 @@ def no_package(self, picking_id, selected_line_ids):
return response
return self._response_for_select_line(
picking,
message={
"message_type": "success",
"body": _("Product(s) processed as raw product(s)"),
},
message=self.msg_store.products_processed_as_raw_products(),
)

def list_dest_package(self, picking_id, selected_line_ids):
Expand Down Expand Up @@ -1464,10 +1452,7 @@ def set_packaging(self, picking_id, package_id, package_type_id):
package.package_type_id = packaging
return self._response_for_summary(
picking,
message={
"message_type": "success",
"body": _("Packaging changed on package {}").format(package.name),
},
message=self.msg_store.packaging_changed_on_package(package),
)

def cancel_line(self, picking_id, package_id=None, line_id=None):
Expand Down Expand Up @@ -1512,13 +1497,11 @@ def cancel_line(self, picking_id, package_id=None, line_id=None):
"shopfloor_checkout_done": False,
}
)
msg = _("Package cancelled")
msg = self.msg_store.package_cancelled()
if line:
line.write({"qty_done": 0, "shopfloor_checkout_done": False})
msg = _("Line cancelled")
return self._response_for_select_line(
picking, message={"message_type": "success", "body": msg}
)
msg = self.msg_store.line_cancelled()
return self._response_for_select_line(picking, message=msg)

def done(self, picking_id, confirmation=False):
"""Set the moves as done
Expand Down Expand Up @@ -1548,10 +1531,7 @@ def done(self, picking_id, confirmation=False):
return self._response_for_summary(
picking,
need_confirm=True,
message={
"message_type": "warning",
"body": _("Remaining raw product not packed, proceed anyway?"),
},
message=self.msg_store.remaining_raw_product_not_packed(),
)
lines_done = self._lines_checkout_done(picking)
dest_location = lines_done.move_id.location_dest_id
Expand Down
19 changes: 4 additions & 15 deletions shopfloor/services/cluster_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,7 @@ def find_batch(self):
return self._response_for_confirm_start(selected)
else:
return self._response_for_start(
message={
"message_type": "info",
"body": _("No more work to do, please create a new batch transfer"),
},
message=self.msg_store.no_more_batch_todo(),
)

def list_batch(self):
Expand Down Expand Up @@ -316,10 +313,7 @@ def select(self, picking_batch_id):
else:
return self._response(
base_response=self.list_batch(),
message={
"message_type": "warning",
"body": _("This batch cannot be selected."),
},
message=self.msg_store.batch_cannot_be_selected(),
)

def confirm_start(self, picking_batch_id):
Expand Down Expand Up @@ -796,12 +790,7 @@ def scan_destination_pack(self, picking_batch_id, move_line_id, barcode, quantit
if not multi_pick_allowed and (bin_package.quant_ids or different_picking):
return self._response_for_scan_destination(
move_line,
message={
"message_type": "error",
"body": _(
"The destination bin {} is not empty, please take another."
).format(bin_package.name),
},
message=self.msg_store.destination_bin_not_empty(bin_package),
qty_done=quantity,
)
move_line.write({"qty_done": quantity, "result_package_id": bin_package.id})
Expand Down Expand Up @@ -1274,7 +1263,7 @@ def unload_scan_pack(self, picking_batch_id, package_id, barcode):
return self._response_for_unload_single(
batch,
package,
message={"message_type": "error", "body": _("Wrong bin")},
message=self.msg_store.wrong_bin(),
)
return self._response_for_unload_set_destination(batch, package)

Expand Down
10 changes: 3 additions & 7 deletions shopfloor/services/location_content_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Copyright 2020-2022 Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
# Copyright 2023 Michael Tietz (MT Software) <mtietz@mt-software.de>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import _
from odoo.fields import first

from odoo.addons.base_rest.components.service import to_int
Expand Down Expand Up @@ -355,10 +354,7 @@ def scan_location(self, barcode): # noqa: C901
picking_types = move_lines.picking_id.picking_type_id
if len(picking_types) > 1:
return self._response_for_start(
message={
"message_type": "error",
"body": _("This location content can't be moved at once."),
}
message=self.msg_store.location_cant_be_moved_at_once()
)
if picking_types - self.picking_types:
return self._response_for_start(
Expand Down Expand Up @@ -556,7 +552,7 @@ def scan_package(self, location_id, package_level_id, barcode):
# the correct package, so ask to scan the package.
return self._response_for_start_single(
move_lines.mapped("picking_id"),
message={"message_type": "error", "body": _("Scan the package")},
message=self.msg_store.scan_the_package(),
)
else:
return self._response_for_scan_destination(location, package_level)
Expand All @@ -566,7 +562,7 @@ def scan_package(self, location_id, package_level_id, barcode):
if lot in other_move_lines.mapped("lot_id"):
return self._response_for_start_single(
move_lines.mapped("picking_id"),
message={"message_type": "error", "body": _("Scan the package")},
message=self.msg_store.scan_the_package(),
)
else:
return self._response_for_scan_destination(location, package_level)
Expand Down
7 changes: 1 addition & 6 deletions shopfloor/tests/test_checkout_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,5 @@ def _assert_select_package_qty_above(self, response, picking):
"no_package_enabled": True,
"package_allowed": True,
},
message={
"message_type": "warning",
"body": "The quantity scanned for one or more lines cannot be "
"higher than the maximum allowed. "
f"({line.product_id.name} : {str(line.qty_done)} > {str(line.reserved_uom_qty)})", # noqa
},
message=self.msg_store.selected_lines_qty_done_higher_than_allowed(line),
)
14 changes: 4 additions & 10 deletions shopfloor/tests/test_checkout_cancel_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_cancel_package_ok(self):
response,
next_state="select_line",
data=self._data_for_select_line(picking),
message={"body": "Package cancelled", "message_type": "success"},
message=self.msg_store.package_cancelled(),
)

def test_cancel_line_ok(self):
Expand All @@ -114,7 +114,7 @@ def test_cancel_line_ok(self):
response,
next_state="select_line",
data=self._data_for_select_line(picking),
message={"body": "Line cancelled", "message_type": "success"},
message=self.msg_store.line_cancelled(),
)

def test_cancel_line_error_package_not_found(self):
Expand All @@ -129,10 +129,7 @@ def test_cancel_line_error_package_not_found(self):
"picking": self._stock_picking_data(self.picking, done=True),
"all_processed": False,
},
message={
"message_type": "error",
"body": "The record you were working on does not exist anymore.",
},
message=self.msg_store.record_not_found(),
)

def test_cancel_line_error_line_not_found(self):
Expand All @@ -147,8 +144,5 @@ def test_cancel_line_error_line_not_found(self):
"picking": self._stock_picking_data(self.picking, done=True),
"all_processed": False,
},
message={
"message_type": "error",
"body": "The record you were working on does not exist anymore.",
},
message=self.msg_store.record_not_found(),
)
20 changes: 4 additions & 16 deletions shopfloor/tests/test_checkout_change_packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,7 @@ def test_list_packaging_error_package_not_found(self):
"picking": self._stock_picking_data(self.picking, done=True),
"all_processed": False,
},
message={
"message_type": "error",
"body": "The record you were working on does not exist anymore.",
},
message=self.msg_store.record_not_found(),
)

def test_set_packaging_ok(self):
Expand All @@ -133,10 +130,7 @@ def test_set_packaging_ok(self):
"picking": self._stock_picking_data(self.picking, done=True),
"all_processed": False,
},
message={
"message_type": "success",
"body": f"Packaging changed on package {self.package.name}",
},
message=self.msg_store.packaging_changed_on_package(self.package),
)

def test_set_packaging_error_package_not_found(self):
Expand All @@ -155,10 +149,7 @@ def test_set_packaging_error_package_not_found(self):
"picking": self._stock_picking_data(self.picking, done=True),
"all_processed": False,
},
message={
"message_type": "error",
"body": "The record you were working on does not exist anymore.",
},
message=self.msg_store.record_not_found(),
)

def test_set_packaging_error_packaging_not_found(self):
Expand All @@ -177,8 +168,5 @@ def test_set_packaging_error_packaging_not_found(self):
"picking": self._stock_picking_data(self.picking, done=True),
"all_processed": False,
},
message={
"message_type": "error",
"body": "The record you were working on does not exist anymore.",
},
message=self.msg_store.record_not_found(),
)
10 changes: 2 additions & 8 deletions shopfloor/tests/test_checkout_done.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ def test_done_ok(self):
self.assert_response(
response,
next_state="select_document",
message={
"message_type": "success",
"body": f"Transfer {picking.name} done",
},
message=self.msg_store.transfer_done_success(picking),
data={"restrict_scan_first": False},
)

Expand Down Expand Up @@ -136,10 +133,7 @@ def test_done_partial(self):
response,
next_state="confirm_done",
data={"picking": self._stock_picking_data(self.picking, done=True)},
message={
"message_type": "warning",
"body": "Remaining raw product not packed, proceed anyway?",
},
message=self.msg_store.remaining_raw_product_not_packed(),
)

def test_done_partial_confirm(self):
Expand Down
Loading
Loading