Skip to Content
Menu
This question has been flagged

I have a controller that has several routes that handle different HTTP requests and perform various actions related to sales and billing management in Odoo. With these routes and their functionalities.

/web/session/authenticate : This route is used to authenticate users in the Odoo session.

/api/validate_sale: This path is used to validate a sale by receiving JSON data in the request and performs various checks against that data and returns an appropriate response.

/api/get_invoice: This path is used to get information about an invoice, receives JSON data in the request and performs several actions related to invoice generation in Odoo.

It generates invoices, gets XML and PDF data related to the invoice and returns a response with this information.


The problem I have with the last route because the other two do return a response but in the last one I have a CORS problem, I don't know if it has something to do with my function. The data sending is from an external page to Odoo sh.

This is an example of the function.

@http.route('/api/get_invoice', type='json', auth='user', methods=['POST'], csrf=False, cors="*")

def invoice_get(self, **kw):

try:

resp = {}

data = http.request.jsonrequest

data = data['params']

sale = http.request.env['sale.order'].sudo().search([

('id', '=', data['invoice']['id'])

], limit=1)

if sale.id:

# GET XML

if sale.invoice_status == 'to invoice':

if sale.partner_id.name == 'PUBLICO EN GENERAL':

partner_id = self._create_client(data)

sale.partner_id = partner_id

sale.partner_invoice_id = partner_id

sale.partner_shipping_id = partner_id

else:

sale.partner_id.vat = data['client']['rfc']

sale.partner_id.name = data['client']['name']

sale.partner_id.zip = data['client']['postal_code']

in_id = self.make_invoice(sale, data, '1', None)

resp['invoice_id'] = in_id

## GET XML AND PDF

resp['invoice_edo'] = 'Factura creada correctamente'

return resp

Avatar
Discard
Related Posts Replies Views Activity
0
Sep 23
1265
1
Mar 25
3035
0
Jan 23
1905
0
Aug 20
3343
0
Jun 20
2340