feat: Add public API endpoint /api/loyalty/branches to retrieve company branch details.

This commit is contained in:
Suherdy Yacob 2026-03-26 08:15:43 +07:00
parent b1eb7fb39a
commit e5077a2319

View File

@ -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)}