Repository: OCA/l10n-spain
Pull request #4037: [16.0][FIX] l10n_es_aeat_mod190: computo primeros hijos
Author: login: EmilioPascual
Labels: name: approved
name: merged 🎉
Created: 2025-02-21T18:12:15Z | Merged: 2025-03-11T08:31:58Z

El computo de los 3 primeros hijos sólo debe ser visible para percepciones correspondientes a las claves A, B01, B03 y C siguiendo el [último diseño de registro del modelo 190](https://sede.agenciatributaria.gob.es/static_files/Sede/Disenyo_registro/DR_100_199/archivos_24/DISENOS_LOGICOS_190-2024.pdf)

![image](https://github.com/user-attachments/assets/03710207-2cc7-4912-8ed2-423b42bdf0dd)

Tal y como está ahora no se puede rellenar cuando se selecciona la clave A

![image](https://github.com/user-attachments/assets/5708bae8-fd04-4d87-b5b5-d786267fa224)

Pero si aparece para otras claves que no debería.

![image](https://github.com/user-attachments/assets/9fb9f0a4-df3a-468f-9ddf-193b258d7d82)


@moduon MT-8874

@loida-vm @Shide @pedrobaeza @etobella @victoralmau podéis revisarlo, por favor. Gracias


Diff:
diff --git a/l10n_es_aeat_mod190/i18n/es.po b/l10n_es_aeat_mod190/i18n/es.po
index 1ad87e49efb..44b11141716 100644
--- a/l10n_es_aeat_mod190/i18n/es.po
+++ b/l10n_es_aeat_mod190/i18n/es.po
@@ -6,8 +6,9 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Odoo Server 15.0\n"
 "Report-Msgid-Bugs-To: \n"
-"PO-Revision-Date: 2024-01-22 13:36+0000\n"
-"Last-Translator: loida-vm <loida@moduon.team>\n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: 2025-02-28 09:45+0100\n"
+"Last-Translator: Emilio Pascual <emilio@moduon.team>\n"
 "Language-Team: none\n"
 "Language: es\n"
 "MIME-Version: 1.0\n"
@@ -871,6 +872,12 @@ msgstr "Ingresos a cuenta repercutidos"
 msgid "Is Aeat Perception Subkey Visible"
 msgstr "Es visible la subclave Aeat de Percepción"
 
+#. module: l10n_es_aeat_mod190
+#: model:ir.model.fields,field_description:l10n_es_aeat_mod190.field_res_partner__is_first_child_computation_visible
+#: model:ir.model.fields,field_description:l10n_es_aeat_mod190.field_res_users__is_first_child_computation_visible
+msgid "Is First Child Computation Visible"
+msgstr "Cómputo de los primeros hijos visible"
+
 #. module: l10n_es_aeat_mod190
 #: model:ir.model.fields,field_description:l10n_es_aeat_mod190.field_l10n_es_aeat_mod190_report__message_is_follower
 msgid "Is Follower"
@@ -1719,25 +1726,3 @@ msgstr "[03] Importe de las retenciones"
 #: model:ir.model.fields,field_description:l10n_es_aeat_mod190.field_l10n_es_aeat_mod190_report_line__ejercicio_devengo
 msgid "year"
 msgstr "año"
-
-#~ msgid "Calculated"
-#~ msgstr "Calculado"
-
-#, python-format
-#~ msgid "You have to recalculate the report before confirm it."
-#~ msgstr "Debe volver a calcular el informe antes de confirmarlo."
-
-#~ msgid "Number of messages which requires an action"
-#~ msgstr "Número de mensajes que requieren una acción"
-
-#~ msgid "Number of unread messages"
-#~ msgstr "Número de mensajes no leídos"
-
-#~ msgid "SMS Delivery error"
-#~ msgstr "Error en la entrega de sms"
-
-#~ msgid "Unread Messages"
-#~ msgstr "Mensajes No Leídos"
-
-#~ msgid "Unread Messages Counter"
-#~ msgstr "Contador de Mensajes no leídos"
diff --git a/l10n_es_aeat_mod190/i18n/l10n_es_aeat_mod190.pot b/l10n_es_aeat_mod190/i18n/l10n_es_aeat_mod190.pot
index d20baa1388b..50ae84bb958 100644
--- a/l10n_es_aeat_mod190/i18n/l10n_es_aeat_mod190.pot
+++ b/l10n_es_aeat_mod190/i18n/l10n_es_aeat_mod190.pot
@@ -818,6 +818,12 @@ msgstr ""
 msgid "Is Aeat Perception Subkey Visible"
 msgstr ""
 
+#. module: l10n_es_aeat_mod190
+#: model:ir.model.fields,field_description:l10n_es_aeat_mod190.field_res_partner__is_first_child_computation_visible
+#: model:ir.model.fields,field_description:l10n_es_aeat_mod190.field_res_users__is_first_child_computation_visible
+msgid "Is First Child Computation Visible"
+msgstr ""
+
 #. module: l10n_es_aeat_mod190
 #: model:ir.model.fields,field_description:l10n_es_aeat_mod190.field_l10n_es_aeat_mod190_report__message_is_follower
 msgid "Is Follower"
diff --git a/l10n_es_aeat_mod190/models/res_partner.py b/l10n_es_aeat_mod190/models/res_partner.py
index 7e13ded80d7..6bd271ca395 100644
--- a/l10n_es_aeat_mod190/models/res_partner.py
+++ b/l10n_es_aeat_mod190/models/res_partner.py
@@ -240,6 +240,9 @@ class ResPartner(models.Model):
     is_aeat_perception_subkey_visible = fields.Boolean(
         compute="_compute_is_aeat_perception_subkey_visible"
     )
+    is_first_child_computation_visible = fields.Boolean(
+        compute="_compute_is_first_child_computation_visible"
+    )
 
     @api.depends("aeat_perception_key_id", "aeat_perception_subkey_id")
     def _compute_ad_required(self):
@@ -264,6 +267,24 @@ def _compute_is_aeat_perception_subkey_visible(self):
                 )
             )
 
+    @api.depends("aeat_perception_key_id", "aeat_perception_subkey_id")
+    def _compute_is_first_child_computation_visible(self):
+        aeat_perception_key_id = [  # A, C
+            "l10n_es_aeat_mod190.aeat_m190_perception_key_01",
+            "l10n_es_aeat_mod190.aeat_m190_perception_key_03",
+        ]
+        aeat_perception_subkey_id = [  # B01, B03
+            "l10n_es_aeat_mod190.aeat_m190_perception_subkey_02_01",
+            "l10n_es_aeat_mod190.aeat_m190_perception_subkey_02_03",
+        ]
+        for record in self:
+            record.is_first_child_computation_visible = (
+                record.aeat_perception_key_id
+                in {self.env.ref(item) for item in aeat_perception_key_id}
+                or record.aeat_perception_subkey_id
+                in {self.env.ref(item) for item in aeat_perception_subkey_id}
+            )
+
     @api.onchange("aeat_perception_key_id")
     def onchange_aeat_perception_key_id(self):
         if self.aeat_perception_key_id:
diff --git a/l10n_es_aeat_mod190/views/partner_view.xml b/l10n_es_aeat_mod190/views/partner_view.xml
index 407f737bdda..5e2979253b8 100644
--- a/l10n_es_aeat_mod190/views/partner_view.xml
+++ b/l10n_es_aeat_mod190/views/partner_view.xml
@@ -27,6 +27,10 @@
                         />
                         <field name="ad_required" invisible="1" />
                         <field name="is_aeat_perception_subkey_visible" invisible="1" />
+                        <field
+                            name="is_first_child_computation_visible"
+                            invisible="1"
+                        />
                     </group>
                     <group
                         string="Perception data"
@@ -62,7 +66,7 @@
                     <group
                         groups="account.group_account_invoice,l10n_es_aeat.group_account_aeat"
                         string="First 3 compute"
-                        attrs="{'invisible': [('is_aeat_perception_subkey_visible', '=', False)]}"
+                        attrs="{'invisible': [('is_first_child_computation_visible', '=', False)]}"
                     >
                         <field name="computo_primeros_hijos_1" string="1" />
                         <field name="computo_primeros_hijos_2" string="2" />


Reviews:
user: login: rafaelbn
body: 👍🏼 

Yo, escucha hermano, esto es un shout-out,
pa’ un dev con flow que la rompe sin doubt.
Hizo un PR, arregló el 190,
la AEAT tembló, se cayó la compuerta.

Los primeros hijos contaban mal,
pero él vino al código a ponerlo a andar.
Con commits de fuego, git en su mano,
se nota que el código lo lleva en el alma, hermano.

Ey yo, dev, esto va por ti,
gracias por el fix, un crack hasta el fin.
Disfruta el finde con tu family,
que el código espera, pero ellos están aquí.

Debugging skills como un beat en loop,
limpia los bugs, deja el código en mute.
No hay stacktrace que te haga frenar,
el código es tuyo, lo haces brillar.

Así que relájate, disfruta el weekend,
que el lunes seguimos con más commits fresh.
Gracias por el PR, eso es calidad,
en Moduon te queremos como eres man

💙
state: APPROVED
author_association: MEMBER
submitted_at: 2025-02-21T18:46:33Z
user: login: pedrobaeza
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-02-26T16:31:27Z
user: login: EmilioPascual
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-02-28T09:08:22Z
user: login: EmilioPascual
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-02-28T09:08:37Z
user: login: pedrobaeza
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-01T09:15:39Z
user: login: EmilioPascual
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-05T07:55:32Z
user: login: pedrobaeza
body: /ocabot merge minor
state: APPROVED
author_association: MEMBER
submitted_at: 2025-03-06T19:03:37Z

Review comments:
diff_hunk: @@ -240,6 +251,9 @@ class ResPartner(models.Model):
     is_aeat_perception_subkey_visible = fields.Boolean(
         compute="_compute_is_aeat_perception_subkey_visible"
     )
+    computo_primeros_hijos_visible = fields.Boolean(
path: l10n_es_aeat_mod190/models/res_partner.py
user: login: pedrobaeza
body: Mejor seguir el mismo esquema de nombre, pero en este caso vamos ya a pasarlo a inglés:

```suggestion
    is_first_child_computation_visible = fields.Boolean(
```
created_at: 2025-02-26T16:29:37Z
author_association: MEMBER
diff_hunk: @@ -1,5 +1,16 @@
 from odoo import api, fields, models
 
+COMPUTE_FIRST_KIDS_VISIBLE = {
path: l10n_es_aeat_mod190/models/res_partner.py
user: login: pedrobaeza
body: Esto mejor que quede dentro del propio compute, ya que no tiene más uso que ése, y además, no es necesario hacer un diccionario con dos claves, solo tener dos variables con el listado de XML-IDs.
created_at: 2025-02-26T16:31:20Z
author_association: MEMBER
diff_hunk: @@ -240,6 +251,9 @@ class ResPartner(models.Model):
     is_aeat_perception_subkey_visible = fields.Boolean(
         compute="_compute_is_aeat_perception_subkey_visible"
     )
+    computo_primeros_hijos_visible = fields.Boolean(
path: l10n_es_aeat_mod190/models/res_partner.py
user: login: EmilioPascual
body: Cambiado el nombre del campo al inglés
created_at: 2025-02-28T09:08:22Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,5 +1,16 @@
 from odoo import api, fields, models
 
+COMPUTE_FIRST_KIDS_VISIBLE = {
path: l10n_es_aeat_mod190/models/res_partner.py
user: login: EmilioPascual
body: Actualizado. Gracias por la aportación.
created_at: 2025-02-28T09:08:36Z
author_association: CONTRIBUTOR
diff_hunk: @@ -871,6 +872,12 @@ msgstr "Ingresos a cuenta repercutidos"
 msgid "Is Aeat Perception Subkey Visible"
 msgstr "Es visible la subclave Aeat de Percepción"
 
+#. module: l10n_es_aeat_mod190
+#: model:ir.model.fields,field_description:l10n_es_aeat_mod190.field_res_partner__is_first_child_computation_visible
+#: model:ir.model.fields,field_description:l10n_es_aeat_mod190.field_res_users__is_first_child_computation_visible
+msgid "Is First Child Computation Visible"
+msgstr "Computo de los primeros hijos visible"
path: l10n_es_aeat_mod190/i18n/es.po
user: login: pedrobaeza
body: ```suggestion
msgstr "Cómputo de los primeros hijos visible"
```
created_at: 2025-03-01T09:14:59Z
author_association: MEMBER
diff_hunk: @@ -871,6 +872,12 @@ msgstr "Ingresos a cuenta repercutidos"
 msgid "Is Aeat Perception Subkey Visible"
 msgstr "Es visible la subclave Aeat de Percepción"
 
+#. module: l10n_es_aeat_mod190
+#: model:ir.model.fields,field_description:l10n_es_aeat_mod190.field_res_partner__is_first_child_computation_visible
+#: model:ir.model.fields,field_description:l10n_es_aeat_mod190.field_res_users__is_first_child_computation_visible
+msgid "Is First Child Computation Visible"
+msgstr "Computo de los primeros hijos visible"
path: l10n_es_aeat_mod190/i18n/es.po
user: login: EmilioPascual
body: Hecho.
created_at: 2025-03-05T07:55:32Z
author_association: CONTRIBUTOR

PR comments:
user: login: pedrobaeza
created_at: 2025-02-21T18:50:07Z
body: Los tests están en rojo.
author_association: MEMBER
user: login: EmilioPascual
created_at: 2025-02-26T15:45:48Z
body: > Los tests están en rojo.

Ya están en verde. Salían en rojo pero no por este commit.
author_association: CONTRIBUTOR
user: login: EmilioPascual
created_at: 2025-03-06T09:37:55Z
body: ¿@pedrobaeza puedes revisarlo y fusionarlo si ya está todo correcto? Gracias.
author_association: CONTRIBUTOR
user: login: OCA-git-bot
created_at: 2025-03-06T19:03:44Z
body: Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch [16.0-ocabot-merge-pr-4037-by-pedrobaeza-bump-minor](https://github.com/OCA/l10n-spain/commits/16.0-ocabot-merge-pr-4037-by-pedrobaeza-bump-minor), awaiting test results.
author_association: CONTRIBUTOR
user: login: OCA-git-bot
created_at: 2025-03-06T19:21:52Z
body: @pedrobaeza your merge command was aborted due to failed check(s), which you can inspect on [this commit of 16.0-ocabot-merge-pr-4037-by-pedrobaeza-bump-minor](https://github.com/OCA/l10n-spain/commits/aee653b36a79c4228e5eae68ae2d45eed00897f8).

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.
author_association: CONTRIBUTOR
user: login: pedrobaeza
created_at: 2025-03-06T19:27:59Z
body: /ocabot merge minor
author_association: MEMBER
user: login: OCA-git-bot
created_at: 2025-03-06T19:28:06Z
body: This PR looks fantastic, let's merge it!
Prepared branch [16.0-ocabot-merge-pr-4037-by-pedrobaeza-bump-minor](https://github.com/OCA/l10n-spain/commits/16.0-ocabot-merge-pr-4037-by-pedrobaeza-bump-minor), awaiting test results.
author_association: CONTRIBUTOR
user: login: pedrobaeza
created_at: 2025-03-10T08:19:07Z
body: /ocabot merge minor
author_association: MEMBER
user: login: OCA-git-bot
created_at: 2025-03-10T08:19:15Z
body: Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch [16.0-ocabot-merge-pr-4037-by-pedrobaeza-bump-minor](https://github.com/OCA/l10n-spain/commits/16.0-ocabot-merge-pr-4037-by-pedrobaeza-bump-minor), awaiting test results.
author_association: CONTRIBUTOR
user: login: OCA-git-bot
created_at: 2025-03-10T08:41:42Z
body: @pedrobaeza your merge command was aborted due to failed check(s), which you can inspect on [this commit of 16.0-ocabot-merge-pr-4037-by-pedrobaeza-bump-minor](https://github.com/OCA/l10n-spain/commits/7f20e407f386fe9467a2663e8ccb0b216be0ef85).

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.
author_association: CONTRIBUTOR
user: login: pedrobaeza
created_at: 2025-03-11T08:14:07Z
body: /ocabot merge minor
author_association: MEMBER
user: login: OCA-git-bot
created_at: 2025-03-11T08:14:15Z
body: This PR looks fantastic, let's merge it!
Prepared branch [16.0-ocabot-merge-pr-4037-by-pedrobaeza-bump-minor](https://github.com/OCA/l10n-spain/commits/16.0-ocabot-merge-pr-4037-by-pedrobaeza-bump-minor), awaiting test results.
author_association: CONTRIBUTOR
user: login: OCA-git-bot
created_at: 2025-03-11T08:32:00Z
body: Congratulations, your PR was merged at 93c6f85be991e5211b12cd30df0b37592bef2f08. Thanks a lot for contributing to OCA. ❤️
author_association: CONTRIBUTOR