summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2024-07-22 06:35:51 +0000
committerIT Fixcomart <it@fixcomart.co.id>2024-07-22 06:35:51 +0000
commit46f09173d91d9df68d47437c254878ba58bb0992 (patch)
tree75df34bc5b127f9c8d8f029d77ec8de2b71fc285
parentf25cdb1a793740a91d9f5813b80da6bd0308961e (diff)
parent96b76106958d1743a99b11600cc99c7abaadbbb1 (diff)
Merged in feature/iman-categories-homepage (pull request #172)
<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()
+