odoo cron job when I fetch data in odoo from external api I set cron job for automatic insert data but when I insert a data in api and set cron job automatic by 1 minutes Its show the data repeatedly after 1 minute execution. that means same data inserting repeatedly after 1 minutes. But I need to insert 1 data in one time only. how can I do that. Please help me.
here is the code for fetching data from external api:
def get_fees_structure_data(self):
url = "http://localhost:8080/api/v1/admission/applicant/fees"
payload = json.dumps({
"status": "Unpaid"
})
headers = {
'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImNyZWF0ZWQiOjE2NjUzODA1MzUyNjIsInJvbGVzIjpbIkFETUlOIiwiVVNFUiJdLCJleHAiOjE2NjYyNDQ1MzV9.AqRay2CKj1EpvOs4wtNfapdmWQdfdBQS7wwiu9W9CGEXeDmr3_3Lz5b6xRRseTo3Uz02hHeGndicM6c0N4bXIw',
'Content-Type': 'application/json',
'Cookie': 'session_id=7ff9ada3ad9660f00dbf51381e33ff414d7536f6'
}
response = requests.request("GET", url, headers=headers, data=payload)
data = response.json()
for i in data['payload']:
self.env['fees.structure'].sudo().create(
{'unique_id':i['applicantUniqueId'],'name':i['feesStructureName'], 'payment': i['amount'], 'paid': i['paid'], 'date': i['createdAt'], 'state': i['pstatus']}
)
cron job code:
Update Fees Structurefield>
1field>
minutesfield>
ir.actions.serverfield>
-1field>
model.get_fees_structure_data()field>
codefield>
record>