Ir al contenido
Menú
Se marcó esta pregunta

I have created an API for creating a ticket. I just started working on it.

I am getting an error. When I access the API I select the related database and in that database, if my module is installed then I get the response. 
But If I open the URL in incognito mode of the browser then It gives me the error. because the database is not selected by default in incognito mode


Here is the code of the controller file

from odoo import http
from odoo.http import request
import json


class MetaWithHelpdesk(http.Controller):

@http.route('/api/create_ticket', type='http', auth='public', methods=['POST', 'GET'], csrf=False)
def create_ticket(self, **kw):
print('reached')
try:
return json.dumps({'message': 'Ticket created successfully'})
except Exception as e:
return json.dumps({'error': str(e)})


here is the code of __manifest__.py

# -*- coding: utf-8 -*-
{
'name': "Helpdesk Ticket",

'summary': """
Helpdesk Ticket"""
,

'description': """
Helpdesk Ticket
"""
,

# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/16.0/odoo/addons/base/data/ir_module_category_data.xml
# for the full list
'category': 'helpdesk',
'version': '16.0.1',

# any module necessary for this one to work correctly
'depends': ['base', 'web'],
'auto_install': True,
'bootstrap': True, # load translations for login screen,
'license': 'LGPL-3',
# always loaded
'data': [
# 'security/ir.model.access.csv',
'views/views.xml',
],
}



Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
sept 23
1948
0
jun 22
2609
3
may 21
13307
2
dic 24
1247
1
ago 24
1494