summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2024-07-22 09:52:28 +0000
committerIT Fixcomart <it@fixcomart.co.id>2024-07-22 09:52:28 +0000
commit948755e3d3ad6d1fdf22452b0b9f82ff1974a9ea (patch)
tree63ae6100579b316fd9b3260572b484d85c93b369
parent5cf8f1b647934c4f3934ae0e247cbb0707e4b640 (diff)
parent828e0a0cbd8a328817aeb66f55585902f533349d (diff)
Merged in feature/iman-categories-homepage (pull request #173)
Feature/iman categories homepage
-rw-r--r--indoteknik_api/controllers/api_v1/__init__.py1
-rw-r--r--indoteknik_api/controllers/api_v1/category_management.py42
-rw-r--r--indoteknik_custom/views/website_categories_management.xml14
3 files changed, 50 insertions, 7 deletions
diff --git a/indoteknik_api/controllers/api_v1/__init__.py b/indoteknik_api/controllers/api_v1/__init__.py
index 36fcbd53..5952a929 100644
--- a/indoteknik_api/controllers/api_v1/__init__.py
+++ b/indoteknik_api/controllers/api_v1/__init__.py
@@ -20,6 +20,7 @@ from . import sub_district
from . import user
from . import wishlist
from . import brand_homepage
+from . import category_management
from . import customer
from . import content
from . import midtrans
diff --git a/indoteknik_api/controllers/api_v1/category_management.py b/indoteknik_api/controllers/api_v1/category_management.py
new file mode 100644
index 00000000..3c53960a
--- /dev/null
+++ b/indoteknik_api/controllers/api_v1/category_management.py
@@ -0,0 +1,42 @@
+from odoo import http
+from odoo.http import request
+from .. import controller
+
+class CategoryManagement(controller.Controller):
+ prefix = '/api/v1/'
+
+ @http.route(prefix + 'categories_management', auth='public', methods=['GET', 'OPTIONS'], csrf=False)
+ @controller.Controller.must_authorized()
+ def get_categories_management(self, **kw):
+ base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url')
+
+ query = [('status', '=', 'tayang')]
+
+ categories = request.env['website.categories.management'].search(query, order='sequence')
+ data = []
+ for category in categories:
+ category_id2_data = []
+ for x in category.category_id2:
+ child_data = [
+ {'id_level_3': child.id, 'name': child.name,
+ 'image': request.env['ir.attachment'].api_image('product.public.category', 'image_1920', child.id)}
+ for child in x.child_frontend_id2
+ ]
+ category_id2_data.append({
+ 'id_level_2': x.id,
+ 'name': x.name,
+ 'image': request.env['ir.attachment'].api_image('product.public.category', 'image_1920', x.id),
+ 'child_frontend_id_i': child_data
+ })
+
+ data.append({
+ 'id': category.id,
+ 'sequence': category.sequence,
+ 'category_id_i': category.category_id.id,
+ 'name': category.category_id.name,
+ 'image': request.env['ir.attachment'].api_image('product.public.category', 'image_1920', category.category_id.id),
+ 'categories': category_id2_data,
+ })
+ return self.response(data, headers=[('Cache-Control', 'max-age=3600, public')])
+
+
diff --git a/indoteknik_custom/views/website_categories_management.xml b/indoteknik_custom/views/website_categories_management.xml
index 2a9f4d99..648814e2 100644
--- a/indoteknik_custom/views/website_categories_management.xml
+++ b/indoteknik_custom/views/website_categories_management.xml
@@ -48,13 +48,13 @@
</field>
</record>
- <record id="ir_actions_server_website_categories_management_sync_to_solr" model="ir.actions.server">
- <field name="name">Sync to solr</field>
- <field name="model_id" ref="indoteknik_custom.model_website_categories_management"/>
- <field name="binding_model_id" ref="indoteknik_custom.model_website_categories_management"/>
- <field name="state">code</field>
- <field name="code">model.action_sync_to_solr()</field>
- </record>
+<!-- <record id="ir_actions_server_website_categories_management_sync_to_solr" model="ir.actions.server">-->
+<!-- <field name="name">Sync to solr</field>-->
+<!-- <field name="model_id" ref="indoteknik_custom.model_website_categories_management"/>-->
+<!-- <field name="binding_model_id" ref="indoteknik_custom.model_website_categories_management"/>-->
+<!-- <field name="state">code</field>-->
+<!-- <field name="code">model.action_sync_to_solr()</field>-->
+<!-- </record>-->
<menuitem
id="website_categories_management"