summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMqdd <ahmadmiqdad27@gmail.com>2025-12-18 16:00:19 +0700
committerMqdd <ahmadmiqdad27@gmail.com>2025-12-18 16:00:19 +0700
commit41e5e8defc0d0b928e43307f72887b0789ffb589 (patch)
tree7c46f1628530154fc5766b758c7126d5fca37e63
parent9596f3806d8f177c5a701c16be4b10c964be7c07 (diff)
<Miqdad> fix duplicate keywords functions
-rw-r--r--indoteknik_custom/models/keywords.py31
1 files changed, 17 insertions, 14 deletions
diff --git a/indoteknik_custom/models/keywords.py b/indoteknik_custom/models/keywords.py
index b2ada3f8..41deea3e 100644
--- a/indoteknik_custom/models/keywords.py
+++ b/indoteknik_custom/models/keywords.py
@@ -8,7 +8,6 @@ from odoo.exceptions import UserError
import base64
import xlrd, xlwt
import io
-from bs4 import BeautifulSoup
_logger = logging.getLogger(__name__)
@@ -19,7 +18,7 @@ class Keywords(models.Model):
_name = 'keywords'
_order= 'id desc'
- category_id = fields.Many2one('product.public.category', string='Category', required=True)
+ category_id = fields.Many2one('product.public.category', string='Category', required=True, help="Category to filter products when generating products for this keyword and to throw to solr")
keywords = fields.Char('Keywords', required=True)
product_ids = fields.Many2many(
'product.product',
@@ -29,9 +28,9 @@ class Keywords(models.Model):
string='Products'
)
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)
+ skip = fields.Boolean('Skip Generate Product', default=False, help="If checked, the system will not generate products for this keyword")
+ url = fields.Char('Website URL', compute="_compute_url", help="Generated website url based on keywords")
+ sum = fields.Integer('Total Product', compute="_compute_total_product", readonly=True, help="Total products found for this keyword including variants")
@api.depends('product_ids')
def _compute_total_product(self):
@@ -54,15 +53,19 @@ class Keywords(models.Model):
if not record.name:
record.name = record.keywords
- # @api.constrains('keywords')
- # def check_already_exist(self):
- # model = self.env['keywords']
- # for record in self:
- # match = model.search([
- # ('name', 'ilike', record.name)
- # ])
- # if match:
- # raise UserError("Tidak bisa create/write/duplicate karena keywords sudah dipakai")
+ @api.constrains('keywords', 'name')
+ def check_already_exist(self):
+ model = self.env['keywords']
+ for record in self:
+ match = model.search([ '|',
+ ('name', '=', record.name),
+ ('keywords', '=', record.keywords)
+ ])
+ if match:
+ raise UserError("Tidak bisa create/write/duplicate karena keywords sudah dipakai")
+
+ def copy(self):
+ raise UserError("Duplicate Record not allowed")
def clear_products(self):