Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • Odoo के ऑफ़िस में आएं
    सॉफ़्टवेयर पाएं
    • डाउनलोड
    • वर्शन की तुलना करें
    • रिलीज़
    साथ मिलकर काम करें
    • Github
    • फ़ोरम
    • इवेंट
    • अनुवाद
    • पार्टनर बनें
    • Services for Partners
    • अपना अकाउंटिंग फ़र्म रजिस्टर करें
    सेवाएं पाएं
    • पार्टनर ढूंढें
    • अकाउंटेंट खोजें
    • सलाहकार की मदद लें
    • इम्प्लिमेंटेशन सेवाएं
    • कस्टमर रेफ़रेंस
    • सहायता
    • अपग्रेड
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    डेमो देखें
  • कीमत
  • सहायता

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • सीआरएम
  • e-Commerce
  • लेखांकन
  • इन्वेंटरी
  • PoS
  • प्रोजेक्ट
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

How to inherit the POS to add a new print button and QWeb report?

Subscribe

Get notified when there's activity on this post

This question has been flagged
javascriptinheritancepoint_of_salebackbone.jsodoo8
13 Replies
24020 Views
Avatar
Yenthe Van Ginneken (Mainframe Monkey)

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:

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

the javascript file (pos_button.js):

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

But this gives me the following error in the console:

TypeError: module.ScreenWidget is undefined

So I remain with two questions: 
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?

this.add_action_button({ label: _t('Print Receipt'); icon: '/pos_print/static/src/img/icons/printer.png', click: function(){ self.print(); }, });

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:

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

});

};

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:

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

3
Avatar
Discard
Avatar
Axel Mendoza
Best Answer

This code is working ok, it's based on your code. The thing is that the refresh function of the ReceiptScreenWidget render the original report and that function is called when you call 

this.pos_widget.screen_selector.set_current_screen('receipt');

That's way I put the "no_refresh = true" flag to check if the original refresh function of the ReceiptScreenWidget need to get called or not
Here is the code:

openerp.aa_pippa_pepper_pos = function(instance){

var module = instance.point_of_sale;

var Qweb = instance.web.qweb;

var _t = instance.web._t;

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.refresh();

},

});

},

refresh: function() {

var order = this.pos.get('selectedOrder');

$('.pos-receipt-container').html(Qweb.render('PosTicket2',{

widget:this,

order: order,

orderlines: order.get('orderLines').models,

paymentlines: order.get('paymentLines').models,

}));

this.pos_widget.receipt_screen.no_refresh = true;

this.pos_widget.screen_selector.set_current_screen('receipt');

this.pos_widget.receipt_screen.no_refresh = false;

},

close: function(){

this._super();

}

});

module.ReceiptScreenWidget.include({

refresh: function() {

if(this.no_refresh){

return

} else{

this._super();

}

},

});

};

--- Update to fix the report template ---

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

<table class='receipt-orderlines'>

<colgroup>

<col width='50%' />

<col width='25%' />

<col width='25%' />

</colgroup>

<tr t-foreach="orderlines" t-as="orderline">

<td>

<t t-esc="orderline.get_product().display_name"/>

<t t-if="orderline.get_discount() > 0">

<div class="pos-disc-font">

With a <t t-esc="orderline.get_discount()"/>% discount

</div>

</t>

</td>

<td class="pos-right-align">

<t t-esc="orderline.get_quantity_str_with_unit()"/>

</td>

<td class="pos-right-align">

<t t-esc="widget.format_currency(orderline.get_display_price())"/>

</td>

</tr>

</table>

<br />

<table class='receipt-total'>

<tr>

<td>Subtotal:</td>

<td class="pos-right-align">

<t t-esc="widget.format_currency(order.getSubtotal())"/>

</td>

</tr>

<t t-foreach="order.getTaxDetails()" t-as="taxdetail">

<tr>

<td><t t-esc="taxdetail.name" /></td>

<td class="pos-right-align">

<t t-esc="widget.format_currency(taxdetail.amount)" />

</td>

</tr>

</t>

<tr>

<td>Discount:</td>

<td class="pos-right-align">

<t t-esc="widget.format_currency(order.getDiscountTotal())"/>

</td>

</tr>

<tr class="emph">

<td>Total:</td>

<td class="pos-right-align">

<t t-esc="widget.format_currency(order.getTotalTaxIncluded())"/>

</td>

</tr>

</table>

</div>

</t>

</templates>


6
Avatar
Discard
Yenthe Van Ginneken (Mainframe Monkey)
Author

Thanks Axel, a step closer! The thing is, I've now extended my custom ticket since it should show the prices too. So I added a line: but when I now run the JS I will get the error 'Error: QWeb2 - template['PosTicket2']: Runtime Error: TypeError: dict.order.get_subtotal is not a function' so I'm missing something in the JS that gets the get_subtotal but I'm not sure how to call it.. Think you could give me a helping hand there too?

