From 4bc68435bc20d7da0f38bd2370057481cb995584 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 23 Jan 2023 10:52:49 +0700 Subject: add dynamic limit for new product --- indoteknik_api/controllers/api_v1/product.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indoteknik_api/controllers/api_v1') diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py index cfa2dbef..23dcf48e 100644 --- a/indoteknik_api/controllers/api_v1/product.py +++ b/indoteknik_api/controllers/api_v1/product.py @@ -19,6 +19,8 @@ class Product(controller.Controller): is_brand_only = int(kw.get('is_brand_only', 0)) base_url = request.env['ir.config_parameter'].get_param('web.base.url') + limit_new_products = request.env['ir.config_parameter'].get_param('limit.new.product') + limit_new_products = int(limit_new_products) # current_time = datetime.now() # delta_time = current_time - timedelta(days=30) @@ -32,7 +34,7 @@ class Product(controller.Controller): ('x_manufacture', '!=', False), # ('create_date', '>=', delta_time), ] - new_products = request.env['product.template'].search(query_products, order='create_date desc', limit=250) + new_products = request.env['product.template'].search(query_products, order='create_date desc', limit=limit_new_products) brands = [] for product in new_products: brands.append(product.x_manufacture) -- cgit v1.2.3