Skip to content

Commit 6be60be

Browse files
Merge pull request #1 from acsone/8.0-imp-accounting-none-sbi
8.0 imp accounting none sbi
2 parents d91746b + fe4fa67 commit 6be60be

File tree

4 files changed

+61
-15
lines changed

4 files changed

+61
-15
lines changed

mis_builder/__openerp__.py

100755100644
File mode changed.

mis_builder/models/accounting_none.py

100755100644
Lines changed: 61 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# -*- coding: utf-8 -*-
2-
3-
2+
# © 2016 Thomas Binsfeld
3+
# © 2016 ACSONE SA/NV (<http://acsone.eu>)
4+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
45
"""
5-
Provides the AccountingNone singleton
6+
Provides the AccountingNone singleton.
67
78
AccountingNone is a null value that dissolves in basic arithmetic operations,
8-
as illustrated in the examples below
9+
as illustrated in the examples below. In comparisons, AccountingNone behaves
10+
the same as zero.
911
1012
>>> 1 + 1
1113
2
@@ -51,8 +53,38 @@
5153
AccountingNone
5254
>>> AccountingNone * None
5355
AccountingNone
56+
>>> None * AccountingNone
57+
AccountingNone
58+
>>> str(AccountingNone)
59+
''
60+
>>> bool(AccountingNone)
61+
False
62+
>>> AccountingNone > 0
63+
False
64+
>>> AccountingNone < 0
65+
False
66+
>>> AccountingNone < 1
67+
True
68+
>>> AccountingNone > 1
69+
False
70+
>>> 0 < AccountingNone
71+
False
72+
>>> 0 > AccountingNone
73+
False
74+
>>> 1 < AccountingNone
75+
False
76+
>>> 1 > AccountingNone
77+
True
78+
>>> AccountingNone == 0
79+
True
80+
>>> AccountingNone == 0.0
81+
True
82+
>>> AccountingNone == None
83+
True
5484
"""
5585

86+
__all__ = ['AccountingNone']
87+
5688

5789
class AccountingNoneType(object):
5890

@@ -89,10 +121,15 @@ def __pos__(self):
89121
def __neg__(self):
90122
return self
91123

124+
def __div__(self, other):
125+
if other is AccountingNone:
126+
return AccountingNone
127+
return 0.0
128+
129+
def __rdiv__(self, other):
130+
raise ZeroDivisionError
131+
92132
def __floordiv__(self, other):
93-
"""
94-
Overload of the // operator
95-
"""
96133
if other is AccountingNone:
97134
return AccountingNone
98135
return 0.0
@@ -101,9 +138,6 @@ def __rfloordiv__(self, other):
101138
raise ZeroDivisionError
102139

103140
def __truediv__(self, other):
104-
"""
105-
Overload of the / operator
106-
"""
107141
if other is AccountingNone:
108142
return AccountingNone
109143
return 0.0
@@ -116,17 +150,29 @@ def __mul__(self, other):
116150
return AccountingNone
117151
return 0.0
118152

119-
def __rmul__(self, other):
120-
if other is None or other is AccountingNone:
121-
return AccountingNone
122-
return 0.0
153+
__rmul__ = __mul__
123154

124155
def __repr__(self):
125156
return 'AccountingNone'
126157

127-
def __unicode__(self):
158+
def __str__(self):
128159
return ''
129160

161+
def __nonzero__(self):
162+
return False
163+
164+
def __bool__(self):
165+
return False
166+
167+
def __eq__(self, other):
168+
return other == 0 or other is None or other is AccountingNone
169+
170+
def __lt__(self, other):
171+
return 0 < other
172+
173+
def __gt__(self, other):
174+
return 0 > other
175+
130176

131177
AccountingNone = AccountingNoneType()
132178

mis_builder/models/aep.py

100755100644
File mode changed.

mis_builder/models/mis_builder.py

100755100644
File mode changed.

0 commit comments

Comments
 (0)