[IMP] hr_timesheet_sheet: improve API to signin/signout with new method 'attendance_action_change'
bzr revid: hmo@tinyerp.com-20120511073320-ilnxqtenca01l563
This commit is contained in:
parent
9f9b3276c1
commit
80ef7b58dd
|
@ -68,7 +68,7 @@ openerp.hr_attendance = function(instance) {
|
|||
return this._super(ids, callback, error_callback);
|
||||
},
|
||||
call_button: function (method, args, callback, error_callback) {
|
||||
if (this._model.name == "hr.employee" && method == "attendance_action_change"){
|
||||
if (method == "attendance_action_change"){
|
||||
callback = instance.hr_attendance.callback(callback);
|
||||
}
|
||||
return this._super(method, args, callback, error_callback);
|
||||
|
|
|
@ -312,31 +312,14 @@ class hr_timesheet_sheet(osv.osv):
|
|||
self.write(cr, uid, [sheet.id], {'date_current': sheet.date_to,}, context=context)
|
||||
return True
|
||||
|
||||
def check_sign(self, cr, uid, ids, typ, context=None):
|
||||
sheet = self.browse(cr, uid, ids, context=context)[0]
|
||||
if not sheet.date_current == time.strftime('%Y-%m-%d'):
|
||||
raise osv.except_osv(_('Error !'), _('You cannot sign in/sign out from an other date than today'))
|
||||
return True
|
||||
|
||||
def attendance_action_change(self, cr, uid, ids, context=None):
|
||||
hr_employee = self.pool.get('hr.employee')
|
||||
employee_ids = []
|
||||
for sheet in self.browse(cr, uid, ids, context=context):
|
||||
if sheet.employee_id.id not in employee_ids: employee_ids.append(sheet.employee_id.id)
|
||||
return hr_employee.attendance_action_change(cr, uid, employee_ids, context=context)
|
||||
|
||||
def sign(self, cr, uid, ids, typ, context=None):
|
||||
self.check_sign(cr, uid, ids, typ, context=context)
|
||||
sign_obj = self.pool.get('hr.sign.in.out')
|
||||
sheet = self.browse(cr, uid, ids, context=context)[0]
|
||||
context['emp_id'] = [sheet.employee_id.id]
|
||||
sign_id = sign_obj.create(cr, uid, {}, context=context)
|
||||
methods = {'sign_in': sign_obj.si_check,
|
||||
'sign_out': sign_obj.so_check}
|
||||
wizard_result = methods[typ](cr, uid, [sign_id], context=context)
|
||||
if wizard_result.get('type', False) == 'ir.actions.act_window_close':
|
||||
return True # ensure we do not close the main window !
|
||||
wizard_result['nodestroy'] = True # do not destroy the main window !
|
||||
return wizard_result
|
||||
|
||||
def sign_in(self, cr, uid, ids, context=None):
|
||||
return self.sign(cr, uid, ids, 'sign_in', context=context)
|
||||
|
||||
def sign_out(self, cr, uid, ids, context=None):
|
||||
return self.sign(cr, uid, ids, 'sign_out', context=context)
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Note', size=64, select=1,
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
<openerp>
|
||||
<data noupdate="1">
|
||||
|
||||
<record id="sheet1" model="hr_timesheet_sheet.sheet">
|
||||
<!-- <record id="sheet1" model="hr_timesheet_sheet.sheet">
|
||||
<field name="name">Sheet 1</field>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field name="employee_id" ref="hr.employee_fp" />
|
||||
<field eval="time.strftime('%Y-%m-%d')" name="date_current"/>
|
||||
</record>
|
||||
|
||||
-->
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -91,6 +91,8 @@
|
|||
</field>
|
||||
<group col="4" colspan="1">
|
||||
<field name="state_attendance"/>
|
||||
<button name="attendance_action_change" attrs="{'invisible': ['|', ('state_attendance','=',False), ('state_attendance', '=', 'absent')]}" type="object" string="Sign Out" icon="gtk-go-forward" groups="base.group_hr_manager"/>
|
||||
<button name="attendance_action_change" attrs="{'invisible': [('state_attendance', '=', 'present')]}" type="object" string="Sign In" icon="gtk-go-back" groups="base.group_hr_manager"/>
|
||||
<field name="total_attendance_day" widget="float_time" colspan="4"/>
|
||||
</group>
|
||||
<field colspan="4" context="{'date':date_current,'user_id':user_id}" domain="[('name','=',date_current)]" name="timesheet_ids" nolabel="1">
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
Now, at the time of login, I create Attendances and perform "Sign In" action.
|
||||
-
|
||||
!python {model: hr_timesheet_sheet.sheet}: |
|
||||
self.sign_in(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], {})
|
||||
self.attendance_action_change(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], {})
|
||||
task_work = self.search(cr, uid, [("name","=","Quentin Paolinon")],context)[0]
|
||||
task_ids = self.browse(cr, uid, task_work, context)
|
||||
assert task_ids.state == "draft", "I State In Timesheet"
|
||||
|
|
Loading…
Reference in New Issue