diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2024-07-26 06:53:58 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2024-07-26 06:53:58 +0000 |
| commit | 310dc5b1ae50cec8e24cc36ace4d440b42f27eff (patch) | |
| tree | e90a3cbec5a494dfaf8ecb8de4e76256c952a91e | |
| parent | 88035e3c9586fdd58275834f64b6cad4c8df0711 (diff) | |
| parent | 2813f944bb28906bdc7348bb7437af77a85c68cf (diff) | |
Merged in feature/iman-categories-homepage (pull request #181)
Feature/iman categories homepage
| -rw-r--r-- | indoteknik_api/controllers/api_v1/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_api/controllers/api_v1/category_management_lob.py | 36 | ||||
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/solr/product_template.py | 21 | ||||
| -rw-r--r-- | indoteknik_custom/models/website_categories_lob.py | 15 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 1 | ||||
| -rw-r--r-- | indoteknik_custom/views/website_categories_lob.xml | 58 |
8 files changed, 122 insertions, 12 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..0f666f2f --- /dev/null +++ b/indoteknik_api/controllers/api_v1/category_management_lob.py @@ -0,0 +1,36 @@ +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 request.make_response( + json.dumps(data), + headers=[('Cache-Control', 'max-age=3600, public'), ('Content-Type', 'application/json')] + ) 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 3305c7ba..19143be3 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -66,11 +66,8 @@ class ProductTemplate(models.Model): variant_codes = ', '.join([x.default_code or '' for x in template.product_variant_ids]) # Mengumpulkan semua kategori - category_ids = [] - category_names = [] - for category in template.public_categ_ids: - category_ids.append(category.id) - category_names.append(category.name) + 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({ @@ -93,7 +90,7 @@ 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": ','.join(map(str, category_ids)), # ID kategori sebagai string yang dipisahkan koma + "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 '', @@ -102,12 +99,12 @@ class ProductTemplate(models.Model): '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 |
