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

Hello,

I would want to print invoices the same way that receipts are being printed (don't save, just push on invoice and print).
Is it possible?

Thank you in advance.

Regards
Alejandro

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

You'll need to extend the logic from the backbone.js. look at the JavaScript files under /point_of_sale/static/src/js/ and look at models.js and screens.js. What you want is a rather big task to extend though!

Tác giả

Hello Yenthe, thank you for your comment! I was checking those files and found this: screens.js > line 1333 > this.pos.proxy.print_receipt(...). I think this is a good start, but I'm not sure now how to call the invoice report instead of the receipt one..

Câu trả lời hay nhất

Hello Alejandro (and everyone), Here is a possible solution for odoo v13 community edition:

1. Extend the PosModel (javascript) defined in point_of_sale/static/src/js/models.js, and override the push_and_invoice_order to save the order_server_id into the order object:

models.PosModel = models.PosModel.extend({

push_and_invoice_order: function (order) {

// other operations

transfer.then(function(order_server_id){

// next line is important!

order.server_id = order_server_id;

// generate the pdf and download it

if (order_server_id.length && !order.is_to_email()) {

//next operations

}

});


2. Patch the ReceiptScreenWidget, defined in point_of_sale/static/src/js/screens.js and override print function to make an server request of the pos invoice report with order server ids, saved when validating the order:

screens.ReceiptScreenWidget.include({

print: function() {

var order = this.pos.get_order();

// check the server_id lenth, server_id is an array

if (order.server_id.length) {

// print the invoice report with server ids saved

this.chrome.do_action('point_of_sale.pos_invoice_report',{additional_context:{ active_ids:order.server_id, }});

}

},

});


3. Extend the ReceipScreenWidet template defined in point_of_sale/static/src/xml/pos.xml to change button's label:

t-inherit='point_of_sale.ReceiptScreenWidget'

t-inherit-mode='extension'>

Print Invoice




Hope it helps someone.

Regards.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 7 25
738
2
thg 3 25
1973
1
thg 7 23
4414
1
thg 3 21
1975
0
thg 9 18
2842