Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] l10n_es_irnr: Assign core tax_groups to taxes that had template… #3791

Conversation

aritzolea
Copy link
Contributor

@aritzolea aritzolea commented Oct 22, 2024

… removed from module

Nos ha salido el siguiente error:

2024-10-22 11:43:12,226 275344 INFO <dbname> odoo.addons.base.models.ir_model: Deleting 28@account.tax.group (l10n_es_irnr.tax_group_irnr_ue) 
2024-10-22 11:43:12,230 275344 ERROR <dbname> odoo.sql_db: bad query: DELETE FROM "account_tax_group" WHERE id IN (28)
ERROR: update or delete on table "account_tax_group" violates foreign key constraint "account_tax_tax_group_id_fkey" on table "account_tax"
DETAIL:  Key (id)=(28) is still referenced from table "account_tax".

cc. @ljsalvatierra-factorlibre @edlopen @pedrobaeza

UPDATE account_tax SET tax_group_id =
(SELECT id FROM account_tax_group WHERE name::text LIKE '%Retenciones 0\%%')
WHERE name IN (
'Retenciones a cuenta IRPF No residentes no-UE exento por convenio',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mejor que evites esta comparación. Enlaza con ir_model_data y utiliza el XML-ID.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cambiado!

@aritzolea aritzolea force-pushed the 16.0-fix-l10n_es_irnr-non_existing_tax_group_on_taxes branch from 6c51fc8 to ca67e60 Compare October 22, 2024 14:22
@aritzolea aritzolea marked this pull request as ready for review October 22, 2024 14:26
@pedrobaeza pedrobaeza added this to the 16.0 milestone Oct 22, 2024
retenciones_24 = env.ref("l10n_es.tax_group_retenciones_24")
retenciones_19 = env.ref("l10n_es.tax_group_retenciones_19")
retenciones_0 = env.ref("l10n_es.tax_group_retenciones_0")
env["ir.model.data"].search(
Copy link
Member

@pedrobaeza pedrobaeza Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hay que ser elegante, hombre! Haz un bucle con repetiendo este código teniendo una lista de entrada de cada XML-ID y detino como datos variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hecho, lo he reducido bastante

@aritzolea aritzolea force-pushed the 16.0-fix-l10n_es_irnr-non_existing_tax_group_on_taxes branch from ca67e60 to b89f8a7 Compare October 22, 2024 17:33
Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahí está, haciendo código bonito 😃

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 16.0-ocabot-merge-pr-3791-by-pedrobaeza-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 1c29a27 into OCA:16.0 Oct 22, 2024
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 5fadee3. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants