Last active
August 26, 2023 13:59
-
-
Save drkpkg/5e1f16946e4b83bad9c4f2835d5d9ddf to your computer and use it in GitHub Desktop.
Dynamic size report invoice odoo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Dynamic size in account_invoice report | |
Just send the account_invoice_line_id take the len() and multiply it with 7 (millimeters) | |
This example is simulating the paper of a supermarket invoice, the default size in my country is 24 millimeters for a correct | |
format, but you can change it! | |
How it works: You need pass this method inside the qweb report sending the lines. | |
""" | |
#Qweb | |
<t t-esc="o.change_size_page(o.lines)"/> | |
#account_invoice.py | |
def change_size_page(self, items): | |
paper_format = self.env['report.paperformat'].search([('{name or id}', '=', '{name of the paper format or the id}')]) | |
if len(items) > 10: | |
paper_format.page_height = 240 + (len(items) * 7) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment