Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
7719 Lượt xem

Hi to all,

In python I have data that I get from an API.

The data looks like that: {19459,XXXXXX, BRAVUS,1}, {19459,XXXXXXX,AVANT,1}

How can I display this data in my own module but in another sub menu item and in a tree view?

Please I really need help.

Finger up to a useful replies. Thanks so much in advance! :)

Juan.


EDIT: If you tell me how to send data to a bill it can also serve as a good answer. TYYY

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

One option is you can create a compute field on the model. And in the function you can have the code to get the data from API and extract the value you want and set that value to the compute field. You can that call that field in the tree view.

For eg:

class model_name(models.Model):
_inherit = 'model.name'

api_data = fields.Text(compute='_get_data', string="Data")

def _get_data(self):
for record in self:
..............
.............. // code to get data from api

record.api_data = value

Ảnh đại diện
Huỷ bỏ
Tác giả

Hi Akhil, thanks so much for your reply. The problem is that I have a function called 'search_calls_by_customer' which calls API and saves data in array called 'clientDataAndBillIdArray'. I need that this array starts at 0 each time I call the API. So if I do a method called '_get_data' I can't access to this data array. Odoo had any method to create a new tree view line for each array object? I need create the tree line in the same function that calls API. Here me py code: client_name= fields.Char('Nombre cliente', readonly=True) client_cif= fields.Char('CIF cliente', readonly=True) bill_id= fields.Char('ID de factura', readonly=True) . . . for key2 in jData2: for key in billIdClientIdArray: if(key2[u'id']==key[u'client']): clientDataAndBillIdArray.append("{"+key2[u'id']+","+key2[u'cif']+","+key2[u'name']+","+key[u'id']+"}") self.client_name=key2[u'name'] I tried this, but only show the last name client of the array. Thank so much in advance! :)

Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 5 20
8899
1
thg 4 25
3682
3
thg 12 22
11604
5
thg 4 24
42161
6
thg 4 24
39012