Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
2794 Vizualizări

Somehow I can't define a local class variable that I can read and write to in multiple methods.


class Queue(models.Model):
​myVar = {}

​def method(self):
​​ ​self.myVar = {"var":"value"}


Error:

ValueError: : "'module.model' object attribute 'var' is read-only" while evaluating


How would this be approached in Odoo? 

Imagine profil
Abandonează
Cel mai bun răspuns

Hi

perhaps you can try to access from class level using dot notation.

Therefore, the solution might be close to :

Queue.myVar = {"var":"value"}

Queue is the class and myVar is part of the Queue class.

Or, if it still unable to access it you need to identify the upper level like the module name or the file name like

​YourModule.YourFile.Queue.myVar = {"var":"value"}

Best regards,

Altela (altelasoftware.com)

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
3
feb. 16
5376
1
mar. 15
10748
1
mar. 15
4999
2
mai 25
596
0
mar. 25
878