To define two different paper formats for a report in Odoo, you can override the get_report_paperformat method in your custom report template. Here's an example of how you can achieve this:
from odoo import models
class CustomReport(models.AbstractModel):
_name = 'report.custom_module.custom_report_template'
def get_report_paperformat(self, docids, data=None):
if condition: # Define your condition to determine the paper format
return self.env.ref('report.paperformat_custom_format').sudo()
else:
return self.env.ref('report.paperformat_custom_format2').sudo()
In this example, we have a custom report template defined in the module custom_module with the report XML ID custom_report_template. We override the get_report_paperformat method to dynamically select the appropriate paper format based on a condition.