# -*- 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 WO sticker to the work-order form. Uses Odoo 17+/19's action-URL format so the backend opens directly on the WO's form view. Falls back to a generic not-found URL if the id doesn't resolve. """ wo = request.env['mrp.workorder'].sudo().browse(wo_id).exists() if not wo: # Land on the list of all WOs so staff can search manually. return request.redirect('/odoo/manufacturing/work-orders') # /odoo/action-/ opens the record's form view. # Using the vanilla MRP action here so it works regardless of # whether the user has Plating-specific menus. return request.redirect( '/odoo/action-mrp.action_mrp_workorder/%d' % wo.id )