22 lines
720 B
Python
22 lines
720 B
Python
from odoo import http
|
|
from odoo.http import request
|
|
|
|
|
|
class FusionOcrController(http.Controller):
|
|
|
|
@http.route('/fusion/ocr/request_for_invoice', type='jsonrpc', auth='user')
|
|
def request_for_invoice(self, move_id):
|
|
move = request.env['account.move'].browse(int(move_id))
|
|
move.check_access('write')
|
|
try:
|
|
move.action_request_ocr()
|
|
return {
|
|
'status': 'ok',
|
|
'state': move.ocr_state,
|
|
'backend': move.ocr_backend,
|
|
'confidence': move.ocr_confidence,
|
|
'extracted': move.ocr_extracted_data,
|
|
}
|
|
except Exception as e:
|
|
return {'status': 'error', 'message': str(e)}
|