From a5e3151dc5afa25d9dc36d7448165eaa6654d4f9 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 9 Jun 2023 12:59:26 +0700 Subject: Disable button delete on table product and contact --- indoteknik_custom/models/product_template.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'indoteknik_custom/models/product_template.py') 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 -- cgit v1.2.3