Skip to content

Commit

Permalink
[IMP] l10n_br_base: add partner.create_company tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelsavegnago authored and rvalyi committed Nov 21, 2024
1 parent acfc515 commit 03811e5
Showing 1 changed file with 68 additions and 2 deletions.
70 changes: 68 additions & 2 deletions l10n_br_base/tests/test_valid_createid.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def test_vat_computation_with_company_name_and_vat(self):
partner_data.update(
{
"company_name": "Company Partner",
"vat": "123456789",
"vat": "93.429.799/0001-17",
}
)
partner = (
Expand All @@ -248,10 +248,76 @@ def test_vat_computation_with_company_name_and_vat(self):
partner._compute_vat_from_cnpj_cpf()
self.assertEqual(
partner.vat,
"123456789",
"93.429.799/0001-17",
"The VAT must be the same as what was registered",
)

def test_create_company_in_brazil(self):
"""Test the creation of a company in Brazil"""
partner_data = self.partner_valid.copy()
partner_data.update(
{
"company_name": "Company Partner",
"vat": "93.429.799/0001-17",
}
)
partner = (
self.env["res.partner"]
.with_context(tracking_disable=True)
.create(partner_data)
)
partner.create_company()
company = partner.parent_id
self.assertTrue(company, "The company was not created")
self.assertEqual(
company.legal_name,
company.name,
"The legal name must be the same as the company name",
)
self.assertEqual(
company.cnpj_cpf,
company.vat,
"The company CNPJ_CPF must be the same as the company VAT",
)
self.assertEqual(
company.cnpj_cpf,
partner.vat,
"The company CNPJ_CPF must be the same as the partner VAT",
)
self.assertEqual(
company.inscr_est,
partner.inscr_est,
"The company INSCR_EST must be the same as the partner INSCR_EST",
)
self.assertEqual(
company.inscr_mun,
partner.inscr_mun,
"The company INSCR_MUN must be the same as the partner INSCR_MUN",
)

def test_create_company_outside_brazil(self):
"""Test the creation of a company outside Brazil"""
partner_data = self.partner_outside_br.copy()
partner_data.update(
{
"company_name": "Company Partner",
}
)
partner = (
self.env["res.partner"]
.with_context(tracking_disable=True)
.create(partner_data)
)
partner.create_company()
company = partner.parent_id
self.assertTrue(company, "The company was not created")
self.assertEqual(
company.vat,
partner.vat,
"The company CNPJ_CPF must be the same as the partner VAT",
)
self.assertFalse(company.cnpj_cpf, "CNPJ_CPF should be False")


# No test on Inscricao Estadual for partners with CPF
# because they haven't Inscricao Estadual

0 comments on commit 03811e5

Please sign in to comment.