Odoo Help

Welcome!

This community 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.

0

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

By
César Bustíos Benites
on 9/29/14, 10:45 AM 3,007 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
    obj.init(cr)
  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 (
                SELECT
                    id,
                    c.date_deadline,
                    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.user_id,
                    c.probability,
                    c.stage_id,
                    c.type,
                    c.company_id,
                    c.priority,
                    c.section_id,
                    c.campaign_id,
                    c.source_id,
                    c.medium_id,
                    c.partner_id,
                    c.country_id,
                    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
                FROM
                    crm_lead c
                WHERE c.active = 'true'
                GROUP BY c.id
            )

I'm using Odoo 8.0

Thank you,

César B.

1

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
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.

1

deep

--deep--
1617
| 5 4 7
Bengaluru, India
--deep--

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

deep
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
1
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..

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

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