[FIX]project_timesheet:if condition for record
authorKhushboo Bhatt (Open ERP) <kbh@tinyerp.com>
Mon, 15 Oct 2012 10:10:49 +0000 (15:40 +0530)
committerKhushboo Bhatt (Open ERP) <kbh@tinyerp.com>
Mon, 15 Oct 2012 10:10:49 +0000 (15:40 +0530)
bzr revid: kbh@tinyerp.com-20121015101049-vj69950ccpmvwa24

addons/project_timesheet/project_timesheet.py

index bc3e764..55a4d03 100644 (file)
@@ -275,17 +275,19 @@ class account_analytic_line(osv.osv):
    def _default_account_id(self, cr, uid, context=None):
         proxy = self.pool.get('account.analytic.account')
         record_ids = proxy.search(cr, uid, [('user_id', '=', uid)], context=context)
-        employee = proxy.browse(cr, uid, record_ids[0], context=context)
-        if employee:
-            return employee.id
+        if record_ids:
+            employee = proxy.browse(cr, uid, record_ids[0], context=context)
+            if employee:
+                return employee.id
         return False
 
    def _default_product(self, cr, uid, context=None):
         proxy = self.pool.get('hr.employee')
         record_ids = proxy.search(cr, uid, [('user_id', '=', uid)], context=context)
-        employee = proxy.browse(cr, uid, record_ids[0], context=context)
-        if employee.product_id:
-            return employee.product_id.id
+        if record_ids:
+            employee = proxy.browse(cr, uid, record_ids[0], context=context)
+            if employee.product_id:
+                return employee.product_id.id
         return False
 
    _defaults = {