diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-07-23 09:46:08 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-07-23 09:46:08 +0700 |
| commit | 6ef541c443bc4cfe9f3f0250823d4d622035b026 (patch) | |
| tree | c33c30422262dc0052fa7717f0a155d969a842da /indoteknik_api/controllers/api_v1 | |
| parent | 828e0a0cbd8a328817aeb66f55585902f533349d (diff) | |
<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']) |