Axel Mendoza

Update the code to see what is the error now with the get_subtotal function

Yenthe Van Ginneken (Mainframe Monkey)
Author

Excellent answer, upvoted & accepted! Thank you Axel.

Avatar
Emipro Technologies Pvt. Ltd.
Best Answer

Here in your pos_button.js file

For initializing a function in ".js" file you need to do following:

In your case your module name is "my_module_name" which we can see from your ".js" declaration in web.asset.

Now, why do you want to define new "ReceiptScreenWidget", because it already there provided in core module 'point_of_sale'

Try Following:

openerp.my_module_name = function(instance){
     var module = instance.point_of_sale;
     var Qweb = instance.web.qweb;
     var _t =    instance.web._t;
   

module.PaymentScreenWidgetInherit=module.PaymentScreenWidget.include({ 

    show:function(){

                self=this;

                this._super();

                this.add_action_button({

                                    label: _t('NA'),

                                    icon: '/point_of_sale/static/src/img/icons/png48/go-previous.png',

                                   click: function(){

                                                    self.myclick();

                                    },

                });

    },

    myclick:function(){

              alert('My Button Click');

             <<your code for loading qweb template goes here>

   },

});

};



1
Avatar
Discard
Yenthe Van Ginneken (Mainframe Monkey)
Author

Thanks for the great answer Emipro! I've added a line in the JS like this: this.pos_widget.screen_selector.set_current_screen(this.next_screen); which is opening a new view, the default ticket screen. How do I now create another view/report that should be opened in place of the receipt screen? :s

Yenthe Van Ginneken (Mainframe Monkey)
Author

I've added my code as how it looks now, I did some attemps.

Emipro Technologies Pvt. Ltd.

Can you tell your purpose for having a new screen?

Yenthe Van Ginneken (Mainframe Monkey)
Author

The default ticket that is printed in the screen (when you click on the payment method and then on confirm shows you the dialog to print the report but also shows the report inline. I want a second view which shows another version of this ticket in the browser. See: http://i.imgur.com/2iUI5MY.png

Emipro Technologies Pvt. Ltd.

Do you want to keep the old version of the report? If no then I suggest copy whole template of that report version in your xml file and keep the 'same name of the template' and just do the changes you want, so it will load with whatever changes you made. In this case you don't need to add any new button. OR you can create your own new template and in js file you need to override the code where it prints the old version of the report and change the template name with yours new template name. Hope this helps !!.

Yenthe Van Ginneken (Mainframe Monkey)
Author

@Emipro I do need the old ticket lay-out. So I need two buttons next to eachother that both link to another QWeb report. How exactly should I link my second button to the QWeb report then?

Emipro Technologies Pvt. Ltd.

Actually, when you click on confirm button pos makes the order 'paid' and shows you the reciept. I don't know while showing new qweb template do you want to confirm the order or not. If not than, in your case you need to create new screen inherited from 'ScreenWidget'. Then from the code shown above in function 'myclick' you need to show that new screen rendering your new qweb template. For rendering the qweb template, you can just search around in core module how the old report is rendered and check it.

Yenthe Van Ginneken (Mainframe Monkey)
Author

@Emipro I'm talking about the button 'Validate', not 'Invoice'. My new button (named 'Kasticket') should do exactly the same functionalities as 'Validate', the only difference is that it should show another QWeb report. I can't find any working way to show another QWeb report though..

Yenthe Van Ginneken (Mainframe Monkey)
Author

@Emipro I've updated my code again and added in my template for the new QWeb report.

Emipro Technologies Pvt. Ltd.

What error you are facing here?

Yenthe Van Ginneken (Mainframe Monkey)
Author

The new QWeb report is not shown in the ticket view, it is always the old (default) QWeb report

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
Extend a specific popup widget
javascript point_of_sale backbone.js
Avatar
0
फ़र॰ 19
6830
Inherit POS Javascript function in Odoo 10 Solved
javascript inheritance point_of_sale odoo10.0
Avatar
Avatar
1
अप्रैल 18
11430
Add a field and update the value in odoo pos orderline Odoo 11 Solved
javascript inheritance point_of_sale odoo odoo11
Avatar
Avatar
1
जुल॰ 21
16874
(SOLVED) JavaScript: How to add a QR code in POS Receipt?
javascript point_of_sale
Avatar
0
अग॰ 23
4048
Change onclick kanban project view (JS file)
javascript inheritance
Avatar
Avatar
1
मार्च 22
7659
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

Odoo की सबसे बड़ी खासियत है कि यह इस्तेमाल करने में बहुत आसान है और यह पूरी तरह से इंटिग्रेट किया हुआ है.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now