Monday, October 18, 2010

Fabien Pinckaers: OpenERP v6, new logging system for end-users

Fabien Pinckaers: OpenERP v6, new logging system for end-users: "In order to improve the useability of OpenERP v6 and make it easier to use and learn for new users, we added a logging system on main action..."

Today, I saw this new post from the CEO of OpenERP, as always I've watched the code:

http://bazaar.launchpad.net/~openerp/openobject-server/trunk/annotate/head:/bin/addons/base/res/res_log.py

class res_log(osv.osv):
    _name = 'res.log'
    _columns = {
        'name': fields.char('Message', size=128, help='The logging message.', required=True),
        'user_id': fields.many2one('res.users','User', required=True),
        'res_model': fields.char('Object', size=128),
        'context': fields.char('Context', size=250),
        'res_id': fields.integer('Object ID'),
        'secondary': fields.boolean('Secondary Log', help='Do not display this log if it belongs to the same object the user is working on'),
        'create_date': fields.datetime('Created Date', readonly=True),
        'read': fields.boolean('Read', help="If this log item has been read, get() should not send it to the client")
    }
    _defaults = {
        'user_id': lambda self,cr,uid,ctx: uid,
        'context': "{}",
        'read': False
    }
    _order='create_date desc'

Well, this is the logger code, what do you think about it?

Let's look at the get method:


    def get(self, cr, uid, context=None):
        unread_log_ids = self.search(cr, uid,
            [('user_id','=',uid), ('read', '=', False)], context=context)
        ...
        self.write(cr, uid, unread_log_ids, {'read': True}, context=context)
        return result



As you can see the get method returns the unread messages.
Now, imagine you have 2 users using the same login. For example I've a customer using a backoffice login for 4 users.

Imagine 2 users (Mr Smith and Mr West) using the same user. The first connected will see all the unread messages and the other no messages...




4 comments:

  1. Baring in mind the messages are designed to be shown immediately after something is saved (e.g. an order is confirmed) they really only need to be shown to the user that performed the action.

    Since they are saved in the db, it would be possible to add a 'History' tab to whatever entity to show historical log entries to other users, if needed. (there may already be a 'log' screen in v6, I have not checked.

    Looks fine to me ;)

    ReplyDelete
  2. You don't understand I agree that only the user performing the action need to see it. But if you have 2 users with the same login. The first one valide a purchase and the other is connecting to the purchase module then the second one will see the logs and not the first one. This can be disturbing because the first one will think he made nothin...

    ReplyDelete
  3. As usual, openerphell is creating FUD around OpenERP. In every application in the world, users are identified by their login and what they do are attached to their ID.

    The way it is implemented is smart because it allows to get all side effects of an action (if you confirm a SO, you get a log on all events, including those not directly related to an SO: confirm a delivery, trigger a manufacturing, create a draft invoice, etc.)

    ReplyDelete
  4. Then I think you don't have any customers... Some companies don't want to use a login for a person but for example a login for the back-office, a login etc... This is not smart but a normal feature and it is not well implemented.

    ReplyDelete