diff options
| -rw-r--r-- | indoteknik_custom/models/solr/website_categories_management.py | 15 | ||||
| -rw-r--r-- | indoteknik_custom/models/website_categories_management.py | 3 |
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: |
