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

[FIX] l10n_es: split IRPF 19% in two, depending on target model #161633

Closed
wants to merge 1 commit into from

Conversation

yajo
Copy link
Contributor

@yajo yajo commented Apr 12, 2024

Purchase IRPF 19% Spanish tax has 2 target models: 111 and 123.

New law requires a more specific breakdown.

Now, the tax for 111 is relabeled as "Retenciones IRPF 19% (Compra
consejero de persona física)" to be more accurate, and the new one for
model 123 is named "Retenciones IRPF 19% (Compra consejero de
sociedad)".

Since Odoo doesn't implement model 123 yet, that new tax includes no
repartition lines.

See OCA/l10n-spain#3520 for more context.


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@moduon MT-5767

Ticket link: https://www.odoo.com/web#model=project.task&id=3864840
opw-3864840

Purchase IRPF 19% Spanish tax has 2 target models: 111 and 123.

New law requires a more specific breakdown.

Now, the tax for 111 is relabeled as "Retenciones IRPF 19% (Compra
consejero de persona física)" to be more accurate, and the new one for
model 123 is named "Retenciones IRPF 19% (Compra consejero de
sociedad)".

Since Odoo doesn't implement model 123 yet, that new tax includes no
repartition lines.

See OCA/l10n-spain#3520 for more context.

OPW-3864840
@moduon MT-5767

Co-authored-by: Loida Vilaplana <[email protected]>
@robodoo
Copy link
Contributor

robodoo commented Apr 12, 2024

Pull request status dashboard.

@C3POdoo C3POdoo requested review from a team and lordkrandel and removed request for a team April 12, 2024 08:51
@C3POdoo C3POdoo added the Localization about adapting the content to a specify country (usually chart of accounts) label Apr 12, 2024
@rafaelbn
Copy link
Contributor

Hello @jco-odoo @chklop , please could we agile this? we need this tax for this quarter 🥲 ❤️

@rafaelbn
Copy link
Contributor

OPW-3864840

@lordkrandel
Copy link
Contributor

@jco-odoo does this tax change need a $module/migrations script to reload the Chart Template?

@jco-odoo
Copy link
Contributor

@yajo @rafaelbn I think we can do without upgrade script? Sorry for the hesitation, but at some point we will need to support it anyways.

@jco-odoo
Copy link
Contributor

@robodoo r+

robodoo pushed a commit that referenced this pull request Apr 18, 2024
Purchase IRPF 19% Spanish tax has 2 target models: 111 and 123.

New law requires a more specific breakdown.

Now, the tax for 111 is relabeled as "Retenciones IRPF 19% (Compra
consejero de persona física)" to be more accurate, and the new one for
model 123 is named "Retenciones IRPF 19% (Compra consejero de
sociedad)".

Since Odoo doesn't implement model 123 yet, that new tax includes no
repartition lines.

See OCA/l10n-spain#3520 for more context.

OPW-3864840
@moduon MT-5767

closes #161633

Signed-off-by: Josse Colpaert <[email protected]>
Co-authored-by: Loida Vilaplana <[email protected]>
@robodoo robodoo closed this Apr 18, 2024
@rafaelbn
Copy link
Contributor

@jco-odoo , this is not an split, maybe @yajo miss understand it. This is a new tax, totally new for diferent concepts with same %. Do we don't need any migration script IMHO. thank you!

@yajo yajo deleted the 15.0-l10n_es-tax_irpf_19 branch April 19, 2024 06:52
@fw-bot
Copy link
Contributor

fw-bot commented Apr 22, 2024

@yajo @jco-odoo this pull request has forward-port PRs awaiting action (not merged or closed):

1 similar comment
@fw-bot
Copy link
Contributor

fw-bot commented Apr 23, 2024

@yajo @jco-odoo this pull request has forward-port PRs awaiting action (not merged or closed):

@fw-bot
Copy link
Contributor

fw-bot commented Apr 24, 2024

4 similar comments
@fw-bot
Copy link
Contributor

fw-bot commented Apr 25, 2024

@fw-bot
Copy link
Contributor

fw-bot commented Apr 26, 2024

@fw-bot
Copy link
Contributor

fw-bot commented Apr 27, 2024

@fw-bot
Copy link
Contributor

fw-bot commented Apr 28, 2024

@amcorpc
Copy link

amcorpc commented Apr 29, 2024

