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 can i count records in domain and display it in line with menu ?

Abonare

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

Această întrebare a fost marcată
4 Răspunsuri
10044 Vizualizări
Imagine profil
Dr Obx

As I mentioned in title, need count for example all records with state = "in" and add this figure into menu line as it is in Messaging "Inbox"


1
Imagine profil
Abandonează
Imagine profil
Pawan
Cel mai bun răspuns

Dr Obx,

inherit "ir.needaction_mixin" in your class and override _needaction_domain_get()

def _needaction_domain_get(self):
return [('state', '=', 'in')]

 Hope it helps

0
Imagine profil
Abandonează
Dr Obx
Autor

Hi Pawan, Why you not responding my questions on Skype :):):) Thanx, I'll try (Student Rob)

Dr Obx
Autor

TypeError: _needaction_domain_get() takes exactly 1 argument (4 given)

Temur

add @api.model decorator to _needaction_domain_get function definition. as follows:

@api.model
def _needaction_domain_get(self):
    return [('state', '=', 'in')]
Temur

or change it to v7 style:

def _needaction_domain_get(self, cr, uid, context=None):
    return [('state', '=', 'in')]
Temur

then it should work... does it?

Dr Obx
Autor

Better, no errors now ;) So what next, how to add the counter into the line ?

Temur

do you actually have some records with state=in right now?

Dr Obx
Autor

Yes, a lot of them ;)

Temur

if you've done all right, then it should already displaying the counter in the menu... no more actions are required.

Temur

do you inherit additionally "ir.needaction_mixin"? what is your inherit statement?

Dr Obx
Autor

_inherit = 'ir.needaction_mixin' @api.model def _needaction_domain_get(self): return[('state','=','in')]

Temur

you should include _name attribute as well, when you inherit from multiple models then it's necessary, you'll get something like:

_name = "a.base.model.name"
_inherit = ["a.base.model.name", "ir.needaction_mixin"]
Temur

"ir.needaction_mixin" should be additional inherit, not the main one... see comment above

Temur

"a.base.model.name" here is the model name you're extending. if you are NOT extending any model, then just add _name parameter:

_name = "my.new.model.name"
_inherit = "ir.needaction_mixin"
...
Dr Obx
Autor

''class iprodstep_log(models.Model): _name = 'iprodstep.log' _inherit = ["iprodstep.log","ir.needaction_mixin"] ''

Temur

so if you're extending some model, use first option... but you'll need to add _name in both cases... and do not forget to restart odoo and update module from Settings/Modules... page. normally it should work already

Temur

is the 'iprodstep.log' existing model you're extending? if so, then it's correct... if it's a new model then use second option, _inherit = "ir.needaction_mixin". I do not know your scenario, so I posted all two options

Dr Obx
Autor

Whatever i do, either first or second scenario still getting errors :(

class iprodstep_log(models.Model):
    _name = 'iprodstep.log'
    _description = 'iprodstep Log'
    _inherit = ["iprodstep.log","ir.needaction_mixin"]

...
    @api.model
    def _needaction_domain_get(self):
        return[('state','=','in')]
Temur

first things first... is the 'iprodstep.log' another model you're extending OR it's a new model you're creating?

Temur

what kind of errors

Dr Obx
Autor

iprodstep.log is a model I'm creating. I'll tell you, just need restore everyting and solve the Server 500 error now :)

Dr Obx
Autor
  File "/usr/share/pyshared/werkzeug/serving.py", line 159, in run_wsgi
    execute(app)
  File "/usr/share/pyshared/werkzeug/serving.py", line 146, in execute
    application_iter = app(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/openerp/service/server.py", line 285, in app
    return self.app(e, s)
  File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 216, in application
    return application_unproxied(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 202, in application_unproxied
    result = handler(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1281, in __call__
    return self.dispatch(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1255, in __call__
    return self.app(environ, start_wrapped)
  File "/usr/share/pyshared/werkzeug/wsgi.py", line 411, in __call__
    return self.app(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1413, in dispatch
    ir_http = request.registry['ir.http']
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 339, in registry
    return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None
  File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 339, in get
    update_module)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 370, in new
    openerp.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 351, in load_modules
    force, status, report, loaded_modules, update_module)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 255, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 152, in load_module_graph
    models = registry.load(cr, package)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 163, in load
    model = cls._build_model(self, cr)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 595, in _build_model
    original_module = pool[name]._original_module if name in parents else cls._module
  File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 102, in __getitem__
    return self.models[model_name]
KeyError: 'iprodstep.log'

Temur

error you posted is because 'iprodstep.log' is not an existing model, but new one.. as you're not extending any model, then _inherit = "ir.needaction_mixin" is correct option for you

Dr Obx
Autor

Oh i got it, so how can I now assign it to the specified menu ?

Temur

you do not need to.

Temur

it'll be added automatically. you just need to have separated page for your 'iprodstep.log' models, you need ordinary menu for that, nothing special

Dr Obx
Autor

Not really, because at this moment I have a few menus which contain records in state 'in', 'out', 'cancelled' so i have to separate it somehow or create same kind of counters for each state. like in messaging, it separate numbers of messages for specified group. I hope you know what i mean.

Pawan

Rob, for what you what to achieve, you have to add this:
'needaction_menu_ref': ['list_of_other_menu_ids_of_same_object']
to your respective Menu's action's context in xml file....
suppose on menu with id 'a' you will have :
'needaction_menu_ref': ['b', 'c']
suppose on menu with id 'b' you will have :
'needaction_menu_ref': ['a', 'c']
and so on...... Hope this helps you.......

Dr Obx
Autor

it doesn't work ;(

    @api.model
    def _needaction_iprodstep_log_pack_menu_get(self):
        return[('in','out','pack')]
Pawan

Rob, don't add this part and implement above mentioned functionality in action's context.....
and in _needaction_domain_get() just return [('active', '=', True)]

Dr Obx
Autor

Aaaaaa hahahahahah i sorted it. It was quiet simple :)

    @api.model
    def _needaction_domain_get(self):
        return[('state','not in',['draft'])]
and now I can see in each menu a number of orders :) The only problem is.... it update the counter only in one menu if you pass the order to another state. every time you want to know the actual states you have to click on the top bar menu
Temur

congrats :)

Imagine profil
Temur
Cel mai bun răspuns


for count records matching a domain you should use function "search_count", quote from documentation:

search_count(args) → int
Returns the number of records in the current model matching the provided domain.

in your case, it'll be something like,

in v8 style:

count = self.env['model.name.to.search.in'].search_count([('state','=','in')])

in v7 style:

count = self.pool['model.name.to.search.in'].search_count(cr,uid, [('state', '=', 'in')], context=context) 

then in "count" variable you'll have the desired number. adapt it to your case.

0
Imagine profil
Abandonează
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