From e5077a23191c65627d7ce96b85cb62fe59996946 Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Thu, 26 Mar 2026 08:15:43 +0700 Subject: [PATCH] feat: Add public API endpoint `/api/loyalty/branches` to retrieve company branch details. --- controllers/main.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/controllers/main.py b/controllers/main.py index 4c9bd92..eb2b3a8 100644 --- a/controllers/main.py +++ b/controllers/main.py @@ -32,3 +32,18 @@ class AppNotificationController(http.Controller): 'status': 'success', 'data': notifications } + + @http.route('/api/loyalty/branches', type='json', auth='public', methods=['POST'], csrf=False) + def fetch_branches(self, **kw): + """ + Public endpoint for the Flutter app to get branches without exposing API keys. + """ + try: + branches = request.env['res.company'].sudo().search_read( + [('parent_id', '!=', False)], + ['name', 'street', 'city', 'phone'], + limit=50 + ) + return {'status': 'success', 'data': branches} + except Exception as e: + return {'status': 'error', 'message': str(e)}