Skip to content
Draft
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
52 changes: 51 additions & 1 deletion shopfloor_mobile/static/wms/src/scenario/cluster_picking.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ const ClusterPicking = {
</v-row>
</div>
</div>
<div class="unload-set-destination" v-if="state_is('unload_set_destination')">
<v-card class="main">
<v-card-title>
<div class="main-info">
<div class="destination">
<span class="label">Destination:</span>
{{ state.data.location_dest.name }}
</div>
</div>
</v-card-title>
</v-card>
</div>


<div class="unload-all" v-if="state_is('unload_all')">
<item-detail-card
Expand Down Expand Up @@ -114,8 +127,45 @@ const ClusterPicking = {
</div>
</div>

<div class="unload-single" v-if="state_is('unload_single')">
<item-detail-card
v-if="current_carrier()"
:card_color="utils.colors.color_for('success')"
:key="make_state_component_key(['batch-picking', state.data.id])"
:record="current_carrier()"
:options="{main: true, key_title: 'name', title_icon: 'mdi-truck-outline'}"
/>
Test
<detail-package
:card_color="utils.colors.color_for('success')"
:key="make_state_component_key(['batch-picking', state.data.id])"
:record="state.data.package"
:options="{main: true, key_title: 'name', title_icon: 'mdi-truck-outline'}"
/>
<v-card class="main">
<v-card-title>
<div class="main-info">
<div class="package">
<span class="label">Package:</span>
{{ state.data.package.name }}
</div>
</div>
</v-card-title>
</v-card>
<v-card class="main">
<v-card-title>
<div class="main-info">
<div class="destination">
<span class="label">Destination:</span>
{{ state.data.location_dest.name }}
</div>
</div>
</v-card-title>
</v-card>
</div>

<div class="button-list button-vertical-list full">
<v-row align="center" v-if="state_in(['unload_all', 'change_pack_lot'])">
<v-row align="center" v-if="state_in(['unload_all', 'unload_single', 'unload_set_destination', 'change_pack_lot'])">
<v-col class="text-center" cols="12">
<btn-back />
</v-col>
Expand Down
12 changes: 11 additions & 1 deletion shopfloor_mobile_packing/static/src/js/cluster-picking.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ ClusterPickingBase.component.methods.selected_line_ids = function () {
return this.selected_lines().map(_.property("id"));
};

ClusterPickingBase.component.methods.selected_line_ids_for_packing = function () {
return this.selectable_lines_for_packing().map(_.property("id"));
};

ClusterPickingBase.component.methods.selectable_lines = function () {
const stored = this.state_get_data("select_package");
return _.result(stored, "selected_move_lines", []);
Expand All @@ -136,6 +140,11 @@ ClusterPickingBase.component.methods.selected_lines = function () {
});
};

ClusterPickingBase.component.methods.selectable_lines_for_packing = function () {
const lines = this.state.data.selected_lines_for_packing;
return lines;
};

// Replace the data method with our new method to add
// our new state
let component = ClusterPickingBase.component;
Expand Down Expand Up @@ -314,11 +323,12 @@ let data = function () {
on_select: (selected) => {
const picking = this.current_doc().record;
const data = this.state.data.picking;
const ids = this.selected_line_ids_for_packing();
this.wait_call(
this.odoo.call("put_in_pack", {
picking_batch_id: this.current_batch().id,
picking_id: data.id,
selected_line_ids: this.selected_line_ids(),
selected_line_ids: ids,
package_type_id: selected.id,
})
);
Expand Down
26 changes: 26 additions & 0 deletions shopfloor_packing/actions/schema_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,29 @@ def pack_picking_detail(self):
},
}
return schema

def move_line_for_packing_detail(self) -> dict:
schema = {
"type": "list",
"schema": {
"type": "dict",
"schema": {
"id": {"required": True, "type": "integer"},
"qty_done": {"type": "float", "required": True},
"lot": {
"type": "dict",
"required": False,
"nullable": True,
"schema": self.lot(),
},
"package_dest": self._schema_dict_of(
self.package(with_packaging=False), required=False
),
"package_src": self._schema_dict_of(
self.package(with_packaging=False), required=False
),
"product": self._schema_dict_of(self.product()),
},
},
}
return schema
38 changes: 28 additions & 10 deletions shopfloor_packing/services/cluster_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def list_delivery_package_types(
if response:
return response
return self._response_for_select_delivery_package_type(
picking, delivery_packaging
picking, delivery_packaging, selected_lines
)

def scan_package_action(self, picking_id, selected_line_ids, barcode) -> dict:
Expand Down Expand Up @@ -179,7 +179,12 @@ def prepare_unload(self, picking_batch_id) -> dict:
return self._prepare_pack_picking(batch)

def put_in_pack(
self, picking_batch_id, picking_id, nbr_packages=None, package_type_id=None
self,
picking_batch_id,
picking_id,
selected_line_ids,
nbr_packages=None,
package_type_id=None,
) -> dict:
batch = self.env["stock.picking.batch"].browse(picking_batch_id)
if not batch.exists():
Expand All @@ -200,8 +205,9 @@ def put_in_pack(
if result:
return result

lines = self.env["stock.move.line"].browse(selected_line_ids).exists()
savepoint = self._actions_for("savepoint").new()
pack = self._put_in_pack(picking, nbr_packages, package_type_id)
pack = self._put_in_pack(picking, lines, nbr_packages, package_type_id)
picking._reset_packing_packs_scanned()
if not pack:
savepoint.rollback()
Expand Down Expand Up @@ -280,10 +286,16 @@ def _get_next_picking_to_pack(self, batch) -> Picking:
def _get_move_lines_to_pack(self, picking) -> StockMoveLine:
"""
This returns the lines that have an internal package
and the same destination
"""
return picking.move_line_ids.filtered(
move_lines = picking.move_line_ids.filtered(
lambda ml: ml.result_package_id.is_internal
).sorted(key=lambda ml: ml.result_package_id.name)
# Take the first line to filter then the lines per destination
first_line = fields.first(move_lines)
return move_lines.filtered(
lambda line: line.location_dest_id == first_line.location_dest_id
)

def _prepare_pack_picking(self, batch, message=None) -> dict:
picking = self._get_next_picking_to_pack(batch)
Expand All @@ -308,16 +320,13 @@ def _postprocess_put_in_pack(self, picking, pack):
return

def _put_in_pack(
self, picking, number_of_parcels=None, package_type_id=None
self, picking, move_lines, number_of_parcels=None, package_type_id=None
) -> QuantPackage:
"""
This will enhance the put in pack flow by adding the number
of parcels or the package type to the generated package.
"""
move_lines_to_pack = picking.move_line_ids.filtered(
lambda l: l.result_package_id and l.result_package_id.is_internal
)
pack = picking._put_in_pack(move_lines_to_pack)
pack = picking._put_in_pack(move_lines)
if (
isinstance(pack, dict)
and pack.get("res_model") == "stock.quant.package"
Expand Down Expand Up @@ -412,12 +421,15 @@ def _response_for_select_dest_package(self, picking, message=None) -> dict:
)

def _response_for_select_delivery_package_type(
self, picking, packaging, message=None
self, picking, packaging, selected_lines, message=None
) -> dict:
return self._response(
next_state="select_delivery_packaging",
data={
"picking": self.data.picking(picking),
"selected_lines_for_packing": self.data_detail.move_lines(
selected_lines
),
"packaging": self._data_for_delivery_package_type(packaging),
},
message=message,
Expand Down Expand Up @@ -446,6 +458,11 @@ def put_in_pack(self) -> dict:
"type": "integer",
},
"picking_id": {"coerce": to_int, "required": True, "type": "integer"},
"selected_line_ids": {
"type": "list",
"required": True,
"schema": {"coerce": to_int, "required": True, "type": "integer"},
},
"nbr_packages": {"coerce": to_int, "required": False, "type": "integer"},
"package_type_id": {"coerce": to_int, "required": False, "type": "integer"},
}
Expand Down Expand Up @@ -561,6 +578,7 @@ def list_delivery_package_types(self) -> dict:
def _schema_select_delivery_packaging(self) -> dict:
return {
"picking": {"type": "dict", "schema": self.schemas.picking()},
"selected_lines_for_packing": self.schemas_detail.move_line_for_packing_detail(),
"packaging": self.schemas._schema_list_of(
self.schemas.delivery_packaging()
),
Expand Down