Skip to Content
Menu
This question has been flagged

Hello all.  I am looking for a simple solution to automatically generate the invoice report at the same time as posting the invoice, instead of having to do two steps (1. confirm or post the invoice, 2. print the invoice report).

I am using Odoo 16 Community.  Default behavior of invoicing is that you press CONFIRM to save/post the invoice. This posts the invoice but does not generate the report.  Then the PRINT button is enabled and you can now print the invoice which generates either the HTML or PDF version of the invoice report.

I would like to link these two actions into a single button clilck, so that upon posting the invoice, the invoice report is generated.  (Ultimately, I want to automatically print the invoice when it is saved/posted.)  Just one step.

I have tried to add a call to the method that generates the invoice report, at the end of the action_post method for the invoice, but it does not do anything.  I can't figure out how to combine these two methods so that the invoice report is automatically generated.

Any help on this would be appreciated.

Avatar
Discard
Best Answer

Hi,

You can Inherit the account.move model, in the action_post() function supering the function and call the action_invoice_print() for the return.

class AccountMove(models.Model):
_inherit = "account.move"


def action_post(self):
res = super(AccountMove, self).action_post()
return self.action_invoice_print()

Using this method will directly move the posted state and the invoice print automatically when clicking the confirm button.

Regards

Avatar
Discard
Author

Thank you Cybrosys. I have tried this suggestion but have not yet gotten it to work. I put print statements in the inherited action_post method to see if it was in fact calling it and so forth.

It calls the method, prints my log statement, but does not generate the invoice report.

Is it possible that the posting has not completed and so the invoice does not print because it is not yet properly posted?

If I post the invoice normally, and them immediately after that has completed, manually press the button that calls action_print_invoice, this works as expected and generates the invoice report. But if I try to call action_print_invoice programatically within action_post, it does not produce the invoice report.

Related Posts Replies Views Activity
1
Mar 24
1475
1
Jul 23
2545
0
Jul 23
25
1
Dec 24
1839
1
Jun 24
1630