Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
audittrail on write res_parent loops endless when there is a many2many relation to other res_partner(s)
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 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:
(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.
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 10/10/14, 4:29 AM|
|Seen: 840 times|
|Last updated: 3/16/15, 8:10 AM|