Skip to content

Commit

Permalink
[MIG/FIX] stock_barcodes: fix notification usage to adapt to v15.
Browse files Browse the repository at this point in the history
  • Loading branch information
LoisRForgeFlow committed Nov 29, 2022
1 parent b9bfe33 commit bcc18f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
21 changes: 6 additions & 15 deletions stock_barcodes/static/src/js/basic_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,10 @@ odoo.define("stock_barcodes.BasicController", function (require) {
const state_id = this.initialState.data.id;
this._areAccessKeyVisible = false;
if (state_id) {
this._channel_barcode_read = `stock_barcodes_read-${this.initialState.data.id}`;
this._channel_barcode_sound = `stock_barcodes_sound-${this.initialState.data.id}`;
this._channel_barcode = `stock_barcodes-${this.initialState.data.id}`;

if (this.call("bus_service", "isMasterTab")) {
this.call(
"bus_service",
"addChannel",
this._channel_barcode_read
);
this.call(
"bus_service",
"addChannel",
this._channel_barcode_sound
);
this.call("bus_service", "addChannel", this._channel_barcode);
}
}
}
Expand Down Expand Up @@ -114,15 +104,16 @@ odoo.define("stock_barcodes.BasicController", function (require) {
*/
onBusNotificationBarcode: function (notifications) {
for (const notif of notifications) {
const [channel, message] = notif;
if (channel === "stock_barcodes_read-" + this.initialState.data.id) {
const notif_type = notif.type;
const message = notif.payload;
if (notif_type === "stock_barcodes_read-" + this.initialState.data.id) {
if (message.action === "focus") {
setTimeout(() => {
this.$(`[name=${message.field_name}] input`).select();
}, 400);
}
} else if (
channel ===
notif_type ===
"stock_barcodes_sound-" + this.initialState.data.id
) {
if (message.sound === "ok") {
Expand Down
6 changes: 3 additions & 3 deletions stock_barcodes/wizard/stock_barcodes_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,23 +646,23 @@ def action_confirm(self):
def play_sounds(self, res):
if res:
self.env["bus.bus"]._sendone(
"stock_barcodes-{}".format(self.ids[0]),
"stock_barcodes_sound-{}".format(self.ids[0]),
"stock_barcodes",
{"sound": "ok"},
)
else:
self.env["bus.bus"]._sendone(
"stock_barcodes-{}".format(self.ids[0]),
"stock_barcodes_sound-{}".format(self.ids[0]),
"stock_barcodes",
{"sound": "ko"},
)

def _set_focus_on_qty_input(self, field_name="product_qty"):
if field_name == "product_qty" and self.packaging_id:
field_name = "packaging_qty"
self.env["bus.bus"]._sendone(
"stock_barcodes-{}".format(self.ids[0]),
"stock_barcodes_read-{}".format(self.ids[0]),
"stock_barcodes",
{"action": "focus", "field_name": field_name},
)

Expand Down

0 comments on commit bcc18f8

Please sign in to comment.