Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
4791 Vizualizări

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 code

def 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
Imagine profil
Abandonează
Cel mai bun răspuns
self.env['eta.document.types'].sudo().create({

'name': 'dsad',
'description': 'dsad',
'activeFrom': "2021-03-30 10:50:23",
'activeTo': "2021-03-30 10:50:23"

})

Try this, specifying the id would create record in that id
Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
iun. 21
2832
0
ian. 22
3973
1
iul. 25
2319
2
iul. 25
7797
2
iul. 25
4199