File: test_res_company.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 (52 lines) | stat: -rw-r--r-- 2,419 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
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo.addons.mail.tests.common import MailCommon
from odoo.tests.common import tagged, users


@tagged('res_company')
class TestCompany(MailCommon):

    @users('admin')
    def test_company_colors(self):
        """ Test primary and secondary color management, especially the choice
        between document colors and email-specific colors. When setting document
        layout colors, email colors are updated. When updating email colors
        layout is not updated, they are less important. """
        # propagate at create
        new_company = self.env['res.company'].create({
            'name': 'Test Colors',
            'primary_color': '#AAAAAA',
            'secondary_color': '#BBBBBB',
        })
        self.assertEqual(new_company.primary_color, '#AAAAAA')
        self.assertEqual(new_company.secondary_color, '#BBBBBB')
        self.assertEqual(new_company.email_primary_color, '#AAAAAA',
                         'Updating document colors changes email colors')
        self.assertEqual(new_company.email_secondary_color, '#BBBBBB',
                         'Updating document colors changes email colors')

        # email can be changed independently
        new_company.write({
            'email_primary_color': '#CCCCCC',
            'email_secondary_color': '#DDDDDD',
        })
        self.assertEqual(new_company.primary_color, '#AAAAAA',
                         'Updating email colors does not change global layout')
        self.assertEqual(new_company.secondary_color, '#BBBBBB',
                         'Updating email colors does not change global layout')
        self.assertEqual(new_company.email_primary_color, '#CCCCCC')
        self.assertEqual(new_company.email_secondary_color, '#DDDDDD')

        # reset document -> reset email
        new_company.write({
            'primary_color': '#EEEEEE',
            'secondary_color': '#FFFFFF',
        })
        self.assertEqual(new_company.primary_color, '#EEEEEE')
        self.assertEqual(new_company.secondary_color, '#FFFFFF')
        self.assertEqual(new_company.email_primary_color, '#EEEEEE',
                         'Updating document colors changes email colors')
        self.assertEqual(new_company.email_secondary_color, '#FFFFFF',
                         'Updating document colors changes email colors')