Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

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

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
viewssorting
2 Risposte
10956 Visualizzazioni
Avatar
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
Avatar
Abbandona
Mads Søndergaard
Autore

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.

Avatar
Mads Søndergaard
Autore Risposta migliore

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
Avatar
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
Select multiple elements with XPath Risolto
views
Avatar
Avatar
Avatar
Avatar
Avatar
5
ago 24
48223
Filter out (hide) lines in tree component Risolto
views
Avatar
Avatar
Avatar
2
apr 24
3486
What are the different types of views available in Odoo? Risolto
views
Avatar
Avatar
Avatar
Avatar
3
giu 23
7941
view layout (two fields on the same row within an xpath) Risolto
views
Avatar
Avatar
2
giu 23
5838
Create view without model, only with buttons and text
views
Avatar
Avatar
Avatar
3
mar 23
11158
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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