Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

Issue with a new Product Label Template (102x102) in Odoo V17

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
developmentpythonqweb
1751 Widoki
Awatar
Quentin Roland

Hi everyone,

I’m encountering an issue with a custom product label template I created in Odoo based on the standard implementation. The template is supposed to display products with specific dimensions (102x102), but the following problems occur:

  1. No products are displayed at all: The table seems empty, and none of the data I’m passing appears to render correctly.
  2. H1 tag stops iterating: Inside the loop for testing, the <h1> tags only display up to the third iteration and do not proceed further.

Here’s the relevant portion of my code:


<?xml version="1.0" encoding="UTF-8"?>

<odoo>

<data>

<!-- Template principal -->

<template id="template_producttemplatelabel102x102">

<t t-call="web.basic_layout">

<div class="page">

<t t-set="columns" t-value="102"/>

<t t-set="rows" t-value="102"/>

<t t-call="happy_rabbits_custo.report_productlabel_102x102"/>

<t t-log="quantity"/>

<t t-log="current_data"/>

<t t-log="product"/>

<t t-log="barcode"/>


</div>

</t>

</template>


<!-- Template de gestion des labels -->

<template id="report_productlabel_102x102">

<t t-call="web.html_container">

<t t-esc='columns'/>

<t t-esc='rows'/>

<t t-if="columns and rows">

<t t-if="columns == 102 and rows == 102">

<t t-set="padding_page" t-value="'padding: 0mm'"/>

<t t-set="report_to_call" t-value="'102x102'"/>

</t>

<t t-set="page_numbers" t-value="1"/>

<h1>lalalallalalaal3 </h1>

<t t-foreach="range(page_numbers)" t-as="page">

<h1>lalalallalalaal3 </h1>


<div class="o_label_sheet" t-att-style="padding_page">

<table class="my-0 table table-sm table-borderless">

<t t-foreach="range(rows)" t-as="row">

<tr>

<t t-foreach="range(columns)" t-as="column">

<t t-if="not current_quantity and quantity and not (current_data and current_data[1])">

<h1>lalalallalalaal5 </h1>

<t t-set="current_data" t-value="quantity.popitem()"/>

<t t-set="product" t-value="current_data[0]"/>

<h1>lalalallalalaal6 </h1>


<t t-set="barcode_and_qty" t-value="current_data[1].pop()"/>

<t t-set="barcode" t-value="barcode_and_qty[0]"/>

<t t-set="current_quantity" t-value="barcode_and_qty[1]"/>

</t>

<t t-if="current_quantity">

<t t-set="make_invisible" t-value="False"/>

<t t-set="current_quantity" t-value="current_quantity - 1"/>

</t>

<t t-else="">

<t t-set="make_invisible" t-value="True"/>

</t>

</t>

<t t-if="report_to_call == '102x102'">

<t t-call="happy_rabbits_custo.report_simple_label102x102"/>

</t>

</tr>

</t>

</table>

</div>

</t>

</t>

</t>

</template>


<template id="report_simple_label102x102">

<t t-set="barcode_size" t-value="'width:80mm;height:80mm'"/>

<t t-set="table_style" t-value="'width:102mm;height:102mm;'"/>

<td t-att-style="make_invisible and 'visibility:hidden;'">

<div class="o_label_full" t-att-style="table_style">

<div class="o_label_name">

<t t-if="quantity">

<p>Quantity: <t t-esc="quantity"/></p>

</t>

<t t-if="product">

<p>Product: <t t-esc="product.display_name"/></p>

</t>

<t t-else="">

<p>No product data available.</p>

</t>


</div>

</div>

</td>

</template>


<record id="happy_rabbits_custo.report_product_template_label_102x102" model="ir.actions.report">

<field name="name">Product Label 102x102</field>

<field name="model">product.template</field>

<field name="report_type">qweb-pdf</field>

<field name="report_name">happy_rabbits_custo.template_producttemplatelabel102x102</field>

<field name="report_file">happy_rabbits_custo.template_producttemplatelabel102x102</field>

<field name="print_report_name">'Products Labels - %s' % (object.name)</field>

</record>


</data>

</odoo>

And the python model : 

from odoo import models, fields

import logging


_logger = logging.getLogger(__name__)


class ProductLabelLayout(models.TransientModel):

_inherit = 'product.label.layout'


print_format = fields.Selection(

selection_add=[('102x102xprice', '102x102')],

ondelete={'102x102xprice': 'set default'}, # Définir une politique pour la valeur ajoutée

)


def _prepare_report_data(self):

xml_id, data = super()._prepare_report_data()

if self.print_format in ['102x102xprice']:

if 'product.' in xml_id:

xml_id = xml_id.replace('product.', 'happy_rabbits_custo.')

active_model = ''

if self.product_tmpl_ids:

products = self.product_tmpl_ids.ids

active_model = 'product.template'

_logger.info('products: %s', products)

elif self.product_ids:

products = self.product_ids.ids

active_model = 'product.product'

_logger.info('products: %s', products)

else:

raise UserError(_("No product to print, if the product is archived please unarchive it before printing its label."))


_logger.info('products: %s', products)

data.update({

'active_model': active_model,

'quantity_by_product': {p: self.custom_quantity for p in products},

'layout_wizard': self.id,

'price_included': 'xprice' in self.print_format,

})



return xml_id, data



def _prepare_data(env, docids, data):

_logger.info("Starting _prepare_data with data: %s", data)


layout_wizard = env['product.label.layout'].browse(data.get('layout_wizard'))

if not layout_wizard:

_logger.error("Layout wizard is missing.")

return {}


if layout_wizard.print_format == '102x102xprice':

quantity = data.get('quantity_by_product', {})

_logger.info("Quantity by Product: %s", quantity)


if not quantity:

_logger.error("Quantity by product is empty.")

return {}


total = sum(quantity.values())

rows = layout_wizard.rows or 1

columns = layout_wizard.columns or 1

page_numbers = (total - 1) // (rows * columns) + 1


products = env['product.template'].browse(list(quantity.keys()))

_logger.info("Products loaded: %s", products)


return {

'quantity': {p.id: quantity[str(p.id)] for p in products}, # Correct format

'page_numbers': page_numbers,

'price_included': data.get('price_included'),

'extra_html': layout_wizard.extra_html,

'pricelist': layout_wizard.pricelist_id,

}



class ReportHappyRabbitsProductTemplateLabel102x102(models.AbstractModel):

_name = 'report.happy_rabbits_custo.report_producttemplatelabel102x102'

_description = 'Product Label Report 102x102'


def _get_report_values(self, docids, data):

return ProductLabelLayout._prepare_data(self.env, docids, data)


Questions:

  1. Why might the data not display in the template like my products name or other? Could there be an issue with the t-set assignments?

Any insights or suggestions would be greatly appreciated! Thanks in advance for your help.

0
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
TypeError str and datetime Rozwiązane
development python
Awatar
Awatar
Awatar
2
sie 24
2279
Duplicate Orders in POS When Clicking Order Button (Odoo 18)
development python Point Of Sale
Awatar
Awatar
2
lut 25
2391
Email template - list of followers
python qweb email
Awatar
Awatar
Awatar
2
cze 23
3161
Best practices for code reuse in Odoo addon development ?
development python methodology
Awatar
Awatar
1
kwi 23
6050
My custom report is changing when user Configured the Document Layout Rozwiązane
python qweb v14
Awatar
Awatar
1
sty 23
3331
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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