Why would I get python UnboundLocalError when calling super()? -


my class this:

from openerp import tools openerp.osv import osv, fields import requests import logging import json  _logger = logging.getlogger(__name__)  class stock_move(osv.model):     _inherit = 'stock.move'      def create(self, cr, uid, vals, context=none):         new_id = super(stock_move, self).create(cr, uid, vals, context=context) 

but when run it, this:

file "/opt/odoo/ebuynow/ebn_oddjobs/models.py", line 15, in create     new_id = super(stock_move, self).create(cr, uid, vals, context=context) unboundlocalerror: local variable 'stock_move' referenced before assignment 

i'm pretty sure correct way use super(), because code working fine on system. question more asking if there out there knows might in system or python environment cause not recognize stock_move class name purpose of calling parent class's create() method.

system ubuntu server 14.04, python 2.7.6. previous system code ran on ubuntu desktop 14.04 running python 2.7.6.

i don't see reason why happen. why python think stock_move local variable?

edit:

after changing class name, this:

new_id = super(stock_move_too, self).create(cr, uid, vals, context=context) unboundlocalerror: local variable 'stock_move' referenced before assignment 

stock_move isn't used @ , error still shows??

edit2:

the problem caused odoo-server not shutting down when issued "sudo /etc/init.d/odoo-server restart" command. once killed process, restarted it, began restarting properly.

you used same name inside create method, python earmarked stock_move local, not global name.

python determines scope of names at compile time, , name scope applies whole block. names seen local bind name anywhere in function scope; means used name in assignment (stock_move = ...), used parameter name function, used in import (from somewhere import stock_move) or used target in for loop, with statement or except handler (with foo stock_move, etc.).


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -