19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:31:16 +01:00
parent 89c6e82fe7
commit 1b82c20a58
572 changed files with 43570 additions and 53303 deletions

View file

@ -0,0 +1,4 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import test_l10n_br_fiscal_position
from . import test_l10n_br_pix

View file

@ -0,0 +1,46 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
from odoo.tests import tagged
@tagged("post_install_l10n", "post_install", "-at_install")
class TestL10nBrFiscalPosition(AccountTestInvoicingCommon):
@classmethod
@AccountTestInvoicingCommon.setup_country('br')
def setUpClass(cls):
super().setUpClass()
cls.br_company = cls.company_data['company']
def test_get_fiscal_position_multicompany(self):
"""When a partner has a fiscal position on both a BR company and
another (non-BR) company, calling _get_fiscal_position from the BR company
should return the BR fiscal position, not the one from the other company."""
other_company = self.env['res.company'].create({
'name': 'Other Company',
'country_id': self.env.ref('base.us').id,
})
other_fp = self.env['account.fiscal.position'].create({
'name': 'Other Company FP',
'company_id': other_company.id,
'sequence': 1,
})
br_fp = self.env['account.fiscal.position'].create({
'name': 'BR Manual FP',
'company_id': self.br_company.id,
'sequence': 2,
})
partner = self.env['res.partner'].with_company(other_company).create({
'name': 'Test Partner',
'country_id': self.env.ref('base.br').id,
'property_account_position_id': other_fp.id,
})
partner.with_company(self.br_company).property_account_position_id = br_fp
fiscal_position = self.env['account.fiscal.position'].with_company(self.br_company)._get_fiscal_position(partner)
self.assertEqual(
fiscal_position, br_fp,
"Should return the BR fiscal position, not the fiscal position from another company",
)

View file

@ -0,0 +1,104 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import Command
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
from odoo.exceptions import ValidationError
from odoo.tests import tagged
@tagged("post_install_l10n", "post_install", "-at_install")
class TestL10nBrPix(AccountTestInvoicingCommon):
@classmethod
@AccountTestInvoicingCommon.setup_country('br')
def setUpClass(cls):
super().setUpClass()
cls.partner_bank = cls.env["res.partner.bank"].create(
{
"acc_number": "123456789012345678",
"partner_id": cls.company_data["company"].partner_id.id,
"proxy_type": "br_random",
"proxy_value": "71d6c6e1-64ea-4a11-9560-a10870c40ca2",
"include_reference": True,
}
)
cls.invoice = cls.env["account.move"].create(
{
"move_type": "out_invoice",
"partner_id": cls.partner_a.id,
"partner_bank_id": cls.partner_bank.id,
"invoice_line_ids": [
Command.create({"quantity": 1, "price_unit": 12.30})
], # .30 to make sure we keep the trailing zero
}
)
def test_constraints(self):
self.partner_bank.write({"proxy_type": "email", "proxy_value": "a@example.com"})
with self.assertRaises(ValidationError, msg="not a valid email"):
self.partner_bank.proxy_value = "example.com"
self.partner_bank.write({"proxy_type": "br_cpf_cnpj", "proxy_value": "00740886967"})
with self.assertRaises(ValidationError, msg="not a valid CPF"):
self.partner_bank.proxy_value = "444444321"
self.partner_bank.write({"proxy_type": "mobile", "proxy_value": "+5561912345678"})
with self.assertRaises(ValidationError, msg="The mobile number"):
self.partner_bank.proxy_value = "061912345678"
self.partner_bank.write({"proxy_type": "br_random", "proxy_value": "71d6c6e1-64ea-4a11-9560-a10870c40ca2"})
with self.assertRaises(ValidationError, msg="The random key"):
self.partner_bank.proxy_value = "not a random key"
def _get_qr_code_string(self):
self.invoice.qr_code_method = "emv_qr"
demo_payment_reference = "NFe TÉST 0001" # É and spaces should be removed
emv_qr_vals = self.invoice.partner_bank_id._get_qr_vals(
qr_method=self.invoice.qr_code_method,
amount=self.invoice.amount_residual,
currency=self.invoice.currency_id,
debtor_partner=self.invoice.partner_id,
free_communication=demo_payment_reference,
structured_communication=None,
)
return "".join(emv_qr_vals)
def test_get_qr_vals(self):
self.assertEqual(
self._get_qr_code_string(),
"00020101021226580014br.gov.bcb.pix013671d6c6e1-64ea-4a11-9560-a10870c40ca2520400005303986540512.305802BR5912COMPANY1DATA62150511NFeTEST00016304A5C7",
)
def test_get_qr_vals_without_reference(self):
self.partner_bank.include_reference = False
self.assertEqual(
self._get_qr_code_string(),
"00020101021226580014br.gov.bcb.pix013671d6c6e1-64ea-4a11-9560-a10870c40ca2520400005303986540512.305802BR5912COMPANY1DATA62070503***6304F1E4",
)
def test_get_qr_vals_for_pos_default_qr(self):
self.partner_bank.include_reference = False
self.invoice.invoice_line_ids.price_unit = 0
qr_code_str = (
"00020101021226580014br.gov.bcb.pix013671d6c6e1-64ea-4a11-9560-"
"a10870c40ca25204000053039865802BR5912COMPANY1DATA62070503***630490CA"
)
self.assertEqual(
self._get_qr_code_string(),
qr_code_str,
)
self.invoice.invoice_line_ids.price_unit = 0.01
self.assertNotEqual(
self._get_qr_code_string(),
qr_code_str,
"An invoice line of $0.01 shouldn't return the same code as $0.00",
)
def test_get_qr_vals_company_with_emoji(self):
self.partner_bank.include_reference = False
self.env.company.name = "Company with émoji 😇"
self.assertEqual(
self._get_qr_code_string(),
"00020101021226580014br.gov.bcb.pix013671d6c6e1-64ea-4a11-9560-a10870c40ca2520400005303986540512.305802BR5919COMPANY WITH EMOJI 62070503***63043984",
)