summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-07-26 15:43:46 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-07-26 15:43:46 +0700
commit525072694a3544d65a1075d6087600edbe173f18 (patch)
tree8963a437df3e40a57f9f95633e58c652e9d7a452
parent5e6c42803281ffc3098061113ca153a59a6eeb58 (diff)
parent54f5accd8e23cdc944f74dcf4399ac1d21455065 (diff)
Merge branch 'production' of bitbucket.org:altafixco/indoteknik-addons into production
-rw-r--r--indoteknik_api/controllers/api_v1/__init__.py1
-rw-r--r--indoteknik_api/controllers/api_v1/category_management_lob.py33
-rwxr-xr-xindoteknik_custom/__manifest__.py1
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rw-r--r--indoteknik_custom/models/solr/product_template.py26
-rw-r--r--indoteknik_custom/models/website_categories_lob.py15
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv1
-rw-r--r--indoteknik_custom/views/website_categories_lob.xml58
8 files changed, 122 insertions, 14 deletions
diff --git a/indoteknik_api/controllers/api_v1/__init__.py b/indoteknik_api/controllers/api_v1/__init__.py
index 5952a929..2d774071 100644
--- a/indoteknik_api/controllers/api_v1/__init__.py
+++ b/indoteknik_api/controllers/api_v1/__init__.py
@@ -21,6 +21,7 @@ from . import user
from . import wishlist
from . import brand_homepage
from . import category_management
+from . import category_management_lob
from . import customer
from . import content
from . import midtrans
diff --git a/indoteknik_api/controllers/api_v1/category_management_lob.py b/indoteknik_api/controllers/api_v1/category_management_lob.py
new file mode 100644
index 00000000..e453e402
--- /dev/null
+++ b/indoteknik_api/controllers/api_v1/category_management_lob.py
@@ -0,0 +1,33 @@
+from odoo import http
+from odoo.http import request
+from .. import controller
+import json
+
+class BrandHomepage(controller.Controller):
+ prefix = '/api/v1/'
+
+ @http.route(prefix + 'lob_homepage', auth='public', methods=['GET', 'OPTIONS'], csrf=False)
+ @controller.Controller.must_authorized()
+ def get_brand_homepage(self, **kw):
+ base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url')
+
+ query = [('status', '=', 'tayang')]
+ lob = request.env['website.categories.lob'].search(query, order='sequence')
+
+ data = []
+ for category in lob:
+ category_ids = [
+ {
+ 'id': cat.id,
+ 'name': cat.name
+ } for cat in category.category_ids
+ ]
+ data.append({
+ 'id': category.id,
+ 'sequence': category.sequence,
+ 'industries': category.category_id.name if category.category_id else '',
+ 'image': base_url + '/api/image/website.categories.lob/image/' + str(category.id) if category.image else '',
+ 'category_ids': category_ids
+ })
+
+ return self.response(data, headers=[('Cache-Control', 'max-age=3600, public')]) \ No newline at end of file
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index 6848ca7c..32678ef5 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -59,6 +59,7 @@
'views/website_brand_homepage.xml',
'views/website_categories_homepage.xml',
'views/website_categories_management.xml',
+ 'views/website_categories_lob.xml',
'views/sales_target.xml',
'views/purchase_outstanding.xml',
'views/sales_outstanding.xml',
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index ee9c9429..116354d6 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -37,6 +37,7 @@ from . import user_company_request
from . import users
from . import website_brand_homepage
from . import website_categories_homepage
+from . import website_categories_lob
from . import website_categories_management
from . import website_content
from . import website_page_content
diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py
index 3d7d3a80..19143be3 100644
--- a/indoteknik_custom/models/solr/product_template.py
+++ b/indoteknik_custom/models/solr/product_template.py
@@ -65,11 +65,9 @@ class ProductTemplate(models.Model):
variant_names = ', '.join([x.display_name or '' for x in template.product_variant_ids])
variant_codes = ', '.join([x.default_code or '' for x in template.product_variant_ids])
- category_id = 0
- category_name = ''
- for category in template.public_categ_ids:
- category_id, category_name = category.id, category.name
- break
+ # Mengumpulkan semua kategori
+ category_ids = [category.id for category in template.public_categ_ids]
+ category_names = [category.name for category in template.public_categ_ids]
document = solr_model.get_doc('product', template.id)
document.update({
@@ -92,21 +90,21 @@ class ProductTemplate(models.Model):
"variants_code_t": variant_codes,
"search_rank_i": template.search_rank,
"search_rank_weekly_i": template.search_rank_weekly,
- "category_id_i": category_id,
- "category_name_s": category_name,
- "category_name": category_name,
+ "category_id_ids": category_ids, # ID kategori sebagai string yang dipisahkan koma
+ "category_name_s": ', '.join(category_names), # Nama kategori sebagai string yang dipisahkan koma
+ "category_name": category_names, # Nama kategori sebagai list
"description_t": template.website_description or '',
'has_product_info_b': True,
'publish_b': not template.unpublished,
'sni_b': template.unpublished,
'tkdn_b': template.unpublished,
"qty_sold_f": template.qty_sold,
- "voucher_pastihemat" : {
- "min_purchase" : voucher.min_purchase_amount,
- "discount_type" : voucher.discount_type,
- "discount_amount" : voucher.discount_amount,
- "max_discount" : voucher.max_discount_amount
- }
+ # "voucher_pastihemat" : {
+ # "min_purchase" : voucher.min_purchase_amount,
+ # "discount_type" : voucher.discount_type,
+ # "discount_amount" : voucher.discount_amount,
+ # "max_discount" : voucher.max_discount_amount
+ # }
})
self.solr().add(docs=[document], softCommit=True)
diff --git a/indoteknik_custom/models/website_categories_lob.py b/indoteknik_custom/models/website_categories_lob.py
new file mode 100644
index 00000000..88182ba5
--- /dev/null
+++ b/indoteknik_custom/models/website_categories_lob.py
@@ -0,0 +1,15 @@
+from odoo import fields, models
+
+
+class WebsiteCategoriesLob(models.Model):
+ _name = 'website.categories.lob'
+ _rec_name = 'category_id'
+
+ category_id = fields.Many2one('res.partner.industry', string='Industri', help='table ecommerce category')
+ image = fields.Binary(string='Image')
+ sequence = fields.Integer(string='Sequence')
+ status = fields.Selection([
+ ('tayang', 'Tayang'),
+ ('tidak_tayang', 'Tidak Tayang')
+ ], string='Status')
+ category_ids = fields.Many2many('product.public.category', string='Category Parent') \ No newline at end of file
diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv
index 7731cc6f..95ad57f0 100755
--- a/indoteknik_custom/security/ir.model.access.csv
+++ b/indoteknik_custom/security/ir.model.access.csv
@@ -21,6 +21,7 @@ access_website_user_cart,access.website.user.cart,model_website_user_cart,,1,1,1
access_website_user_wishlist,access.website.user.wishlist,model_website_user_wishlist,,1,1,1,1
access_website_brand_homepage,access.website.brand.homepage,model_website_brand_homepage,,1,1,1,1
access_website_categories_homepage,access.website.categories.homepage,model_website_categories_homepage,,1,1,1,1
+access_website_categories_lob,access.website.categories.lob,model_website_categories_lob,,1,1,1,1
access_website_categories_management,access.website.categories.management,model_website_categories_management,,1,1,1,1
access_sales_target,access.sales.target,model_sales_target,,1,1,1,1
access_purchase_outstanding,access.purchase.outstanding,model_purchase_outstanding,,1,1,1,1
diff --git a/indoteknik_custom/views/website_categories_lob.xml b/indoteknik_custom/views/website_categories_lob.xml
new file mode 100644
index 00000000..86784d75
--- /dev/null
+++ b/indoteknik_custom/views/website_categories_lob.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<odoo>
+ <data>
+ <record id="website_categories_lob_action" model="ir.actions.act_window">
+ <field name="name">Website Categories LOB</field>
+ <field name="res_model">website.categories.lob</field>
+ <field name="view_mode">tree,form</field>
+ </record>
+
+ <record id="website_categories_lob_tree" model="ir.ui.view">
+ <field name="name">Website Categories LOB</field>
+ <field name="model">website.categories.lob</field>
+ <field name="arch" type="xml">
+ <tree default_order="sequence">
+ <field name="sequence"/>
+ <field name="category_id"/>
+ <field name="status"/>
+ </tree>
+ </field>
+ </record>
+
+ <record id="website_categories_lob_form" model="ir.ui.view">
+ <field name="name">Website Categories LOB</field>
+ <field name="model">website.categories.lob</field>
+ <field name="arch" type="xml">
+ <form>
+ <sheet>
+ <group>
+ <group>
+ <field name="sequence"/>
+ <field name="category_id"/>
+ <field name="image" widget="image"/>
+ <field name="status"/>
+ </group>
+ </group>
+ <notebook>
+ <page string="Category" name="category_ids">
+ <field name="category_ids" domain="[('parent_id', '=', False)]">
+ <tree>
+ <field name="display_name" />
+ </tree>
+ </field>
+ </page>
+ </notebook>
+ </sheet>
+ </form>
+ </field>
+ </record>
+
+ <menuitem
+ id="website_categories_lob"
+ name="Website Categories LOB"
+ parent="website_sale.menu_orders"
+ sequence="1"
+ action="website_categories_lob_action"
+ />
+ </data>
+</odoo> \ No newline at end of file