Skip to Content
मेन्यू
This question has been flagged
3 Replies
7881 Views

Hi ,

I need to print my custom report in odoo pos interface. In the ReceiptScreenWidget I have added a button to print my custom report. So while clicking on that button I need to print or download that report. How can I do that?

This is my qweb template I used to add the print button in ReceiptScreenWidget

<t t-extend="ReceiptScreenWidget">

<t t-jquery=".button.print_invoice" t-operation="after">

<div class="button print_report_custom">

<i class='fa fa-print'></i> Print  report </div> </t> </t>


I need to print the report in the following click function.



screens.ReceiptScreenWidget.include({

    renderElement: function() {

        var self = this;

        this._super();


        var button_print_custom = this.$('.button.print_report_custom');

        button_print_custom.click(function () {

            var order = self.pos.get_order();

            if (!self._locked) 

            {

           

            }

            });

},

        });


 

Thanks in Advance


Avatar
Discard

Even I am looking something like this

Author Best Answer

Hi,

Found the solution for this 

In the onclick of the button I just called a rpc query and added the function to print the report in that python file, and its worked for me.

Avatar
Discard

can you share your code?

Best Answer

Sharing a full code not possible but  I can guide you through it.

Steps:

1) Define a xml reciept view like Bill 

name - :  OrderReportReceipt

<t t-name="PaymentSummaryReportXmlReceipt">
<receipt align='center' width='50' value-thousands-separator='' >
//your code
</receipt>
</t>

2) Define an Action Button


var reportorder_button = ActionButtonWidget.extend({
    template: 'ReportorderButton',
init: function (parent, options) { this._super(parent, options); // youre code  }, 
button_click: function () {
var self = this;   
self.gui.show_popup('report_selection'
,{ title: _t('Report'),
list: selection_list,
confirm: function (repor_data) { var order = self.pos.get_order();
// your code  },
 }); },
});
define_action_button({ 'name': 'reportorder',
'widget': reportorder_button,
 });
3) define a popup with name which I have mentioned above
var ReprotPopupWidget = PopupWidget.extend({
template: 'ReprotPopupWidget',
print funtion(){
var self = this;
receipt = QWeb.render('OrderReportXmlReceipt', {
                                    widget: self,
                                    pos: self.pos,
                                    order: order,
  });
self.gui.show_screen('receipt');
},


});
gui.define_popup({name:'report_selection',widget: ReprotPopupWidget});
Codes and contribution from your side needed but it may help to get an idea.

Refer Screen.js code in Base module - point_of_sale

Avatar
Discard
Related Posts Replies Views Activity
1
जुल॰ 25
968
2
अग॰ 24
1521
1
मार्च 24
2508
1
नव॰ 22
5664
0
सित॰ 20
2182