From 7d9ab0d2d9ce5dce5976d6d86e38593c7cf20cd5 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 26 Jul 2024 10:23:41 +0700 Subject: update code category_id_i sync to solr --- indoteknik_custom/models/solr/apache_solr.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/solr/apache_solr.py b/indoteknik_custom/models/solr/apache_solr.py index 6560c9b5..9ba3b721 100644 --- a/indoteknik_custom/models/solr/apache_solr.py +++ b/indoteknik_custom/models/solr/apache_solr.py @@ -22,10 +22,10 @@ class ApacheSolr(models.Model): url = '' if env == 'development': - url = 'http://192.168.23.5:8983/solr/' + url = 'http://localhost:8983/solr/' elif env == 'production': url = 'http://34.101.189.218:8983/solr/' - + return pysolr.Solr(url + schema, always_commit=False, timeout=10) def get_doc(self, schema, id): -- cgit v1.2.3 From 468a7d1cea1b19844ae18be4c926bdd5276d7bbd Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 26 Jul 2024 10:29:40 +0700 Subject: Revert " update code category_id_i sync to solr" This reverts commit 7d9ab0d2d9ce5dce5976d6d86e38593c7cf20cd5. --- indoteknik_custom/models/solr/apache_solr.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/solr/apache_solr.py b/indoteknik_custom/models/solr/apache_solr.py index 9ba3b721..6560c9b5 100644 --- a/indoteknik_custom/models/solr/apache_solr.py +++ b/indoteknik_custom/models/solr/apache_solr.py @@ -22,10 +22,10 @@ class ApacheSolr(models.Model): url = '' if env == 'development': - url = 'http://localhost:8983/solr/' + url = 'http://192.168.23.5:8983/solr/' elif env == 'production': url = 'http://34.101.189.218:8983/solr/' - + return pysolr.Solr(url + schema, always_commit=False, timeout=10) def get_doc(self, schema, id): -- cgit v1.2.3 From 093455f8ad3219670a50898c16d70394d2f1e227 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 26 Jul 2024 10:34:08 +0700 Subject: update code category_id_i sync to solr --- indoteknik_custom/models/solr/product_template.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index b3787499..4bf0b88d 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -65,11 +65,12 @@ 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 = '' + # Mengumpulkan semua kategori + category_ids = [] + category_names = [] for category in template.public_categ_ids: - category_id, category_name = category.id, category.name - break + category_ids.append(category.id) + category_names.append(category.name) document = solr_model.get_doc('product', template.id) document.update({ @@ -92,9 +93,9 @@ 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_i": ','.join(map(str, 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, -- cgit v1.2.3 From 4b855ffcaeee0d961bb900f4cc9d4665cee87dd4 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 26 Jul 2024 12:07:48 +0700 Subject: add catefories lob --- indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/website_categories_lob.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 indoteknik_custom/models/website_categories_lob.py (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index a6bab518..1c41bbff 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/website_categories_lob.py b/indoteknik_custom/models/website_categories_lob.py new file mode 100644 index 00000000..5fd7bfef --- /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='Category', 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 -- cgit v1.2.3 From e394d734ca4e53bd63b767c9c7fe77a5ebe49245 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 26 Jul 2024 13:48:31 +0700 Subject: add website categories lob --- indoteknik_custom/models/solr/product_template.py | 21 +++++++++------------ indoteknik_custom/models/website_categories_lob.py | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 4bf0b88d..2143fbe2 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 + # } }) print(document) diff --git a/indoteknik_custom/models/website_categories_lob.py b/indoteknik_custom/models/website_categories_lob.py index 5fd7bfef..88182ba5 100644 --- a/indoteknik_custom/models/website_categories_lob.py +++ b/indoteknik_custom/models/website_categories_lob.py @@ -5,7 +5,7 @@ class WebsiteCategoriesLob(models.Model): _name = 'website.categories.lob' _rec_name = 'category_id' - category_id = fields.Many2one('res.partner.industry', string='Category', help='table ecommerce category') + 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([ -- cgit v1.2.3