I am trying to create record in my newly created model.
here is my model
class EtaDocumentTypes(models.Model):
_name = "eta.document.types"
_description = "ETA Documents Types for invoicing"
eta_id=fields.Integer('Document Type ID')
name=fields.Char("Name")
description=fields.Char("Description")
activeFrom=fields.Datetime("Active From",default=None)
activeTo=fields.Datetime("Active To",default=None)
I had writtne a function that works on button click and save records
here is my codedef get_eta_document_types(self):
_create_unverified_https_context = ssl._create_unverified_context
url = "https://api.preprod.invoicing.eta.gov.eg/api/v1/documenttypes"
eta_api_model = self.search([("client_id", "=", self.client_id)])
access_token=str(eta_api_model.access_token)
payload = {}
headers = {
'Accept-Language': 'ar',
'Accept': 'application/json',
'Content-type': 'application/json',
'Authorization': "Bearer 2343"
}
response = requests.request("GET", url, headers=headers, data=payload,verify=False)
self.env['eta.document.types'].sudo().create({
'eta_id': '1',
'name': 'dsad',
'description': 'dsad',
'activeFrom': "2021-03-30 10:50:23",
'activeTo': "2021-03-30 10:50:23"
})
So this code either gives any error nor create record in my model.I am trying it with super user right now.
Thanks Best Regards