Skip to content

Commit

Permalink
Merge PR OCA#716 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by jbaudoux
  • Loading branch information
OCA-git-bot committed Nov 27, 2023
2 parents 0004aeb + fe180ad commit 5eddd29
Show file tree
Hide file tree
Showing 25 changed files with 225 additions and 169 deletions.
8 changes: 4 additions & 4 deletions shopfloor/docs/single_pack_transfer_diag_seq.plantuml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ header <img:oca_logo.png>
title <size:35>Single Pack Transfer scenario</size>

== /start ==
start -> scan_location: **/start**(barcode[pack|location], confirmation=False)
start -> start: **/start**(barcode[pack|location], confirmation=False)
start -> scan_location: **/start**(barcode[pack|location], confirmation=None)
start -> start: **/start**(barcode[pack|location], confirmation=None)

== /cancel ==
scan_location -> start: **/cancel**(package_level_id)

== /validate ==
scan_location -> scan_location: **/validate**(package_level_id, location_barcode, confirmation=False)
scan_location -> start: **/validate**(package_level_id, location_barcode, confirmation=False)
scan_location -> scan_location: **/validate**(package_level_id, location_barcode, confirmation=None)
scan_location -> start: **/validate**(package_level_id, location_barcode, confirmation=None)

@enduml
Binary file modified shopfloor/docs/single_pack_transfer_diag_seq.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 28 additions & 16 deletions shopfloor/services/cluster_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ def _response_for_unload_all(self, batch, message=None):
message=message,
)

def _response_for_confirm_unload_all(self, batch, message=None):
def _response_for_confirm_unload_all(self, batch, message=None, confirmation=None):
return self._response(
next_state="confirm_unload_all",
data=self._data_for_unload_all(batch),
data=self._data_for_unload_all(batch, confirmation=confirmation),
message=message,
)

Expand All @@ -166,10 +166,14 @@ def _response_for_unload_set_destination(self, batch, package, message=None):
message=message,
)

def _response_for_confirm_unload_set_destination(self, batch, package):
def _response_for_confirm_unload_set_destination(
self, batch, package, confirmation=None
):
return self._response(
next_state="confirm_unload_set_destination",
data=self._data_for_unload_single(batch, package),
data=self._data_for_unload_single(
batch, package, confirmation=confirmation
),
)

def find_batch(self):
Expand Down Expand Up @@ -814,20 +818,24 @@ def prepare_unload(self, picking_batch_id):
# the lines have different destinations
return self._unload_next_package(batch)

def _data_for_unload_all(self, batch):
def _data_for_unload_all(self, batch, confirmation=None):
lines = self._lines_to_unload(batch)
# all the lines destinations are the same here, it looks
# only for the first one
first_line = fields.first(lines)
data = self.data.picking_batch(batch)
data.update({"location_dest": self.data.location(first_line.location_dest_id)})
if confirmation:
data.update({"confirmation": confirmation})
return data

