OCA/account-financial-tools

[15.0] account_chart_update : error on update

saxomanu opened this issue · 1 comments

Module

account_chart_update

Describe the bug

When updating the chart, have an exception :
bad query: DELETE FROM account_tax_repartition_line WHERE id IN (38)
ERROR: update or delete on table "account_tax_repartition_line" violates foreign key constraint "account_move_line_tax_repartition_line_id_fkey" on table "account_move_line"
DETAIL: Key (id)=(38) is still referenced from table "account_move_line".

2023-03-07 12:11:12,181 1190891 DEBUG mercioscar_test odoo.service.model: IntegrityError
Traceback (most recent call last):
File "/opt/odoo/odoo/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo/odoo/http.py", line 348, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/odoo/odoo/http.py", line 916, in call
# The eq and hash magic methods allow older EndPoint objects
File "/opt/odoo/odoo/odoo/http.py", line 535, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/odoo/addons/web/controllers/main.py", line 1346, in call_button
:param int offset: sequence number for first record in ids, allows
File "/opt/odoo/odoo/addons/web/controllers/main.py", line 1334, in _call_kw
File "/opt/odoo/odoo/odoo/api.py", line 464, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/opt/odoo/odoo/odoo/api.py", line 451, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "/opt/odoo/merci_oscar_test/account-financial-tools/account_chart_update/wizard/wizard_chart_update.py", line 376, in action_update_records
self._update_taxes_pending_for_accounts(todo_dict)
File "/opt/odoo/merci_oscar_test/account-financial-tools/account_chart_update/wizard/wizard_chart_update.py", line 1116, in _update_taxes_pending_for_accounts
tax.write(vals)
File "/opt/odoo/odoo/addons/point_of_sale/models/account_tax.py", line 26, in write
return super(AccountTax, self).write(vals)
File "/opt/odoo/merci_oscar_test/connector/component_event/models/base.py", line 109, in write
result = super(Base, self).write(vals)
File "/opt/odoo/odoo/odoo/models.py", line 3861, in write
self.modified(relational_names, before=True)
File "/opt/odoo/odoo/odoo/fields.py", line 3296, in write
return self.write_batch([(records, value)])
File "/opt/odoo/odoo/odoo/fields.py", line 3317, in write_batch
return self.write_real(records_commands_list, create)
File "/opt/odoo/odoo/odoo/fields.py", line 3493, in write_real
flush()
File "/opt/odoo/odoo/odoo/fields.py", line 3451, in flush
comodel.browse(to_delete).unlink()
File "/opt/odoo/merci_oscar_test/connector/component_event/models/base.py", line 118, in unlink
result = super(Base, self).unlink()
File "/opt/odoo/odoo/odoo/models.py", line 3667, in unlink
# Check if the records are used as default properties.
File "", line 2, in execute
File "/opt/odoo/odoo/odoo/sql_db.py", line 90, in check
return f(self, *args, **kwargs)
File "/opt/odoo/odoo/odoo/sql_db.py", line 313, in execute
if self._default_log_exceptions if log_exceptions is None else log_exceptions:
psycopg2.errors.ForeignKeyViolation: update or delete on table "account_tax_repartition_line" violates foreign key constraint "account_move_line_tax_repartition_line_id_fkey" on table "account_move_line"

Update only taxes and see what happens. The module works. The problem should be in you data. Test it on runboat (OCA). If you can reproduce it in runboat then we can look the STR (step to reproduce) in OCA runboat. Thank! 😄