Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to override completely javascript update_summary function in the file point_of_sale/static/src/js/widgets.js file?

By
Pascal Tremblay
on 1/11/16, 8:24 AM 710 views

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?

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

Javier Almancevo
on 1/11/16, 9:15 AM

I'm sorry. We use Odoo 8.

Pascal Tremblay
on 1/11/16, 9:16 AM

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...

},

});

}

Temur
on 1/11/16, 9:32 AM

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

Temur
on 1/11/16, 9:39 AM
1

Pascal Tremblay

--Pascal Tremblay--
1312
| 5 2 7
Alma, Canada
--Pascal Tremblay--


Pascal Tremblay
On 1/11/16, 9:25 AM

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);

},

});

}

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/11/16, 8:24 AM
Seen: 710 times
Last updated: 1/11/16, 9:34 AM