Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

[v14] How can I create a Tree View that shows ONLY the last 5 records?

Subscriure's

Get notified when there's activity on this post

This question has been flagged
domainlimitv14
2 Respostes
4268 Vistes
Avatar
Hugo

Hi,


I want to create a custom tree view (list view) of sale.order that displays ONLY the last 5 sales.


I've tried using 5 but that limits the number of records per page, meaning users can still go to the next pages and see the whole data.


I believe I should be using "domain" to do that, but I don't know how.


Can anyone help?


Thanks in advance!    

0
Avatar
Descartar
Avatar
CandidRoot Solutions Private Limited
Best Answer


Hello

You should create new menu with new window action where you can pass context as define in below screenshot to identify action in search_read method.

please find below search_read method for sale.order model, i assume that we need to find last 5 record based on create_date desc order.  you can apply and modify domain as per your needs.


@api.model
def search_read
(self, domain=None, fields=None, offset=0, limit=None, order=None):
if 'display_last_five_records' in self.env.context:
order = 'create_date desc'
res = super().search_read(domain=domain, fields=fields, offset=offset, limit=limit, order=order)
if 'display_last_five_records' in self.env.context:return res[:5]
return res




Thanks & Regards,

​

CandidRoot Solutions Pvt. Ltd.

Mobile: (+91) 8849036209
Email: info@candidroot.com
Skype: live:candidroot
Web: https://www.candidroot.com
Address: 1229 - 1230, Iconic Shyamal, Near Shyamal Cross Road, Ahmedabad, Gujarat 380015
    

3
Avatar
Descartar
Avatar
Ray Carnes (ray)
Best Answer

A domain is the right approach, the challenge is defining "the last 5 sales".

Is it the last five created, confirmed, by sequence, etc?

You would want a new Menu, connected to Window Action, that uses an existing View.  The Window Action is where the domain would go. 

If you create (and save to Favorites) a Custom Filter (to help you define your definition of the last 5), you can see the domain syntax when you view it in the User Defined Filters Menu. The black "code editor" section is what you can copy (edit) and paste into the Window Action.

https://www.odoo.com/documentation/14.0/applications/productivity/studio/use_cases/filters_status_bar.html

https://www.odoo.com/documentation/14.0/applications/finance/documents.html#advanced-condition-type-domain

https://www.odoo.com/documentation/14.0/developer/reference/addons/actions.html (technical, but useful to know how this works, even if you don't do all of this customization in a module).



0
Avatar
Descartar
Hugo
Autor

Sorry for not being more especific. I need to show the last 5 created sales, regardless of the state.

To be even more especific, I'm trying to alter the sale.act_res_partner_2_sale_order action to show only the last 5 created sales (instead of every sale to that customer)

My code:
<record id="sale.act_res_partner_2_sale_order" model="ir.actions.act_window">
<field name="name">Quotations and Sales TEST</field>
<field name="res_model">sale.order</field>
<field name="view_mode">kanban,form</field>
<field name="context">{}</field>
<field name="domain">
[
'|',('partner_id.parent_id','=', active_id),('partner_id','=', active_id)
]
</field>
</record>

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

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

Registrar-se
Related Posts Respostes Vistes Activitat
Set domain to allow everything when no value in controlling field Solved
domain v14
Avatar
1
de juny 21
3797
Nginx Rate Limits Preventing Odoo pages to load completely
nginx limit v14
Avatar
0
de març 23
2653
DOMAIN Solved
domain helpme v14
Avatar
Avatar
1
de febr. 21
2920
filter many2many field
filter domain many2many v14
Avatar
Avatar
1
de set. 23
2990
ver 14: how to search parent_id and its all child in model product.category in Many2one field
domain parent child v14
Avatar
Avatar
1
de jul. 23
6292
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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