This question has been flagged
1 Reply
4691 Views

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

Avatar
Discard

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!

Author

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

Best Answer

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.

Avatar
Discard