Se rendre au contenu
Menu
Cette question a été signalée
2 Réponses
7723 Vues

Hi guys thks for reading my request. Got my odoo v15 upgrade it seem have some changes. Hope looking for a option to change the label size and orientation of the information inside. Any tips.

Here is a link of the image, Hope that help you guys to understand. 

https://ibb.co/pyZL5mZ

Avatar
Ignorer
Meilleure réponse

Hello, David

Odoo has only specific label layouts and sizes, as mentioned in your screenshot. 

You may consider this solution, which will allow you to create and design a product label with your layout: https://apps.odoo.com/apps/modules/15.0/garazd_product_label_pro/


Best regards, Yurii Razumovskyi.

Company Garazd Creation


Avatar
Ignorer
Meilleure réponse

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

Avatar
Ignorer
Publications associées Réponses Vues Activité
2
nov. 24
1169
2
mars 15
5618
5
déc. 23
17996
2
juil. 25
315
2
mai 24
3231