Skip to content

Commit

Permalink
[IMP]l10n_es_facturae_face: add unidad tramitadora and oficina contab…
Browse files Browse the repository at this point in the history
…le checks
  • Loading branch information
manuelregidor committed Feb 28, 2025
1 parent 32dcf4a commit 308e0e5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
15 changes: 14 additions & 1 deletion l10n_es_facturae_face/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ def _get_l10n_es_facturae_excluded_status(self):

def validate_facturae_fields(self):
super().validate_facturae_fields()
if not self.partner_id.organo_gestor:
if (
self.partner_id.l10n_es_facturae_sending_code == "face"
and not self.partner_id.organo_gestor
):
raise ValidationError(_("Organo Gestor not provided"))
if (
self.partner_id.l10n_es_facturae_sending_code == "face"
and not self.partner_id.unidad_tramitadora
):
raise ValidationError(_("Unidad Tramitadora not provided"))
if (
self.partner_id.l10n_es_facturae_sending_code == "face"
and not self.partner_id.oficina_contable
):
raise ValidationError(_("Oficina Contable not provided"))
return
26 changes: 26 additions & 0 deletions l10n_es_facturae_face/tests/test_facturae_face.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,32 @@ def test_create_facturae_file_without_organo_gestor(self):
with self.assertRaises(exceptions.ValidationError):
wizard.create_facturae_file()

def test_create_facturae_file_without_unidad_tramitadora(self):
self._activate_certificate(self.certificate_password)
self.move.action_post()
self.move.name = "2999/99999"
wizard = (
self.env["create.facturae"]
.with_context(active_ids=self.move.ids, active_model="account.move")
.create({})
)
self.partner.unidad_tramitadora = False
with self.assertRaises(exceptions.ValidationError):
wizard.create_facturae_file()

def test_create_facturae_file_without_oficina_contable(self):
self._activate_certificate(self.certificate_password)
self.move.action_post()
self.move.name = "2999/99999"
wizard = (
self.env["create.facturae"]
.with_context(active_ids=self.move.ids, active_model="account.move")
.create({})
)
self.partner.oficina_contable = False
with self.assertRaises(exceptions.ValidationError):
wizard.create_facturae_file()

def test_facturae_face_0(self):
class DemoService:
def __init__(self, value):
Expand Down

0 comments on commit 308e0e5

Please sign in to comment.