ORM: Crash on update with fields.function() and store=True)

Bug #318543 reported by Xavier ALT
2
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Undecided
Unassigned

Bug Description

After adding a functional field with store=True, and launching server in update mode (-u MODULE), it crash with the following traceback:

[Sun Jan 18 2009 21:44:58] WARNING:init:<class 'osv.fields.function'> type not supported!
Traceback (most recent call last):
  File "./openerp-server.py", line 106, in <module>
    pooler.get_db_and_pool(db, update_module=tools.config['init'] or tools.config['update'])
  File "/home/dex/w/oerp/dex4/server/bin/pooler.py", line 40, in get_db_and_pool
    addons.load_modules(db, force_demo, status, update_module)
  File "/home/dex/w/oerp/dex4/server/bin/addons/__init__.py", line 665, in load_modules
    load_module_graph(cr, graph, status, report=report)
  File "/home/dex/w/oerp/dex4/server/bin/addons/__init__.py", line 557, in load_module_graph
    init_module_objects(cr, m, modules)
  File "/home/dex/w/oerp/dex4/server/bin/addons/__init__.py", line 313, in init_module_objects
    result = obj._auto_init(cr, {'module': module_name})
  File "/home/dex/w/oerp/dex4/server/bin/osv/orm.py", line 1500, in _auto_init
    cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" %s' % (self._table, k, get_pg_type(f)[1]))
TypeError: 'NoneType' object is unsubscriptable

Here is the code i used to reproduce the problem:
<code>
class res_partner_function_index_code(osv.osv):

        def _get_oops(self, cr, uid, ids, field_name, arg, context):
                return dict([(id, "Ooops") for id in ids])

        _inherit = 'res.partner.function'
        _columns = {
                'code': fields.char('Code', size=8, select=True),
                'oops': fields.function(_get_oops, type='char', size=64, method=True, store=True),
        }
res_partner_function_index_code()
</code>

Versions:
openobject-server: 1602

Revision history for this message
Xavier ALT (dex-phx) wrote :

Here is a patch!

Revision history for this message
Stephane Wirtel (OpenERP) (stephane-openerp) wrote :

Thank you for your patch, it has been merged into the trunk.

Changed in openobject-server:
status: New → 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.