Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Odoo Pos - QWeb2: Error while extending template No expression given

I am using Odoo 9 and I am trying to copy a payment button. I want to copy the 50+ button over to the left side.

enter image description here

I tried adding

<t t-extend="PaymentScreen-Paymentmethods">
        <div class="paymentmethods">
            <button class="mode-button" data-action='+50'>+50</button>
        </div>
            </t>

But all I get is a black screen in the POS. When I inspect element on the page i get the following error

Error: QWeb2: Error while extending template 'PaymentScreen-PaymentmethodsNo expression given
like image 249
user2379186 Avatar asked May 06 '26 02:05

user2379186


1 Answers

<t t-extend="PaymentScreen-Paymentmethods">
        <t t-jquery='.paymentmethods' t-operation='append'>
            <div class="button mode-button" data-action='+50'>
                    +50
             </div>
        </t>
    </t>

Okay then you also need to extend the widget and override the method.

odoo.define('module_name.jsfilename', function (require) {
"use strict";
var PosBaseWidget = require('point_of_sale.screens');
var gui = require('point_of_sale.gui');
var QWeb = core.qweb;
var _t = core._t;

var PaymentScreenWidget = PaymentScreenWidget.extend({
init: function(parent, options) {
        var self = this;
        this._super(parent, options);
},
render_paymentmethods: function() {
        var self = this;
        var methods = $(QWeb.render('PaymentScreen-Paymentmethods', { widget:this }));
            methods.on('click','.paymentmethod',function(){
                self.click_paymentmethods($(this).data('id'));
            });
            methods.on('click','.mode-button',function(){
                self.click_numpad($(this));
            });
        return methods;
    },

});
});

Then you need to add that js file to point of sale backend like this.

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <template id="assets_backend" name="custom_key_pad" inherit_id="web.assets_backend">
        <xpath expr="." position="inside">
            <script type="text/javascript" src="/your_module/static/src/js/your_js_file.js"></script>
        </xpath>
    </template>
</odoo>

Then that xml should be in your manifest.xml.

Try this code. I am sure now definitely works.

like image 155
Chavada Viki Avatar answered May 07 '26 17:05

Chavada Viki