diff options
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/product.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py index 2e8e0226..bf3505e4 100644 --- a/indoteknik_api/controllers/api_v1/product.py +++ b/indoteknik_api/controllers/api_v1/product.py @@ -3,6 +3,9 @@ from odoo import http from odoo.http import request from datetime import datetime, timedelta import ast +import logging + +_logger = logging.getLogger(__name__) class Product(controller.Controller): @@ -33,7 +36,6 @@ class Product(controller.Controller): data = [] count = 0 for brand in brands: - count += 1 if count == 11: break query = [ @@ -44,15 +46,21 @@ class Product(controller.Controller): ('website_description', '!=', False), ('create_date', '>=', delta_time), ] - products = request.env['product.template'].search(query, order='name', limit=36) + count_products = request.env['product.template'].search_count(query) + if count_products < 5: + _logger.info('Brand Skipped %s' % brand.x_name) + continue + products = request.env['product.template'].search(query, order='name', limit=6) data.append({ 'manufacture_id': brand.id, 'sequence': brand.sequence if brand.sequence else count, 'name': brand.x_name, 'image': base_url + 'api/image/x_manufactures/x_logo_manufacture/' + str( brand.id) if brand.x_logo_manufacture else '', + 'products_total': count_products, 'products': [request.env['product.template'].api_single_response(x) for x in products] }) + count += 1 return self.response(data) @http.route(prefix + 'product', auth='public', methods=['GET', 'OPTIONS']) |
