【问题标题】:How to know the last attendance action of the current user ('sign_in' or 'sign_out') in odoo 9?如何在odoo 9中知道当前用户的最后一次出勤动作('sign_in'或'sign_out')?
【发布时间】:2016-09-02 07:41:24
【问题描述】:

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

但我不知道如何在扩展模块中调用该函数,或者是否有其他方法可以获取该值。

【问题讨论】:

    标签: openerp odoo-9


    【解决方案1】:

    查看数据库表我找到了解决方案:

    首先我们获取与登录用户关联的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的最后一个action

    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"(当前用户在考勤模块中完成的最后一个操作)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-01
      • 2021-05-08
      相关资源
      最近更新 更多