Comment 6 for bug 944197

Revision history for this message
Daniel Reis (dreis-pt) wrote :

The above branch doesn't fix the issue.
The problem is that Rules are only "registered" the first time the the scheduler action runs, which by 6.1 defaults happens at 1 hour intervals.
A workaround might be to reduce interval for the "Check Action Rules" scheduled action (say, every 5mn).
The solution should be the server to register the action rules as soon as it finishes loading modules.

The closes thing I came up is implemented a workaround as part a Action Rule Triggers module: http://apps.openerp.com/addon/7738.
In base_action_rule.py, the users.login() is extended to force Rules be registered as soon as a user logins:

#Force register hooks on user Login, to not depend on scheduler
#BUG https://bugs.launchpad.net/openobject-addons/+bug/944197
class users(osv.osv):
    _inherit = "res.users"

    def login(self, db, login, password):
        #Perform login
        user_id = super(users, self).login(db, login, password)
        #Register hooks
        cr = pooler.get_db(db).cursor()
        rule_pool = pooler.get_pool(db).get('base.action.rule')
        rule_ids = rule_pool.search(cr, 1, [])
        rule_pool._register_hook(cr, 1, rule_ids)
        rule_ids = None
        cr.close()
        #End
        return user_id
users()