Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

How to sort report lines in invoices, SO or DO?

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
2 Răspunsuri
8479 Vizualizări
Imagine profil
Tomás Pascual

Hi Sirs,

I'm trying to sort lines by a field in reports, but in rml i'm unable to get.

Any idea wellcoming,

Regards,

0
Imagine profil
Abandonează
Ivan

First, the lines will be sorted by the model's _order attribute (which defaults to id) when it is browsed (or SELECT-ed). In order to change that, you need to either do a manual search and specify the order_by parameter or sort the records after the being selected. Maybe you can share the result that you needed and what is the result that you are getting so that we can help you further.

Imagine profil
Bole
Cel mai bun răspuns

To sort invoice, you need a srto method in your rml parser... 
best way is to make a custom report parser... 
Here is an example parser :
 

class account_invoice(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context):
        super(account_invoice, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({
            'time': time,
            'sort':self._sort})

    def _sort(self, theList):
        #sorting by name ... change to apropriate: sequence, code price...
        theList.sort(key=lambda x: x.name, reverse=False)
        return theList

 

Now, in your rml you can instead of: [[ repeatIn(o.sort_print,'l') ]]

use :   [[ repeatIn(sort(o.invoice_line),'l') ]]
for reveserse sort order : [[ repeatIn(sort(o.invoice_line, reverse=True),'l') ]]
modifiy sort conditions to your needs...
hope it helps...

2
Imagine profil
Abandonează
Tomás Pascual
Autor

Hi sirs, I undestand that must to create a new app, isn't it? I tell you something.

Bole

yes, in order to do this you have to write the code somewhere, so best place is custom module...

Imagine profil
Tomás Pascual
Autor Cel mai bun răspuns

Hi Ivan,

Thanks for your fast response, it is attached a DO that I want to sort by the 3rd field in column (rack). It seems like always it is sorted by description.

https://docs.google.com/a/onduex.com/file/d/0B0aJ9T6EXAWBeUtfNFRERnQxMnc/edit?usp=drivesdk

0
Imagine profil
Abandonează
Ivan

Yes, DO lines (stock.move) are sorted by description by default. If you need to change the sort order, first, if the field is a function field or related field, it need to be stored in database. Then, @Bole has provided a very good example of a way to get it sorted without having to change the model's _order attribute (which will change all sorting order in the whole application for stock.move). The x.name in the _sort method should be replaced with the field that you want to sort with. If you want to change the model's sorting order in the whole application (mind you that stock.move is used for Incoming Shipment lines and Internal Move lines aside from Delivery Order lines), then you inherit the model can specify the _order attribute.

Ivan

Sorry, to complete @Bole's example, the _sort method should accept reverse optional argument and pass it to the sort, i.e. def _sort(self, theList, reverse=False): #sorting by name ... change to apropriate: sequence, code price... theList.sort(key=lambda x: x.name, reverse=reverse) return theList

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

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

Înscrie-te
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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