File: ir.py

package info (click to toggle)
tryton-modules-attendance 7.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 540 kB
  • sloc: python: 616; xml: 399; makefile: 11; sh: 3
file content (29 lines) | stat: -rw-r--r-- 915 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# This file is part of Tryton.  The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.

from trytond.pool import Pool, PoolMeta

_EMPLOYEES_RULE_MODELS = {
    'attendance.line', 'attendance.sheet', 'attendance.sheet.line'}


class Rule(metaclass=PoolMeta):
    __name__ = 'ir.rule'

    @classmethod
    def _get_context(cls, model_name):
        pool = Pool()
        User = pool.get('res.user')
        context = super()._get_context(model_name)
        if model_name in _EMPLOYEES_RULE_MODELS:
            context['employees'] = User.get_employees()
        return context

    @classmethod
    def _get_cache_key(cls, model_name):
        pool = Pool()
        User = pool.get('res.user')
        key = super()._get_cache_key(model_name)
        if model_name in _EMPLOYEES_RULE_MODELS:
            key = (*key, User.get_employees())
        return key