summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-07-22 13:34:12 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-07-22 13:34:12 +0700
commit96b76106958d1743a99b11600cc99c7abaadbbb1 (patch)
treed0425da3206ffee1e626021e7f4ae66f3a53ba8f
parent2f9a8ddd6c18c113dbe60ffec3881ef0e1a3829c (diff)
<iman> update delete code category management
-rw-r--r--indoteknik_custom/models/website_categories_management.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/indoteknik_custom/models/website_categories_management.py b/indoteknik_custom/models/website_categories_management.py
index f7b321c0..208b07a2 100644
--- a/indoteknik_custom/models/website_categories_management.py
+++ b/indoteknik_custom/models/website_categories_management.py
@@ -46,4 +46,20 @@ class WebsiteCategoriesManagement(models.Model):
for category in record.category_id2:
for child_category in category.child_frontend_id2:
if child_category.parent_frontend_id.id not in category_ids:
- raise ValidationError(f"Category Level 3 {child_category.name} bukan bagian dari category Level 2 {category.name}")
+ raise ValidationError(
+ f"Category Level 3 {child_category.name} bukan bagian dari category Level 2 {category.name}")
+
+ def unlink(self):
+ for record in self.category_id2:
+ if record.id:
+ related_categories = self.env['product.public.category'].search([
+ ('id', 'in', record.ids)
+ ])
+ for category in related_categories:
+ for category3 in record.child_frontend_id2.ids:
+ if category3 in category.child_frontend_id2.ids:
+ category.write({
+ 'child_frontend_id2': [(3, category3)]
+ })
+ return super(WebsiteCategoriesManagement, self).unlink()
+