Mercurial > hgweb > health
changeset 2818:9bc93b909d82 stable
fix bug #52579: some on_change numeric method operations generate traceback
| author | Luis Falcon <falcon@gnu.org> |
|---|---|
| date | Sun, 03 Dec 2017 11:23:44 +0000 |
| parents | 206182f73a91 |
| children | 086b1b7aba01 |
| files | tryton/health/health.py tryton/health_lab/health_lab.py |
| diffstat | 2 files changed, 13 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/tryton/health/health.py +++ b/tryton/health/health.py @@ -4659,11 +4659,12 @@ def on_change_with_whr(self): waist = self.abdominal_circ hip = self.hip - if (hip > 0): - whr = round((waist / hip),2) - else: - whr = 0 - return whr + if waist and hip: + if (hip > 0): + whr = round((waist / hip),2) + else: + whr = 0 + return whr def get_rec_name(self, name): return str(self.evaluation_start)
--- a/tryton/health_lab/health_lab.py +++ b/tryton/health_lab/health_lab.py @@ -224,9 +224,13 @@ @fields.depends('result', 'lower_limit', 'upper_limit') def on_change_with_warning(self): - if (self.result < self.lower_limit or self.result > self.upper_limit): - return True - return False + if (self.result and self.lower_limit): + if (self.result < self.lower_limit): + return True + + if (self.result and self.upper_limit): + if (self.result > self.upper_limit): + return True @classmethod def check_xml_record(cls, records, values):
