summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMqdd <ahmadmiqdad27@gmail.com>2025-12-10 07:53:30 +0700
committerMqdd <ahmadmiqdad27@gmail.com>2025-12-10 07:53:30 +0700
commitc13ed8b1f00d513bec387c614ac785c7c91debf7 (patch)
tree03b805843ac849af87732baf660973ef9fbb2e43
parentea7edf0fee4949203e94360882590ea0c9bb3b0b (diff)
<Miqdad> Add count product
-rw-r--r--indoteknik_custom/models/keywords.py14
-rw-r--r--indoteknik_custom/views/keywords.xml2
2 files changed, 13 insertions, 3 deletions
diff --git a/indoteknik_custom/models/keywords.py b/indoteknik_custom/models/keywords.py
index fd8603c6..a8d2fce6 100644
--- a/indoteknik_custom/models/keywords.py
+++ b/indoteknik_custom/models/keywords.py
@@ -30,6 +30,12 @@ class Keywords(models.Model):
name = fields.Char('Name', compute="_compute_name")
skip = fields.Boolean('Skip Generate Product', default=False)
url = fields.Char('Website URL', compute="_compute_url")
+ sum = fields.Integer('Total Product', compute="_compute_total_product", readonly=True)
+
+ @api.depends('product_ids')
+ def _compute_total_product(self):
+ for record in self:
+ record.sum = len(record.product_ids)
@api.depends('keywords')
def _compute_url(self):
@@ -114,13 +120,15 @@ class Keywords(models.Model):
documents = []
data = {}
for keyword in self.search([]):
+ searchkey = (keyword.keywords or '').strip().lower().replace(' ', '-')
try:
doc = {
'id': keyword.id,
- 'type_s': 'keyword',
- 'keywords_t': keyword.keywords,
+ # 'type_s': 'keyword',
+ 'keywords_s': searchkey,
+ # 'searchkey_t': searchkey,
'url_s': keyword.url,
- 'product_ids_is': keyword.product_ids.ids,
+ 'product_ids_is': [p.product_tmpl_id.id for p in keyword.product_ids]
}
documents.append(doc)
data = doc
diff --git a/indoteknik_custom/views/keywords.xml b/indoteknik_custom/views/keywords.xml
index 9145ec47..f5374655 100644
--- a/indoteknik_custom/views/keywords.xml
+++ b/indoteknik_custom/views/keywords.xml
@@ -8,6 +8,7 @@
<field name="category_id" />
<field name="keywords" />
<field name="url" />
+ <field name="sum" />
<field name="product_ids" widget="many2many_tags" />
</tree>
</field>
@@ -28,6 +29,7 @@
<field name="category_id" />
<field name="keywords" />
<field name="url" />
+ <field name="sum" />
<field name="product_ids" widget="many2many_tags" />
<field name="skip" />
</group>