error on the init of report_timesheet

Bug #310458 reported by phil
2
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Undecided
Stephane Wirtel (OpenERP)

Bug Description

Hi,

This morning I make a bzr pul to get the last revision of the V5.
When I launch the server with the option update=all on my database.
I got the following message:

[Mon Dec 22 09:05:44 2008] INFO:init:module report_timesheet: registering objects
[Mon Dec 22 09:05:44 2008] INFO:init:module report_timesheet loading objects
[Mon Dec 22 09:05:44 2008] INFO:init:module report_timesheet: creating or updating database tables
Traceback (most recent call last):
  File "openerp-server.py", line 116, in <module>
    pooler.get_db_and_pool(db, update_module=tools.config['init'] or tools.config['update'])
  File "/home/phil/trunk/server/bin/pooler.py", line 38, in get_db_and_pool
    addons.load_modules(db, force_demo, status, update_module)
  File "/home/phil/trunk/server/bin/addons/__init__.py", line 589, in load_modules
    load_module_graph(cr, graph, status, report=report)
  File "/home/phil/trunk/server/bin/addons/__init__.py", line 480, in load_module_graph
    init_module_objects(cr, m, modules)
  File "/home/phil/trunk/server/bin/addons/__init__.py", line 262, in init_module_objects
    obj.init(cr)
  File "/home/phil/trunk/server/bin/addons/report_timesheet/report_timesheet.py", line 51, in init
    """)
  File "/home/phil/trunk/server/bin/sql_db.py", line 76, in wrapper
    return f(self, *args, **kwargs)
  File "/home/phil/trunk/server/bin/sql_db.py", line 114, in execute
    res = self._obj.execute(query, params)
psycopg2.ProgrammingError: ERREUR: ne peut pas modifier le nombre de colonnes dans la vue

when i check the code of report_timesheet.py, and try to execute to sql code.
I indentified that the problem comes from this order:
 create or replace view report_timesheet_user as (
                select
                    min(l.id) as id,
                    l.date as name,
                    l.user_id,
                    sum(l.unit_amount) as quantity,
                    sum(l.amount) as cost
                from
                    account_analytic_line l
                where
                    user_id is not null
                group by l.date, l.user_id
            )

In fact, it should do a drop view instead of a "replace view" when you add a new column (company_id in this case).

Changed in openobject-addons:
assignee: nobody → matrixise
Changed in openobject-addons:
status: New → Fix Released
Revision history for this message
Emmanuel Thibierge (e-thibierge) wrote :

Hi,
Could you release the fix in the stable too ?

Revision history for this message
Emmanuel Thibierge (e-thibierge) wrote :

it's the same on stable and trunk, but there are still failures with the init because you need a :
 tools.sql.drop_view_if_exists(cr, 'report_timesheet_invoice')
on each view before the "create or replace".
I don't if I should leave this comment here or create a new bug ?

Revision history for this message
Ferdinand (office-chricar) wrote :

see patch

Changed in openobject-addons:
status: Fix Released → New
Revision history for this message
Ferdinand (office-chricar) wrote :
Revision history for this message
Christophe CHAUVET (christophe-chauvet) wrote :

I made patch which fix this bug and prevent others problems when column name changed

Revision history for this message
Christophe CHAUVET (christophe-chauvet) wrote :

Fix available

Changed in openobject-addons:
status: New → In Progress
Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

fix applied on branch/5

Changed in openobject-addons:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.