summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2024-07-19 04:27:48 +0000
committerIT Fixcomart <it@fixcomart.co.id>2024-07-19 04:27:48 +0000
commit5c7992e9cfe016e2f45dbe2532514cd1b2b4bb81 (patch)
treeced799222328472935e90fdab3bcafc6561e4523
parent1d0be5d6fe6d3e59c76132c9e06ba870013b4306 (diff)
parent6178dd2ae746746ebfdcf68246d13950a45fadf4 (diff)
Merged in feature/iman-categories-homepage (pull request #170)
Feature/iman categories homepage
-rw-r--r--indoteknik_custom/models/solr/website_categories_management.py15
-rw-r--r--indoteknik_custom/models/website_categories_management.py3
2 files changed, 12 insertions, 6 deletions
diff --git a/indoteknik_custom/models/solr/website_categories_management.py b/indoteknik_custom/models/solr/website_categories_management.py
index 15e28df0..2d7e889a 100644
--- a/indoteknik_custom/models/solr/website_categories_management.py
+++ b/indoteknik_custom/models/solr/website_categories_management.py
@@ -63,21 +63,26 @@ class WebsiteCategoriesManagement(models.Model):
category_id2_data = [
{
- x.id: {
- 'child_frontend_id_i': [child.id for child in x.child_frontend_id2]
- }
+ 'id_level_2': x.id,
+ 'name': x.name,
+ 'image': x.image,
+ 'child_frontend_id_i': [{'id_level_3': child.id, 'name': child.name, 'image': child.image} for child in
+ x.child_frontend_id2]
}
for x in category.category_id2
]
-
+ category_id2_json = json.dumps(category_id2_data)
document = solr_model.get_doc('product_category_management', category.id)
document.update({
'id': category.id,
'category_id_i': category.category_id.id,
+ 'image_s': self.env['ir.attachment'].api_image('product.public.category', 'image', category.category_id.id),
'name_s': category.category_id.name,
'sequence_i': category.sequence or '',
- 'category_id2': category_id2_data,
+ 'category_id2_s': category_id2_json,
})
+ _logger.info('Category %s synchronized to Solr with document: %s', document)
+ _logger.info('Category %s synchronized to Solr with category_id2_json: %s', category_id2_json)
self.solr().add([document])
category.update_last_update_solr()
diff --git a/indoteknik_custom/models/website_categories_management.py b/indoteknik_custom/models/website_categories_management.py
index 7d3d1dee..f7b321c0 100644
--- a/indoteknik_custom/models/website_categories_management.py
+++ b/indoteknik_custom/models/website_categories_management.py
@@ -16,7 +16,8 @@ class WebsiteCategoriesManagement(models.Model):
@api.onchange('category_id')
def _onchange_category_id(self):
domain = {}
- self.category_id2 = [(5, 0, 0)]
+ if self.category_id != self._origin.category_id: # Check if the category_id has changed
+ self.category_id2 = [(5, 0, 0)] # Clear the category_id2 field if category_id has changed
if self.category_id:
domain['category_id2'] = [('parent_frontend_id', '=', self.category_id.id)]
else: