diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-06-15 15:47:05 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-06-15 15:47:05 +0700 |
| commit | 55c67c71b04fce80c635b3a58d91c8bcb02e17c8 (patch) | |
| tree | ed8833b969800e36b887b4134c14dab89d3b91c7 /indoteknik_custom/models/product_template.py | |
| parent | 1f2995a85428ac4335123bd33d48ae17d3c9f36f (diff) | |
| parent | 24649f8e939484759ef34e5e68f251d951f63c02 (diff) | |
Merge commit '24649f8e939484759ef34e5e68f251d951f63c02'
Conflicts:
indoteknik_custom/__manifest__.py
indoteknik_custom/security/ir.model.access.csv
Diffstat (limited to 'indoteknik_custom/models/product_template.py')
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 11 |
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 |
