# -*- coding: utf-8 -*- # Copyright 2026 Nexa Systems Inc. # License OPL-1 (Odoo Proprietary License v1.0) # Part of the Fusion Plating product family. # # /fp/wo/ — scan-redirect endpoint. # # The WO box sticker embeds a QR code that encodes this URL. When # warehouse staff scan the sticker with their phone / tablet / # handheld scanner, the device opens the URL; this controller then # redirects them to the work-order form inside Odoo's backend. # Logged-out users land on the standard Odoo login page and bounce # back after authenticating (Odoo's redirect handles the round-trip). from odoo import http from odoo.http import request class FpWoScanController(http.Controller): @http.route('/fp/wo/', type='http', auth='user', website=False) def wo_scan_redirect(self, wo_id, **kwargs): """Redirect a scanned sticker to the right backend form. Stickers are printed from two sources — mrp.workorder (WO) and mrp.production (MO) — and both embed their own numeric id in the QR. Try the MO table first (operators live on the MO form — customer, SO, all WOs visible) and fall back to WO. """ MO = request.env['mrp.production'].sudo() WO = request.env['mrp.workorder'].sudo() mo = MO.browse(wo_id).exists() if mo: return request.redirect( '/odoo/action-mrp.mrp_production_action/%d' % mo.id ) wo = WO.browse(wo_id).exists() if wo: return request.redirect( '/odoo/action-mrp.action_mrp_workorder/%d' % wo.id ) # Neither resolved — land on the WO list so staff can search manually. return request.redirect('/odoo/manufacturing/work-orders')