Calculated field as a list in Odoo 10

I have code that retrieves some information on the Internet and returns it as a Python list. I want to display (without saving to the database) as an Odoo tree.

To do this, I created a calculated field as follows:

created_time = fields.Char(compute='_compute_created_time')

@api.multi
def _compute_created_time(self):
    my_data = self.my_internet_data()
    created_time_list = []

    for created_times in my_data:
        created_time_list.append(created_times['created_time'])

    self.created_time = created_time_list

When a tree render is displayed, it displays one row with all the data in it. This is not the way I want.

I want to display each individual information in a list on my line. I believe that for this I should not use fields.Char () as a field type. So what type of field to use for me or some other solution?

+4
source share
1 answer

, , , TransienModel odoo rocords .

selecct (Model) , , .

, :

.

odoo (self.env.cr) , create .

, .

@api.multi
def show_result(self):
   #1- fetch data
   #2- insert data.
   #3- return window action
   return {
       'type': 'ir.actions.act_window',
       'name': '...'
       'res_model': 'your.transienModel.name',
       ..
       ..
       ..
       # special filter here to show only the inserted recrods
       # like date or search parameters.
       'domain': []
   }
+2

Source: https://habr.com/ru/post/1681530/


All Articles