[trunk/7.0/6.1]Audit Trail doesn't Work For Users & Groups Object

Bug #1157497 reported by Togar Hutabarat
32
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Medium
OpenERP Publisher's Warranty Team

Bug Description

Dear Team,

I was installing audittrail module, and the I try to create some Audit Rules for some object. Everything was okay until I tried to create Audit Rules for object res.users and res.groups. I found this error when I create new user, edit or delete a user.

Environment Information :
System : Linux-2.6.32-45-generic-i686-with-Ubuntu-10.04-lucid
OS Name : posix
Distributor ID: Ubuntu
Description: Ubuntu 10.04.4 LTS
Release: 10.04
Codename: lucid
Operating System Release : 2.6.32-45-generic
Operating System Version : #102-Ubuntu SMP Wed Jan 2 21:53:06 UTC 2013
Operating System Architecture : 32bit
Operating System Locale : id_ID.UTF8
Python Version : 2.6.5
OpenERP-Client Version : 6.1-20121207-003046
Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
  File "/opt/OpenERP/server/openerp-6.1/openerp/service/netrpc_server.py", line 64, in run
    result = netsvc.dispatch_rpc(msg[0], msg[1], msg[2:])
  File "/opt/OpenERP/server/openerp-6.1/openerp/netsvc.py", line 360, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/opt/OpenERP/server/openerp-6.1/openerp/service/web_services.py", line 586, in dispatch
    res = fn(db, uid, *params)
  File "/opt/OpenERP/server/openerp-6.1/openerp/osv/osv.py", line 121, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/opt/OpenERP/server/openerp-6.1/openerp/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/opt/OpenERP/server/openerp-6.1/openerp/addons/audittrail/audittrail.py", line 494, in execute_cr
    return self.log_fct(cr, uid, model, method, fct_src, *args)
  File "/opt/OpenERP/server/openerp-6.1/openerp/addons/audittrail/audittrail.py", line 291, in log_fct
    old_values = self.get_data(cr, uid_orig, pool, res_ids, model, method)
  File "/opt/OpenERP/server/openerp-6.1/openerp/addons/audittrail/audittrail.py", line 335, in get_data
    values_text[field] = self.get_value_text(cr, 1, pool, resource_pool, method, field, resource[field])
  File "/opt/OpenERP/server/openerp-6.1/openerp/addons/audittrail/audittrail.py", line 192, in get_value_text
    field_obj = (resource_pool._all_columns.get(field)).column
AttributeError: 'NoneType' object has no attribute 'column'

I try to dig the reason why the error only occur for res.users and res.groups. So far I know that in Users and Groups menu, there are some fields (which is placed in Access Rights tab) that is created NOT BY class declaration instead by function, so the field is not saved nor in object neither in class. It is just my thought.

OS: Ubuntu Lucid
OpenERP version: 6.1

Regards,
Togar - ADSOFT

Tags: maintenance

Related branches

Revision history for this message
Rajesh Prajapati (OpenERP) (rpr-tinyerp) wrote :
Changed in openobject-addons:
status: New → Confirmed
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 1 (openerp-dev-addons1)
importance: Undecided → Medium
summary: - Audit Trail doesn't Work For Users & Groups Object
+ [trunk/7.0/6.1]Audit Trail doesn't Work For Users & Groups Object
Revision history for this message
Togar Hutabarat (to-garnet) wrote :

Thank you for getting this bug report confirmed.

Regards,
Togar - ADSOFT

Revision history for this message
Alvar Vilu (alvar-vilu) wrote :

Hi!

In audittrail_objects_proxy get_data method:

            for field in resource:
                if field in ('__last_update', 'id'):
                    continue

This loops trought all fields in model.
It seems that res.partner has some mystical fields in it like a:
'sel_groups_7_12_8': 8, 'sel_groups_53_54': 54

I don't know why they exist or why they are needed but they are not real fields.
So a quick fix will be :

            for field in resource:
                if field in ('__last_update', 'id') or not resource_pool._all_columns.get(field):
                    continue

This way field existance gets verified.

Revision history for this message
Alvar Vilu (alvar-vilu) wrote :
Download full text (6.8 KiB)

This code stil get's it into recursion somehow:

                        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)
                        data.update(self.get_data(cr, SUPERUSER_ID, pool, field_resource_ids, x2m_model, method))

