← Back to team overview

credativ team mailing list archive

[Bug 912332] [NEW] hr_timesheet_sheet: cannot change data type of view column "total_difference" from numeric to double precision

 

Public bug reported:

Server: Ubuntu Server v11.04
OpenERP-Server version: 6.0.3.
Postgre version: 9.0

Updating the module hr_timesheet_sheet brings up the following error:

---- CUT ----
Environment Information :
System : Windows-Vista-6.1.7601-SP1
OS Name : nt
Operating System Release : Vista
Operating System Version : 6.1.7601
Operating System Architecture : 32bit
Operating System Locale : sv_SE.cp1252
Python Version : 2.5.2
OpenERP-Client Version : 6.0.2
Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
  File "/opt/openerp/server/bin/netsvc.py", line 489, in dispatch
    result = ExportService.getService(service_name).dispatch(method, auth, params)
  File "/opt/openerp/server/bin/service/web_services.py", line 599, in dispatch
    res = fn(db, uid, *params)
  File "/opt/openerp/server/bin/osv/osv.py", line 122, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/opt/openerp/server/bin/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/opt/openerp/server/bin/osv/osv.py", line 167, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/opt/openerp/server/bin/addons/base/module/wizard/base_module_upgrade.py", line 98, in upgrade_module
    _db, pool = pooler.restart_pool(cr.dbname, update_module=True)
  File "/opt/openerp/server/bin/pooler.py", line 60, in restart_pool
    return get_db_and_pool(db_name, force_demo, status, update_module=update_module)
  File "/opt/openerp/server/bin/pooler.py", line 39, in get_db_and_pool
    addons.load_modules(db, force_demo, status, update_module)
  File "/opt/openerp/server/bin/addons/__init__.py", line 883, in load_modules
    processed_modules.extend(load_module_graph(cr, graph, status, report=report, skip_modules=processed_modules))
  File "/opt/openerp/server/bin/addons/__init__.py", line 719, in load_module_graph
    init_module_objects(cr, package.name, modules)
  File "/opt/openerp/server/bin/addons/__init__.py", line 420, in init_module_objects
    obj.init(cr)
  File "/opt/openerp/server/bin/addons/hr_timesheet_sheet/hr_timesheet_sheet.py", line 712, in init
    )) AS bar""")
  File "/opt/openerp/server/bin/sql_db.py", line 78, in wrapper
    return f(self, *args, **kwargs)
  File "/opt/openerp/server/bin/sql_db.py", line 131, in execute
    res = self._obj.execute(query, params)
ProgrammingError: cannot change data type of view column "total_difference" from numeric to double precision
---- CUT ----

The error seems to be located in the hr_timesheet_sheet.py file on line
657 for 6.0 branch and on line 667 for Trunk branch. Show below:

---- CUT (6.0 BRANCH) ----
641	    _columns = {
642	        'name': fields.date('Date', readonly=True),
643	        'sheet_id': fields.many2one('hr_timesheet_sheet.sheet', 'Sheet', readonly=True, select="1"),
644	        'total_timesheet': fields.float('Total Timesheet', readonly=True),
645	        'total_attendance': fields.float('Attendance', readonly=True),
646	        'total_difference': fields.float('Difference', readonly=True),
647	    }
648
649	    def init(self, cr):
650	        cr.execute("""create or replace view hr_timesheet_sheet_sheet_day as
651	            SELECT
652	                id,
653	                name,
654	                sheet_id,
655	                total_timesheet,
656	                total_attendance,
657	                cast(round(cast(total_attendance - total_timesheet as Numeric),2) as Double Precision) AS total_difference
---- CUT ----

