| 1 |
# -*- coding: utf-8 -*- |
| 2 |
|
| 3 |
from markupsafe import Markup |
| 4 |
|
| 5 |
from odoo.addons.account.tests.common import AccountTestInvoicingCommon |
| 6 |
from odoo.tests import tagged |
| 7 |
|
| 8 |
|
| 9 |
@tagged('post_install_l10n', 'post_install', '-at_install') |
| 10 |
class TestGccInvoice(AccountTestInvoicingCommon): |
| 11 |
|
| 12 |
def test_invoice_narration_translation(self): |
| 13 |
''' The narration field should be copied translations included''' |
| 14 |
|
| 15 |
# Activate second lang and parameter needed to display invoice terms |
| 16 |
self.env['res.lang']._activate_lang('ar_001') |
| 17 |
self.env['ir.config_parameter'].sudo().set_param('account.use_invoice_terms', True) |
| 18 |
|
| 19 |
gcc_countries = self.env.ref('base.gulf_cooperation_council').country_ids |
| 20 |
self.env.company.write({ |
| 21 |
'country_id': gcc_countries[0].id, |
| 22 |
'invoice_terms': 'English Terms', |
| 23 |
'terms_type': 'plain', |
| 24 |
}) |
| 25 |
# Add translation to invoice terms |
| 26 |
self.env.company.update_field_translations('invoice_terms', {'en_US': {'English Terms': 'English Terms'}, 'ar_001': {'English Terms': 'Arabic Terms'}}) |
| 27 |
invoice = self.init_invoice('out_invoice', products=self.product_a) |
| 28 |
|
| 29 |
self.assertEqual(invoice.narration, Markup('<p>English Terms</p>'), 'Original narration not correct') |
| 30 |
self.assertEqual(invoice.with_context(lang='ar_001').narration, Markup('<p>Arabic Terms</p>'), 'Translation not loaded succesfully') |