File: test_gcc_invoice.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 (30 lines) | stat: -rw-r--r-- 1,405 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
# -*- coding: utf-8 -*-

from markupsafe import Markup

from odoo.addons.account.tests.common import AccountTestInvoicingCommon
from odoo.tests import tagged


@tagged('post_install_l10n', 'post_install', '-at_install')
class TestGccInvoice(AccountTestInvoicingCommon):

    def test_invoice_narration_translation(self):
        ''' The narration field should be copied translations included'''

        # Activate second lang and parameter needed to display invoice terms
        self.env['res.lang']._activate_lang('ar_001')
        self.env['ir.config_parameter'].sudo().set_param('account.use_invoice_terms', True)

        gcc_countries = self.env.ref('base.gulf_cooperation_council').country_ids
        self.env.company.write({
            'country_id': gcc_countries[0].id,
            'invoice_terms': 'English Terms',
            'terms_type': 'plain',
        })
        # Add translation to invoice terms
        self.env.company.update_field_translations('invoice_terms', {'en_US': {'English Terms': 'English Terms'}, 'ar_001': {'English Terms': 'Arabic Terms'}})
        invoice = self.init_invoice('out_invoice', products=self.product_a)

        self.assertEqual(invoice.narration, Markup('<p>English Terms</p>'), 'Original narration not correct')
        self.assertEqual(invoice.with_context(lang='ar_001').narration, Markup('<p>Arabic Terms</p>'), 'Translation not loaded succesfully')