跳至內容
選單
此問題已被標幟
1 回覆
2776 瀏覽次數

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? 

頭像
捨棄
最佳答案

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)

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
3
2月 16
5359
1
3月 15
10740
1
3月 15
4989
2
5月 25
549
0
3月 25
862