[6.0] Unable to create employee with a no-admin account

Bug #723713 reported by Thibaut DIRLIK (Logica)
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Low
OpenERP R&D Addons Team 3

Bug Description

Hi,

I can't create an Employee in the hr module if I'm not admin. I got an error from this line of code:

hr.py / l194
_defaults = {
        ...[snip]...
        'address_id': lambda self,cr,uid,c: self.pool.get('res.partner.address').browse(cr, uid, uid, c).partner_id.id
    }

File "/home/openerp6rc1/6.0-Stable/server/bin/addons/hr/hr.py", line 194, in <lambda> 'address_id': lambda self,cr,uid,c: self.pool.get('res.partner.address').browse(cr, uid, uid, c).partner_id.id File "/home/openerp6rc1/6.0-Stable/server/bin/osv/orm.py", line 294, in __getattr__ raise AttributeError(e) AttributeError: 'Field partner_id not found in browse_record(res.partner.address, 7)'

I'm pretty sure the bug come from the fact that you browse on 'uid' ids on res.parter.address (instead of the users table). So it works when the user is admin because the address with id=1 exists. But, in my case, the address with id=7 doesn't.

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Thibaut,

I have checked your issue.
Which group did you assign for another user?

Would you please elaborate with more.

Thanks

Changed in openobject-addons:
status: New → Incomplete
Revision history for this message
Thibaut DIRLIK (Logica) (thibaut-dirlik) wrote :

The other use belongs to these groups :

Project / Manager
Project / User
Purchase / Manager
Purchase / User
Human Resources / Manager
Human Resources / User
Partner Manager
Administration / Configuration
Administration / Access Rights
Employee
Marketing / User
Marketing / Manager
Knowledge / User
Accounting / Invoice
Accounting / Accountant
Accounting / Manager
Project / Methodology / Getting Things Done
Warehouse / Manager
Warehouse / User
Sales / Manager
Sales / User
Sales / User - See All Leads
Useability / Extended View

Moreover, if it was a problem of permissions, the form would'nt even show, whereas in this case the bug happens from the _default, which is called when the form is rendering.

To reproduce the bug, you have to use a user with an ID > to the bigger res.partner.address ID. For example, on an empty DB, without demo data, create 4 users, give the 4th needed rights, and try to create an employee (Normaller you have only one res.partner.address defined, with ID 1, and your user will have ID 4).

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello,

This problem can be reproduce when the database does not contain demo data.
Thanks for the reporting.

Thanks.

Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 3 (openerp-dev-addons3)
importance: Undecided → Low
status: Incomplete → Confirmed
Revision history for this message
Amit Parik (amit-parik) wrote :

Hello,

I am faced the following traceback at server side:

Traceback (most recent call last):
  File "/home/tiny/workspace/openobject-server/openerp/osv/osv.py", line 122, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/tiny/workspace/openobject-server/openerp/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/tiny/workspace/openobject-server/openerp/osv/osv.py", line 167, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/tiny/workspace/openobject-server/openerp/osv/orm.py", line 981, in default_get
    defaults[f] = self._defaults[f](self, cr, uid, context)
  File "/home/tiny/workspace/openobject-addons/hr/hr.py", line 194, in <lambda>
    'address_id': lambda self,cr,uid,c: self.pool.get('res.partner.address').browse(cr, uid, uid, c).partner_id.id
  File "/home/tiny/workspace/openobject-server/openerp/osv/orm.py", line 294, in __getattr__
    raise AttributeError(e)
AttributeError: 'Field partner_id not found in browse_record(res.partner.address, 3)'

Thanks

Changed in openobject-addons:
status: Confirmed → In Progress
Changed in openobject-addons:
status: In Progress → Confirmed
Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
Ashvin Rathod (OpenERP) (ara-tinyerp) wrote :

Hello Thibaut,

I have fixed the problem in lp:~openerp-dev/openobject-addons/trunk-bug-723713-ara branch, It will be merged soon with openobject-addons

Revision ID: <email address hidden>
Revision No: 4463

Thank you,
ara

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

Other bug subscribers

Remote bug watches

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