[IMP] useability of timesheet
[odoo/odoo.git] / addons / hr_timesheet / wizard / hr_timesheet_sign_in_out.py
index 9b99055..e3f7f0c 100644 (file)
@@ -27,7 +27,7 @@ class hr_so_project(osv.osv_memory):
     _name = 'hr.sign.out.project'
     _description = 'Sign Out By Project'
     _columns = {
-        'account_id': fields.many2one('account.analytic.account', 'Analytic Account', domain=[('type','=','normal')]),
+        'account_id': fields.many2one('account.analytic.account', 'Project / Analytic Account', domain=[('type','=','normal')]),
         'info': fields.char('Work Description', size=256, required=True),
         'date_start': fields.datetime('Starting Date', readonly=True),
         'date': fields.datetime('Closing Date'),
@@ -40,16 +40,12 @@ class hr_so_project(osv.osv_memory):
 
     def _get_empid(self, cr, uid, context=None):
         emp_obj = self.pool.get('hr.employee')
-        if context is None:
-            context = {}
         emp_ids = emp_obj.search(cr, uid, [('user_id', '=', uid)], context=context)
         if emp_ids:
             for employee in emp_obj.browse(cr, uid, emp_ids, context=context):
                 return {'name': employee.name, 'state': employee.state, 'emp_id': emp_ids[0], 'server_date':time.strftime('%Y-%m-%d %H:%M:%S')}
 
     def _get_empid2(self, cr, uid, context=None):
-        if context is None:
-            context = {}
         res = self._get_empid(cr, uid, context=context)
         cr.execute('select name,action from hr_attendance where employee_id=%s order by name desc limit 1', (res['emp_id'],))
 
@@ -61,8 +57,6 @@ class hr_so_project(osv.osv_memory):
         return res
 
     def default_get(self, cr, uid, fields_list, context=None):
-        if context is None:
-            context = {}
         res = super(hr_so_project, self).default_get(cr, uid, fields_list, context=context)
         res.update(self._get_empid2(cr, uid, context=context))
         return res
@@ -81,7 +75,7 @@ class hr_so_project(osv.osv_memory):
 
         if not res['product_uom_id']:
             raise osv.except_osv(_('UserError'), _('No cost unit defined for this employee !'))
-        up = timesheet_obj.on_change_unit_amount(cr, uid, False, res['product_id'], hour, res['product_uom_id'])['value']
+        up = timesheet_obj.on_change_unit_amount(cr, uid, False, res['product_id'], hour,False, res['product_uom_id'])['value']
 
         res['name'] = data['info']
         res['account_id'] = data['account_id'].id
@@ -94,24 +88,20 @@ class hr_so_project(osv.osv_memory):
         return timesheet_obj.create(cr, uid, res, context=context)
 
     def sign_out_result_end(self, cr, uid, ids, context=None):
-        if context is None:
-            context = {}
         emp_obj = self.pool.get('hr.employee')
         for data in self.browse(cr, uid, ids, context=context):
             emp_id = data.emp_id.id
             emp_obj.attendance_action_change(cr, uid, [emp_id], type='sign_out', dt=data.date)
             self._write(cr, uid, data, emp_id, context=context)
-        return {}
+        return {'type': 'ir.actions.act_window_close'}
 
     def sign_out_result(self, cr, uid, ids, context=None):
-        if context is None:
-            context = {}
         emp_obj = self.pool.get('hr.employee')
         for data in self.browse(cr, uid, ids, context=context):
             emp_id = data.emp_id.id
             emp_obj.attendance_action_change(cr, uid, [emp_id], type='action', dt=data.date)
             self._write(cr, uid, data, emp_id, context=context)
-        return {}
+        return {'type': 'ir.actions.act_window_close'}
 
 hr_so_project()
 
@@ -137,8 +127,6 @@ class hr_si_project(osv.osv_memory):
         @param context: A standard dictionary for contextual values
         """
         emp_obj = self.pool.get('hr.employee')
-        if context is None:
-            context = {}
         emp_id = emp_obj.search(cr, uid, [('user_id', '=', uid)], context=context)
         if not emp_id:
             raise osv.except_osv(_('UserError'), _('No employee defined for your user !'))
@@ -146,8 +134,6 @@ class hr_si_project(osv.osv_memory):
 
     def check_state(self, cr, uid, ids, context=None):
         obj_model = self.pool.get('ir.model.data')
-        if context is None:
-            context = {}
         emp_id = self.default_get(cr, uid, context)['emp_id']
         # get the latest action (sign_in or out) for this employee
         cr.execute('select action from hr_attendance where employee_id=%s and action in (\'sign_in\',\'sign_out\') order by name desc limit 1', (emp_id,))
@@ -168,17 +154,13 @@ class hr_si_project(osv.osv_memory):
 
     def sign_in_result(self, cr, uid, ids, context=None):
         emp_obj = self.pool.get('hr.employee')
-        if context is None:
-            context = {}
         for data in self.browse(cr, uid, ids, context=context):
             emp_id = data.emp_id.id
-            success = emp_obj.attendance_action_change(cr, uid, [emp_id], type = 'sign_in' ,dt=data.date or False)
-        return {}
+            emp_obj.attendance_action_change(cr, uid, [emp_id], type = 'sign_in' ,dt=data.date or False)
+        return {'type': 'ir.actions.act_window_close'}
 
     def default_get(self, cr, uid, fields_list, context=None):
         res = super(hr_si_project, self).default_get(cr, uid, fields_list, context=context)
-        if context is None:
-            context = {}
         emp_obj = self.pool.get('hr.employee')
         emp_id = emp_obj.search(cr, uid, [('user_id', '=', uid)], context=context)
         if emp_id: