Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

sorting multiple fields in tree view via default_order, v13.0

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
viewssorting
2 Replies
10964 Rodiniai
Portretas
Mads Søndergaard

I'm trying to apply default_order to a tree view for multiple fields.
Or rather, I'm looking to (1) make lines drag & droppable while also (2) sort them by date_planned_start. But if they're sorted by (2), they aren't (1), and if they're (1), they aren't (2).

Description:
More specifically, I'm trying to make the lines in mrp.production drag & droppable via a "sequence" field, but at the same time order the lines by date_planned_start.
Going by the documentation, this shouldn't be an issue (as both Odoo 8.0 and 13.0 Doc example show default_order="sequence, name desc", more or less exactly what I'm trying to accomplish.)

But adding:

    _order = 'sequence, date_planned_start'     

to the model does nothing.

Adding an xpath to the tree attribute using:

    <attribute name="default_order">sequence, date_planned_start</attribute>

does order the view, but only according to the first field supplied, i.e. by sequence but not date_planned_start. If I reverse the order to ..>date_planned_start, sequence</.., it orders by date, but not by sequence, and as result the lines are no longer drag & droppable.

As mentioned, I've referenced the official documentation, and by the looks of it, this should be quite possible, as it's almost the exact example given. But for some reason, it doesn't work.


Issue:
Only the first field given in the default_order attribute is sorted. The other isn't.

(Relevant) Code:

 
View:
    <record id="inherited_mrp_production_tree_view" model="ir.ui.view">
            <field name="name">mrp.production.tree</field>
            <field name="model">mrp.production</field>
            <field name="inherit_id" ref="mrp.mrp_production_tree_view"/>
            <field name="arch" type="xml">
                <xpath expr="//tree" position="attributes">
                    <attribute name="default_order">date_planned_start, date_start_wo</attribute>
                </xpath>
                <xpath expr="//field[@name='name']" position="before">
                    <field name="sequence" widget="handle"/>
                </xpath>

Model:
    sequence = fields.Integer('Sequence', default=1)
1
Portretas
Atmesti
Mads Søndergaard
Autorius

Ah, and don't pay any mind to the two fields given in the view code (date_planned_start, date_start_wo), just me playing around trying to get it to work, but forgot to update the code for the example.

Portretas
Mads Søndergaard
Autorius Best Answer

Figured it out why it doesn't work, I think:

Each line has a unique "sequence" integer.
When you sort through "sequence" first, there is effectively no sub-grouping left to sort through.

For example:
if you have 12 lines,
6 with a "number_id" of 1, and 6 with one of 2,
and you sort through number_id first,
whatever secondary field (let's call it "priority_id") you're sorting through will be sorted per "group" of number_ids.

So with default_order="number_id,priority_id", you'd get:
12 ->
2x6 (number_ids 1 and 2) ->
2x3x3 (two groups (number_ids 1 and 2) each subdivided into 3 groups (priority_id 1, 2, and 3).

However, since widget="handle" seems(?) to require unique integers per line, and that you sort it first in order to be able to drag & drop the lines, any further subdivision after it, while technically allowed, has no effect.
Conversely, when you sort "sequence" after something else, it appears to be bound into place.

In the above example, it would be equivalent to:

12 ->
12x1 ->
12x1x1 -> So nothing is effectively sorted beyond "Sequence"

Unless I am missing something, which is also quite possible. :)

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

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

Registracija
Related Posts Replies Rodiniai Veikla
Select multiple elements with XPath Solved
views
Portretas
Portretas
Portretas
Portretas
Portretas
5
rugp. 24
48226
Filter out (hide) lines in tree component Solved
views
Portretas
Portretas
Portretas
2
bal. 24
3490
What are the different types of views available in Odoo? Solved
views
Portretas
Portretas
Portretas
Portretas
3
birž. 23
7945
view layout (two fields on the same row within an xpath) Solved
views
Portretas
Portretas
2
birž. 23
5845
Create view without model, only with buttons and text
views
Portretas
Portretas
Portretas
3
kov. 23
11164
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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