Skip to content

Commit

Permalink
Merge PR #3437 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Oct 30, 2024
2 parents be68563 + 6dd54ad commit ea207cf
Show file tree
Hide file tree
Showing 16 changed files with 163 additions and 31 deletions.
3 changes: 2 additions & 1 deletion l10n_es_facturae/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Creación de Facturae
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:75efb735c82562bb1129cfdd5b206def2d8e35d10f883bd13d7712ffda79ef57
!! source digest: sha256:4b78e87ffb093c3a7559c8afe87a3f3f05bd0e1c987a207eba14e5eab61db612
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -161,6 +161,7 @@ Contributors
* Adrián Gómez <adrian.gomez@pesol.es>
* Eduardo de Miguel (edu@moduon.team)
* Alberto Martínez (alberto.martinez@sygel.es)
* Carolina Fernandez (http://www.tecnativa.com)

Maintainers
~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion l10n_es_facturae/data/Facturaev3_2.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,7 @@
</xs:complexType>
<xs:complexType name="ExtensionsType">
<xs:sequence>
<xs:any namespace="##other" processContents="strict" minOccurs="0" maxOccurs="unbounded"/>
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="AccountType">
Expand Down
2 changes: 1 addition & 1 deletion l10n_es_facturae/data/Facturaev3_2_1.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,7 @@
</xs:complexType>
<xs:complexType name="ExtensionsType">
<xs:sequence>
<xs:any namespace="##other" processContents="strict" minOccurs="0" maxOccurs="unbounded"/>
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="AccountType">
Expand Down
2 changes: 1 addition & 1 deletion l10n_es_facturae/data/Facturaev3_2_2.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,7 @@
</xs:complexType>
<xs:complexType name="ExtensionsType">
<xs:sequence>
<xs:any namespace="##other" processContents="strict" minOccurs="0" maxOccurs="unbounded"/>
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="AccountType">
Expand Down
14 changes: 14 additions & 0 deletions l10n_es_facturae/migrations/15.0.1.10.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2024 Tecnativa - Carolina Fernandez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).


def migrate(env):
env.cr.execute(
"""
UPDATE res_partner child
SET facturae = parent.facturae
FROM res_partner parent
WHERE child.facturae != parent.facturae
AND child.parent_id = parent.id
"""
)
7 changes: 7 additions & 0 deletions l10n_es_facturae/models/account_move.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2017 Creu Blanca
# Copyright 2024 Tecnativa - Carolina Fernandez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

import base64
Expand Down Expand Up @@ -214,6 +215,12 @@ def get_facturae_version(self):
or "3_2"
)

def _get_facturae_headers(self):
return 'xmlns:ds="http://www.w3.org/2000/09/xmldsig#"'

def _facturae_has_extensions(self):
return False

def _get_facturae_tax_info(self):
self.ensure_one()
sign = -1 if self.move_type[:3] == "out" else 1
Expand Down
5 changes: 5 additions & 0 deletions l10n_es_facturae/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2015 Omar Castiñeira (Comunitea)
# Copyright 2017 Creu Blanca
# Copyright 2023 QubiQ - Jan Tugores (jan.tugores@qubiq.es)
# Copyright 2024 Tecnativa - Carolina Fernandez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import _, api, fields, models
Expand Down Expand Up @@ -55,3 +56,7 @@ def check_facturae(self):
raise ValidationError(
_("State must be defined for factura-e enabled partners.")
)

