multiple res_partner records for departements.
multiple res_partner records for helpdesk agents.
So there is a many2many relation between departements and helpdesk users
An Dep. can has many helpdesk agents and a helpdesk agent can support many Departements.
In a custom view, when you select a departement you see all the helpdesk users, in the user you see its dept.
many2many in model:
'organisation_relation_ids': fields.many2many('res.organisation.relation', 'res_organisation_type_relation_rel', 'organisation_type_id', 'relation_type_id', 'organisation relations''),
We get into trouble when we activate audittrail on res_partner. When you look at the code in audittrail.py, in method get_data
(1) field_obj = resource_pool._all_columns.get(field).column
if field_obj._type in ('one2many','many2many'):
# check if an audittrail rule apply in super admin mode
if self.check_rules(cr, SUPERUSER_ID, field_obj._obj, method):
# check if the model associated to a *2m field exists, in super admin mode
x2m_model_ids = pool.get('ir.model').search(cr, SUPERUSER_ID, [('model', '=', field_obj._obj)])
x2m_model_id = x2m_model_ids and x2m_model_ids[0] or False
assert x2m_model_id, _("'%s' Model does not exist..." %(field_obj._obj))
x2m_model = pool.get('ir.model').browse(cr, SUPERUSER_ID, x2m_model_id)
field_resource_ids = list(set(resource[field]))
if model.model == x2m_model.model:
# we need to remove current resource_id from the many2many to prevent an infinit loop
if resource_id in field_resource_ids:
field_resource_ids.remove(resource_id)
(2) data.update(self.get_data(cr, SUPERUSER_ID, pool, field_resource_ids, x2m_model, method))
Looping (1) through the fields when it hits 'organisation_relation_ids', the code (2) will call get_data again
So you change departement > recurse get_data for every helpdesk user in organisation_relation_ids > recurse get_data from every dept. > ... endlessly
Is this a bug in audittrail when many2many for the same model? How can we start fixing this? i am happy to start hacking a fix but community feedback is crucial.
I think that is a bug... try to change the logic, I mean restrict the audit trail if the child object is same as Parent object... or skip that column from logging the actions...