0
votes

I'm trying to add a subtotal to the Point of Sale screen in the section where products are being added so that the cashier can see not only the tax and total but also subtotal.

I've successfully added the subtotal by extending the OrderWidget in the static XML.

Now I'm trying to extend the javascript code that I think modify the value of the tax and total as you're adding products. this is the name of the class I'm extending OrderWidget and this is the method I'm extending update_summary

I follow the same coding I did to extend the PosModel from the models javascript module but in this case, I'm using the screens module

This is the code I have but for some reason, my method is not being called. Am I extending wrong the Widget?

var OrderWidgetParent = screens.OrderWidget.prototype;

screens.OrderWidget = screens.OrderWidget.extend({        
    update_summary: function() {
        console.debug('--------------- START');
        OrderWidgetParent.update_summary.call(this);

        var order = this.pos.get_order();
        if (!order.get_orderlines().length) {
           return;
        }

        this.el.querySelector('.summary .total .subentry .subtotal') 
        .textContent = this.format_currency(total - taxes);            

        console.debug('--------------- END');
    }
}); 
2

2 Answers

0
votes

You just need to call base method of models.js in your xml template file. Method is: 'get_total_without_tax'

This method get total excluded tax. So you can consider this as a subtotal of your order.

0
votes

The solution was to use include instead of extend.