> - four empty writes on res.partner.address where no changes are logged (not
> correct)
yes but no, you didn't implemented it in the right way: what you should do is avoid creating the audittrail log if there is no log line, instead of creating it then deleting it if there is no line. It will avoid useless operations.
For that, you need to do a small change:
=> replace the function
self.create_log_line(cr, uid, log_id, model, lines)
by
self.create_log(cr, uid, model, lines)
> - one write on res.partner.address with the data you just created
> (incorrect, the method logged should be 'create' instead of 'write', otherwise
> it's ok)
i know, but it's not a argument. You can force the method to use. For example, try to add those 2 lines (it seems doing the trick but i didn't test completly):
=== modified file 'audittrail/audittrail.py'
--- audittrail/audittrail.py 2011-11-08 16:55:34 +0000
+++ audittrail/audittrail.py 2011-11-09 09:43:22 +0000
@@ -354,6 +357,8 @@ vals = {'method': method,'object_id': model.id,'user_id': uid_orig } for resource in resource_data: resource_id = resource['id']
+ if resource_id not in dict_to_use.keys():
+ vals.update({'method': 'create'}) vals.update({'res_id': resource_id}) log_id = log_pool.create(cr, uid, vals) lines = []
> - four empty writes on res.partner.address where no changes are logged (not
> correct)
yes but no, you didn't implemented it in the right way: what you should do is avoid creating the audittrail log if there is no log line, instead of creating it then deleting it if there is no line. It will avoid useless operations.
For that, you need to do a small change: create_ log_line( cr, uid, log_id, model, lines) create_ log(cr, uid, model, lines)
=> replace the function
self.
by
self.
def create_log(self, cr, uid, model, lines=[]): get('audittrail .log'). create( cr, uid, vals, context)
if not lines:
return True
vals = { ... }
vals['lines] = [(0, 0, { ... }), ...]
return self.pool.
> - one write on res.partner.address with the data you just created audittrail. py' audittrail. py 2011-11-08 16:55:34 +0000 audittrail. py 2011-11-09 09:43:22 +0000
vals = {'method': method,'object_id': model.id,'user_id': uid_orig }
for resource in resource_data:
resource_ id = resource['id'] {'method' : 'create'})
vals. update( {'res_id' : resource_id})
log_ id = log_pool.create(cr, uid, vals)
lines = []
> (incorrect, the method logged should be 'create' instead of 'write', otherwise
> it's ok)
i know, but it's not a argument. You can force the method to use. For example, try to add those 2 lines (it seems doing the trick but i didn't test completly):
=== modified file 'audittrail/
--- audittrail/
+++ audittrail/
@@ -354,6 +357,8 @@
+ if resource_id not in dict_to_use.keys():
+ vals.update(
i set it back to 'work in progress' ;-)
Quentin