diff options
| author | trisusilo48 <tri.susilo@altama.co.id> | 2025-02-24 11:32:06 +0700 |
|---|---|---|
| committer | trisusilo48 <tri.susilo@altama.co.id> | 2025-02-24 11:32:06 +0700 |
| commit | 7df979b8d5312bb90d13d338f2a787dc35373f17 (patch) | |
| tree | 12a5fd7b487781b52900505a2cffa999da692f9f /indoteknik_custom/models/res_partner.py | |
| parent | a9c4cd0c5ac694074f0e3a4359182a97f27f542e (diff) | |
| parent | 38f8ddd9aaaad58c8d7ea27235cd109ba288693d (diff) | |
Merge branch 'odoo-production' into feature/integrasi_biteship
# Conflicts:
# indoteknik_custom/models/__init__.py
# indoteknik_custom/models/product_template.py
# indoteknik_custom/models/sale_order.py
# indoteknik_custom/security/ir.model.access.csv
Diffstat (limited to 'indoteknik_custom/models/res_partner.py')
| -rw-r--r-- | indoteknik_custom/models/res_partner.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index f081e274..7e574a72 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -147,6 +147,7 @@ class ResPartner(models.Model): "customer is crossed blocking amount." "Set its value to 0.00 to disable " "this feature", tracking=3) + telegram_id = fields.Char(string="Telegram") @api.model def _default_payment_term(self): @@ -182,6 +183,19 @@ class ResPartner(models.Model): # # raise UserError('You name it') # return res + + @api.constrains('name') + def _check_duplicate_name(self): + for record in self: + if record.name: + # Mencari partner lain yang memiliki nama sama (case-insensitive) + existing_partner = self.env['res.partner'].search([ + ('id', '!=', record.id), # Hindari mencocokkan diri sendiri + ('name', '=', record.name) # Case-insensitive search + ], limit=1) + + if existing_partner: + raise ValidationError(f"Nama '{record.name}' sudah digunakan oleh partner lain!") def write(self, vals): # Fungsi rekursif untuk meng-update semua child, termasuk child dari child |
