콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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

아바타
취소
관련 게시물 답글 화면 활동
0
9월 23
1740
0
7월 25
4272
0
1월 23
2332
0
8월 20
3807
0
6월 20
2697