Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda

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
Buang
Post Terkait Replies Tampilan Aktivitas
0
Sep 23
1946
0
Jun 22
2608
3
Mei 21
13307
2
Des 24
1246
1
Agu 24
1491