Hi guys,
I've been trying to inherit and extend the POS from Odoo (V8) but I keep running stock. What do I want to do? When the user clicks on a payment method and the screen is show there is a button 'Confirm'. I want to add another button here, which prints a new created QWeb report. So far I've managed to add a new JS file to the web.assets and started to extend the POS. So my code for adding my customer JS file:
the javascript file (pos_button.js):<openerp> <data> <!-- Inherit the js template in the module and include js file there. --> <template id="assets_backend_pippa" name="pos_print" inherit_id="web.assets_backend"> <xpath expr="." position="inside"> <script type="text/javascript" src="/my_module_name/static/src/js/pos_button.js"></script> </xpath> </template> </data> </openerp>
But this gives me the following error in the console:function openerp_pos_screens(instance, module){ var QWeb = instance.web.qweb, _t = instance.web._t;
module.ReceiptScreenWidget = module.ScreenWidget.extend({ template: 'ReceiptScreenWidget', show_numpad: true, show_leftpane: true, init: function(parent, options) { this._super(parent,options); this.model = options.model; this.user = this.pos.get('user'); this.company = this.pos.get('company'); this.shop_obj = this.pos.get('shop'); }, renderElement: function() { this._super(); this.pos.bind('change:selectedOrder', this.change_selected_order, this); this.change_selected_order(); }, show: function(){ this._super(); var self = this;
this.add_action_button({ label: _t('Print Receipt'), icon: '/pos_print/static/src/img/icons/printer.png', click: function(){ self.print(); }, }); }, close: function(){ this._super(); } }); }
So I remain with two questions:TypeError: module.ScreenWidget is undefined
1) Why am I getting this TypeError? I don't get why it is undefined.
2) How can I pass this part of the code to open up a new custom QWeb report in the POS?
Update: I managed to get the new button working thanks to Emipro. I'm now trying to call another report lay-out, but this doesn't seem to work. My code:this.add_action_button({ label: _t('Print Receipt'); icon: '/pos_print/static/src/img/icons/printer.png', click: function(){ self.print(); }, });
This opens a new page but shows the old report lay-out, while it should show the new one I created. My new report code:module.PaymentScreenWidgetInherit=module.PaymentScreenWidget.include({ show:function(){ self=this; this._super(); this.add_action_button({ label: _t('Kasticket'), icon: '/point_of_sale/static/src/img/icons/png48/invoice.png', click: function(){ self.print_report(); }, }); }, //This variable will keep the link to another view. next_screen: 'receipt', print_report:function(){ //This opens the next page (which is the receipt page) this.pos_widget.screen_selector.set_current_screen('receipt');
},
refresh: function() { var order = this.pos.get('selectedOrder'); $('.pos-receipt-container', this.$el).html(Qweb.render('PosTicket2',{ widget:this, order: order, orderlines: order.get('orderLines').models, paymentlines: order.get('paymentLines').models, })); },
});
};
<?xml version="1.0" encoding="UTF-8"?> <templates id="template" xml:space="preserve"> <t t-name="PosTicket2"> <div class="pos-sale-ticket"> <div class="pos-center-align"><t t-esc="new Date().toString(Date.CultureInfo.formatPatterns.shortDate + ' ' + Date.CultureInfo.formatPatterns.longTime)"/> <t t-esc="order.get('name')"/></div> <br /> <t t-esc="widget.pos.company.name"/><br /> Phone: <t t-esc="widget.pos.company.phone || ''"/><br /> User: <t t-esc="widget.pos.cashier ? widget.pos.cashier.name : widget.pos.user.name"/><br /> Shop: <t t-esc="widget.pos.shop.name"/><br /> <br /> <t t-if="widget.pos.config.receipt_header"> <div style='text-align:center'> <t t-esc="widget.pos.config.receipt_header" /> </div> <br /> </t> </div> </t> </templates>
Thanks,
Yenthe