File: test_currency.py

package info (click to toggle)
odoo 18.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 878,716 kB
  • sloc: javascript: 927,937; python: 685,670; xml: 388,524; sh: 1,033; sql: 415; makefile: 26
file content (53 lines) | stat: -rw-r--r-- 1,764 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from odoo.tests.common import TransactionCase

class TestCurrencyRates(TransactionCase):
    @classmethod
    def setUpClass(cls):
        super(TestCurrencyRates, cls).setUpClass()
        cls.env["res.currency"].create(
            [
                {
                    "name": "MC1",
                    "symbol": ":D",
                    "rounding": 0.001,
                },
                {
                    "name": "MC2",
                    "symbol": "§",
                },
            ]
        )
        eur_company = cls.env["res.company"].create(
            {"name": "Company with EUR", "currency_id": cls.env.ref("base.EUR").id}
        )
        usd_company = cls.env["res.company"].create(
            {"name": "Company with USD", "currency_id": cls.env.ref("base.USD").id}
        )
        cls.env.user.company_ids |= eur_company
        cls.env.user.company_ids |= usd_company
        cls.env.user.company_id = eur_company
        cls.usd_company_id = usd_company.id

    def test_get_company_currency_for_spreadsheet(self):
        self.assertEqual(
            self.env["res.currency"].get_company_currency_for_spreadsheet(),
            {
                "code": "EUR",
                "symbol": "€",
                "decimalPlaces": 2,
                "position": "after",
            }
        )
        self.assertEqual(
            self.env["res.currency"].get_company_currency_for_spreadsheet(self.usd_company_id),
            {
                "code": "USD",
                "symbol": "$",
                "decimalPlaces": 2,
                "position": "before",
            }
        )
        self.assertEqual(
            self.env["res.currency"].get_company_currency_for_spreadsheet(123456),
            False
        )