Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
7725 Lượt xem

Hello all,

In my new module, I want to modify (override) completely the update_summary function of the file point_of_sale/static/src/js/widgets.js ? But I don't manage it.

Here is my trying  code in my module pos_lapagept :

console.log('WIDGETS_CF.JS'); //this one works!!!

openerp.pos_lapagept = function (instance) {

var module = instance.point_of_sale

module.PosBaseWidget.include({

update_summary: function(){

console.log('NEW UPDATE_SUMMARY FUNCTION');

var order = this.pos.get('selectedOrder');

var total = order ? order.getTotalTaxIncluded() : 0;

var taxes = order ? total - order.getTotalTaxExcluded() : 0;

this.el.querySelector('.summary .total > .value').textContent = this.format_currency(total);

this.el.querySelector('.summary .total .subentry .value').textContent = 'dsdds';//this.format_currency(taxes);

},

});

}


I have no error in the console, none reaction... Only the first line of my code works!


Could you please help?

Ảnh đại diện
Huỷ bỏ

What version of Odoo are you using? There was a major change on how JS is structured from v8 to v9.

Tác giả

I'm sorry. We use Odoo 8.

console.log('WIDGETS_CF.JS'); //this one works!!!

openerp.pos_lapagept = function (instance) {

var module = instance.point_of_sale

 instance.point_of_sale.OrderWidget = instance.point_of_sale.OrderWidget.extend({ 

update_summary: function(){

console.log('NEW UPDATE_SUMMARY FUNCTION');

//your code here...

},

});

}

nice :) you've found a solution yourself while I was editing the answer

Tác giả Câu trả lời hay nhất

Ok I get it! Thanks all!

console.log('WIDGETS_CF.JS');

openerp.pos_lapagept = function (instance) {

var QWeb = instance.web.qweb;

var _t = instance.web._t;

var module=instance.point_of_sale

console.log('TESTING TESTING');

module.OrderWidget = module.OrderWidget.extend({

update_summary: function(){

console.log('NEW UPDATE_SUMMARY FUNCTION');

var order = this.pos.get('selectedOrder');

var total = order ? order.getTotalTaxIncluded() : 0;

var taxes = order ? total - order.getTotalTaxExcluded() : 0;

this.el.querySelector('.summary .total > .value').textContent = this.format_currency(total);

this.el.querySelector('.summary .total .subentry .value').textContent = 'dsdds';//this.format_currency(taxes);

},

});

}

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 23
2957
Override JS mail Đã xử lý
3
thg 7 21
5242
1
thg 8 19
3003
1
thg 5 23
2395
4
thg 11 19
8632