>>> traceback <<<
  File "/usr/lib/python2.7/threading.py", line 524, in __bootstrap
    self.__bootstrap_inner()
  File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 504, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib/python2.7/SocketServer.py", line 582, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 638, in __init__
    self.handle()
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 181, in handle
    rv = BaseHTTPRequestHandler.handle(self)
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 214, in handle_one_request
    return self.run_wsgi()
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 159, in run_wsgi
    execute(app)
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 146, in execute
    application_iter = app(environ, start_response)
  File "/erp/41/openerp/service/wsgi_server.py", line 415, in application
    return werkzeug.contrib.fixers.ProxyFix(application_unproxied)(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/werkzeug/contrib/fixers.py", line 125, in __call__
    return self.app(environ, start_response)
  File "/erp/41/openerp/service/wsgi_server.py", line 403, in application_unproxied
    result = handler(environ, start_response)
  File "/erp/41/openerp/addons/web/http.py", line 502, in __call__
    return self.dispatch(environ, start_response)
  File "/erp/41/openerp/addons/web/http.py", line 472, in __call__
    return self.app(environ, start_wrapped)
  File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 411, in __call__
    return self.app(environ, start_response)
  File "/erp/41/openerp/addons/web/http.py", line 527, in dispatch
    result = handler(request)
  File "/erp/41/openerp/addons/web/http.py", line 591, in <lambda>
    return lambda request: JsonRequest(request).dispatch(method)
  File "/erp/41/openerp/addons/web/http.py", line 203, in dispatch
    response["result"] = method(self, **self.params)
  File "/erp/41/openerp/addons/web/controllers/main.py", line 1129, in call_kw
    return self._call_kw(req, model, method, args, kwargs)
  File "/erp/41/openerp/addons/web/controllers/main.py", line 1121, in _call_kw
    return getattr(req.session.model(model), method)(*args, **kwargs)
  File "/erp/41/openerp/addons/web/session.py", line 43...

Read more...

Changed in openobject-addons:
status: Confirmed → In Progress
Changed in openobject-addons:
assignee: OpenERP R&D Addons Team 1 (openerp-dev-addons1) → OpenERP Publisher's Warranty Team (openerp-opw)
tags: added: maintenance
Revision history for this message
Ravi Gohil (OpenERP) (rgo-openerp) wrote :

Hi,

For V7, this issue has been fixed in the branch: lp:~openerp-dev/openobject-addons/7.0-opw-589931-rgo. This branch will soon be reviewed by our experts and once it gets approved by them, it'll be merged with main stable.

Thanks.

Revision history for this message
Togar Hutabarat (to-garnet) wrote :

Hi Ravi,

Thank you for your information. Glad to know that this bug has been fixed in v7.0. But unfortunately, I still need it in v6.1. Anyway, v7.0 is great great version of OpenERP.

Thanks.

Revision history for this message
Ravi Gohil (OpenERP) (rgo-openerp) wrote :

This issue should not be faced in V6.1 after applying the attached patch.

Revision history for this message
Togar Hutabarat (to-garnet) wrote :

Wow! Thank you for the patch. But how can I apply this patch? Is there any way like "Upgrade Module" ? Please guide me..

Revision history for this message
Ravi Gohil (OpenERP) (rgo-openerp) wrote :

There are various ways of applying patch depending on the OS your OpenERP server is running. Let me share a few,

Note: From the traceback provided in bug report, I'll assume that your audittrail.py(which contains fix) is located at path in your Ubuntu machine, /opt/OpenERP/server/openerp-6.1/openerp/addons/audittrail/audittrail.py

Now, you can use the patch command from terminal like this,
patch /opt/OpenERP/server/openerp-6.1/openerp/addons/audittrail/audittrail.py < audittrail_res_user6.1.patch

or, you can manually go to the file location and open the file in your desired editor and make the changes by yourself.

After successfully applying the patch, you need to restart the openerp service, below command should do it(assuming "openerp" as the OpenERPV6.1 service name),
sudo service openerp restart

Hope this helps.

Changed in openobject-addons:
status: In Progress → Fix Committed
Revision history for this message
Martin Trigaux (OpenERP) (mat-openerp) wrote :

Hello,

It now works for these models. It was fixed in the revision below as well as some other issues.

revno: 9808 [merge]
revision-id: <email address hidden>

Changed in openobject-addons:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.