Add constraint on percentage in allocation

The percentage field in allocations allowed zero and negative
values. This resulted in computational errors.

issue2729
review443001
This commit is contained in:
Sharoon Thomas
2012-07-26 08:06:23 +05:30
parent 798112f9f3
commit f2dac3b377
+7
View File
@@ -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