Hello everyone,
I am using Odoo 12 and need to run a code after printing a report.
The code I am inheriting from 'account.invoice' is:
@api.multi
def invoice_print(self):
res = super(AccountInvoice, self).invoice_print()
# First, I need to print the report... and then
# ...run the code here (after printing the report)...
First, I need to print the report and then execute a code to change a value of a field.
Can anyone help me please?
Thank you all in advance
Regards
PM
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Księgowość
- Zapasy
- PoS
- Project
- MRP
To pytanie dostało ostrzeżenie
Hi Paulo,
If the order doesn't strictly matter, then the following code is the easiest approach:
@api.multi
def invoice_print(self):
res = super(ReportController, self).invoice_print()
self.write({'print_button_pressed': True})
return res
The main thing to note is that you are returning the result of the super, which contains the print action. As I mentioned, the order wrong in this, but in most case it shouldn't matter. This change will technically come into effect before the invoice is printed, which will only matter if you are showing that field on the invoice and need the value from before the change.
If you do need the original value, you can use the following at the end of the invoice report:
<t t-set="dummy" t-value="o.your_function_name()"/>
Then create a function your_function_name on the invoice with the code you need.
Thank you @Jake Robinson,
This is what I need: <t t-set="dummy" t-value="o.your_function_name()"/>
Best regards
PM
Report will print only if you return report action from a function which means you can not run code after print report.
You can call another function from qweb report which will get called during report print. With browse object you can call function of same class in qweb code.
Thanks
Podoba Ci się ta dyskusja? Dołącz do niej!
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj sięPowiązane posty | Odpowiedzi | Widoki | Czynność | |
---|---|---|---|---|
|
1
sty 20
|
4022 | ||
|
2
gru 19
|
4554 | ||
|
3
gru 19
|
6992 | ||
|
1
lut 19
|
9267 | ||
|
1
lis 24
|
756 |