Odoo Help


session global variable in Odoo V8

on 7/1/15, 9:35 AM 1,298 views

Is there any possibility to define a session global variable which is accessible by several functions of the same class?


I have an on_change function which creates a dict array in a wizard (validation).

I would like to use that array within an other function (of the same class)


is there any possibility to define a class level variable which is NOT a fields type

like that:

class base_plan(models.Model):

_name = 'base.plan'

account_number = fields.Char(equired=True)

myarray = []

On 7/3/15, 2:20 PM

I've found the answer. It's easier than I've thought. The answer is python, rather then odoo. :-)

I just have to declare my variable outside of the classes, so it is available by every function within the same module.



from openerp import models, fields, api

lines = []

class base_plan(models.Model):

_name = 'base.plan'

account_number = fields.Char(required=True)

name = fields.Char(required=True)

def func1(self)

    mydict = {}

    #some lines come here


def func2(self)

    for i in range(0, len(lines)):

        # use lines[]

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

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

1 follower(s)


Asked: 7/1/15, 9:35 AM
Seen: 1298 times
Last updated: 7/3/15, 2:26 PM