summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/product_template.py
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models/product_template.py')
-rwxr-xr-xindoteknik_custom/models/product_template.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index 49235ec7..9c480f4c 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -1,5 +1,6 @@
from odoo import fields, models, api
from datetime import datetime, timedelta
+from odoo.exceptions import AccessError, UserError, ValidationError
import logging
_logger = logging.getLogger(__name__)
@@ -69,6 +70,10 @@ class ProductTemplate(models.Model):
rate += 2
product.virtual_rating = rate
+ def unlink(self):
+ if self._name == 'product.template':
+ raise UserError('Maaf anda tidak bisa delete product')
+
def update_new_product(self):
current_time = datetime.now()
delta_time = current_time - timedelta(days=30)
@@ -185,6 +190,8 @@ class ProductTemplate(models.Model):
product.product_rating = rate
product.last_calculate_rating = current_time
+
+
class ProductProduct(models.Model):
_inherit = "product.product"
@@ -223,3 +230,7 @@ class ProductProduct(models.Model):
for product in self:
stock_vendor = self.env['stock.vendor'].search([('product_variant_id', '=', product.id)], limit=1)
product.qty_stock_vendor = stock_vendor.quantity + product.qty_available
+
+ def unlink(self):
+ if self._name == 'product.product':
+ raise UserError('Maaf anda tidak bisa delete product') \ No newline at end of file