From 61c89397e839f546c796a596a1fbbc840aa85311 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 28 Aug 2023 15:04:51 +0700 Subject: Validate Data Product & Purchase Pricelist --- indoteknik_custom/models/purchase_pricelist.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'indoteknik_custom/models/purchase_pricelist.py') 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 -- cgit v1.2.3 From 513bce9e13dee0453ce24b41a54d3b408e58c7f0 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 5 Sep 2023 14:45:18 +0700 Subject: Fix bug solr product variants, add analytic tags to jurnal entries line, remove validation edit di purchase pricelist --- indoteknik_custom/models/purchase_pricelist.py | 5 ----- 1 file changed, 5 deletions(-) (limited to 'indoteknik_custom/models/purchase_pricelist.py') diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py index 5d077e04..86a5544d 100755 --- a/indoteknik_custom/models/purchase_pricelist.py +++ b/indoteknik_custom/models/purchase_pricelist.py @@ -42,11 +42,6 @@ class PurchasePricelist(models.Model): 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 -- cgit v1.2.3 From c4bf293cd29fab412d38e7590acdc99f2456c0d8 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 5 Sep 2023 15:05:06 +0700 Subject: fix purchase pricelist --- indoteknik_custom/models/purchase_pricelist.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'indoteknik_custom/models/purchase_pricelist.py') diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py index 86a5544d..6a8a4650 100755 --- a/indoteknik_custom/models/purchase_pricelist.py +++ b/indoteknik_custom/models/purchase_pricelist.py @@ -31,17 +31,14 @@ class PurchasePricelist(models.Model): @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) - existing_purchase = self.search(domain, limit=1) - if existing_purchase: - raise UserError(massage) \ No newline at end of file + 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 -- cgit v1.2.3