Browse Source

Merge pull request #1 from acsone/8.0-imp-accounting-none-sbi

8.0 imp accounting none sbi
pull/169/head
Thomas Binsfeld 9 years ago
parent
commit
6be60bed45
  1. 0
      mis_builder/__openerp__.py
  2. 76
      mis_builder/models/accounting_none.py
  3. 0
      mis_builder/models/aep.py
  4. 0
      mis_builder/models/mis_builder.py

0
mis_builder/__openerp__.py

76
mis_builder/models/accounting_none.py

@ -1,11 +1,13 @@
# -*- coding: utf-8 -*-
# © 2016 Thomas Binsfeld
# © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
"""
Provides the AccountingNone singleton
Provides the AccountingNone singleton.
AccountingNone is a null value that dissolves in basic arithmetic operations,
as illustrated in the examples below
as illustrated in the examples below. In comparisons, AccountingNone behaves
the same as zero.
>>> 1 + 1
2
@ -51,8 +53,38 @@ AccountingNone
AccountingNone
>>> AccountingNone * None
AccountingNone
>>> None * AccountingNone
AccountingNone
>>> str(AccountingNone)
''
>>> bool(AccountingNone)
False
>>> AccountingNone > 0
False
>>> AccountingNone < 0
False
>>> AccountingNone < 1
True
>>> AccountingNone > 1
False
>>> 0 < AccountingNone
False
>>> 0 > AccountingNone
False
>>> 1 < AccountingNone
False
>>> 1 > AccountingNone
True
>>> AccountingNone == 0
True
>>> AccountingNone == 0.0
True
>>> AccountingNone == None
True
"""
__all__ = ['AccountingNone']
class AccountingNoneType(object):
@ -89,10 +121,15 @@ class AccountingNoneType(object):
def __neg__(self):
return self
def __div__(self, other):
if other is AccountingNone:
return AccountingNone
return 0.0
def __rdiv__(self, other):
raise ZeroDivisionError
def __floordiv__(self, other):
"""
Overload of the // operator
"""
if other is AccountingNone:
return AccountingNone
return 0.0
@ -101,9 +138,6 @@ class AccountingNoneType(object):
raise ZeroDivisionError
def __truediv__(self, other):
"""
Overload of the / operator
"""
if other is AccountingNone:
return AccountingNone
return 0.0
@ -116,17 +150,29 @@ class AccountingNoneType(object):
return AccountingNone
return 0.0
def __rmul__(self, other):
if other is None or other is AccountingNone:
return AccountingNone
return 0.0
__rmul__ = __mul__
def __repr__(self):
return 'AccountingNone'
def __unicode__(self):
def __str__(self):
return ''
def __nonzero__(self):
return False
def __bool__(self):
return False
def __eq__(self, other):
return other == 0 or other is None or other is AccountingNone
def __lt__(self, other):
return 0 < other
def __gt__(self, other):
return 0 > other
AccountingNone = AccountingNoneType()

0
mis_builder/models/aep.py

0
mis_builder/models/mis_builder.py

Loading…
Cancel
Save