---- CUT (TRUNK BRANCH) ----
651	   _columns = {
652	        'name': fields.date('Date', readonly=True),
653	        'sheet_id': fields.many2one('hr_timesheet_sheet.sheet', 'Sheet', readonly=True, select="1"),
654	        'total_timesheet': fields.float('Total Timesheet', readonly=True),
655	        'total_attendance': fields.float('Attendance', readonly=True),
656	        'total_difference': fields.float('Difference', readonly=True),
657	    }
658
659	    def init(self, cr):
660	        cr.execute("""create or replace view hr_timesheet_sheet_sheet_day as
661	            SELECT
662	                id,
663	                name,
664	                sheet_id,
665	                total_timesheet,
666	                total_attendance,
667	                cast(round(cast(total_attendance - total_timesheet as Numeric),2) as Double Precision) AS total_difference
---- CUT ----

The columns description says that the total_difference is of type float
(python data type), but the SQL will try to cast it from Numeric
(postgre data type) to Double Precision (postgre data type).

This bug will disappear if SQL query is modified to look like this
instead:

---- CUT ----
657/667	                round(cast(total_attendance - total_timesheet as Numeric),2) AS total_difference
---- CUT ----

The postgre function round will return it as Numeric and the error will
disappear.

** Affects: openobject-addons
     Importance: Undecided
         Status: New

** Description changed:

  Server: Ubuntu Server v11.04
  OpenERP-Server version: 6.0.3.
  Postgre version: 9.0
  
  Updating the module hr_timesheet_sheet brings up the following error:
  
  ---- CUT ----
- Environment Information : 
+ Environment Information :
  System : Windows-Vista-6.1.7601-SP1
  OS Name : nt
  Operating System Release : Vista
  Operating System Version : 6.1.7601
  Operating System Architecture : 32bit
  Operating System Locale : sv_SE.cp1252
  Python Version : 2.5.2
  OpenERP-Client Version : 6.0.2
  Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
-   File "/opt/openerp/server/bin/netsvc.py", line 489, in dispatch
-     result = ExportService.getService(service_name).dispatch(method, auth, params)
-   File "/opt/openerp/server/bin/service/web_services.py", line 599, in dispatch
-     res = fn(db, uid, *params)
-   File "/opt/openerp/server/bin/osv/osv.py", line 122, in wrapper
-     return f(self, dbname, *args, **kwargs)
-   File "/opt/openerp/server/bin/osv/osv.py", line 176, in execute
-     res = self.execute_cr(cr, uid, obj, method, *args, **kw)
-   File "/opt/openerp/server/bin/osv/osv.py", line 167, in execute_cr
-     return getattr(object, method)(cr, uid, *args, **kw)
-   File "/opt/openerp/server/bin/addons/base/module/wizard/base_module_upgrade.py", line 98, in upgrade_module
-     _db, pool = pooler.restart_pool(cr.dbname, update_module=True)
-   File "/opt/openerp/server/bin/pooler.py", line 60, in restart_pool
-     return get_db_and_pool(db_name, force_demo, status, update_module=update_module)
-   File "/opt/openerp/server/bin/pooler.py", line 39, in get_db_and_pool
-     addons.load_modules(db, force_demo, status, update_module)
-   File "/opt/openerp/server/bin/addons/__init__.py", line 883, in load_modules
-     processed_modules.extend(load_module_graph(cr, graph, status, report=report, skip_modules=processed_modules))
-   File "/opt/openerp/server/bin/addons/__init__.py", line 719, in load_module_graph
-     init_module_objects(cr, package.name, modules)
-   File "/opt/openerp/server/bin/addons/__init__.py", line 420, in init_module_objects
-     obj.init(cr)
-   File "/opt/openerp/server/bin/addons/hr_timesheet_sheet/hr_timesheet_sheet.py", line 712, in init
-     )) AS bar""")
-   File "/opt/openerp/server/bin/sql_db.py", line 78, in wrapper
-     return f(self, *args, **kwargs)
-   File "/opt/openerp/server/bin/sql_db.py", line 131, in execute
-     res = self._obj.execute(query, params)
+   File "/opt/openerp/server/bin/netsvc.py", line 489, in dispatch
+     result = ExportService.getService(service_name).dispatch(method, auth, params)
+   File "/opt/openerp/server/bin/service/web_services.py", line 599, in dispatch
+     res = fn(db, uid, *params)
+   File "/opt/openerp/server/bin/osv/osv.py", line 122, in wrapper
+     return f(self, dbname, *args, **kwargs)
+   File "/opt/openerp/server/bin/osv/osv.py", line 176, in execute
+     res = self.execute_cr(cr, uid, obj, method, *args, **kw)
+   File "/opt/openerp/server/bin/osv/osv.py", line 167, in execute_cr
+     return getattr(object, method)(cr, uid, *args, **kw)
+   File "/opt/openerp/server/bin/addons/base/module/wizard/base_module_upgrade.py", line 98, in upgrade_module
+     _db, pool = pooler.restart_pool(cr.dbname, update_module=True)
+   File "/opt/openerp/server/bin/pooler.py", line 60, in restart_pool
+     return get_db_and_pool(db_name, force_demo, status, update_module=update_module)
+   File "/opt/openerp/server/bin/pooler.py", line 39, in get_db_and_pool
+     addons.load_modules(db, force_demo, status, update_module)
+   File "/opt/openerp/server/bin/addons/__init__.py", line 883, in load_modules
+     processed_modules.extend(load_module_graph(cr, graph, status, report=report, skip_modules=processed_modules))
+   File "/opt/openerp/server/bin/addons/__init__.py", line 719, in load_module_graph
+     init_module_objects(cr, package.name, modules)
+   File "/opt/openerp/server/bin/addons/__init__.py", line 420, in init_module_objects
+     obj.init(cr)
+   File "/opt/openerp/server/bin/addons/hr_timesheet_sheet/hr_timesheet_sheet.py", line 712, in init
+     )) AS bar""")
+   File "/opt/openerp/server/bin/sql_db.py", line 78, in wrapper
+     return f(self, *args, **kwargs)
+   File "/opt/openerp/server/bin/sql_db.py", line 131, in execute
+     res = self._obj.execute(query, params)
  ProgrammingError: cannot change data type of view column "total_difference" from numeric to double precision
  ---- CUT ----
  
  The error seems to be located in the hr_timesheet_sheet.py file on line
  657 for 6.0 branch and on line 667 for Trunk branch. Show below:
  
  ---- CUT (6.0 BRANCH) ----
  641	    _columns = {
  642	        'name': fields.date('Date', readonly=True),
  643	        'sheet_id': fields.many2one('hr_timesheet_sheet.sheet', 'Sheet', readonly=True, select="1"),
  644	        'total_timesheet': fields.float('Total Timesheet', readonly=True),
  645	        'total_attendance': fields.float('Attendance', readonly=True),
  646	        'total_difference': fields.float('Difference', readonly=True),
  647	    }
- 648	
+ 648
  649	    def init(self, cr):
  650	        cr.execute("""create or replace view hr_timesheet_sheet_sheet_day as
  651	            SELECT
  652	                id,
  653	                name,
  654	                sheet_id,
  655	                total_timesheet,
  656	                total_attendance,
  657	                cast(round(cast(total_attendance - total_timesheet as Numeric),2) as Double Precision) AS total_difference
  ---- CUT ----
  
  ---- CUT (TRUNK BRANCH) ----
  651	   _columns = {
  652	        'name': fields.date('Date', readonly=True),
  653	        'sheet_id': fields.many2one('hr_timesheet_sheet.sheet', 'Sheet', readonly=True, select="1"),
  654	        'total_timesheet': fields.float('Total Timesheet', readonly=True),
  655	        'total_attendance': fields.float('Attendance', readonly=True),
  656	        'total_difference': fields.float('Difference', readonly=True),
  657	    }
