From 9738d29d66d287719bea583ecee4f11cc5f1e0de Mon Sep 17 00:00:00 2001 From: Daniel STAN Date: Mon, 20 Apr 2015 17:37:43 +0200 Subject: [PATCH] solde(): handle absence de solde Et __float__ pour les attributs --- attributs.py | 3 +++ objets.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/attributs.py b/attributs.py index 19be9e8..2c33efa 100644 --- a/attributs.py +++ b/attributs.py @@ -471,6 +471,9 @@ class floatAttr(Attr): def __unicode__(self): return unicode(self.value) + def __float__(self): + return self.value + class boolAttr(Attr): __slots__ = () python_type = bool diff --git a/objets.py b/objets.py index 2d0911e..382b650 100644 --- a/objets.py +++ b/objets.py @@ -1071,7 +1071,7 @@ class proprio(CransLdapObject): assert isinstance(diff, int) or isinstance(diff, float) assert isinstance(comment, unicode) - solde = float(self["solde"][0].value) + solde = float((self["solde"] or [0.])[0]) new_solde = solde + diff # On vérifie qu'on ne dépasse par le découvert autorisé