summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/purchase_pricelist.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2023-08-31 11:57:26 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2023-08-31 11:57:26 +0700
commita0d1350c1eb7b93007ff7e11cf846263d558fc87 (patch)
tree0f3a1d987ef6192281263cdabf42a5db824fc752 /indoteknik_custom/models/purchase_pricelist.py
parentb7dba2d8eed3c2af22dca53a916f12e9b842c2aa (diff)
parent76e97903641e6dc35f4158f2a08cfa70bed50afe (diff)
Merge branch 'validate-product' into production
# Conflicts: # indoteknik_custom/models/product_template.py
Diffstat (limited to 'indoteknik_custom/models/purchase_pricelist.py')
-rwxr-xr-xindoteknik_custom/models/purchase_pricelist.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py
index 419ca8e0..5d077e04 100755
--- a/indoteknik_custom/models/purchase_pricelist.py
+++ b/indoteknik_custom/models/purchase_pricelist.py
@@ -27,3 +27,26 @@ class PurchasePricelist(models.Model):
self.system_last_update = current_time
else:
self.human_last_update = current_time
+
+ @api.constrains('vendor_id', 'product_id','human_last_update','write_date')
+ def _check_duplicate_purchase_pricelist(self):
+ for price in self:
+ if price.write_date == price.create_date:
+ domain = [
+ ('product_id', '=', price.product_id.id),
+ ('vendor_id', '=', price.vendor_id.id)
+ ]
+
+ domain.append(('id', '!=', price.id))
+ massage="Product dan vendor yang anda gunakan sudah ada di purchase pricelist"
+ existing_purchase = self.search(domain, limit=1)
+ if existing_purchase:
+ raise UserError(massage)
+ else:
+ domain = [
+ ('id', '=', price.id)
+ ]
+ massage="Tidak Dapat Merubah Product"
+ existing_purchase = self.search(domain, limit=1)
+ if existing_purchase:
+ raise UserError(massage) \ No newline at end of file