summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/solr
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2023-10-02 16:45:07 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2023-10-02 16:45:07 +0700
commit9fe4b646f1b1cda3d704a66dfbca3e935e38d96b (patch)
treed22e810cbd1f0b409378ff363fb4427f89702481 /indoteknik_custom/models/solr
parentb0b5d0a094a1a87810b45bfcc52c17a82b73d3eb (diff)
Group by brand, sync to solr when validate stock picking, add new name function solr queue
Diffstat (limited to 'indoteknik_custom/models/solr')
-rw-r--r--indoteknik_custom/models/solr/apache_solr_queue.py2
-rw-r--r--indoteknik_custom/models/solr/product_product.py2
-rw-r--r--indoteknik_custom/models/solr/product_template.py23
3 files changed, 7 insertions, 20 deletions
diff --git a/indoteknik_custom/models/solr/apache_solr_queue.py b/indoteknik_custom/models/solr/apache_solr_queue.py
index 8dd7c273..f66d356d 100644
--- a/indoteknik_custom/models/solr/apache_solr_queue.py
+++ b/indoteknik_custom/models/solr/apache_solr_queue.py
@@ -8,7 +8,7 @@ _logger = logging.getLogger(__name__)
class ApacheSolrQueue(models.Model):
_name = 'apache.solr.queue'
- display_name = fields.Char('Display Name', compute="_compute_display_name")
+ display_name = fields.Char('Display Name', compute="_compute_display_name", store=True)
res_model = fields.Char('Resource Model')
res_id = fields.Integer('Resource ID')
function_name = fields.Char('Function Name')
diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py
index 41af2d0e..16135e5e 100644
--- a/indoteknik_custom/models/solr/product_product.py
+++ b/indoteknik_custom/models/solr/product_product.py
@@ -63,7 +63,7 @@ class ProductProduct(models.Model):
'search_rank_weekly_i': variant.product_tmpl_id.search_rank_weekly,
'attributes': [x.name for x in variant.product_template_attribute_value_ids],
'has_product_info_b': True,
- 'publish_b': variant.product_tmpl_id.publish,
+ 'publish_b': variant.product_tmpl_id.active and variant.product_tmpl_id.type == 'product',
})
self.solr().add(docs=[document], softCommit=True)
diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py
index b4782d1c..e39530a7 100644
--- a/indoteknik_custom/models/solr/product_template.py
+++ b/indoteknik_custom/models/solr/product_template.py
@@ -23,23 +23,7 @@ class ProductTemplate(models.Model):
'function_name': function_name
})
- @api.constrains('active', 'type')
- def constrains_active(self):
- for template in self:
- template.publish = template.active and template.type == 'product'
- self._create_solr_queue('_sync_product_template_to_solr')
-
- @api.constrains('publish')
- def constrains_publish(self):
- for template in self:
- if template.active and template.type == 'product':
- continue
- template.product_variant_ids.publish = template.publish
- self._create_solr_queue('_sync_product_template_to_solr')
-
- constrains_active._priority = 1
-
- @api.constrains('name', 'default_code', 'weight', 'x_manufacture', 'public_categ_ids', 'search_rank', 'search_rank_weekly', 'image_1920')
+ @api.constrains('name', 'default_code', 'weight', 'x_manufacture', 'public_categ_ids', 'search_rank', 'search_rank_weekly', 'image_1920', 'active')
def _create_solr_queue_sync_product_template(self):
self._create_solr_queue('_sync_product_template_to_solr')
@@ -54,6 +38,9 @@ class ProductTemplate(models.Model):
product._create_solr_queue('_sync_price_to_solr')
product.solr_flag = 1
+ def _sync_product_stock_to_solr(self):
+ self._sync_product_template_to_solr()
+
def _sync_product_template_to_solr(self):
solr_model = self.env['apache.solr']
@@ -93,7 +80,7 @@ class ProductTemplate(models.Model):
"category_name": category_name,
"description_t": template.website_description or '',
'has_product_info_b': True,
- 'publish_b': template.publish
+ 'publish_b': template.active and template.type == 'product'
})
self.solr().add(docs=[document], softCommit=True)