[FIX] project_timesheet : Fix the integrity error when we embeded 'Timesheet Line...
authorDivyesh Makwana (Open ERP) <mdi@tinyerp.com>
Thu, 4 Oct 2012 11:40:21 +0000 (17:10 +0530)
committerDivyesh Makwana (Open ERP) <mdi@tinyerp.com>
Thu, 4 Oct 2012 11:40:21 +0000 (17:10 +0530)
bzr revid: mdi@tinyerp.com-20121004114021-rgbzhr84uditlhhj

addons/project_timesheet/project_timesheet.py

index 41478d6..6125d59 100644 (file)
@@ -46,6 +46,9 @@ class project_project(osv.osv):
 
     def open_timesheets(self, cr, uid, ids, context=None):
         """ open Timesheets view """
+        mod_obj = self.pool.get('ir.model.data')
+        act_obj = self.pool.get('ir.actions.act_window')
+
         project = self.browse(cr, uid, ids[0], context)
         view_context = {
             'search_default_account_id': [project.analytic_account_id.id],
@@ -59,16 +62,13 @@ class project_project(osv.osv):
             # if the user do not have access rights on the partner
             pass
 
-        return {
-            'type': 'ir.actions.act_window',
-            'name': _('Timesheets'),
-            'res_model': 'hr.analytic.timesheet',
-            'view_type': 'form',
-            'view_mode': 'tree,form',
-            'context': view_context,
-            'nodestroy': True,
-            'help': help
-        }
+        result = mod_obj.get_object_reference(cr, uid, 'hr_timesheet', 'act_hr_timesheet_line_evry1_all_form')
+        id = result and result[1] or False
+        result = act_obj.read(cr, uid, [id], context=context)[0]
+        result['name'] = _('Timesheets')
+        result['context'] = view_context
+        result['help'] = help
+        return result
 
 project_project()