Odoo Help


Strange behavior of record rule

Tomas Parnarauskas
on 6/17/13, 4:38 AM 1,928 views

I encountered strange behavior of custom access rule and it happens at only one database (don't know how it is different from others). So I created this record rule (on res.partner object for read, write, create and delete):


When I create new user and give it group with this rule it gives me error when I try to create new partner (or when I try to open that users window, for example through salesperson field (it looks like that user don't have access to himself..)):

image description

The stranger thing is that this error does not show up with old users. When I give them same access rights, it creates new partners without problems. Also if I duplicate old user it also bypasses this error. So it seems something is wrong with creating new users.

I also tried to backup and restore that database to another server where are no such problems, but it gives this error there too. So it seems modules are fine. Something has to be with configuration in database, but I don't know what could be wrong. Any ideas?

EDIT: I managed to pinpoint why this rule was behaving so strange with newly created users. The problems seems to be with module I created. That module sets default salesman on partner when it presses create button in partners view. For example if John Doe presses button to create new partner he will be automatically assigned as salesman to that partner. Somehow this module blocks new users as being default ones for salesman on any partner. With old users (before installing that module) it works even when that module is installed.

My module is very simple, but I don't see it why it corrupts newly created users (and only when record rule that I talked earlier about is applied). Code looks like this:

from openerp.osv import osv

class res_partner(osv.osv):
    _name = 'res.partner'
    _inherit = 'res.partner'
    _defaults = {
        'user_id': lambda obj, cr, uid, context: uid,


Should such module have to be defined somehow differently? Or did I miss something?


ClueLogics Technologies Pvt. Ltd.

--ClueLogics Technologies Pvt. Ltd.--
| 6 5 8
Delhi NCR, India
--ClueLogics Technologies Pvt. Ltd.--

 ClueLogics Technologies Pvt Ltd is a Software product and services provider. We are positioned to deliver robust, rapid and reliable Information Technology solutions that work. What we succeed upon is Technology and Technical Expertise. The industry review of ClueLogics has been commendable for the past years as most of its business comes from repeat orders by highly satisfied clients.

ClueLogics Technologies Pvt. Ltd.
On 6/17/13, 5:27 AM


this problem happen many time because, there is a security rule already added for this case

for solved it you have to do one thing

  1.  your user company should be false (means no company selected )  or the main company  in ` user record`
  2 . you will have to create a complete rule for that company if company is change and you want to select new company for this user

then there will be no error's

even you can check it, just inactive that rule (a default rule) from settings - --> technical --> security --> records rules menu , then you will see that this error never happen


I tried to make inactive 'user rule'. But problem is still here (I tried to disable default company rule too). Also in my database there is only one company. And it seems strange that old users don't get this error, when they are added to the same company as new users. Am I doing something wrong?

NOD Baltic, UAB, Tomas Parnarauskas
on 6/17/13, 5:48 AM

must check res.partner company rule , for same company there should not be any problem

ClueLogics Technologies Pvt. Ltd.
on 6/17/13, 6:54 AM

I disabled that rule, but still getting this error. Don't understand what's wrong. Also it does not happen in any other database (record rules are the same) with or wthout checking res.partner company rule.

NOD Baltic, UAB, Tomas Parnarauskas
on 6/17/13, 8:37 AM

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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 6/17/13, 4:38 AM
Seen: 1928 times
Last updated: 3/16/15, 8:10 AM