Create field/attribute that is not saved in database

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:


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

Sam fayad
Melhor Resposta

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.