如何知道当前用户的最后一次出勤行为('sign

编程入门 行业动态 更新时间:2024-10-27 09:47:30
如何知道当前用户的最后一次出勤行为('sign_in'或'sign_out')在odoo 9中?(How to know the last attendance action of the current user ('sign_in' or 'sign_out') in odoo 9?)

我已经扩展了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)

更多推荐

本文发布于:2023-07-16 07:46:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1125539.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用户   sign

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!