Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1593 Visualizzazioni

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
set 23
2456
0
giu 22
2997
3
mag 21
13738
2
dic 24
2143
1
ago 24
2230