diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-06-09 12:59:26 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-06-09 12:59:26 +0700 |
| commit | a5e3151dc5afa25d9dc36d7448165eaa6654d4f9 (patch) | |
| tree | f768b20563c66139c4f06e302aa5871e96ed34e8 | |
| parent | dd785718ca1e7fd1da034dec2bb2c8bf8381def6 (diff) | |
Disable button delete on table product and contact
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 11 | ||||
| -rw-r--r-- | indoteknik_custom/models/res_partner.py | 7 |
2 files changed, 18 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 diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index eaf93717..77abaaf9 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -1,4 +1,5 @@ from odoo import models, fields +from odoo.exceptions import UserError, ValidationError class GroupPartner(models.Model): _name = 'group.partner' @@ -13,3 +14,9 @@ class ResPartner(models.Model): custom_pricelist_id = fields.Many2one('product.pricelist', string='Price Matrix') group_partner_id = fields.Many2one('group.partner', string='Group Partner') + def unlink(self): + if self._name == 'res.partner': + raise UserError('Maaf anda tidak bisa delete contact') + + + |
