Skip to content

Instantly share code, notes, and snippets.

@allanaguilar
Forked from drkpkg/size.py
Created October 15, 2021 03:42
Show Gist options
  • Save allanaguilar/50e832345c33cf9b637bd9991a691f1a to your computer and use it in GitHub Desktop.
Save allanaguilar/50e832345c33cf9b637bd9991a691f1a to your computer and use it in GitHub Desktop.
Dynamic size report invoice odoo
"""
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