Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

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

Odoberať

Get notified when there's activity on this post

This question has been flagged
2 Replies
8475 Zobrazenia
Avatar
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
Avatar
Zrušiť
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.

Avatar
Bole
Best Answer

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
Avatar
Zrušiť
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...

Avatar
Tomás Pascual
Autor Best Answer

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
Avatar
Zrušiť
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!

Registrácia
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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