Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Discuss
    • Kecerdasan Buatan
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Manajemen Properti
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Konsultasi
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

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

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
reportingreportsplitOdoo13.0
2 Replies
11706 Tampilan
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
Buang
Avatar
EvilTweats
Jawaban Terbai

 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
Buang
Nao possuo empresa, Hugo
Penulis

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
Jawaban Terbai

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
Buang
Nao possuo empresa, Hugo
Penulis

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.

Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
Chaning the Reportname
reporting report
Avatar
Avatar
1
Jul 24
3017
How many types of reports are available?
reporting report
Avatar
Avatar
1
Mar 15
550
Is it possible to generate reports with dynamic columns?
reporting report
Avatar
Avatar
1
Mar 15
11813
report in open erp through interface
reporting report
Avatar
0
Mar 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
Mar 15
5546
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Karir
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah software terintegrasi dengan 70+ aplikasi seperti CRM, Akuntansi, Inventaris, Sales, eCommerce, Marketing, POS; plus fitur lokal Indonesia!

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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