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
    Real Estate
    • Real Estate Agency
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consulting
    • Accounting Firm
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Furnitures
    • Food
    • 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
    • Solar Energy Systems
    • Shoe Maker
    • Serveis de neteja
    • HVAC Services
    Others
    • 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

Porcentages in graph view

Subscriure's

Get notified when there's activity on this post

This question has been flagged
viewsgraphgraphicgraphics
3 Respostes
10765 Vistes
Avatar
Lester Oscar

There is a way in odoo v8 to show the percentages in the graph view, for example, if I filter a model by sex, that I can see 80% women and 20% men, and if I apply another filter such as age> 43, keep the result in porcent, currently only graphics me the sum of the values filtered.

0
Avatar
Descartar
Avatar
Axel Mendoza
Best Answer

The thing is that the results to render graph view is tied to the use of read_group method using the group_operator argument of the field definition that by default is sum when you don't define the group_operator. That field argument only works with aggregated functions in postgresql and percent is not an aggregated function for postgresql.

You could do it by overriding the read_group method of the graph view model to manually change the field value for the result. Like:

def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False, lazy=True):

read_group_res = super(your_model self).read_group(cr, uid, domain, fields, groupby, offset=offset, limit=limit, context=context, orderby=orderby, lazy=lazy)

for res in read_group_res:

domain_filter = res.get('__domain', [])

line_ids = self.search(cr, uid, domain_filter, context=context)

if line_ids:

res_id = self.browse(cr, uid, line_ids[0], context=context)

res['results'] = res_id.results

return read_group_re

As the docstring of the read_group methods states:

:return: list of dictionaries(one dictionary for each record) containing:

* the values of fields grouped by the fields in ``groupby`` argument

* __domain: list of tuples specifying the search criteria

* __context: dictionary with argument like ``groupby``

Use this example to build your own solution based on your needs



0
Avatar
Descartar
Pascal Tremblay

Why don't you write about the 'graph view model'? I don't find a model who has 'graph' in the name...

Axel Mendoza

it's not a model, it's a js view classes that implements the graph views behaviors

Pascal Tremblay

My override of read_group method works now in the stock.quant model. I can see log of the variable and the returned dictionnary.

To display percentage instead/with the qty, do I have to create a new field in the model?

Should we instead modify the 'qty' in the dictionnary?

Do you know other urls that could show a complete example of displaying percentage on pie graph?

Thanks

Axel Mendoza

You could see this complete example https://github.com/odoo/odoo/blob/9.0/addons/product_margin/product_margin.py#L12-L115

You could modify the qty value but better create another field because it's a field that it's used for a lot of calculations and perhaps you could be altering results in some ways as read_group is not just used for graph views, just create another field

Avatar
Lester Oscar
Autor Best Answer

Ibra thanks very much for your answer but the problem is that i need see the porcentage related whit all my models in a graph view, for example if i have 5 employees, 3 male and 2 female when i filter for sex in my graph view for hr_employee model i wan to see the result of all my models in porcent, not the quantity like by default odoo work. 

0
Avatar
Descartar
Avatar
Ibrahim Boudmir
Best Answer

Hello Oscar,

you can use a widget called progressbar for this :

<field name="your_field" widget="progressbar"/>

to show the percentages, your field should be computed.
example :  add the percentage of taken seats

you .py :

seat = fields.Integer(string="Number of seats")

attendees_ids = fields.Many2many('res.partner', string="Attendees")

taken_seats = fields.Float(string="Taken seats", compute='_taken_seats')

then you add the decorator depends because taken seats depends on both seats and attendees

@api.depends('seat', 'attendees_ids')

def _taken_seats(self):

    for r in self:

        if not r.seat:

            r.taken_seats = 0.0

   else:

        r.taken_seats = 100.0*len(r.attendees_ids)/r.seat

your .xml :

<field name= "taken_seats" widget="progressbar"/>

this is a simple example on how to dislay percentage. Try to work on your own example with the same logic and tell us if it works.

Best regards. 

0
Avatar
Descartar
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
Graph view in Odoo Website
graph graphic graphics website odoo
Avatar
1
de març 18
3979
Looking for a way to customise the axis of graphs.
views graph
Avatar
0
de jul. 17
4004
How make a simple graphic ??
views xml view graph graphic
Avatar
0
de març 15
5790
How to customize graphic view in odoo16?
views graph odoo16
Avatar
0
de maig 24
2361
When load graph view it gives an error NS_ERROR_FAILURE in firefox only.
javascript views graph
Avatar
0
de jul. 16
4958
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