@api.model
def _commercial_fields(self):
return super()._commercial_fields() + ["facturae"]
1 change: 1 addition & 0 deletions l10n_es_facturae/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
* Adrián Gómez <adrian.gomez@pesol.es>
* Eduardo de Miguel (edu@moduon.team)
* Alberto Martínez (alberto.martinez@sygel.es)
* Carolina Fernandez (http://www.tecnativa.com)
4 changes: 3 additions & 1 deletion l10n_es_facturae/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -366,7 +367,7 @@ <h1 class="title">Creación de Facturae</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:75efb735c82562bb1129cfdd5b206def2d8e35d10f883bd13d7712ffda79ef57
!! source digest: sha256:4b78e87ffb093c3a7559c8afe87a3f3f05bd0e1c987a207eba14e5eab61db612
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/l10n-spain/tree/15.0/l10n_es_facturae"><img alt="OCA/l10n-spain" src="https://img.shields.io/badge/github-OCA%2Fl10n--spain-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/l10n-spain-15-0/l10n-spain-15-0-l10n_es_facturae"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-spain&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>En virtud de la Ley 25/2013, de 27 de diciembre, de impulso de la factura
Expand Down Expand Up @@ -508,6 +509,7 @@ <h2><a class="toc-backref" href="#toc-entry-10">Contributors</a></h2>
<li>Adrián Gómez &lt;<a class="reference external" href="mailto:adrian.gomez&#64;pesol.es">adrian.gomez&#64;pesol.es</a>&gt;</li>
<li>Eduardo de Miguel (<a class="reference external" href="mailto:edu&#64;moduon.team">edu&#64;moduon.team</a>)</li>
<li>Alberto Martínez (<a class="reference external" href="mailto:alberto.martinez&#64;sygel.es">alberto.martinez&#64;sygel.es</a>)</li>
<li>Carolina Fernandez (<a class="reference external" href="http://www.tecnativa.com">http://www.tecnativa.com</a>)</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
19 changes: 19 additions & 0 deletions l10n_es_facturae/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,3 +749,22 @@ def test_hide_discount(self):
self.assertFalse(
facturae_xml.xpath("//InvoiceLine//DiscountAmount"),
)

def test_facturae_commercial_field(self):
child_partner = self.partner.copy()
child_partner.name = "Child partner"
child_partner.parent_id = self.partner.id
self.assertEqual(child_partner.facturae, self.partner.facturae)
self.partner.facturae = False
self.assertEqual(child_partner.facturae, self.partner.facturae)

def _create_wizard_facturae_file(self):
self.move.action_post()
self._activate_certificate(self.certificate_password)
self.move.name = "2999/99999"
wizard = (
self.env["create.facturae"]
.with_context(active_ids=self.move.ids, active_model="account.move")
.create({})
)
return wizard
30 changes: 18 additions & 12 deletions l10n_es_facturae/views/report_facturae.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,29 @@
</record>
<template id="facturae_header">
<t t-if="version == '3_2'">
&lt;fe:Facturae xmlns:fe="http://www.facturae.es/Facturae/2009/v3.2/Facturae"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"&gt;
&lt;fe:Facturae xmlns:fe="http://www.facturae.es/Facturae/2009/v3.2/Facturae" <t
t-raw="headers"
/> &gt;
<t t-out="0" />
&lt;/fe:Facturae&gt;
</t>
<t t-elif="version == '3_2_1'">
&lt;fe:Facturae xmlns:fe="http://www.facturae.es/Facturae/2014/v3.2.1/Facturae"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"&gt;
&lt;fe:Facturae xmlns:fe="http://www.facturae.es/Facturae/2014/v3.2.1/Facturae" <t
t-raw="headers"
/> &gt;
<t t-out="0" />
&lt;/fe:Facturae&gt;
</t>
<t t-elif="version == '3_2_2'">
&lt;fe:Facturae xmlns:fe="http://www.facturae.gob.es/formato/Versiones/Facturaev3_2_2.xml"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"&gt;
&lt;fe:Facturae xmlns:fe="http://www.facturae.gob.es/formato/Versiones/Facturaev3_2_2.xml" <t
t-raw="headers"
/> &gt;
<t t-out="0" />
&lt;/fe:Facturae&gt;
</t>
</template>
<template id="administrative_center">
<AdministrativeCentre>
<AdministrativeCentre t-if="centre_code">
<CentreCode t-length="10" t-esc="centre_code" />
<RoleTypeCode t-esc="role_type_code" />
<Name
Expand All @@ -45,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 @@ -116,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 Expand Up @@ -189,6 +192,7 @@
<t t-set="currency_rate" t-value="currency.rate if currency else 1.0" />
<t t-set="euro_rate" t-value="euro.rate if euro else 1.0" />
<t t-set="version" t-value="move.get_facturae_version()" />
<t t-set="headers" t-value="move._get_facturae_headers()" />
<t t-call="l10n_es_facturae.facturae_header">
<FileHeader>
<SchemaVersion
Expand Down Expand Up @@ -728,7 +732,9 @@
t-set="attachments"
t-value="move._get_facturae_move_attachments()"
/>
<AdditionalData t-if="move.get_narration() or attachments">
<AdditionalData
t-if="move.narration or attachments or move._facturae_has_extensions()"
>
<RelatedInvoice t-if="False" />
<RelatedDocuments t-if="attachments">
<Attachment t-foreach="attachments" t-as="attachment">
Expand All @@ -753,7 +759,7 @@
t-esc="move.get_narration()"
t-if="move.get_narration()"
/>
<Extensions t-if="False" />
<Extensions t-if="move._facturae_has_extensions()" />
</AdditionalData>
</Invoice>
</Invoices>
Expand Down
20 changes: 7 additions & 13 deletions l10n_es_facturae/views/res_partner_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
</group>
</xpath>
<group name='accounting_entries' position="inside">
<field name="facturae" />
<field
name="facturae"
attrs="{'invisible': [('parent_id', '!=', False)]}"
/>
</group>
<group name="accounting_entries" position="after">
<group
Expand All @@ -35,18 +38,9 @@
attrs="{'invisible': [('facturae', '=', False)]}"
>
<field name="facturae_version" />
<field
name="organo_gestor"
attrs="{'required': [('facturae', '=', True)]}"
/>
<field
name="unidad_tramitadora"
attrs="{'required': [('facturae', '=', True)]}"
/>
<field
name="oficina_contable"
attrs="{'required': [('facturae', '=', True)]}"
/>
<field name="organo_gestor" />
<field name="unidad_tramitadora" />
<field name="oficina_contable" />
<field name="organo_proponente" />
<field name="attach_invoice_as_annex" />
<field name="facturae_hide_discount" />
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
16 changes: 15 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,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
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 ea207cf

Please sign in to comment.