def _data_for_unload_single(self, batch, package):
def _data_for_unload_single(self, batch, package, confirmation=None):
line = fields.first(
package.planned_move_line_ids.filtered(self._filter_for_unload)
)
data = self.data.picking_batch(batch)
if confirmation:
data.update({"confirmation": confirmation})
data.update(
{
"package": self.data.package(package),
Expand Down Expand Up @@ -1068,7 +1076,7 @@ def change_pack_lot(self, picking_batch_id, move_line_id, barcode, quantity=None
message=self.msg_store.no_package_or_lot_for_barcode(barcode),
)

def set_destination_all(self, picking_batch_id, barcode, confirmation=False):
def set_destination_all(self, picking_batch_id, barcode, confirmation=None):
"""Set the destination for all the lines of the batch with a dest. package
This method must be used only if all the move lines which have a destination
Expand Down Expand Up @@ -1109,10 +1117,10 @@ def set_destination_all(self, picking_batch_id, barcode, confirmation=False):
batch, message=self.msg_store.dest_location_not_allowed()
)

if not confirmation and self.is_dest_location_to_confirm(
if confirmation != barcode and self.is_dest_location_to_confirm(
first_line.location_dest_id, scanned_location
):
return self._response_for_confirm_unload_all(batch)
return self._response_for_confirm_unload_all(batch, confirmation=barcode)

self._unload_write_destination_on_lines(lines, scanned_location)
completion_info = self._actions_for("completion.info")
Expand Down Expand Up @@ -1215,7 +1223,7 @@ def unload_scan_pack(self, picking_batch_id, package_id, barcode):
return self._response_for_unload_set_destination(batch, package)

def unload_scan_destination(
self, picking_batch_id, package_id, barcode, confirmation=False
self, picking_batch_id, package_id, barcode, confirmation=None
):
"""Scan the final destination for all the move lines moved with the Bin
Expand All @@ -1227,7 +1235,7 @@ def unload_scan_destination(
* unload_single: line is processed and the next bin can be unloaded
* confirm_unload_set_destination: the destination is valid but not the
expected, ask a confirmation. This state has to call again the
endpoint with confirmation=True
endpoint with confirmation=barcode
* start_line: if the batch still has lines to pick
* start: if the batch is done. In this case, this method *has*
to handle the closing of the batch to create backorders.
Expand Down Expand Up @@ -1257,7 +1265,7 @@ def _lock_lines(self, lines):
self._actions_for("lock").for_update(lines)

def _unload_scan_destination_lines(
self, batch, package, lines, barcode, confirmation=False
self, batch, package, lines, barcode, confirmation=None
):
# Lock move lines that will be updated
self._lock_lines(lines)
Expand All @@ -1271,10 +1279,12 @@ def _unload_scan_destination_lines(
return self._response_for_unload_set_destination(
batch, package, message=self.msg_store.dest_location_not_allowed()
)
if not confirmation and self.is_dest_location_to_confirm(
if confirmation != barcode and self.is_dest_location_to_confirm(
first_line.location_dest_id, scanned_location
):
return self._response_for_confirm_unload_set_destination(batch, package)
return self._response_for_confirm_unload_set_destination(
batch, package, confirmation=barcode
)

self._unload_write_destination_on_lines(lines, scanned_location)

Expand Down Expand Up @@ -1379,7 +1389,7 @@ def set_destination_all(self):
return {
"picking_batch_id": {"coerce": to_int, "required": True, "type": "integer"},
"barcode": {"required": True, "type": "string"},
"confirmation": {"type": "boolean", "nullable": True, "required": False},
"confirmation": {"type": "string", "nullable": True, "required": False},
}

def unload_split(self):
Expand All @@ -1399,7 +1409,7 @@ def unload_scan_destination(self):
"picking_batch_id": {"coerce": to_int, "required": True, "type": "integer"},
"package_id": {"coerce": to_int, "required": True, "type": "integer"},
"barcode": {"required": True, "type": "string"},
"confirmation": {"type": "boolean", "nullable": True, "required": False},
"confirmation": {"type": "string", "nullable": True, "required": False},
}


Expand Down Expand Up @@ -1594,13 +1604,15 @@ def _schema_for_single_line_details(self):
def _schema_for_unload_all(self):
schema = self.schemas.picking_batch()
schema["location_dest"] = self.schemas._schema_dict_of(self.schemas.location())
schema["confirmation"] = {"type": "string", "nullable": True, "required": False}
return schema

@property
def _schema_for_unload_single(self):
schema = self.schemas.picking_batch()
schema["package"] = self.schemas._schema_dict_of(self.schemas.package())
schema["location_dest"] = self.schemas._schema_dict_of(self.schemas.location())
schema["confirmation"] = {"type": "string", "nullable": True, "required": False}
return schema

@property
Expand Down
32 changes: 16 additions & 16 deletions shopfloor/services/location_content_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _response_for_scan_location(self, location=None, message=None):
)

def _response_for_scan_destination_all(
self, pickings, message=None, confirmation_required=False
self, pickings, message=None, confirmation_required=None
):
"""Transition to the 'scan_destination_all' state
Expand Down Expand Up @@ -116,7 +116,7 @@ def _response_for_start_single(self, pickings, message=None, popup=None):
)

def _response_for_scan_destination(
self, location, next_content, message=None, confirmation_required=False
self, location, next_content, message=None, confirmation_required=None
):
"""Transition to the 'scan_destination' state
Expand Down Expand Up @@ -461,7 +461,7 @@ def _lock_lines(self, lines):
"""Lock move lines"""
self._actions_for("lock").for_update(lines)

def set_destination_all(self, location_id, barcode, confirmation=False):
def set_destination_all(self, location_id, barcode, confirmation=None):
"""Scan destination location for all the moves of the location
barcode is a stock.location for the destination
Expand Down Expand Up @@ -489,11 +489,11 @@ def set_destination_all(self, location_id, barcode, confirmation=False):
return self._response_for_scan_destination_all(
pickings, message=self.msg_store.dest_location_not_allowed()
)
if not confirmation and self.is_dest_location_to_confirm(
if confirmation != barcode and self.is_dest_location_to_confirm(
move_lines.location_dest_id, scanned_location
):
return self._response_for_scan_destination_all(
pickings, confirmation_required=True
pickings, confirmation_required=barcode
)
self._lock_lines(move_lines)

Expand Down Expand Up @@ -663,7 +663,7 @@ def scan_line(self, location_id, move_line_id, barcode):
)

def set_destination_package(
self, location_id, package_level_id, barcode, confirmation=False
self, location_id, package_level_id, barcode, confirmation=None
):
"""Scan destination location for package level
Expand Down Expand Up @@ -697,11 +697,11 @@ def set_destination_package(
package_level,
message=self.msg_store.dest_location_not_allowed(),
)
if not confirmation and self.is_dest_location_to_confirm(
if confirmation != barcode and self.is_dest_location_to_confirm(
package_level.location_dest_id, scanned_location
):
return self._response_for_scan_destination(
location, package_level, confirmation_required=True
location, package_level, confirmation_required=barcode
)
package_move_lines = package_level.move_line_ids
self._lock_lines(package_move_lines)
Expand All @@ -722,7 +722,7 @@ def set_destination_package(
)

def set_destination_line(
self, location_id, move_line_id, quantity, barcode, confirmation=False
self, location_id, move_line_id, quantity, barcode, confirmation=None
):
"""Scan destination location for move line
Expand Down Expand Up @@ -754,11 +754,11 @@ def set_destination_line(
return self._response_for_scan_destination(
location, move_line, message=self.msg_store.dest_location_not_allowed()
)
if not confirmation and self.is_dest_location_to_confirm(
if confirmation != barcode and self.is_dest_location_to_confirm(
move_line.location_dest_id, scanned_location
):
return self._response_for_scan_destination(
location, move_line, confirmation_required=True
location, move_line, confirmation_required=barcode
)

self._lock_lines(move_line)
Expand Down Expand Up @@ -983,7 +983,7 @@ def set_destination_all(self):
return {
"location_id": {"coerce": to_int, "required": True, "type": "integer"},
"barcode": {"required": True, "type": "string"},
"confirmation": {"type": "boolean", "nullable": True, "required": False},
"confirmation": {"type": "string", "nullable": True, "required": False},
}

def go_to_single(self):
Expand All @@ -1008,7 +1008,7 @@ def set_destination_package(self):
"location_id": {"coerce": to_int, "required": True, "type": "integer"},
"package_level_id": {"coerce": to_int, "required": True, "type": "integer"},
"barcode": {"required": True, "type": "string"},
"confirmation": {"type": "boolean", "nullable": True, "required": False},
"confirmation": {"type": "string", "nullable": True, "required": False},
}

def set_destination_line(self):
Expand All @@ -1017,7 +1017,7 @@ def set_destination_line(self):
"move_line_id": {"coerce": to_int, "required": True, "type": "integer"},
"quantity": {"coerce": to_float, "required": True, "type": "float"},
"barcode": {"required": True, "type": "string"},
"confirmation": {"type": "boolean", "nullable": True, "required": False},
"confirmation": {"type": "string", "nullable": True, "required": False},
}

def postpone_package(self):
Expand Down Expand Up @@ -1084,7 +1084,7 @@ def _schema_all(self):
"package_levels": self.schemas._schema_list_of(package_level_schema),
"move_lines": self.schemas._schema_list_of(move_line_schema),
"confirmation_required": {
"type": "boolean",
"type": "string",
"nullable": True,
"required": False,
},
Expand All @@ -1099,7 +1099,7 @@ def _schema_single(self):
"package_level": self.schemas._schema_dict_of(schema_package_level),
"move_line": self.schemas._schema_dict_of(schema_move_line),
"confirmation_required": {
"type": "boolean",
"type": "string",
"nullable": True,
"required": False,
},
Expand Down
Loading

0 comments on commit 5eddd29

Please sign in to comment.