- 658	
+ 658
  659	    def init(self, cr):
  660	        cr.execute("""create or replace view hr_timesheet_sheet_sheet_day as
  661	            SELECT
  662	                id,
  663	                name,
  664	                sheet_id,
  665	                total_timesheet,
  666	                total_attendance,
  667	                cast(round(cast(total_attendance - total_timesheet as Numeric),2) as Double Precision) AS total_difference
  ---- CUT ----
  
  The columns description says that the total_difference is of type float
  (python data type), but the SQL will try to cast it from Numeric
  (postgre data type) to Double Precision (postgre data type).
  
- This bug will disapper if SQL query is modified to look like this
+ This bug will disappear if SQL query is modified to look like this
  instead:
  
  ---- CUT ----
  657/667	                round(cast(total_attendance - total_timesheet as Numeric),2) AS total_difference
  ---- CUT ----
  
  The postgre function round will return it as Numeric and the error will
- disapper.
+ disappear.

-- 
You received this bug notification because you are a member of OpenERP
Framework Experts, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/912332

Title:
  hr_timesheet_sheet: cannot change data type of view column
  "total_difference" from numeric to double precision

Status in OpenERP Addons (modules):
  New

Bug description:
  Server: Ubuntu Server v11.04
  OpenERP-Server version: 6.0.3.
  Postgre version: 9.0

  Updating the module hr_timesheet_sheet brings up the following error:

  ---- CUT ----
  Environment Information :
  System : Windows-Vista-6.1.7601-SP1
  OS Name : nt
  Operating System Release : Vista
  Operating System Version : 6.1.7601
  Operating System Architecture : 32bit
  Operating System Locale : sv_SE.cp1252
  Python Version : 2.5.2
  OpenERP-Client Version : 6.0.2
  Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
    File "/opt/openerp/server/bin/netsvc.py", line 489, in dispatch
      result = ExportService.getService(service_name).dispatch(method, auth, params)
    File "/opt/openerp/server/bin/service/web_services.py", line 599, in dispatch
      res = fn(db, uid, *params)
    File "/opt/openerp/server/bin/osv/osv.py", line 122, in wrapper
      return f(self, dbname, *args, **kwargs)
    File "/opt/openerp/server/bin/osv/osv.py", line 176, in execute
      res = self.execute_cr(cr, uid, obj, method, *args, **kw)
    File "/opt/openerp/server/bin/osv/osv.py", line 167, in execute_cr
      return getattr(object, method)(cr, uid, *args, **kw)
    File "/opt/openerp/server/bin/addons/base/module/wizard/base_module_upgrade.py", line 98, in upgrade_module
      _db, pool = pooler.restart_pool(cr.dbname, update_module=True)
    File "/opt/openerp/server/bin/pooler.py", line 60, in restart_pool
      return get_db_and_pool(db_name, force_demo, status, update_module=update_module)
    File "/opt/openerp/server/bin/pooler.py", line 39, in get_db_and_pool
      addons.load_modules(db, force_demo, status, update_module)
    File "/opt/openerp/server/bin/addons/__init__.py", line 883, in load_modules
      processed_modules.extend(load_module_graph(cr, graph, status, report=report, skip_modules=processed_modules))
    File "/opt/openerp/server/bin/addons/__init__.py", line 719, in load_module_graph
      init_module_objects(cr, package.name, modules)
    File "/opt/openerp/server/bin/addons/__init__.py", line 420, in init_module_objects
      obj.init(cr)
    File "/opt/openerp/server/bin/addons/hr_timesheet_sheet/hr_timesheet_sheet.py", line 712, in init
      )) AS bar""")
    File "/opt/openerp/server/bin/sql_db.py", line 78, in wrapper
      return f(self, *args, **kwargs)
    File "/opt/openerp/server/bin/sql_db.py", line 131, in execute
      res = self._obj.execute(query, params)
  ProgrammingError: cannot change data type of view column "total_difference" from numeric to double precision
  ---- CUT ----

  The error seems to be located in the hr_timesheet_sheet.py file on
  line 657 for 6.0 branch and on line 667 for Trunk branch. Show below:

  ---- CUT (6.0 BRANCH) ----
  641	    _columns = {
  642	        'name': fields.date('Date', readonly=True),
  643	        'sheet_id': fields.many2one('hr_timesheet_sheet.sheet', 'Sheet', readonly=True, select="1"),
  644	        'total_timesheet': fields.float('Total Timesheet', readonly=True),
  645	        'total_attendance': fields.float('Attendance', readonly=True),
  646	        'total_difference': fields.float('Difference', readonly=True),
  647	    }
  648
  649	    def init(self, cr):
  650	        cr.execute("""create or replace view hr_timesheet_sheet_sheet_day as
  651	            SELECT
  652	                id,
  653	                name,
  654	                sheet_id,
  655	                total_timesheet,
  656	                total_attendance,
  657	                cast(round(cast(total_attendance - total_timesheet as Numeric),2) as Double Precision) AS total_difference
  ---- CUT ----

  ---- CUT (TRUNK BRANCH) ----
  651	   _columns = {
  652	        'name': fields.date('Date', readonly=True),
  653	        'sheet_id': fields.many2one('hr_timesheet_sheet.sheet', 'Sheet', readonly=True, select="1"),
  654	        'total_timesheet': fields.float('Total Timesheet', readonly=True),
  655	        'total_attendance': fields.float('Attendance', readonly=True),
  656	        'total_difference': fields.float('Difference', readonly=True),
  657	    }
  658
  659	    def init(self, cr):
  660	        cr.execute("""create or replace view hr_timesheet_sheet_sheet_day as
  661	            SELECT
  662	                id,
  663	                name,
  664	                sheet_id,
  665	                total_timesheet,
  666	                total_attendance,
  667	                cast(round(cast(total_attendance - total_timesheet as Numeric),2) as Double Precision) AS total_difference
  ---- CUT ----

  The columns description says that the total_difference is of type
  float (python data type), but the SQL will try to cast it from Numeric
  (postgre data type) to Double Precision (postgre data type).

  This bug will disappear if SQL query is modified to look like this
  instead:

  ---- CUT ----
  657/667	                round(cast(total_attendance - total_timesheet as Numeric),2) AS total_difference
  ---- CUT ----

  The postgre function round will return it as Numeric and the error
  will disappear.

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/912332/+subscriptions


Follow ups

References