I have a problem. I want to display data from external API in tree view with depends/refresh automatically. Installation is success and I have the data in external url. But they won't appear in the tree view when I requested it. I am still new at this. Please help me. I am stuck at this.
<<<<<<<<<This is my function>>>>>>>>
@api.depends()
def get_folders_request(self):
# https = urllib3.PoolManager()
url = ""
user = ""
querystring = {"limit":"10","offset":"0","sort":"desc"}
headers = {"Accept": "application/json"}
response = requests.get(url, headers=headers, params=querystring, auth=(user, ''))
res = simplejson.loads(response.text)
_logger.info("response: %s", res)
if 'error_code' in res:
raise UserError(res['message'])
for record in self:
record.name = res['name']
record.email_blacklist = res['totalBlacklisted']
record.email_subscribers = res['totalSubscribers']
record.unique_subscribers = res['uniqueSubscribers']
record.email_count = res['count']
<<<<<<<<<<<<<This is my views>>>>>>>>>>>>
<record id="view_sib_template_tree" model="ir.ui.view">
<field name="name">view.sib.template.tree</field>
<field name="model">sendinblue.get_folders</field>
<field name="type">tree</field>
<field name="priority" eval="8"/>
<field name="arch" type="xml">
<tree string="LeadsInBlue">
<field name="id"/>
<field name="name"/>
<field name="email_blacklist"/>
<field name="email_subscribers"/>
<field name="unique_subscribers"/>
<field name="email_count"/>
</tree>
</field>
</record>
As you try doing is not possible. It's important to understand the odoo logical.
All informations showing in Odoo coming from a DB.
When you try called a field with a compute method (I think you try a compute method because you set an @api.depends). If you don't have a record the compute will not be called.
If you want connected a external data to your Odoo, you have 2 possibilities.
The easier method is create the external data in your database.
To do this you can create a CRON, this CRON will call your extrenal data and set in DB.
In Odoo you have a commun method called read. This method is called each time when the Odoo try read data from cloud. You can overriden this method of your model to return "ephemeral" data.
This option is for my opinion the better solution BUT this method is very complicated to make it realy 100% sure. And I don't will explain all the solution here.
Juste for your information.
def read(self, fields,load)
).