From 53aca0ee6e0940021def72f8b0a5395fb13593fa Mon Sep 17 00:00:00 2001 From: houssine Date: Tue, 11 Jun 2019 19:32:53 +0200 Subject: [PATCH 1/2] [IMP] add check in validate function --- easy_my_coop/models/operation_request.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/easy_my_coop/models/operation_request.py b/easy_my_coop/models/operation_request.py index 28b2dc7..34d4a07 100644 --- a/easy_my_coop/models/operation_request.py +++ b/easy_my_coop/models/operation_request.py @@ -175,6 +175,13 @@ class operation_request(models.Model): " shares that he/she owns.")) if self.operation_type == 'convert': + amount_to_convert = self.share_unit_price * self.quantity + share_price = self.share_to_product_id.list_price + remainder = amount_to_convert % share_price + + if remainder != 0: + raise ValidationError(_("The conversion must give a whole" + " number for quantity")) if self.company_id.unmix_share_type: if self.share_product_id.code == self.share_to_product_id.code: raise ValidationError(_("You can't convert the share to" @@ -228,7 +235,7 @@ class operation_request(models.Model): elif rec.operation_type == 'convert': amount_to_convert = rec.share_unit_price * rec.quantity convert_quant = int(amount_to_convert / rec.share_to_product_id.list_price) - remainder = amount_to_convert % rec.share_to_product_id.list_price + remainder = amount_to_convert % rec.share_to_product_id.list_price if convert_quant > 0 and remainder == 0: share_ids = rec.partner_id.share_ids From 80e58389f143884f89a88822658cb2beeb53aa76 Mon Sep 17 00:00:00 2001 From: houssine Date: Wed, 12 Jun 2019 09:57:51 +0200 Subject: [PATCH 2/2] [IMP] remove state dield from there --- easy_my_coop/view/operation_request_view.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/easy_my_coop/view/operation_request_view.xml b/easy_my_coop/view/operation_request_view.xml index 7f07bda..6fb444f 100644 --- a/easy_my_coop/view/operation_request_view.xml +++ b/easy_my_coop/view/operation_request_view.xml @@ -32,7 +32,6 @@ -