mirror of
https://github.com/bringout/oca-ocb-l10n_americas.git
synced 2026-04-27 05:12:05 +02:00
19.0 vanilla
This commit is contained in:
parent
89c6e82fe7
commit
1b82c20a58
572 changed files with 43570 additions and 53303 deletions
2
odoo-bringout-oca-ocb-l10n_uy/l10n_uy/tests/__init__.py
Normal file
2
odoo-bringout-oca-ocb-l10n_uy/l10n_uy/tests/__init__.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
from . import test_check_vat
|
||||
from . import test_doc_types
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
from odoo.exceptions import ValidationError
|
||||
from odoo.tests import tagged
|
||||
|
||||
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||
|
||||
|
||||
@tagged("post_install_l10n", "post_install", "-at_install")
|
||||
class CheckUyVat(AccountTestInvoicingCommon):
|
||||
|
||||
@classmethod
|
||||
@AccountTestInvoicingCommon.setup_country('uy')
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
|
||||
@classmethod
|
||||
def _create_partner(cls, identification_type, vat):
|
||||
return cls.env["res.partner"].create({
|
||||
"name": "Uruguayan Partner",
|
||||
"l10n_latam_identification_type_id": cls.env.ref(f"l10n_uy.{identification_type}").id,
|
||||
"vat": vat,
|
||||
"country_id": cls.env.ref("base.uy").id
|
||||
})
|
||||
|
||||
def test_valid_ci(self):
|
||||
# Valid CI
|
||||
partner = self._create_partner("it_ci", "3:402.010-1")
|
||||
self.assertTrue(partner._l10n_uy_ci_nie_is_valid())
|
||||
|
||||
partner = self._create_partner("it_ci", "3 402 010 1")
|
||||
self.assertTrue(partner._l10n_uy_ci_nie_is_valid())
|
||||
|
||||
partner = self._create_partner("it_ci", "34020101")
|
||||
self.assertTrue(partner._l10n_uy_ci_nie_is_valid())
|
||||
|
||||
def test_valid_nie(self):
|
||||
partner = self._create_partner("it_nie", "93:402.010-1")
|
||||
self.assertTrue(partner._l10n_uy_ci_nie_is_valid())
|
||||
|
||||
partner = self._create_partner("it_nie", "934020101")
|
||||
self.assertTrue(partner._l10n_uy_ci_nie_is_valid())
|
||||
|
||||
partner = self._create_partner("it_nie", "93 402 010 1")
|
||||
self.assertTrue(partner._l10n_uy_ci_nie_is_valid())
|
||||
|
||||
def test_valid_rut(self):
|
||||
self._create_partner("it_rut", "215521750017")
|
||||
self._create_partner("it_rut", "21-55217500-17")
|
||||
self._create_partner("it_rut", "21 55217500 17")
|
||||
self._create_partner("it_rut", "UY215521750017")
|
||||
|
||||
def test_invalid_ci(self):
|
||||
common_msg = "The CI/NIE number.*does not seem to be valid"
|
||||
with self.assertRaisesRegex(ValidationError, common_msg, msg="not valid verification digit"):
|
||||
self._create_partner("it_ci", "3:402.010-2")
|
||||
with self.assertRaisesRegex(ValidationError, common_msg, msg="should not contain letters"):
|
||||
self._create_partner("it_ci", " ABC 3:402 asas .010-1")
|
||||
|
||||
def test_invalid_nie(self):
|
||||
common_msg = "The CI/NIE number.*does not seem to be valid"
|
||||
with self.assertRaisesRegex(ValidationError, common_msg, msg="not valid verification digit"):
|
||||
self._create_partner("it_nie", "93:402.010-2")
|
||||
with self.assertRaisesRegex(ValidationError, common_msg, msg="should not contain letters"):
|
||||
self._create_partner("it_nie", "ABC 93:402. asas 010-1")
|
||||
|
||||
def test_invalid_rut(self):
|
||||
common_msg = "The VAT number.*does not seem to be valid."
|
||||
with self.assertRaisesRegex(ValidationError, common_msg, msg="invalid number"):
|
||||
self._create_partner("it_rut", "215521750018")
|
||||
with self.assertRaisesRegex(ValidationError, common_msg, msg="do not accept dot ('.') character"):
|
||||
self._create_partner("it_rut", "21.55217500.17")
|
||||
with self.assertRaisesRegex(ValidationError, common_msg, msg="should not contain letters"):
|
||||
self._create_partner("it_rut", "2155 ABC 21750017")
|
||||
|
||||
with self.assertRaisesRegex(ValidationError, common_msg, msg="Validation not working with generic VAT id type"):
|
||||
self.env["res.partner"].create({
|
||||
"name": "Uruguayan Partner",
|
||||
"country_id": self.env.ref("base.uy").id,
|
||||
"l10n_latam_identification_type_id": self.env.ref("l10n_latam_base.it_vat").id,
|
||||
"vat": "215521750018",
|
||||
})
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
from odoo import Command
|
||||
from odoo.tests.common import tagged
|
||||
|
||||
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||
|
||||
|
||||
@tagged("-at_install", "post_install", "post_install_l10n")
|
||||
class TestDocTypes(AccountTestInvoicingCommon):
|
||||
|
||||
@classmethod
|
||||
@AccountTestInvoicingCommon.setup_country('uy')
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
|
||||
service_vat_22 = cls.env["product.product"].create({
|
||||
"name": "Virtual Home Staging (VAT 22)",
|
||||
"list_price": 38.25,
|
||||
"standard_price": 45.5,
|
||||
"type": "service",
|
||||
"default_code": "VAT 22",
|
||||
})
|
||||
|
||||
cls.invoice = cls.env["account.move"].create({
|
||||
"partner_id": cls.env["res.partner"].create({"name": "test partner UY"}).id,
|
||||
"move_type": "out_invoice",
|
||||
"l10n_latam_document_type_id": cls.env.ref("l10n_uy.dc_e_inv_exp").id,
|
||||
"invoice_line_ids": [Command.create({
|
||||
"product_id": service_vat_22.id,
|
||||
"quantity": 1.0,
|
||||
"price_unit": 100.0,
|
||||
})]
|
||||
})
|
||||
cls.invoice.action_post()
|
||||
|
||||
def test_credit_note(self):
|
||||
self.assertEqual(self.invoice.l10n_latam_document_type_id.code, "121", "Not Export e-Invoice")
|
||||
|
||||
refund_wizard = self.env["account.move.reversal"]\
|
||||
.with_context({"active_ids": self.invoice.ids, "active_model": "account.move"})\
|
||||
.create({
|
||||
"reason": "Mercadería defectuosa",
|
||||
"journal_id": self.invoice.journal_id.id
|
||||
})
|
||||
res = refund_wizard.refund_moves()
|
||||
refund = self.env["account.move"].browse(res["res_id"])
|
||||
|
||||
self.assertEqual(refund.l10n_latam_document_type_id.code, "122", "Not Export e-Invoice Credit Note")
|
||||
expected_docs = ["122"] if self.env['ir.module.module']._get('l10n_uy_edi').state == 'installed' else ['122', '222']
|
||||
self.assertEqual(refund.l10n_latam_available_document_type_ids.mapped("code"), expected_docs, "Bad Domain")
|
||||
|
||||
def test_debit_note(self):
|
||||
self.assertEqual(self.invoice.l10n_latam_document_type_id.code, "121", "Not Export e-self.invoice")
|
||||
|
||||
debit_note_wizard = self.env["account.debit.note"]\
|
||||
.with_context({"active_ids": self.invoice.ids, "active_model": "account.move"})\
|
||||
.create({
|
||||
"reason": "Mercadería defectuosa",
|
||||
})
|
||||
res = debit_note_wizard.create_debit()
|
||||
debit_note = self.env["account.move"].browse(res["res_id"])
|
||||
|
||||
self.assertEqual(debit_note.l10n_latam_document_type_id.code, "123", "Not Export e-Invoice Debit Note")
|
||||
expected_docs = ["123"] if self.env['ir.module.module']._get('l10n_uy_edi').state == 'installed' else ['123', '223']
|
||||
self.assertEqual(debit_note.l10n_latam_available_document_type_ids.mapped("code"), expected_docs, "Bad Domain")
|
||||
Loading…
Add table
Add a link
Reference in a new issue