|
@ -3,10 +3,32 @@ import {Navbar} from "@point_of_sale/app/navbar/navbar"; |
|
|
import {jsonrpc} from "@web/core/network/rpc_service"; |
|
|
import {jsonrpc} from "@web/core/network/rpc_service"; |
|
|
import {patch} from "@web/core/utils/patch"; |
|
|
import {patch} from "@web/core/utils/patch"; |
|
|
import {SetSaleOrderButton} from "@pos_sale/app/set_sale_order_button/set_sale_order_button" |
|
|
import {SetSaleOrderButton} from "@pos_sale/app/set_sale_order_button/set_sale_order_button" |
|
|
|
|
|
import { useService } from "@web/core/utils/hooks"; |
|
|
|
|
|
import { _t } from "@web/core/l10n/translation"; |
|
|
|
|
|
var beep = new Audio('/click_and_collect_pos/static/src/audio/notification.wav'); |
|
|
|
|
|
|
|
|
Navbar.components = {...Navbar.components, SetSaleOrderButton} |
|
|
Navbar.components = {...Navbar.components, SetSaleOrderButton} |
|
|
|
|
|
|
|
|
patch(Navbar.prototype, { |
|
|
patch(Navbar.prototype, { |
|
|
|
|
|
setup() { |
|
|
|
|
|
super.setup(); |
|
|
|
|
|
this.sound = useService("sound"); |
|
|
|
|
|
this.busService = this.env.services.bus_service |
|
|
|
|
|
this.busService.addChannel('POS_COLLECT_ORDER') |
|
|
|
|
|
this.busService.addEventListener("notification", this.onMessage.bind(this)) |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
onMessage({detail: notifications}) { |
|
|
|
|
|
notifications = notifications.filter(item => item.payload.channel === 'POS_COLLECT_ORDER') |
|
|
|
|
|
if (notifications){ |
|
|
|
|
|
console.log("Notifications") |
|
|
|
|
|
this.env.services.notification.add( |
|
|
|
|
|
_t("One Collect Order Is Created"), |
|
|
|
|
|
{ sticky: true ,type: "success",} |
|
|
|
|
|
); |
|
|
|
|
|
beep.play(); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
async onClick() { |
|
|
async onClick() { |
|
|
const sale_orderSetSaleOrderButton = []; |
|
|
const sale_orderSetSaleOrderButton = []; |
|
|
const stock_picking = this.pos.stock_picking; |
|
|
const stock_picking = this.pos.stock_picking; |
|
@ -19,9 +41,7 @@ patch(Navbar.prototype, { |
|
|
domain: [['state', '=', 'sale'], ['pos_config_id', '=', session_id[0]]], |
|
|
domain: [['state', '=', 'sale'], ['pos_config_id', '=', session_id[0]]], |
|
|
}, |
|
|
}, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const line_ids = [] |
|
|
const line_ids = [] |
|
|
|
|
|
|
|
|
stock_picking.forEach(function (lines) { |
|
|
stock_picking.forEach(function (lines) { |
|
|
lines.move_ids_without_package.forEach(function (line) { |
|
|
lines.move_ids_without_package.forEach(function (line) { |
|
|
if (line.sale_line_id[0] && line.state !== "done") { |
|
|
if (line.sale_line_id[0] && line.state !== "done") { |
|
@ -29,7 +49,6 @@ patch(Navbar.prototype, { |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const sale_order = sale_order_line.filter((line) => line_ids.includes(line.id)); |
|
|
const sale_order = sale_order_line.filter((line) => line_ids.includes(line.id)); |
|
|
this.pos.showScreen("SaleOrderScreen", { |
|
|
this.pos.showScreen("SaleOrderScreen", { |
|
|
click_and_collect: sale_order, |
|
|
click_and_collect: sale_order, |
|
|