İçereği Atla
Menü
Bu soru işaretlendi
3 Cevaplar
7874 Görünümler

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

Even I am looking something like this

Üretici En İyi Yanıt

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

can you share your code?

En İyi Yanıt

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
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Tem 25
965
2
Ağu 24
1520
1
Mar 24
2503
1
Kas 22
5663
0
Eyl 20
2181