Currently, models account.account or account.tax have a m2o field to its template. That means that if we remove an account or tax from the template file (account_es, account_fr, etc), accounts cannot be removed from account.template (or account.tax.template) tables.
That sounds a bit strange to me, as the idea of separating account.template and account.account should be precisely that templates keep changing over time, but not the accounts.
So, do you think adding a “SET NULL” to cascade’s of m2o field be appropriate?
Traceback about can’t delete account.tax.template because is referenced to account.tax:
trytond.model.modelsql.ForeignKeyError: ('UserError', ('Los registros no pueden eliminarse porque se utilizan en el campo "Plantilla" de "Impuesto contable".', ''))
2144 139941849138944 [2019-06-15 14:27:54,864] ERROR trytond.convert Could not delete id: 164 of model account.tax.template
There should be some relation that points to this resource
You should manually fix this and restart --update=module
Traceback (most recent call last):
File "/home/administrator/calfruitos_next/trytond/trytond/convert.py", line 814, in post_import
Model.delete([Model(db_id)])
File "/home/administrator/calfruitos_next/trytond/trytond/model/modelsql.py", line 159, in wrapper
return func(cls, *args, **kwargs)
File "/home/administrator/calfruitos_next/trytond/trytond/model/modelsql.py", line 1127, in delete
**error_args))
Moreover, removing a template is in most of the case not the right thing. If the template was there, it means it was useful during a period. So it is better to fill an end_date.
the topic is “Allow to remove account and tax templates?” The traceback show can’t remove a tax.template that is not more defined in XML account module.
“end_date” is not valid option in our case. We need to remove (deprecated taxes because the definition theaccount chart in 3.x and 5.x are changed).
IIRC there where some taxes on the trytonspains’ account_es fwhere the end_date it was already set.
Those taxes where removed when the account_es was included as oficial module.
If you are in this case, the migration is not supported out of the box and you should update the data on the database. Feel free to ping me if you have any issues.
It will be great to publish a migration script so others can benefit also.
There is available in NaN-TIC upgrades project with other scripts o queries (in bitbucket) because account module don’t support the feature that in case the XML changed, remove deprecated taxes (because try to remove in ir.model.data and can’t).