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

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

頭像
捨棄
最佳答案

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

頭像
捨棄
作者

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! :)

相關帖文 回覆 瀏覽次數 活動
4
5月 20
8920
1
4月 25
3697
3
12月 22
11622
5
4月 24
42177
6
4月 24
39020