Skip to content

Commit

Permalink
fixup! shopfloor_reception_mobile: imp states inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
TDu committed Jun 9, 2023
1 parent e67668a commit 928ad77
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ const Reception = {
return picking.origin.includes(input);
},
_get_states: function () {
return reception_states(this);
return reception_states.bind(this)();
},
},
data: function () {
Expand Down
199 changes: 97 additions & 102 deletions shopfloor_reception_mobile/static/src/scenario/reception_states.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

/*
Define states for reception scenario.
@param $instance VueJS component instance
@param this VueJS component instance
*/
export const reception_states = function ($instance) {
export const reception_states = function () {
return {
init: {
enter: () => {
$instance.wait_call($instance.odoo.call("start"));
this.wait_call(this.odoo.call("start"));
},
},
select_document: {
Expand All @@ -24,21 +24,21 @@ export const reception_states = function ($instance) {
select: "on_select",
},
on_select: (selected) => {
$instance.wait_call(
$instance.odoo.call("scan_document", {
this.wait_call(
this.odoo.call("scan_document", {
barcode: selected.name,
})
);
},
on_scan: (barcode) => {
$instance.wait_call(
$instance.odoo.call("scan_document", {
this.wait_call(
this.odoo.call("scan_document", {
barcode: barcode.text,
})
);
},
on_manual_selection: () => {
$instance.wait_call($instance.odoo.call("list_stock_pickings"));
this.wait_call(this.odoo.call("list_stock_pickings"));
},
},
manual_selection: {
Expand All @@ -48,16 +48,16 @@ export const reception_states = function ($instance) {
go_back: "on_back",
},
on_select: (selected) => {
$instance.wait_call(
$instance.odoo.call("scan_document", {
this.wait_call(
this.odoo.call("scan_document", {
barcode: selected.name,
})
);
},
on_back: () => {
$instance.state_to("select_document");
$instance.reset_notification();
$instance.reset_picking_filter();
this.state_to("select_document");
this.reset_notification();
this.reset_picking_filter();
},
},
select_move: {
Expand All @@ -69,27 +69,27 @@ export const reception_states = function ($instance) {
cancel_picking_line: "on_cancel",
},
on_scan: (barcode) => {
$instance.wait_call(
$instance.odoo.call("scan_line", {
picking_id: $instance.state.data.picking.id,
this.wait_call(
this.odoo.call("scan_line", {
picking_id: this.state.data.picking.id,
barcode: barcode.text,
})
);
},
on_mark_as_done: () => {
$instance.wait_call(
$instance.odoo.call("done_action", {
picking_id: $instance.state.data.picking.id,
this.wait_call(
this.odoo.call("done_action", {
picking_id: this.state.data.picking.id,
})
);
},
on_cancel: () => {
// TODO: $instance endpoing is currently missing in the backend,
// TODO: this endpoing is currently missing in the backend,
// and it's currently in the roadmap.
// Once it's implemented, uncomment $instance call.
// $instance.wait_call(
// $instance.odoo.call("cancel", {
// package_level_id: $instance.state.data.id,
// Once it's implemented, uncomment this call.
// this.wait_call(
// this.odoo.call("cancel", {
// package_level_id: this.state.data.id,
// })
// );
},
Expand All @@ -103,16 +103,16 @@ export const reception_states = function ($instance) {
go_back: "on_back",
},
on_confirm: () => {
$instance.wait_call(
$instance.odoo.call("done_action", {
picking_id: $instance.state.data.picking.id,
this.wait_call(
this.odoo.call("done_action", {
picking_id: this.state.data.picking.id,
confirmation: true,
})
);
},
on_back: () => {
$instance.state_to("select_move");
$instance.reset_notification();
this.state_to("select_move");
this.reset_notification();
},
},
set_lot: {
Expand All @@ -123,39 +123,34 @@ export const reception_states = function ($instance) {
},
on_scan: (barcode) => {
// Scan a lot
$instance
.wait_call(
$instance.odoo.call("set_lot", {
picking_id: $instance.state.data.picking.id,
selected_line_id: $instance.line_being_handled.id,
lot_name: barcode.text,
})
)
.then(() => {
// We need to wait for the call to the backend to be over
// to update the date-picker-input component
// with the expiration_date of the selected lot.
event_hub.$emit(
"datepicker:newdate",
$instance.line_being_handled.lot
);
});
this.wait_call(
this.odoo.call("set_lot", {
picking_id: this.state.data.picking.id,
selected_line_id: this.line_being_handled.id,
lot_name: barcode.text,
})
).then(() => {
// We need to wait for the call to the backend to be over
// to update the date-picker-input component
// with the expiration_date of the selected lot.
event_hub.$emit("datepicker:newdate", this.line_being_handled.lot);
});
},
on_date_picker_selected: (expiration_date) => {
// Select expiration_date
$instance.wait_call(
$instance.odoo.call("set_lot", {
picking_id: $instance.state.data.picking.id,
selected_line_id: $instance.line_being_handled.id,
this.wait_call(
this.odoo.call("set_lot", {
picking_id: this.state.data.picking.id,
selected_line_id: this.line_being_handled.id,
expiration_date: expiration_date,
})
);
},
on_confirm_action: () => {
$instance.wait_call(
$instance.odoo.call("set_lot_confirm_action", {
picking_id: $instance.state.data.picking.id,
selected_line_id: $instance.line_being_handled.id,
this.wait_call(
this.odoo.call("set_lot_confirm_action", {
picking_id: this.state.data.picking.id,
selected_line_id: this.line_being_handled.id,
})
);
},
Expand All @@ -170,60 +165,60 @@ export const reception_states = function ($instance) {
go_back: "on_back",
},
on_qty_edit: (qty) => {
$instance.scan_destination_qty = parseInt(qty, 10);
this.scan_destination_qty = parseInt(qty, 10);
},
on_scan: (barcode) => {
$instance.wait_call(
$instance.odoo.call("set_quantity", {
this.wait_call(
this.odoo.call("set_quantity", {
// TODO: add quantity from qty-picker
picking_id: $instance.state.data.picking.id,
selected_line_id: $instance.line_being_handled.id,
quantity: $instance.scan_destination_qty,
picking_id: this.state.data.picking.id,
selected_line_id: this.line_being_handled.id,
quantity: this.scan_destination_qty,
barcode: barcode.text,
confirmation: $instance.state.data.confirmation_required,
confirmation: this.state.data.confirmation_required,
})
);
},
on_cancel: () => {
// TODO: $instance endpoing is currently missing in the backend,
// TODO: this endpoing is currently missing in the backend,
// and it's currently in the roadmap.
// Once it's implemented, uncomment $instance call.
// $instance.wait_call(
// $instance.odoo.call("cancel", {
// package_level_id: $instance.state.data.id,
// Once it's implemented, uncomment this call.
// this.wait_call(
// this.odoo.call("cancel", {
// package_level_id: this.state.data.id,
// })
// );
},
on_add_to_existing_pack: () => {
$instance.wait_call(
$instance.odoo.call("process_with_existing_pack", {
picking_id: $instance.state.data.picking.id,
selected_line_id: $instance.line_being_handled.id,
quantity: $instance.scan_destination_qty,
this.wait_call(
this.odoo.call("process_with_existing_pack", {
picking_id: this.state.data.picking.id,
selected_line_id: this.line_being_handled.id,
quantity: this.scan_destination_qty,
})
);
},
on_create_new_pack: () => {
$instance.wait_call(
$instance.odoo.call("process_with_new_pack", {
picking_id: $instance.state.data.picking.id,
selected_line_id: $instance.line_being_handled.id,
quantity: $instance.scan_destination_qty,
this.wait_call(
this.odoo.call("process_with_new_pack", {
picking_id: this.state.data.picking.id,
selected_line_id: this.line_being_handled.id,
quantity: this.scan_destination_qty,
})
);
},
on_process_without_pack: () => {
$instance.wait_call(
$instance.odoo.call("process_without_pack", {
picking_id: $instance.state.data.picking.id,
selected_line_id: $instance.line_being_handled.id,
quantity: $instance.scan_destination_qty,
this.wait_call(
this.odoo.call("process_without_pack", {
picking_id: this.state.data.picking.id,
selected_line_id: this.line_being_handled.id,
quantity: this.scan_destination_qty,
})
);
},
on_back: () => {
$instance.state_to("set_lot");
$instance.reset_notification();
this.state_to("set_lot");
this.reset_notification();
},
},
set_destination: {
Expand All @@ -232,10 +227,10 @@ export const reception_states = function ($instance) {
scan_placeholder: "Scan destination location",
},
on_scan: (location) => {
$instance.wait_call(
$instance.odoo.call("set_destination", {
picking_id: $instance.state.data.picking.id,
selected_line_id: $instance.line_being_handled.id,
this.wait_call(
this.odoo.call("set_destination", {
picking_id: this.state.data.picking.id,
selected_line_id: this.line_being_handled.id,
location_name: location.text,
confirmation: true,
})
Expand All @@ -251,19 +246,19 @@ export const reception_states = function ($instance) {
select: "on_select",
},
on_scan: (barcode) => {
$instance.wait_call(
$instance.odoo.call("select_dest_package", {
picking_id: $instance.state.data.picking.id,
selected_line_id: $instance.line_being_handled.id,
this.wait_call(
this.odoo.call("select_dest_package", {
picking_id: this.state.data.picking.id,
selected_line_id: this.line_being_handled.id,
barcode: barcode.text,
})
);
},
on_select: (selected) => {
$instance.wait_call(
$instance.odoo.call("select_dest_package", {
picking_id: $instance.state.data.picking.id,
selected_line_id: $instance.line_being_handled.id,
this.wait_call(
this.odoo.call("select_dest_package", {
picking_id: this.state.data.picking.id,
selected_line_id: this.line_being_handled.id,
barcode: selected.name,
})
);
Expand All @@ -278,18 +273,18 @@ export const reception_states = function ($instance) {
go_back: "on_back",
},
on_confirm: () => {
$instance.wait_call(
$instance.odoo.call("select_dest_package", {
picking_id: $instance.state.data.picking.id,
selected_line_id: $instance.line_being_handled.id,
this.wait_call(
this.odoo.call("select_dest_package", {
picking_id: this.state.data.picking.id,
selected_line_id: this.line_being_handled.id,
confirmation: true,
barcode: $instance.state.data.new_package_name,
barcode: this.state.data.new_package_name,
})
);
},
on_back: () => {
$instance.state_to("select_dest_package");
$instance.reset_notification();
this.state_to("select_dest_package");
this.reset_notification();
},
},
};
Expand Down

0 comments on commit 928ad77

Please sign in to comment.