我已经扩展了hr_attendance模块,我希望得到当前登录用户的'action'的最后一个值(可以是'sign_in'或'sign_out')
我不知道如何访问该值。
在考勤模块中有以下功能:
def _altern_si_so(self, cr, uid, ids, context=None): ... def _state(self, cr, uid, ids, name, args, context=None) ...但我不知道如何在扩展模块中调用这些函数,或者是否有另一种方法来获取该值。
I have extended the hr_attendance module and I want to get the last value of 'action' of the current logged user (It can be 'sign_in' or 'sign_out')
I don't know how to access to that value.
In the attendance module there are these functions:
def _altern_si_so(self, cr, uid, ids, context=None): ... def _state(self, cr, uid, ids, name, args, context=None) ...But I don't know how to call that functions inside the extended module or if there is another way to get that value.
最满意答案
查看数据库表我找到了解决方案:
首先,我们获取与已登录用户关联的employee_id
employee_id = {} cr.execute('SELECT hr.id \ FROM resource_resource AS res JOIN hr_employee AS hr \ ON res.id = hr.resource_id \ WHERE res.user_id = %s',[uid]) for res in cr.fetchall(): employee_id = res[0]然后,我们得到employee_id的最后一个动作
last_action = {} cr.execute('SELECT hr_attendance.action \ FROM hr_attendance \ WHERE employee_id = %s',[employee_id]) for res in cr.fetchall(): last_action = res[0]'last_action'现在有“sign_in”或“sign_out”(当前用户在考勤模块中完成的最后一个操作)
Looking the database tables I found the solution:
First we obtain the employee_id associated to the logged user
employee_id = {} cr.execute('SELECT hr.id \ FROM resource_resource AS res JOIN hr_employee AS hr \ ON res.id = hr.resource_id \ WHERE res.user_id = %s',[uid]) for res in cr.fetchall(): employee_id = res[0]Then, we get the last action of the employee_id
last_action = {} cr.execute('SELECT hr_attendance.action \ FROM hr_attendance \ WHERE employee_id = %s',[employee_id]) for res in cr.fetchall(): last_action = res[0]'last_action' has now "sign_in" or "sign_out" (The last action done by the current user in the attendance module)
更多推荐
发布评论