Skip to content

Commit

Permalink
Merge PR #4052 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by HaraldPanten
  • Loading branch information
OCA-git-bot committed Feb 28, 2025
2 parents bd757f2 + 308e0e5 commit 24327e5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 17 deletions.
4 changes: 0 additions & 4 deletions l10n_es_facturae/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ def validate_facturae_fields(self):
raise ValidationError(_("Partner vat is too small"))
if not self.partner_id.state_id:
raise ValidationError(_("Partner state not provided"))
if not self.partner_id.unidad_tramitadora:
raise ValidationError(_("Unidad Tramitadora not provided"))
if not self.partner_id.oficina_contable:
raise ValidationError(_("Oficina Contable not provided"))
if not self.payment_mode_id:
raise ValidationError(_("Payment mode is required"))
if self.payment_mode_id.facturae_code:
Expand Down
12 changes: 0 additions & 12 deletions l10n_es_facturae/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,15 +751,3 @@ def _create_wizard_facturae_file(self):
.create({})
)
return wizard

def test_create_facturae_file_without_unidad_tramitadora(self):
wizard = self._create_wizard_facturae_file()
self.partner.unidad_tramitadora = False
with self.assertRaises(exceptions.ValidationError):
wizard.create_facturae_file()

def test_create_facturae_file_without_oficina_contable(self):
wizard = self._create_wizard_facturae_file()
self.partner.oficina_contable = False
with self.assertRaises(exceptions.ValidationError):
wizard.create_facturae_file()
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 24327e5

Please sign in to comment.