From f2dac3b37745bd735d3e95463ea2b5f75aa17b70 Mon Sep 17 00:00:00 2001 From: Sharoon Thomas Date: Thu, 26 Jul 2012 08:06:23 +0530 Subject: [PATCH] Add constraint on percentage in allocation The percentage field in allocations allowed zero and negative values. This resulted in computational errors. issue2729 review443001 --- allocation.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/allocation.py b/allocation.py index 4c3bffbaee..d1b6a87663 100644 --- a/allocation.py +++ b/allocation.py @@ -16,6 +16,13 @@ class Allocation(ModelSQL, ModelView): select=True) percentage = fields.Float('Percentage', digits=(16, 2), required=True) + def __init__(self): + super(Allocation, self).__init__() + self._sql_constraints += [ + ('percentage_positive', 'CHECK(percentage > 0)', + 'Percentage must be greater than zero') + ] + def default_percentage(self): return 100