diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2024-07-23 02:48:34 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2024-07-23 02:48:34 +0000 |
| commit | 382bdcbf4ec7e58dc0388d0525d7372981483207 (patch) | |
| tree | 790dedcb39a560e02ad1c81a3bc5facbaf3b2426 /indoteknik_api/controllers/api_v1 | |
| parent | 948755e3d3ad6d1fdf22452b0b9f82ff1974a9ea (diff) | |
| parent | 6ef541c443bc4cfe9f3f0250823d4d622035b026 (diff) | |
Merged in feature/iman-categories-homepage (pull request #174)
<iman> add image to category api
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/category.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/indoteknik_api/controllers/api_v1/category.py b/indoteknik_api/controllers/api_v1/category.py index 44a60bc9..82347196 100644 --- a/indoteknik_api/controllers/api_v1/category.py +++ b/indoteknik_api/controllers/api_v1/category.py @@ -18,7 +18,19 @@ class Category(controller.Controller): if params['value']['parent_id'] == 0: params['value']['parent_id'] = False - categories = request.env['product.public.category'].search_read([('parent_frontend_id', '=', params['value']['parent_id'])], ['id', 'name']) + parent_id = params['value'].get('parent_id', 0) + if parent_id == 0: + parent_id = False + + categories = request.env['product.public.category'].search_read( + [('parent_frontend_id', '=', parent_id)], + ['id', 'name', 'image_1920'] + ) + + for category in categories: + category['image_1920'] = request.env['ir.attachment'].api_image( + 'product.public.category', 'image_1920', category['id'] + ) return self.response(categories) @http.route(prefix + 'category/tree', auth='public', methods=['GET', 'OPTIONS']) |
