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.

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
<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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With