Skip to content

Commit fda33e5

Browse files
author
GabbasovDinar
committed
💣 not load multi-session mp orders
1 parent ba04a23 commit fda33e5

File tree

1 file changed

+24
-13
lines changed
  • pos_wechat_miniprogram/static/src/js

1 file changed

+24
-13
lines changed

pos_wechat_miniprogram/static/src/js/models.js

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,25 @@ odoo.define('pos_wechat_miniprogram.models', function(require){
1111
models.load_models({
1212
model: 'pos.miniprogram.order',
1313
fields: [],
14-
domain:[['confirmed_from_pos', '=', false]],
14+
domain: function(self) {
15+
return [['confirmed_from_pos', '=', false], ['shop_id', '=', self.config.shop_id[0]]];
16+
},
1517
loaded: function(self, orders) {
16-
// load not confirmed orders
17-
orders.forEach(function(order) {
18-
self.unconfirmed_miniprogram_orders_ids.push(order.id);
19-
order.lines_ids = [];
20-
self.get_miniprogram_order_lines_by_order_id(order.id).then(function(lines) {
21-
if (Array.isArray(lines)) {
22-
order.lines_ids = order.lines_ids.concat(lines);
23-
} else {
24-
order.lines_ids.push(lines);
25-
}
26-
self.on_wechat_miniprogram(order);
18+
if (self.config.allow_message_from_miniprogram) {
19+
// load not confirmed orders
20+
orders.forEach(function (order) {
21+
self.unconfirmed_miniprogram_orders_ids.push(order.id);
22+
order.lines_ids = [];
23+
self.get_miniprogram_order_lines_by_order_id(order.id).then(function (lines) {
24+
if (Array.isArray(lines)) {
25+
order.lines_ids = order.lines_ids.concat(lines);
26+
} else {
27+
order.lines_ids.push(lines);
28+
}
29+
self.on_wechat_miniprogram(order);
30+
});
2731
});
28-
});
32+
}
2933
},
3034
});
3135

@@ -207,6 +211,13 @@ odoo.define('pos_wechat_miniprogram.models', function(require){
207211
return this.cashregisters.find(function(c) {
208212
return c.journal.wechat && c.journal.wechat === 'jsapi';
209213
});
214+
},
215+
ms_create_order: function(options) {
216+
var data = options.data;
217+
if (data.miniprogram_order && data.miniprogram_order.id) {
218+
return false;
219+
}
220+
return PosModelSuper.prototype.ms_create_order.apply(this, arguments);
210221
}
211222
});
212223

0 commit comments

Comments
 (0)