Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
3391 Zobrazení

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? 

Avatar
Zrušit
Nejlepší odpověď

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)

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
3
úno 16
5704
1
bře 15
11071
1
bře 15
5304
2
kvě 25
1123
0
bře 25
1384