diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-09-06 13:59:28 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-09-06 13:59:28 +0700 |
| commit | 4986c63d2a6bd8e2feadbd2403a211b0b0cf405f (patch) | |
| tree | b80d2d415b887a7ab66c9d55d5a4857d34142bea /indoteknik_custom/models/purchase_pricelist.py | |
| parent | ea48748650d1abe7b9c09f961eaa3762750e21be (diff) | |
| parent | e07379886024a313695a56ebdd072bfd87b6626a (diff) | |
Merge branch 'production' into feature/voucher-group
Diffstat (limited to 'indoteknik_custom/models/purchase_pricelist.py')
| -rwxr-xr-x | indoteknik_custom/models/purchase_pricelist.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py index 419ca8e0..6a8a4650 100755 --- a/indoteknik_custom/models/purchase_pricelist.py +++ b/indoteknik_custom/models/purchase_pricelist.py @@ -27,3 +27,18 @@ 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: + 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) +
\ No newline at end of file |
