Context_get can misbehave for M2O.

Bug #594496 reported by Christophe CHAUVET
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
High
Unassigned
5.0
Fix Released
High
JMA(Open ERP)

Bug Description

In 5.0.11

I had a field in res.users call context_warehouse_id (many2one) as

----------------8<-------------------8<-----------------
class ResUsers(osv.osv):
    _inherit = 'res.users'

    _columns = {
        'context_warehouse_id': fields.many2one('stock.warehouse', 'Warehouse',
            help='Enter the default warehouse for this user, leave blank if user works on many warehouse'),
    }

    _defaults = {
        'context_warehouse_id': lambda *a: False,
    }
----------------8<-------------------8<-----------------
i try to login with the GTK client and i have this traceback
----------------8<-------------------8<-----------------
[2010-06-15 09:46:41,188] ERROR:orm:[01]:
[2010-06-15 09:46:41,188] ERROR:orm:[02]: Environment Information :
[2010-06-15 09:46:41,189] ERROR:orm:[03]: System : Linux-2.6.32-22-generic-i686-with-Ubuntu-10.04-lucid
[2010-06-15 09:46:41,189] ERROR:orm:[04]: OS Name : posix
[2010-06-15 09:46:41,189] ERROR:orm:[05]: Distributor ID: Ubuntu
[2010-06-15 09:46:41,189] ERROR:orm:[06]: Description: Ubuntu 10.04 LTS
[2010-06-15 09:46:41,189] ERROR:orm:[07]: Release: 10.04
[2010-06-15 09:46:41,190] ERROR:orm:[08]: Codename: lucid
[2010-06-15 09:46:41,190] ERROR:orm:[09]: Operating System Release : 2.6.32-22-generic
[2010-06-15 09:46:41,190] ERROR:orm:[10]: Operating System Version : #36-Ubuntu SMP Thu Jun 3 22:02:19 UTC 2010
[2010-06-15 09:46:41,190] ERROR:orm:[11]: Operating System Architecture : 32bit
[2010-06-15 09:46:41,190] ERROR:orm:[12]: Operating System Locale : fr_FR.UTF8
[2010-06-15 09:46:41,191] ERROR:orm:[13]: Python Version : 2.6.5
[2010-06-15 09:46:41,191] ERROR:orm:[14]: OpenERP-Server Version : 5.0.10
[2010-06-15 09:46:41,191] ERROR:orm:[15]: Last revision No. & ID :
[2010-06-15 09:46:41,191] ERROR:orm:[16]: Programming error: field '__getstate__' does not exist in object 'stock.warehouse' !
Exception in thread Thread-13:
Traceback (most recent call last):
  File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner
    self.run()
  File "/home/neolog/instances/neolog/server/bin/netsvc.py", line 391, in run
    ts.mysend(result)
  File "/home/neolog/instances/neolog/server/bin/tiny_socket.py", line 50, in mysend
    msg = cPickle.dumps([msg,traceback])
  File "/usr/lib/python2.6/copy_reg.py", line 84, in _reduce_ex
    dict = getstate()
TypeError: 'bool' object is not callable
----------------8<-------------------8<-----------------

The problem is the many2one with getattr() return a browse_record or browse_null

I attach a patch to correct this behaviour

Regards,

Revision history for this message
Christophe CHAUVET (christophe-chauvet) wrote :
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Hello Christophe Chauvet,

I tried with several databases, but I did not face such an error.

Would you attach a module here?

Thanks.

Revision history for this message
Christophe CHAUVET (christophe-chauvet) wrote :

Hi Jay

You can find the module as attachment

Step to reproduce

1) new database with demo
2) Install the test_preference module
3) go to the menu user -> preferences
4) fill the default warehouse field
5) and save (the screen must be freeze and a traceback appear on the server side)
6) restart openerp server
7) try to login (the screen must be freeze also)

Regards,

Revision history for this message
JMA(Open ERP) (jma-openerp) wrote :

Hello ,

Thanks for reporting, it can really break the channel.

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Thanks for the patch.
It has been fixed by revision 2071 <email address hidden>.

Changed in openobject-server:
status: Confirmed → Fix Released
summary: - Impossible to login after create a many2one field in res.users
+ Context_get can misbehave for M2O.
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.