Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Umělá inteligence
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětvíInauguration Odoo Lyon
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

[QWEB] How do I split text using the comma?

Odebírat

Get notified when there's activity on this post

This question has been flagged
reportingreportsplitOdoo13.0
2 Odpovědi
11712 Zobrazení
Avatar
Nao possuo empresa, Hugo


Hi,

I'm trying to edit report_saleorder_document to display each variant on a product's template separately.


I'm using the code:

<t t-foreach="doc.order_line" t-as="line">
    <span t-field="line.name"/>
    <span t-field="line.product_template_attribute_value_ids"/>
</t>
and the result is:

T-Shirt   Blue,Size XL,Cotton

but how can I retrieve ONLY the second variant (Size) to get a result like this?

T-Shirt   Size XL


NOTE ****************************************************************************************************

I have already tried to split the text, but it's not working

<t t-set="splited" t-value="line.product_template_attribute_value_ids.split(',')"/>
<t t-esc="splited[2]"/>

I get the error

AttributeError: 'product.template.attribute.value' object has no attribute 'split'
1
Avatar
Zrušit
Avatar
EvilTweats
Nejlepší odpověď

 Hi,

If you are sure that you will get more than one attribute than you can use this code to get your second index attribute value:

<t t-foreach="doc.order_line" t-as="line">
    <span t-field="line.name"/>
    <span t-field="line.product_template_attribute_value_ids[1].name"/>
</t>

0
Avatar
Zrušit
Nao possuo empresa, Hugo
Autor

I am not sure that there will be more than one attribute, would this t-if work?

<t t-foreach="doc.order_line" t-as="line">

<span t-field="line.name"/>

<t t-if=""line.product_template_attribute_value_ids[1].name"/>

<span t-field="line.product_template_attribute_value_ids[1].name"/>

</t>

EvilTweats

That would work. But your use case looks different though. From what I am getting is that, if your product attribute is "Size XL" only then you want to show it otherwise not. So I think better approach would be to specifically check that condition. For example:

<t t-foreach="doc.order_line" t-as="line">

<span t-field="line.name"/>

<t t-if=""line.product_template_attribute_value_ids.filtered(lambda i: i.name == 'Size XL')"/>

<span">Size XL</span>

</t>

</t>

What this code does is it checks for if attribute with name "Size XL" is present in all the attributes for that product. If it does it will write Size XL in front of it. Otherwise it will just skip over for that product.

Avatar
Paresh Wagh
Nejlepší odpověď

Hi Hugo:

Try this in place of the 2 lines of code you have listed.

Since this is a many2many relationship, the "mapped" function will retrieve a mapped list of the attribute names and "1" will retrieve the 2nd attribute since the index numbers start at 0.

<span t-esc="line.product_template_attribute_value_ids.mapped('name')[1]"/>
0
Avatar
Zrušit
Nao possuo empresa, Hugo
Autor

Both your solution and Deepak's solution worked really well, thanks

But what is the difference between:

<span t-field="line.product_template_attribute_value_ids[1].name"/>

<span t-esc="line.product_template_attribute_value_ids.mapped('name')[1]"/>

Is there a benefit in using mapped ?

EvilTweats

'mapped' and 'filtered' are iterations method provided by odoo. My solution was directly accessing the second index(place) value of Attributes therefore little quick but almost negligible in term of speed.

Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Chaning the Reportname
reporting report
Avatar
Avatar
1
čvc 24
3020
How many types of reports are available?
reporting report
Avatar
Avatar
1
bře 15
550
Is it possible to generate reports with dynamic columns?
reporting report
Avatar
Avatar
1
bře 15
11815
report in open erp through interface
reporting report
Avatar
0
bře 15
5197
when i make rml report i got an named "(<type 'exceptions.KeyError'>, KeyError(u'report.bi',), <traceback object at 0xb301052c>)
reporting report
Avatar
0
bře 15
5549
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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