In #3137 it is prevented to create auditlogs without log lines.
In this particular test, it is tested that no log line is created for excluded
fields. We would expect therefore that no auditlog is created after #3137, but
depending on the setup, an log line may be created for field phone_sanitized
which is not an excluded field in the test.
To fix this, the test is adapted to write another, non excluded field so that
the auditlog is created in any case.
When adding/removing a group in a user (and tracking a user or a partner), odoo sends a 'reified' val 'in_group_{group_id}'. We must convert this value into the real groups_id one.
Odoo allows creating or updating records with values like ``{"many2one_field_id": empty.recordset()}``,
but this crashes when using ``deepcopy``, which fails in recreating the ``api.Environment`` object
attached to the recordset.
This commit should fix the issue by updating the values before passing them to ``deepcopy``.
When a field or a model is unlinked, keep the related audit logs. Denormalize
the field and model info on the logs and log lines so that the information
is still available after the deletion of the related data model.
Also, to improve the performance of the deletion of fields and models,
add indexes on the log's model_id and log line's field_id.
Co-Authored-By: Stefan Rijnhart <stefan@opener.am>