File: ir.py

package info (click to toggle)
tryton-modules-currency 7.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 636 kB
  • sloc: python: 1,175; xml: 234; makefile: 11; sh: 3
file content (34 lines) | stat: -rw-r--r-- 1,127 bytes parent folder | download | duplicates (2)
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
30
31
32
33
34
# 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.config import config
from trytond.model import fields
from trytond.pool import PoolMeta

rate_decimal = config.getint('currency', 'rate_decimal', default=6)


class Configuration(metaclass=PoolMeta):
    __name__ = 'ir.configuration'
    currency_rate_decimal = fields.Integer("Currency Rate Decimal")

    @classmethod
    def default_currency_rate_decimal(cls):
        return rate_decimal

    def check(self):
        super().check()
        if self.currency_rate_decimal != rate_decimal:
            raise ValueError(
                "The rate_decimal %s in the [currency] configuration section "
                "is different from the value %s in 'ir.configuration'." % (
                    rate_decimal, self.currency_rate_decimal))


class Cron(metaclass=PoolMeta):
    __name__ = 'ir.cron'

    @classmethod
    def __setup__(cls):
        super().__setup__()
        cls.method.selection.append(
            ('currency.cron|update', "Update Currency Rates"))