Odoo Help


'column "c.date_deadline" must appear in the GROUP BY clause or be used in an aggregate function' Error while installing CRM module

César Bustíos Benites
on 9/29/14, 10:45 AM 4,137 views

I'm trying to install the CRM module but I get the same error every time ProgrammingError: column "c.date_deadline" must appear in the GROUP BY clause or be used in an aggregate function. Here's the full Traceback:

Traceback (most recent call last):
  File "/opt/odoo/openerp/http.py", line 499, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo/openerp/http.py", line 516, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo/openerp/http.py", line 282, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/openerp/http.py", line 279, in checked_call
    return self.endpoint(*a, **kw)
  File "/opt/odoo/openerp/http.py", line 732, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo/openerp/http.py", line 375, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo/addons/web/controllers/main.py", line 948, in call_button
    action = self._call_kw(model, method, args, {})
  File "/opt/odoo/addons/web/controllers/main.py", line 936, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/opt/odoo/openerp/api.py", line 237, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/openerp/addons/base/module/module.py", line 450, in button_immediate_install
    return self._button_immediate_function(cr, uid, ids, self.button_install, context=context)
  File "/opt/odoo/openerp/api.py", line 237, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/openerp/addons/base/module/module.py", line 497, in _button_immediate_function
    registry = openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)
  File "/opt/odoo/openerp/modules/registry.py", line 324, in new
    openerp.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/opt/odoo/openerp/modules/loading.py", line 358, in load_modules
    loaded_modules, update_module)
  File "/opt/odoo/openerp/modules/loading.py", line 263, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/opt/odoo/openerp/modules/loading.py", line 163, in load_module_graph
    init_module_models(cr, package.name, models)
  File "/opt/odoo/openerp/modules/module.py", line 287, in init_module_models
  File "/opt/odoo/openerp/api.py", line 237, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/addons/crm/report/crm_lead_report.py", line 105, in init
  File "/opt/odoo/openerp/sql_db.py", line 158, in wrapper
    return f(self, *args, **kwargs)
  File "/opt/odoo/openerp/sql_db.py", line 235, in execute
    except psycopg2.ProgrammingError, pe:
ProgrammingError: column "c.date_deadline" must appear in the GROUP BY clause or be used in an aggregate function
LINE 5:                     c.date_deadline,


And this is the query that is trying to execute:

CREATE OR REPLACE VIEW crm_lead_report AS (
                    count(id) as nbr_cases,

                    c.date_open as opening_date,
                    c.date_closed as date_closed,

                    c.date_last_stage_update as date_last_stage_update,

                    c.planned_revenue as planned_revenue,
                    c.planned_revenue*(c.probability/100) as probable_revenue,
                    c.create_date as create_date,
                    extract('epoch' from (c.date_closed-c.create_date))/(3600*24) as  delay_close,
                    abs(extract('epoch' from (c.date_deadline - c.date_closed))/(3600*24)) as  delay_expected,
                    extract('epoch' from (c.date_open-c.create_date))/(3600*24) as  delay_open
                    crm_lead c
                WHERE c.active = 'true'
                GROUP BY c.id

I'm using Odoo 8.0

Thank you,

César B.




| 5 5 7
Bikaner, India

OpenERP Developer at SunARC Technology

On 10/9/14, 6:05 AM

Please ensure that version Postgresql 9.2 or Later is installed. Default Odoo 8CRM module Report query worked in the version 9.2 or later. In the version 8. servies its shows error in CRM module Report query.


Techno-Functional Associate with 7+ years of experience in Odoo (formerly known as OpenERP).

On 9/30/14, 8:42 AM

When you are using GROUP BY clause,  you need to specify all non aggregate columns...

So you code should be..

GROUP BY c.id, c.date_deadline, c.date_open, c.date_closed .... [all other columns which you are fetching]

So I should include all the columns in the select part in the group by part? Is there any patch for it?

Sreedath Namangalam
on 12/18/14, 7:38 AM
Jeff Ragot
On 10/2/14, 8:02 AM

Same error for me, problem it's  that not have modified the code, this error is when we want to install crm module. I have exactly the same..

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 9/29/14, 10:45 AM
Seen: 4137 times
Last updated: 3/16/15, 8:10 AM