diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2023-08-03 06:15:54 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2023-08-03 06:15:54 +0000 |
| commit | 0be8a77f6cbb31d3ac8cf9e3e606d2266a20c2ec (patch) | |
| tree | 6f62bce6e049935b5a85e445ee7d959242fe7e7c /indoteknik_api/controllers/api_v1 | |
| parent | f0f30aa566c0e49b03fd86f86bbcd80d6c7383ce (diff) | |
| parent | 4a670f1f85848ef46c605fd67ff4e3d305571522 (diff) | |
Merged in production (pull request #80)
Production
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/banner.py | 17 | ||||
| -rw-r--r-- | indoteknik_api/controllers/api_v1/lead.py | 4 | ||||
| -rw-r--r-- | indoteknik_api/controllers/api_v1/manufacture.py | 3 |
3 files changed, 18 insertions, 6 deletions
diff --git a/indoteknik_api/controllers/api_v1/banner.py b/indoteknik_api/controllers/api_v1/banner.py index 1bd0fea6..79aa5fa5 100644 --- a/indoteknik_api/controllers/api_v1/banner.py +++ b/indoteknik_api/controllers/api_v1/banner.py @@ -1,6 +1,7 @@ from .. import controller from odoo import http from odoo.http import request +from datetime import datetime class Banner(controller.Controller): @@ -13,14 +14,17 @@ class Banner(controller.Controller): type = kw.get('type') limit = int(kw.get('limit', 0)) offset = int(kw.get('offset', 0)) - order = kw.get('order') - if not order: - order = 'write_date DESC' + order = kw.get('order', 'write_date DESC') query = [('x_status_banner', '=', 'tayang')] if type: query += [('x_banner_category.x_studio_field_KKVl4', '=', type)] + week_number = self.get_week_number_of_current_month() + if type == 'index-a-1': + order = 'sequence ASC' + query += [('for_week', 'in', [week_number, False])] + if manufacture_id: query += [('x_relasi_manufacture', '=', int(manufacture_id))] @@ -35,4 +39,9 @@ class Banner(controller.Controller): 'image': request.env['ir.attachment'].api_image('x_banner.banner', 'x_banner_image', banner.id), }) - return self.response(data, headers=[('Cache-Control', 'max-age=3600, public')])
\ No newline at end of file + return self.response(data, headers=[('Cache-Control', 'max-age=3600, public')]) + + def get_week_number_of_current_month(self): + today = datetime.now().day + week_number = (today - 1) // 7 + 1 + return min(week_number, 4)
\ No newline at end of file diff --git a/indoteknik_api/controllers/api_v1/lead.py b/indoteknik_api/controllers/api_v1/lead.py index df4f46bd..23c3bf99 100644 --- a/indoteknik_api/controllers/api_v1/lead.py +++ b/indoteknik_api/controllers/api_v1/lead.py @@ -20,7 +20,9 @@ class Lead(controller.Controller): if not params['valid']: return self.response(code=400, description=params) - + + params['value']['user_id'] = 20 + lead = request.env['crm.lead'].create(params['value']) return self.response(True)
\ No newline at end of file diff --git a/indoteknik_api/controllers/api_v1/manufacture.py b/indoteknik_api/controllers/api_v1/manufacture.py index 345fd660..cbee253d 100644 --- a/indoteknik_api/controllers/api_v1/manufacture.py +++ b/indoteknik_api/controllers/api_v1/manufacture.py @@ -16,6 +16,7 @@ class Manufacture(controller.Controller): level = kw.get('level') limit = int(kw.get('limit', 0)) offset = int(kw.get('offset', 0)) + order = 'sequence ASC' if name: name = '%' + name.replace(' ', '%') + '%' if '%' not in name else name @@ -26,7 +27,7 @@ class Manufacture(controller.Controller): return self.response(code=400, description='level possible value is prioritas, gold, silver') query.append(('x_manufacture_level', '=', level)) - manufactures = request.env['x_manufactures'].search(query, limit=limit, offset=offset) + manufactures = request.env['x_manufactures'].search(query, order=order, limit=limit, offset=offset) data = { 'manufacture_total': request.env['x_manufactures'].search_count(query), 'manufactures': [request.env['x_manufactures'].api_single_response(x) for x in manufactures] |
