[IMP]project_timesheet:added method for setting default product.
authorKhushboo Bhatt (Open ERP) <kbh@tinyerp.com>
Fri, 12 Oct 2012 08:25:25 +0000 (13:55 +0530)
committerKhushboo Bhatt (Open ERP) <kbh@tinyerp.com>
Fri, 12 Oct 2012 08:25:25 +0000 (13:55 +0530)
bzr revid: kbh@tinyerp.com-20121012082525-y600x8lv0xteej6a

addons/project_timesheet/project_timesheet.py

index 12fac78..2154f6d 100644 (file)
@@ -284,6 +284,19 @@ class account_analytic_line(osv.osv):
            raise osv.except_osv(_('Invalid Analytic Account !'), _('You cannot select a Analytic Account which is in Close or Cancelled state.'))
        return res
 
+   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)
+        print "record_ids",record_ids
+        employee = proxy.browse(cr, uid, record_ids[0], context=context)
+        if employee.product_id:
+            return employee.product_id.id
+        return False
+
+   _defaults = {
+        'product_id': _default_product,
+        }
+
 account_analytic_line()
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: