Skip to content

Commit

Permalink
[IMP] l10n_es_facturae: Make it work for physical people
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinafernandez-tecnativa committed May 16, 2024
1 parent 1fbe171 commit cca55f7
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 64 deletions.
18 changes: 0 additions & 18 deletions l10n_es_facturae/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 0 additions & 18 deletions l10n_es_facturae/i18n/l10n_es_facturae.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions l10n_es_facturae/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 0 additions & 18 deletions l10n_es_facturae/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
6 changes: 3 additions & 3 deletions l10n_es_facturae/views/report_facturae.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<FirstSurname
t-length="40"
t-esc="administrative_partner.lastname if administrative_partner._fields.get('lastname') else ''"
t-if="not partner.is_company"
t-if="not partner.is_company and administrative_partner.lastname if administrative_partner._fields.get('lastname') else ''"
/>
<SecondSurname t-if="False" />
<t t-call="l10n_es_facturae.address_contact" />
Expand Down Expand Up @@ -119,9 +119,9 @@
/>
<FirstSurname
t-length="40"
t-esc="partner.lastname if partner._fields.get('lastname') else ''"
t-esc="partner.lastname if partner._fields.get('lastname') else '.'"
/>
<SecondSurname t-length="40" t-esc="''" />
<SecondSurname t-length="40" t-esc="''" t-if="False" />
<t t-call="l10n_es_facturae.address_contact">
</t>
</Individual>
Expand Down
18 changes: 18 additions & 0 deletions l10n_es_facturae_face/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions l10n_es_facturae_face/i18n/l10n_es_facturae_face.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion l10n_es_facturae_face/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -83,3 +84,13 @@ def _get_l10n_es_facturae_excluded_status(self):
"face-2600",
"face-3100",
]

def validate_facturae_fields(self):
super().validate_facturae_fields()
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"))
return
33 changes: 33 additions & 0 deletions l10n_es_facturae_face/tests/test_facturae_face.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit cca55f7

Please sign in to comment.