summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/purchase_order.py1
-rw-r--r--indoteknik_custom/models/res_partner.py13
2 files changed, 14 insertions, 0 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 12a94730..54d771ba 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -86,6 +86,7 @@ class PurchaseOrder(models.Model):
total_cost_service = fields.Float(string='Total Cost Service')
total_delivery_amt = fields.Float(string='Total Delivery Amt')
store_name = fields.Char(string='Nama Toko')
+ purchase_order_count = fields.Integer('Purchase Order Count', related='partner_id.purchase_order_count')
@api.onchange('total_cost_service')
def _onchange_total_cost_service(self):
diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py
index 5322515a..3c5e0e05 100644
--- a/indoteknik_custom/models/res_partner.py
+++ b/indoteknik_custom/models/res_partner.py
@@ -183,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', 'ilike', 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