This question has been flagged
3512 Views

Hi, I've been trying to print invoice directly from the POS interface. I managed to add print invoice button next to the next order button and some functionality to it. I've used the module tg_pos_enhanced developed by Thierry Godin. Therefore, the customer will set directly inside the POS onterface, so there is no problem with no selected customer.

All code below is works fine but it does not generate PDF invoice downloaded. Please help me, it seems very close to successfully print pos invoice directly from POS interface.

Here is the button function in javascript, it will active when I click on the print invoice button:

    var model = new instance.web.Model("pos.order");
    model.query(['id']).all().then(function(results) {
        posid = results[0].id;
        model.call("action_invoice", [[posid]], { context: new instance.web.CompoundContext({shadow:true}) })
                .then(function(result) {
                        console.log("Generate pos invoice WOO HOO!!!");
                });
       model.call("print_pos_invoice", [[posid]], { context: new instance.web.CompoundContext({shadow:true}) })
                .then(function(result) {
                        console.log("Print pos invoice WOO HOO!!!");
                });
       });

Here's the print_pos_invoice method in python:

def print_pos_invoice(self, cr, uid, ids, context=None):

        assert len(ids) == 1, 'This option should only be used for a single id at a time'
        datas = {
                 'model': 'pos.order',
                 'ids': ids,
                 'form': self.read(cr, uid, ids[0], context=context),
        }
        return {'type': 'ir.actions.report.xml', 'report_name': 'pos.invoice', 'datas': datas, 'nodestroy': True}

The console.log shows everything as expected. The last thing left is the generate PDF invoice is not downloaded. Could anyone help me accomplish this please?

Avatar
Discard

did you get a solution for this? i am stuck up on the same thing. could you please help ? Thanks....

I'm also stuck in this point, did you found the solution ?