Hi,
In the selection option for the layout, we cant add a particular format manually that need some python code, for getting the particular out we can customize the layout structure
first, we can add the form view for the format type '
In a python file, you can inherit the layout, this comes in the wizard action.
class ProductLabelLayout(models.TransientModel):
_inherit = 'product.label.layout'
print_format = fields.Selection(selection_add=[
('new_fromat', 'Format'), ], ondelete={'new_format': 'set default'})
def _prepare_report_data(self):
xml_id, data = super()._prepare_report_data()
if 'new_format' in self.print_format:
xml_id = 'report.custom_labels.report_new_fromat'
data = {
'active_model': active_model,
'product_tmpl_name': self.product_tmpl_ids.name,
'product_tmpl_price': price,
#you can add particular data in the label printing
}
return xml_id, data
python file for a report
class ReportProductLabelTag(models.AbstractModel):
_name = 'report.custom_labels.report_new_fromat'
_description = 'Label'
def _get_report_values(self, docids, data):
if data.get('active_model') == 'product.template':
Product = self.env['product.template']
elif data.get('active_model') == 'product.product':
Product = self.env['product.product']
else:
raise UserError(
_('Product model not defined, Please contact your administrator.'))
return {
'doc_ids': docids,
'data': data,
}
report XML
# create the paper format
<record id="paperformat_new_format" model="report.paperformat">
<field name="name">Label</field>
<field name="default" eval="True"/>
<field name="format">custom</field>
<field name="page_height">267</field>
<field name="page_width">175</field>
<field name="orientation">Landscape</field>
<field name="margin_top">0</field>
<field name="margin_bottom">0</field>
<field name="margin_left">0</field>
<field name="margin_right">0</field>
<field name="disable_shrinking" eval="True"/>
<field name="header_line" eval="False"/>
<field name="header_spacing">0</field>
<field name="dpi">96</field>
</record>
<record id="report_new_format" model="ir.actions.report">
<field name="name">New</field>
<field name="model">product.template</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">module_name.report_new_fromat</field>
<field name="report_file">module_name.report_new_fromat</field>
<field name="paperformat_id" ref="paperformat_new_format"/>
</record>
and also you can design your own templates using
<template id="report_new_format">
# add custom template format
</template
Regards