Skip to content

Commit

Permalink
shopfloor_mobile: zone picking handle complete mix package
Browse files Browse the repository at this point in the history
  • Loading branch information
TDu committed Aug 23, 2023
1 parent eddfb9b commit 7962b3c
Showing 1 changed file with 145 additions and 13 deletions.
158 changes: 145 additions & 13 deletions shopfloor_mobile/static/wms/src/scenario/zone_picking.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const template_mobile = `
<div v-if="state_is('select_line')">
<item-detail-card
v-if="device_mode == 'mobile'"
v-for="line in state.data.move_lines"
v-for="line in select_line_detail_card_items()"
:key="make_state_component_key(['line', line.id])"
:record="line"
:options="select_line_move_line_detail_options()"
Expand Down Expand Up @@ -118,20 +118,31 @@ const template_mobile = `
:card_color="utils.colors.color_for('screen_step_done')"
/>
<item-detail-card
v-if="state_in(['set_line_destination', 'stock_issue', 'change_pack_lot'])"
v-if="state_in(['set_line_destination', 'stock_issue', 'change_pack_lot']) && !hide_qty_picker()"
:key="make_state_component_key(['detail-move-line-product', state.data.move_line.id])"
:record="state.data.move_line"
:options="utils.wms.move_line_product_detail_options(state.data.move_line, {fields_blacklist: ['quantity']})"
:card_color="utils.colors.color_for(state_in(['set_line_destination']) ? 'screen_step_done': 'screen_step_todo')"
/>
<item-detail-card
v-if="hide_qty_picker()"
:key="make_state_component_key(['detail-move-line-dest-pack', state.data.move_line.id])"
:record="state.data.move_line"
:options="{main: true, key_title: 'package_src.name', title_action_field: {action_val_path: 'package_src.name'}}"
:card_color="utils.colors.color_for(state_in(['set_line_destination']) ? 'screen_step_done': 'screen_step_todo')"
/>
<item-detail-card
v-if="state_in(['set_line_destination'])"
:key="make_state_component_key(['detail-move-line-loc-dest', state.data.move_line.id])"
:record="state.data.move_line"
:options="{main: true, key_title: 'location_dest.name', title_action_field: {action_val_path: 'location_dest.barcode'}}"
:card_color="utils.colors.color_for('screen_step_todo')"
/>
<v-card v-if="state_in(['set_line_destination', 'change_pack_lot'])"
<v-card v-if="state_in(['set_line_destination', 'change_pack_lot']) && !hide_qty_picker()"
class="pa-2" :color="utils.colors.color_for('screen_step_todo')">
<packaging-qty-picker
:key="make_state_component_key(['packaging-qty-picker', state.data.move_line.id])"
Expand Down Expand Up @@ -384,33 +395,138 @@ const ZonePicking = {
},
select_line_table_items: function () {
const self = this;
// For line with a complete mix package only show one line per package
// with the name of the package
var full_package_handeled = [];
// Convert to v-data-table keys
const items = _.map(this.state.data.move_lines, function (record) {
const item_data = {};
_.forEach(self.move_line_list_fields(true), function (field) {
item_data[field.path] = _.result(record, field.path);
if (field.renderer) {
item_data[field.path] = field.renderer(record, field);
if (record.handle_complete_mix_pack) {
if (full_package_handeled.includes(record.package_src.name)) {
return {};
}
});
item_data._origin = record;
full_package_handeled.push(record.package_src.name);
_.forEach(self.package_list_fields(true), function (field) {
item_data[field.path] = _.result(record, field.path);
if (field.renderer) {
item_data[field.path] = field.renderer(record, field);
}
});
item_data._origin = record;
} else {
_.forEach(self.move_line_list_fields(true), function (field) {
item_data[field.path] = _.result(record, field.path);
if (field.renderer) {
item_data[field.path] = field.renderer(record, field);
}
});
item_data._origin = record;
}
return item_data;
});
return items.filter((value) => JSON.stringify(value) !== "{}");
},
select_line_detail_card_items: function () {
var items = [];
var full_package_handeled = [];

for (const line of this.state.data.move_lines) {
if (line.handle_complete_mix_pack) {
if (full_package_handeled.includes(line.package_src.name)) {
continue;
}
full_package_handeled.push(line.package_src.name);
}
items.push(line);
}
return items;
},
select_line_move_line_detail_options: function () {
const options = {
key_title: "location_src.name",
loud_labels: true,
title_action_field: {action_val_path: "product.barcode"},
title_action_field: {
action_val_path: function (record, field) {
return record.handle_complete_mix_pack
? "package_src.name"
: "product.barcode";
},
},
fields: this.move_line_list_fields(),
};
return options;
},

package_list_fields: function (table_mode = false) {
const self = this;
const fields = [
{
path: "product.display_name",
label: table_mode ? "Product" : null,
renderer: function (rec, field) {
return "";
},
},
{
path: "package_src.name",
label: "Pack / Lot",
renderer: function (rec, field) {
const pkg = _.result(rec, "package_src.name", "");
const lot = _.result(rec, "lot.name", "");
return lot ? pkg + "\n" + lot : pkg;
},
},
{
path: "quantity",
label: "Qty",
renderer: function (rec, field) {
return rec.handle_complete_mix_pack
? rec.package_src.total_quantity
: rec.quantity;
},
},
{path: "package_src.weight", label: "Weight"},
{
path: "picking.scheduled_date",
label: "Date",
renderer: function (rec, field) {
return self.utils.display.render_field_date(rec, field);
},
},
{
path: "priority",
label: table_mode ? "Priority" : null,
render_component: "priority-widget",
render_options: function (record) {
return {priority: parseInt(record.priority || "0", 10)};
},
},
{
path: "location_will_be_empty",
render_component: "empty-location-icon",
display_no_value: true,
},
];
if (table_mode) {
fields.unshift({path: "location_src.name", label: "Location"});
}
return fields;
},

move_line_list_fields: function (table_mode = false) {
const self = this;
const fields = [
{path: "product.display_name", label: table_mode ? "Product" : null},
{
path: "product.display_name",
label: table_mode ? "Product" : null,
renderer: function (rec, field) {
if (rec.handle_complete_mix_pack) {
return "";
} else {
return rec.product.display_name;
}
},
},
{
path: "package_src.name",
label: "Pack / Lot",
Expand All @@ -426,7 +542,9 @@ const ZonePicking = {
render_component: "packaging-qty-picker-display",
render_props: function (record) {
return self.utils.wms.move_line_qty_picker_props(record, {
qtyInit: record.quantity,
qtyInit: record.handle_complete_mix_pack
? record.package_src.total_quantity
: record.quantity,
});
},
},
Expand Down Expand Up @@ -516,6 +634,12 @@ const ZonePicking = {
picking_summary_move_line_detail_fields: function () {
return [{path: "package_src.name", klass: "loud"}];
},
hide_qty_picker: function () {
if ("handle_complete_mix_pack" in this.state.data) {
return this.state.data.handle_complete_mix_pack;
}
return false;
},
},
computed: {
sort_lines_by_btn_label() {
Expand Down Expand Up @@ -706,12 +830,20 @@ const ZonePicking = {
},
on_scan: (scanned) => {
const data = this.state.data;
// When handling a complete pack the quantity picker is hidden
// because all move line of the package will be handled.
// So for that case we pass a positive quantity
const quantity = data.handle_complete_mix_pack
? data.move_line.quantity
: this.scan_destination_qty;
this.wait_call(
this.odoo.call("set_destination", {
move_line_id: data.move_line.id,
barcode: scanned.text,
quantity: this.scan_destination_qty,
quantity: quantity,
confirmation: data.confirmation_required,
// package_id: data.is_complete_mix_pack ? data.move_line.package_src.id : null,
handle_complete_mix_pack: data.handle_complete_mix_pack,
})
);
},
Expand Down

0 comments on commit 7962b3c

Please sign in to comment.