diff --git a/l10n_es_facturae/i18n/es.po b/l10n_es_facturae/i18n/es.po
index c7b5542e184..432a9f603df 100644
--- a/l10n_es_facturae/i18n/es.po
+++ b/l10n_es_facturae/i18n/es.po
@@ -712,24 +712,6 @@ msgstr "Órgano Gestor"
msgid "Otro"
msgstr "Otro"
-#. module: l10n_es_facturae
-#: code:addons/l10n_es_facturae/models/account_move.py:0
-#, python-format
-msgid "Oficina Contable not provided"
-msgstr "La Oficina Contable es obligatorio"
-
-#. module: l10n_es_facturae
-#: code:addons/l10n_es_facturae/models/account_move.py:0
-#, python-format
-msgid "Organo Gestor not provided"
-msgstr "El Organo Gestor es obligatorio"
-
-#. module: l10n_es_facturae
-#: code:addons/l10n_es_facturae/models/account_move.py:0
-#, python-format
-msgid "Unidad Tramitadora not provided"
-msgstr "La Unidad Tramitadora es obligatorio"
-
#. module: l10n_es_facturae
#: code:addons/l10n_es_facturae/models/account_move.py:0
#, python-format
diff --git a/l10n_es_facturae/i18n/l10n_es_facturae.pot b/l10n_es_facturae/i18n/l10n_es_facturae.pot
index 3876b5626fb..b474214e741 100644
--- a/l10n_es_facturae/i18n/l10n_es_facturae.pot
+++ b/l10n_es_facturae/i18n/l10n_es_facturae.pot
@@ -678,24 +678,6 @@ msgstr ""
msgid "Otro"
msgstr ""
-#. module: l10n_es_facturae
-#: code:addons/l10n_es_facturae/models/account_move.py:0
-#, python-format
-msgid "Oficina Contable not provided"
-msgstr ""
-
-#. module: l10n_es_facturae
-#: code:addons/l10n_es_facturae/models/account_move.py:0
-#, python-format
-msgid "Organo Gestor not provided"
-msgstr ""
-
-#. module: l10n_es_facturae
-#: code:addons/l10n_es_facturae/models/account_move.py:0
-#, python-format
-msgid "Unidad Tramitadora not provided"
-msgstr ""
-
#. module: l10n_es_facturae
#: code:addons/l10n_es_facturae/models/account_move.py:0
#, python-format
diff --git a/l10n_es_facturae/models/account_move.py b/l10n_es_facturae/models/account_move.py
index 4d27bcaf9a1..11943829f1c 100644
--- a/l10n_es_facturae/models/account_move.py
+++ b/l10n_es_facturae/models/account_move.py
@@ -148,12 +148,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.organo_gestor:
- raise ValidationError(_("Organo Gestor 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:
diff --git a/l10n_es_facturae/tests/common.py b/l10n_es_facturae/tests/common.py
index 83d6ab66822..09034969012 100644
--- a/l10n_es_facturae/tests/common.py
+++ b/l10n_es_facturae/tests/common.py
@@ -768,21 +768,3 @@ def _create_wizard_facturae_file(self):
.create({})
)
return wizard
-
- def test_create_facturae_file_without_organo_gestor(self):
- wizard = self._create_wizard_facturae_file()
- self.partner.organo_gestor = False
- with self.assertRaises(exceptions.ValidationError):
- wizard.create_facturae_file()
-
- 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()
diff --git a/l10n_es_facturae/views/report_facturae.xml b/l10n_es_facturae/views/report_facturae.xml
index 9734cdd173e..a0df8b32217 100644
--- a/l10n_es_facturae/views/report_facturae.xml
+++ b/l10n_es_facturae/views/report_facturae.xml
@@ -48,7 +48,7 @@
@@ -119,9 +119,9 @@
/>
-
+
diff --git a/l10n_es_facturae_face/i18n/es.po b/l10n_es_facturae_face/i18n/es.po
index 28dae05b88a..f39e336ebb1 100644
--- a/l10n_es_facturae_face/i18n/es.po
+++ b/l10n_es_facturae_face/i18n/es.po
@@ -231,6 +231,18 @@ msgstr "No solicitado"
msgid "OK"
msgstr "Aceptar"
+#. module: l10n_es_facturae_face
+#: code:addons/l10n_es_facturae_face/models/account_move.py:0
+#, python-format
+msgid "Oficina Contable not provided"
+msgstr "La Oficina Contable es obligatoria"
+
+#. module: l10n_es_facturae_face
+#: code:addons/l10n_es_facturae_face/models/account_move.py:0
+#, python-format
+msgid "Organo Gestor not provided"
+msgstr "El Organo Gestor es obligatorio"
+
#. module: l10n_es_facturae_face
#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-2500
msgid "Paid"
@@ -265,6 +277,12 @@ msgstr ""
"La provincia debe estar definido si el país es España para poder enviar por "
"FACe"
+#. module: l10n_es_facturae_face
+#: code:addons/l10n_es_facturae_face/models/account_move.py:0
+#, python-format
+msgid "Unidad Tramitadora not provided"
+msgstr "La Unidad Tramitadora es obligatoria"
+
#. module: l10n_es_facturae_face
#: code:addons/l10n_es_facturae_face/models/res_partner.py:0
#, python-format
diff --git a/l10n_es_facturae_face/i18n/l10n_es_facturae_face.pot b/l10n_es_facturae_face/i18n/l10n_es_facturae_face.pot
index 7795132b3e4..d4506c28216 100644
--- a/l10n_es_facturae_face/i18n/l10n_es_facturae_face.pot
+++ b/l10n_es_facturae_face/i18n/l10n_es_facturae_face.pot
@@ -227,6 +227,18 @@ msgstr ""
msgid "OK"
msgstr ""
+#. module: l10n_es_facturae_face
+#: code:addons/l10n_es_facturae_face/models/account_move.py:0
+#, python-format
+msgid "Oficina Contable not provided"
+msgstr ""
+
+#. module: l10n_es_facturae_face
+#: code:addons/l10n_es_facturae_face/models/account_move.py:0
+#, python-format
+msgid "Organo Gestor not provided"
+msgstr ""
+
#. module: l10n_es_facturae_face
#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-2500
msgid "Paid"
@@ -259,6 +271,12 @@ msgstr ""
msgid "State must be defined in Spain in order to send to FACe"
msgstr ""
+#. module: l10n_es_facturae_face
+#: code:addons/l10n_es_facturae_face/models/account_move.py:0
+#, python-format
+msgid "Unidad Tramitadora not provided"
+msgstr ""
+
#. module: l10n_es_facturae_face
#: code:addons/l10n_es_facturae_face/models/res_partner.py:0
#, python-format
diff --git a/l10n_es_facturae_face/models/account_move.py b/l10n_es_facturae_face/models/account_move.py
index 9ef9d5688f8..5cb48402c27 100644
--- a/l10n_es_facturae_face/models/account_move.py
+++ b/l10n_es_facturae_face/models/account_move.py
@@ -2,7 +2,8 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
-from odoo import api, fields, models
+from odoo import _, api, fields, models
+from odoo.exceptions import ValidationError
class AccountMove(models.Model):
@@ -83,3 +84,16 @@ def _get_l10n_es_facturae_excluded_status(self):
"face-2600",
"face-3100",
]
+
+ def validate_facturae_fields(self):
+ super().validate_facturae_fields()
+ if (
+ self.partner_id.l10n_es_facturae_sending_code == "face"
+ and not self.partner_id.organo_gestor
+ ):
+ raise ValidationError(_("Organo Gestor 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"))
+ return
diff --git a/l10n_es_facturae_face/tests/test_facturae_face.py b/l10n_es_facturae_face/tests/test_facturae_face.py
index 63c3813c7b6..ffb4bf0b762 100644
--- a/l10n_es_facturae_face/tests/test_facturae_face.py
+++ b/l10n_es_facturae_face/tests/test_facturae_face.py
@@ -238,6 +238,39 @@ def test_facturae_face_error(self):
exchange_record.backend_id.exchange_send(exchange_record)
self.assertEqual(exchange_record.edi_exchange_state, "output_error_on_send")
+ def test_create_facturae_file_without_organo_gestor(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.organo_gestor = False
+ with self.assertRaises(exceptions.ValidationError):
+ wizard.create_facturae_file()
+
+ def test_create_facturae_file_without_unidad_tramitadora(self):
+ 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):
+ 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(object):
def __init__(self, value):