HR_TIMESHEET(_SHEET): improve sign in/out and view name

bzr revid: ced-b967016431a5929a873402632937ee72cbccf48a
This commit is contained in:
ced 2007-04-24 09:57:49 +00:00
parent f9a86b5fbf
commit ae9c14730d
4 changed files with 9 additions and 4 deletions

View File

@ -45,6 +45,7 @@ hr_employee()
class hr_analytic_timesheet(osv.osv):
_name = "hr.analytic.timesheet"
_table = 'hr_analytic_timesheet'
_description = "Timesheet line"
_inherits = {'account.analytic.line': 'line_id'}
_order = "id desc"
_columns = {

View File

@ -24,7 +24,7 @@
<field name="model">hr.analytic.timesheet</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Timesheet Line">
<form string="Timesheet Lines">
<field name="name" colspan="3"/>
<field name="user_id" select="1" required="1"/>
<field name="date" select="1"/>

View File

@ -189,6 +189,8 @@ class hr_timesheet_sheet(osv.osv):
return True
def sign_in(self, cr, uid, ids, context):
if not self.browse(cr, uid, ids, context)[0].date_current == time.strftime('%Y-%m-%d'):
raise osv.except_osv('Error !', 'You can not sign in from an other date than today')
emp_obj = self.pool.get('hr.employee')
emp_id = emp_obj.search(cr, uid, [('user_id', '=', uid)])
context['sheet_id']=ids[0]
@ -196,6 +198,8 @@ class hr_timesheet_sheet(osv.osv):
return True
def sign_out(self, cr, uid, ids, context):
if not self.browse(cr, uid, ids, context)[0].date_current == time.strftime('%Y-%m-%d'):
raise osv.except_osv('Error !', 'You can not sign out from an other date than today')
emp_obj = self.pool.get('hr.employee')
emp_id = emp_obj.search(cr, uid, [('user_id', '=', uid)])
context['sheet_id']=ids[0]
@ -208,7 +212,7 @@ class hr_timesheet_sheet(osv.osv):
'date_from': fields.date('Date from', required=True, select=1, readonly=True, states={'new':[('readonly', False)]}),
'date_to': fields.date('Date to', required=True, select=1, readonly=True, states={'new':[('readonly', False)]}),
'date_current': fields.date('Current date', required=True),
'timesheet_ids' : one2many_mod('hr.analytic.timesheet', 'sheet_id', 'Timesheets', domain=[('date','=',time.strftime('%Y-%m-%d'))], readonly=True, states={'draft':[('readonly',False)],'new':[('readonly',False)]}),
'timesheet_ids' : one2many_mod('hr.analytic.timesheet', 'sheet_id', 'Timesheet lines', domain=[('date','=',time.strftime('%Y-%m-%d'))], readonly=True, states={'draft':[('readonly',False)],'new':[('readonly',False)]}),
'attendances_ids' : one2many_mod2('hr.attendance', 'sheet_id', 'Attendances', readonly=True, states={'draft':[('readonly',False)],'new':[('readonly',False)]}),
'state' : fields.selection([('new', 'New'),('draft','Draft'),('confirm','Confirmed'),('done','Done')], 'state', select=True, required=True, readonly=True),
'state_attendance' : fields.function(_state_attendance, method=True, type='selection', selection=[('absent', 'Absent'), ('present', 'Present'),('none','No employee defined')], string='Current state'),

View File

@ -6,7 +6,7 @@
<field name="model">hr_timesheet_sheet.sheet</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Timesheet Sheet">
<tree string="Timesheets">
<field name="user_id"/>
<field name="date_from" />
<field name="date_to" />
@ -41,7 +41,7 @@
<field name="model">hr_timesheet_sheet.sheet</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Timesheet Sheet">
<form string="Timesheet">
<field name="name" />
<field name="user_id"/>
<field name="date_from" />