콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
2623 화면

To make my code more readable, I need two methods so that the first one loads in memory the data that the second one will process.


class Sample(models.Model)

    data = []

    def get_data():

        self.data = _get_data

    def process_data():

       for item in self.data:

          _process_data(item)

The problem I'm having is that the first method can't write to the "field/attribute" because it says: : "'sample.sample' object attribute 'data' is read-only" while evaluating

아바타
취소
베스트 답변

Hi,
I think you should try to use Odoo Fields in order to achive your goal, I don't think it is appropriate to define lists and tuples or dictionaries in Odoo models.
instead, I suggest to write Cron Object that fetch those data (while you can define that 'data' list inside the function (temporary values) then process them and apply changes, you can also set your options about how many times you want that fuction to run or every how many minutes etc...

아바타
취소
작성자

Thanks for your reply. I expand the context a bit:

* The _get_data function gets data from a remote server
* These data must be enriched with the information registered in Odoo
* The processes are complex and go through about 3 or 4 methods
* That's why my idea was to have a list with data in memory so as not to have to extend the list of arguments of those 3 or 4 methods.

관련 게시물 답글 화면 활동
1
2월 25
1193
3
5월 25
1705
1
4월 25
1272
3
9월 24
14160
0
8월 24
1249