Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
weboob
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
179
Issues
179
List
Boards
Labels
Milestones
Merge Requests
53
Merge Requests
53
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
weboob
weboob
Commits
cb957a57
Commit
cb957a57
authored
Feb 27, 2020
by
Vincent Ardisson
Committed by
Vincent A
Jan 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
weboob.capabilities.bill: warnings when using deprecated .income and .price
parent
5ebc341b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletion
+25
-1
weboob/capabilities/base.py
weboob/capabilities/base.py
+4
-0
weboob/capabilities/bill.py
weboob/capabilities/bill.py
+21
-1
No files found.
weboob/capabilities/base.py
View file @
cb957a57
...
...
@@ -679,3 +679,7 @@ class Currency(object):
def
capability_to_string
(
capability_klass
):
return
re
.
match
(
r'^Cap(\w+)'
,
capability_klass
.
__name__
)
.
group
(
1
)
.
lower
()
class
DeprecatedFieldWarning
(
UserWarning
):
pass
weboob/capabilities/bill.py
View file @
cb957a57
...
...
@@ -17,10 +17,11 @@
# You should have received a copy of the GNU Lesser General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
import
warnings
from
.base
import
(
BaseObject
,
StringField
,
DecimalField
,
BoolField
,
UserError
,
Currency
,
Field
,
empty
,
empty
,
DeprecatedFieldWarning
,
)
from
.date
import
DateField
from
.collection
import
CapCollection
...
...
@@ -124,12 +125,21 @@ class Bill(Document, Currency):
# compatibility properties
@
property
def
price
(
self
):
warnings
.
warn
(
'Field "price" is deprecated, use "total_amount" field instead.'
,
DeprecatedFieldWarning
,
stacklevel
=
3
,
)
if
empty
(
self
.
total_price
):
return
self
.
total_price
return
abs
(
self
.
total_price
)
@
price
.
setter
def
price
(
self
,
value
):
warnings
.
warn
(
'Field "price" is deprecated, use "total_amount" field instead.'
,
DeprecatedFieldWarning
,
stacklevel
=
3
,
)
if
empty
(
value
):
self
.
total_price
=
value
self
.
_income
=
None
...
...
@@ -144,12 +154,22 @@ class Bill(Document, Currency):
@
property
def
income
(
self
):
warnings
.
warn
(
'Field "income" is deprecated, use "total_amount" field instead.'
,
DeprecatedFieldWarning
,
stacklevel
=
3
,
)
if
empty
(
self
.
total_price
):
return
self
.
_income
or
False
return
self
.
total_price
<=
0
@
income
.
setter
def
income
(
self
,
value
):
warnings
.
warn
(
'Field "income" is deprecated, use "total_amount" field instead.'
,
DeprecatedFieldWarning
,
stacklevel
=
3
,
)
if
empty
(
self
.
total_price
):
self
.
_income
=
value
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment