Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
7865 Lượt xem

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


Ảnh đại diện
Huỷ bỏ

Even I am looking something like this

Tác giả Câu trả lời hay nhấ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.

Ảnh đại diện
Huỷ bỏ

can you share your code?

Câu trả lời hay nhấ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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 25
959
2
thg 8 24
1516
1
thg 3 24
2501
1
thg 11 22
5659
0
thg 9 20
2180