Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Additional label formats

Odoberať

Get notified when there's activity on this post

This question has been flagged
reportinglabelsv15
1 Odpoveď
6053 Zobrazenia
Avatar
Eauzon

I was trying to add aditional label formats using this module code:


from collections import defaultdict
from odoo import fields, models


class ProductLabelLayout(models.TransientModel):
_inherit = 'product.label.layout'

print_format = fields.Selection(selection_add=[
('2x4', '2 x 4')
], ondelete={'2x4': 'set default'})


And i thought that would do it, but it leads to an error. Any ideas ?


load could not load template
ValueError: Invalid template id: ''
Template: product.report_productlabel


0
Avatar
Zrušiť
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

You need to try this code.When we create new selection field on the prin_format you must add new functions for that types and need to create new printing format

from collections import defaultdict
from odoo import fields, models,
_
from odoo.exceptions import UserError


class ProductLabelLayout(models.TransientModel):
_inherit =
'product.label.layout'

print_format = fields.Selection(selection_add=[
    (
'price_card', 'Price Card'), ], ondelete={'price_card': 'set default'})

def _prepare_report_data(self):
    xml_id, data =
super()._prepare_report_data()

   
if 'price_card' in self.print_format:
        xml_id =
module_name.report_product_label_product_price_tag'

        active_model =
''
       
if self.product_tmpl_ids:
            products =
self.product_tmpl_ids.ids
            active_model =
'product.template'
        elif
self.product_ids:
            products =
self.product_ids.ids
            active_model =
'product.product'
        price = format(
self.product_tmpl_ids.list_price, ".2f")
        data = {
           
'active_model': active_model,
           
'product_tmpl_name': self.product_tmpl_ids.name,
           
'product_tmpl_price': price,
           
'product_tmpl': self.product_tmpl_ids,
           
'product_name': self.product_ids.name,
           
'product_id': self.product_ids,
        }
   
return xml_id, data

def process(self):
    action =
super(ProductLabelLayout, self).process()
   
self.ensure_one()
    xml_id, data =
self._prepare_report_data()
   
if not xml_id:
        raise UserError(
_('Unable to find report template for %s format', self.print_format))
    report_action =
self.env.ref(xml_id).report_action(None, data=data)
    report_action.update({
'close_on_report_download': True})
   
return action

Also, try to add the paper format and further details

<record id="paperformat_product_price_tag" model="report.paperformat">
    <field name="name">Price Card 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_product_label_product_price_tag" model="ir.actions.report">
 
  <field name="name">Product Price Card</field>
    <field name="model">product.template</field>
    <field name="report_type">qweb-pdf</field>
    <field name="report_name">module_name.report_product_price_tag</field>
    <field name="report_file">module_name.report_product_price_tag</field>
    <field name="binding_type">report</field>
    <field name="binding_model_id" ref="model_product_template"/>
    <field name="paperformat_id" ref="paperformat_product_price_tag"/>
</record>
<template id="report_product_price_tag">
    //content
</template>




Hope it helps

1
Avatar
Zrušiť
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrácia
Related Posts Replies Zobrazenia Aktivita
ODOO 15 for "Einnahmenüberschussrechnung EÜR"
reporting v15
Avatar
Avatar
Avatar
2
aug 25
3870
report layout generates error on pdf export but works in preview
reporting v15
Avatar
Avatar
1
apr 25
5314
Reports: table headers repeating PO vs SO Solved
reporting v15
Avatar
Avatar
2
júl 24
6898
Insert image into a report Solved
reporting v15
Avatar
Avatar
1
apr 24
2628
V15 - Multiple IoT boxes with label printers
labels iot v15
Avatar
Avatar
Avatar
Avatar
3
máj 24
3221
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now