Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
615 Zobrazení

hello i'm trying to fetch some data from an external api and display it on odoo, i tried to use crons, the response is being displayed on the terminal each few minute but nothing gets displayed, instead i get error No action with id '335' could be found check the code below


python:
class YalidineDashboard(models.Model):   
_name = 'hamiz_api.yalidine'   
_description = 'Fetches Parcel\'s Data from Yalidine Dashboard'

tracking = fields.Char(string='Tracking Code')    assurance = fields.Boolean(string='Insurance')    status = fields.Char(string='Status')    first_name = fields.Char(string='First Name')    family_name = fields.Char(string='Family Name')    commune = fields.Char(string='Commune')    wilaya = fields.Char(string='Wilaya')    stopdesk = fields.Char(string='Stopdesk')    label_url = fields.Char(string='Pr')

 @api.model    
def fetch_data_from_api(self):       
response = requests.get('http://127.0.0.1:5000/parcels')       
if response.status_code == 200:
     self.search([]).unlink()           
​for item in data:             
​self.create({'tracking': item.get('tracking'),                    'assurance': bool(item.get('assurance')),                    'status': item.get('status'),                    'first_name': item.get('name'),                    'family_name': item.get('family_name'),                    'commune': item.get('commune'),                    'wilaya': item.get('wilaya'),                    'stopdesk': item.get('stopdesk'),                    'label_url': item.get('label_url'),                })       
else:            raise Exception('Failed to fetch data from API')       
return True this is the xml code:

                        Yalidine                        code            model.fetch_data_from_api()       

 

name="Fetch Yalidine Data"                  

action="action_fetch_yalidine_data"                 

 sequence="10"/>

             

Fetch Yalidine Data            

            

1            

minutes            

-1           

 model.fetch_data_from_api()            

       

     




Avatar
Zrušit