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
    Rantai Pasokan
    • 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
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-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
    • Estate Management
    • 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
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
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

[Odoo SH] How to order by child fields ?

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
pythonxmlqwebOdooSH
1 Balas
3297 Tampilan
Avatar
florent.uagolf@gmail.com

Hi !


I'm doing a search to create a qweb page displaying products and size variants.
I want to have variants sorted by attribute sequence !!
the query in .py file :
produits=request.env['product.template'].search([],0,200,'id desc ')

in Xml views, I unsuccessfully tried :
<t t-set="attribute" t-value="my_query.product_variant_ids" t-options="{'order by': 'sequence'}"/>
and I use a loop to display them

<t t-foreach="attribute" t-as="size">

Can anyone explain how to do it

0
Avatar
Buang
Avatar
Jainesh Shah(Aktiv Software)
Jawaban Terbai

Hi,

We are also directly using a sorted function in the XML 

Can you please try with the following syntax for sorting by attributes sequence?

<t t-foreach="my_query.product_variant_ids.sorted(key=lambda m: m.attribute_id.sequence)" t-as="size" >

Thank you!

Regards,




Email:      odoo@aktivsoftware.com  

Skype: kalpeshmaheshwari

   

1
Avatar
Buang
florent.uagolf@gmail.com
Penulis

Hi !

Thanks a lot for your interest !

Nice that the lambda sort works directly !!

I tried your code, but maybe I don't really know where to use it, as I use a <t t-set in place of your foreach.

So I didn't on which foreach I should write your code ?

First I have a foreach named "toto" that display the product request from my class in .py file.

In second I have a foreach named "tutu" to display all the variants for each product (in the last try I wrote the sorting code here)

But wherever I write this code I have a qweb error !?

Here is my full code with the sort code (so not working) :

<table border="0">

<t t-foreach="produits" t-as="toto">

<tr bgcolor="#FFF7F7">

<th nowrap="nowrap"></th>

<th coslpan="2" valign="bottom"><P t-esc="toto.name"/></th>

<th><t t-esc="toto.list_price"/> € / <strike><t t-esc="toto.x_studio_pvpc_eur"/> €</strike></th>

</tr>

<tr>

<td><span t-field="toto.image_128" t-options="{'widget': 'image', 'preview_image': 'image_1024' if product_image_big else 'image_128'}" width="50" class="d-flex h-50 justify-content-center align-items-center"/></td>

<td>

<table border="0">

<tr>

<t t-set="attribute" t-value="toto.product_variant_ids"/>

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

<t t-foreach="attribute.product_variant_ids.sorted(key=lambda m: m.attribute_id.sequence)" t-as="tutu">

<t t-if="index_i==10 or index==5">

<tr bgcolor="#FFF7F7"></tr>

</t>

<td><table><tr><td bgcolor="#FFF7F7"><t t-esc="tutu.product_template_attribute_value_ids.name" class=""/></td><td bgcolor="#FEFBFB"><font size="xsmall"> : <t t-if="int(tutu.qty_available)&lt;=0"><font color="brown"> 0 </font></t><t t-else=""><font color="green"> <t t-esc="int(tutu.qty_available)"/></font></t> </font> <t t-set="index_i" t-value="index_i+1"/></td></tr><tr><td colspan="2"><input type="text" size="3" value="0"></input><input type="hidden" size="3" value="tutu.default_code"></input></td></tr></table>

</td>

</t>

</tr>

</table>

Thanks a lot !

florent.uagolf@gmail.com
Penulis

Hi !

Can't make it work, I have object has no attribute 'sequence'

Thansk a lot !

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
missing headers, footers and CSS layout (i.e. are ugly) on server. Odoo v8 Diselesaikan
python xml qweb
Avatar
1
Okt 15
5447
Report text and header is overlaps when description is too long in QWeb report Invoice / Odoo 17
python xml qweb report odoo17
Avatar
0
Sep 25
1925
t-att-href url get error Diselesaikan
xml qweb
Avatar
Avatar
2
Apr 23
9695
How to change total amount in purchase qweb report ' , ' in odoo for different currency
purchase python xml qweb v14
Avatar
Avatar
1
Apr 23
4606
How to hide view.xml fields group in Account module with attr
python xml
Avatar
Avatar
Avatar
2
Des 23
13951
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
  • Tugas
  • 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 ภาษาไทย Türkçe українська Tiếng Việt

Odoo adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

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