Hello,
I believe this PR has an issue. The new tax template has amount_type = percent and lacks repartition_lines,
So, In the following code, it triggers the raise :( https://github.com/odoo/odoo/blob/15.0/addons/account/models/account_tax.py#L161-L180
Could this be resolved by adding the repartition lines ?
Now, I believe the migration process is broken because of this in version 15.0
Regards

@yajo @jco-odoo

@pedrobaeza
Copy link
Collaborator

I confirm there's an issue when the update taxes migration script is executed.

@fw-bot
Copy link
Contributor

fw-bot commented Apr 30, 2024

@yajo
Copy link
Contributor Author

yajo commented Apr 30, 2024

Do you have any tracebacks or STR?

@amcorpc
Copy link

amcorpc commented Apr 30, 2024

Hello Jairo,
This is the database log I'm migrating; it was working fine before.

The new tax template pass this if, and trigger the ValidationError : 0 != 1
https://github.com/odoo/odoo/blob/15.0/addons/account/models/account_tax.py#L171-L175

            # if the tax is an aggregation of its sub-taxes (group) it can have no repartition lines
            if record.amount_type == 'group' and \
                    not record.invoice_repartition_line_ids and \
                    not record.refund_repartition_line_ids:
                continue
2024-04-29 20:04:41,291 28 INFO db_1541860 odoo.modules.migration: module l10n_es: Running migration [15.0.5.1>] post-migrate_update_taxes 
2024-04-29 20:04:42,319 28 INFO db_1541860 odoo.models.unlink: User #1 deleted ir.model.data records with IDs: [41131] 
2024-04-29 20:04:42,333 28 INFO db_1541860 odoo.models.unlink: User #1 deleted ir.model.data records with IDs: [41156] 
2024-04-29 20:04:42,435 28 WARNING db_1541860 odoo.modules.loading: Transient module states were reset 
2024-04-29 20:04:42,435 28 ERROR db_1541860 odoo.modules.registry: Failed to load registry 
Traceback (most recent call last):
  File "/home/odoo/src/odoo/15.0/odoo/modules/registry.py", line 87, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/home/odoo/src/odoo/15.0/odoo/modules/loading.py", line 470, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/home/odoo/src/odoo/15.0/odoo/modules/loading.py", line 363, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/home/odoo/src/odoo/15.0/odoo/modules/loading.py", line 227, in load_module_graph
    migrations.migrate_module(package, 'post')
  File "/home/odoo/src/odoo/15.0/odoo/modules/migration.py", line 186, in migrate_module
    migrate(self.cr, installed_version)
  File "/home/odoo/src/odoo/15.0/addons/l10n_es/upgrades/15.0.5.1/post-migrate_update_taxes.py", line 7, in migrate
    update_taxes_from_templates(cr, 'l10n_es.account_chart_template_common')
  File "/home/odoo/src/odoo/15.0/addons/account/models/chart_template.py", line 262, in update_taxes_from_templates
    new_template2tax += _create_taxes_from_template(company, templates_to_tax_create, templates_to_tax_update)
  File "/home/odoo/src/odoo/15.0/addons/account/models/chart_template.py", line 76, in _create_taxes_from_template
    new_template2tax_company = templates_to_create._generate_tax(
  File "/home/odoo/src/odoo/15.0/addons/account/models/chart_template.py", line 1428, in _generate_tax
    taxes = ChartTemplate._create_records_with_xmlid('account.tax', tax_template_vals, company)
  File "/home/odoo/src/odoo/15.0/addons/account/models/chart_template.py", line 913, in _create_records_with_xmlid
    return self.env[model]._load_records(data_list)
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 4453, in _load_records
    records = self._load_records_create([data['values'] for data in to_create])
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 4358, in _load_records_create
    return self.create(values)
  File "<decorator-gen-117>", line 2, in create
  File "/home/odoo/src/odoo/15.0/odoo/api.py", line 418, in _model_create_multi
    return create(self, arg)
  File "/tmp/tmp8sahbx61/migrations/util/orm.py", line 231, in wrapper
    return f(*args, **kwargs)
  File "/tmp/tmp8sahbx61/migrations/base/0.0.0/pre-models-match_uniq.py", line 91, in create
    records = super().create([vals_list[idx] for idx in create_idx_list])
  File "<decorator-gen-69>", line 2, in create
  File "/home/odoo/src/odoo/15.0/odoo/api.py", line 418, in _model_create_multi
    return create(self, arg)
  File "/home/odoo/src/odoo/15.0/odoo/addons/base/models/ir_fields.py", line 613, in create
    recs = super().create(vals_list)
  File "<decorator-gen-15>", line 2, in create
  File "/home/odoo/src/odoo/15.0/odoo/api.py", line 418, in _model_create_multi
    return create(self, arg)
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 4095, in create
    records = self._create(data_list)
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 4260, in _create
    records._validate_fields(name for data in data_list for name in data['stored'])
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 1378, in _validate_fields
    check(self)
  File "/home/odoo/src/odoo/15.0/addons/account/models/account_tax.py", line 179, in _validate_repartition_lines
    record._check_repartition_lines(invoice_repartition_line_ids)
  File "/home/odoo/src/odoo/15.0/addons/account/models/account_tax.py", line 166, in _check_repartition_lines
    raise ValidationError(_("Invoice and credit note distribution should each contain exactly one line for the base."))
odoo.exceptions.ValidationError: Invoice and credit note distribution should each contain exactly one line for the base.
2024-04-29 20:04:42,439 28 CRITICAL db_1541860 odoo.service.server: Failed to initialize database `db_1541860`. 
Traceback (most recent call last):
  File "/home/odoo/src/odoo/15.0/odoo/service/server.py", line 1260, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "/home/odoo/src/odoo/15.0/odoo/modules/registry.py", line 87, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/home/odoo/src/odoo/15.0/odoo/modules/loading.py", line 470, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/home/odoo/src/odoo/15.0/odoo/modules/loading.py", line 363, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/home/odoo/src/odoo/15.0/odoo/modules/loading.py", line 227, in load_module_graph
    migrations.migrate_module(package, 'post')
  File "/home/odoo/src/odoo/15.0/odoo/modules/migration.py", line 186, in migrate_module
    migrate(self.cr, installed_version)
  File "/home/odoo/src/odoo/15.0/addons/l10n_es/upgrades/15.0.5.1/post-migrate_update_taxes.py", line 7, in migrate
    update_taxes_from_templates(cr, 'l10n_es.account_chart_template_common')
  File "/home/odoo/src/odoo/15.0/addons/account/models/chart_template.py", line 262, in update_taxes_from_templates
    new_template2tax += _create_taxes_from_template(company, templates_to_tax_create, templates_to_tax_update)
  File "/home/odoo/src/odoo/15.0/addons/account/models/chart_template.py", line 76, in _create_taxes_from_template
    new_template2tax_company = templates_to_create._generate_tax(
  File "/home/odoo/src/odoo/15.0/addons/account/models/chart_template.py", line 1428, in _generate_tax
    taxes = ChartTemplate._create_records_with_xmlid('account.tax', tax_template_vals, company)
  File "/home/odoo/src/odoo/15.0/addons/account/models/chart_template.py", line 913, in _create_records_with_xmlid
    return self.env[model]._load_records(data_list)
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 4453, in _load_records
    records = self._load_records_create([data['values'] for data in to_create])
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 4358, in _load_records_create
    return self.create(values)
  File "<decorator-gen-117>", line 2, in create
  File "/home/odoo/src/odoo/15.0/odoo/api.py", line 418, in _model_create_multi
    return create(self, arg)
  File "/tmp/tmp8sahbx61/migrations/util/orm.py", line 231, in wrapper
    return f(*args, **kwargs)
  File "/tmp/tmp8sahbx61/migrations/base/0.0.0/pre-models-match_uniq.py", line 91, in create
    records = super().create([vals_list[idx] for idx in create_idx_list])
  File "<decorator-gen-69>", line 2, in create
  File "/home/odoo/src/odoo/15.0/odoo/api.py", line 418, in _model_create_multi
    return create(self, arg)
  File "/home/odoo/src/odoo/15.0/odoo/addons/base/models/ir_fields.py", line 613, in create
    recs = super().create(vals_list)
  File "<decorator-gen-15>", line 2, in create
  File "/home/odoo/src/odoo/15.0/odoo/api.py", line 418, in _model_create_multi
    return create(self, arg)
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 4095, in create
    records = self._create(data_list)
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 4260, in _create
    records._validate_fields(name for data in data_list for name in data['stored'])
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 1378, in _validate_fields
    check(self)
  File "/home/odoo/src/odoo/15.0/addons/account/models/account_tax.py", line 179, in _validate_repartition_lines
    record._check_repartition_lines(invoice_repartition_line_ids)
  File "/home/odoo/src/odoo/15.0/addons/account/models/account_tax.py", line 166, in _check_repartition_lines
    raise ValidationError(_("Invoice and credit note distribution should each contain exactly one line for the base."))
odoo.exceptions.ValidationError: Invoice and credit note distribution should each contain exactly one line for the base.

@hink-odoo
Copy link

Hello Jairo,

I'm trying to upgrade the database and also have the same issue because the new tax template has been added.

Traceback :

2024-04-25 10:17:59,167 28 WARNING hink_1518675_17.0 odoo.modules.loading: Transient module states were reset 
2024-04-25 10:17:59,168 28 ERROR hink_1518675_17.0 odoo.modules.registry: Failed to load registry 
Traceback (most recent call last):
  File "/home/odoo/src/odoo/15.0/odoo/modules/registry.py", line 87, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/home/odoo/src/odoo/15.0/odoo/modules/loading.py", line 470, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/home/odoo/src/odoo/15.0/odoo/modules/loading.py", line 363, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/home/odoo/src/odoo/15.0/odoo/modules/loading.py", line 227, in load_module_graph
    migrations.migrate_module(package, 'post')
  File "/home/odoo/src/odoo/15.0/odoo/modules/migration.py", line 186, in migrate_module
    migrate(self.cr, installed_version)
  File "/home/odoo/src/odoo/15.0/addons/l10n_es/upgrades/15.0.5.1/post-migrate_update_taxes.py", line 7, in migrate
    update_taxes_from_templates(cr, 'l10n_es.account_chart_template_common')
  File "/home/odoo/src/odoo/15.0/addons/account/models/chart_template.py", line 262, in update_taxes_from_templates
    new_template2tax += _create_taxes_from_template(company, templates_to_tax_create, templates_to_tax_update)
  File "/home/odoo/src/odoo/15.0/addons/account/models/chart_template.py", line 76, in _create_taxes_from_template
    new_template2tax_company = templates_to_create._generate_tax(
  File "/home/odoo/src/odoo/15.0/addons/account/models/chart_template.py", line 1428, in _generate_tax
    taxes = ChartTemplate._create_records_with_xmlid('account.tax', tax_template_vals, company)
  File "/home/odoo/src/odoo/15.0/addons/account/models/chart_template.py", line 913, in _create_records_with_xmlid
    return self.env[model]._load_records(data_list)
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 4453, in _load_records
    records = self._load_records_create([data['values'] for data in to_create])
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 4358, in _load_records_create
    return self.create(values)
  File "<decorator-gen-117>", line 2, in create
  File "/home/odoo/src/odoo/15.0/odoo/api.py", line 418, in _model_create_multi
    return create(self, arg)
  File "/tmp/tmpyivnjv2s/migrations/util/orm.py", line 231, in wrapper
    return f(*args, **kwargs)
  File "/tmp/tmpyivnjv2s/migrations/base/0.0.0/pre-models-match_uniq.py", line 91, in create
    records = super().create([vals_list[idx] for idx in create_idx_list])
  File "<decorator-gen-69>", line 2, in create
  File "/home/odoo/src/odoo/15.0/odoo/api.py", line 418, in _model_create_multi
    return create(self, arg)
  File "/home/odoo/src/odoo/15.0/odoo/addons/base/models/ir_fields.py", line 613, in create
    recs = super().create(vals_list)
  File "<decorator-gen-15>", line 2, in create
  File "/home/odoo/src/odoo/15.0/odoo/api.py", line 418, in _model_create_multi
    return create(self, arg)
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 4095, in create
    records = self._create(data_list)
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 4260, in _create
    records._validate_fields(name for data in data_list for name in data['stored'])
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 1378, in _validate_fields
    check(self)
  File "/home/odoo/src/odoo/15.0/addons/account/models/account_tax.py", line 185, in _validate_repartition_lines
    record._check_repartition_lines(invoice_repartition_line_ids)
  File "/home/odoo/src/odoo/15.0/addons/account/models/account_tax.py", line 170, in _check_repartition_lines
    raise ValidationError(_("Invoice and credit note distribution should each contain exactly one line for the base."))
odoo.exceptions.ValidationError: Pour les factures comme pour les Avoirs, la répartition doit contenir au moins une ligne de base.
2024-04-25 10:17:59,186 28 CRITICAL hink_1518675_17.0 odoo.service.server: Failed to initialize database `hink_1518675_17.0`. 
Traceback (most recent call last):
  File "/home/odoo/src/odoo/15.0/odoo/service/server.py", line 1260, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "/home/odoo/src/odoo/15.0/odoo/modules/registry.py", line 87, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/home/odoo/src/odoo/15.0/odoo/modules/loading.py", line 470, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/home/odoo/src/odoo/15.0/odoo/modules/loading.py", line 363, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/home/odoo/src/odoo/15.0/odoo/modules/loading.py", line 227, in load_module_graph
    migrations.migrate_module(package, 'post')
  File "/home/odoo/src/odoo/15.0/odoo/modules/migration.py", line 186, in migrate_module
    migrate(self.cr, installed_version)
  File "/home/odoo/src/odoo/15.0/addons/l10n_es/upgrades/15.0.5.1/post-migrate_update_taxes.py", line 7, in migrate
    update_taxes_from_templates(cr, 'l10n_es.account_chart_template_common')
  File "/home/odoo/src/odoo/15.0/addons/account/models/chart_template.py", line 262, in update_taxes_from_templates
    new_template2tax += _create_taxes_from_template(company, templates_to_tax_create, templates_to_tax_update)
  File "/home/odoo/src/odoo/15.0/addons/account/models/chart_template.py", line 76, in _create_taxes_from_template
    new_template2tax_company = templates_to_create._generate_tax(
  File "/home/odoo/src/odoo/15.0/addons/account/models/chart_template.py", line 1428, in _generate_tax
    taxes = ChartTemplate._create_records_with_xmlid('account.tax', tax_template_vals, company)
  File "/home/odoo/src/odoo/15.0/addons/account/models/chart_template.py", line 913, in _create_records_with_xmlid
    return self.env[model]._load_records(data_list)
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 4453, in _load_records
    records = self._load_records_create([data['values'] for data in to_create])
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 4358, in _load_records_create
    return self.create(values)
  File "<decorator-gen-117>", line 2, in create
  File "/home/odoo/src/odoo/15.0/odoo/api.py", line 418, in _model_create_multi
    return create(self, arg)
  File "/tmp/tmpyivnjv2s/migrations/util/orm.py", line 231, in wrapper
    return f(*args, **kwargs)
  File "/tmp/tmpyivnjv2s/migrations/base/0.0.0/pre-models-match_uniq.py", line 91, in create
    records = super().create([vals_list[idx] for idx in create_idx_list])
  File "<decorator-gen-69>", line 2, in create
  File "/home/odoo/src/odoo/15.0/odoo/api.py", line 418, in _model_create_multi
    return create(self, arg)
  File "/home/odoo/src/odoo/15.0/odoo/addons/base/models/ir_fields.py", line 613, in create
    recs = super().create(vals_list)
  File "<decorator-gen-15>", line 2, in create
  File "/home/odoo/src/odoo/15.0/odoo/api.py", line 418, in _model_create_multi
    return create(self, arg)
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 4095, in create
    records = self._create(data_list)
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 4260, in _create
    records._validate_fields(name for data in data_list for name in data['stored'])
  File "/home/odoo/src/odoo/15.0/odoo/models.py", line 1378, in _validate_fields
    check(self)
  File "/home/odoo/src/odoo/15.0/addons/account/models/account_tax.py", line 185, in _validate_repartition_lines
    record._check_repartition_lines(invoice_repartition_line_ids)
  File "/home/odoo/src/odoo/15.0/addons/account/models/account_tax.py", line 170, in _check_repartition_lines
    raise ValidationError(_("Invoice and credit note distribution should each contain exactly one line for the base."))

@yajo
Copy link
Contributor Author

yajo commented Apr 30, 2024

🤔 However it is a percent. The problem is that the tax cannot have repartition lines because Odoo doesn't support the report it targets. What do you suggest?

@pedrobaeza
Copy link
Collaborator

You can have repartition lines, but without tax tags.

@jco-odoo
Copy link
Contributor

I was surprised myself that it passed on runbot, but indeed, better to have it with repartition lines, but without tax tags.

@rafaelbn
Copy link
Contributor

@jco-odoo if we have them without tax tags then we cannot map them to AEAT models

@fw-bot
Copy link
Contributor

fw-bot commented May 8, 2024

1 similar comment
@fw-bot
Copy link
Contributor

fw-bot commented May 24, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Localization about adapting the content to a specify country (usually chart of accounts)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants