Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
preetwinder
erp5
Commits
3e45ec35
Commit
3e45ec35
authored
Nov 28, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support use category for total price calculation.
parent
cad38c81
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
+23
-7
product/ERP5/Document/Delivery.py
product/ERP5/Document/Delivery.py
+23
-7
No files found.
product/ERP5/Document/Delivery.py
View file @
3e45ec35
...
...
@@ -116,7 +116,8 @@ class Delivery(XMLObject, ImmobilisationDelivery, SimulableMixin,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getTotalPrice'
)
def
getTotalPrice
(
self
,
fast
=
0
,
src__
=
0
,
base_contribution
=
None
,
rounding
=
False
,
**
kw
):
def
getTotalPrice
(
self
,
fast
=
0
,
src__
=
0
,
base_contribution
=
None
,
use
=
None
,
rounding
=
False
,
**
kw
):
""" Returns the total price for this order
if the `fast` argument is set to a true value, then it use
SQLCatalog to compute the price, otherwise it sums the total
...
...
@@ -125,35 +126,50 @@ class Delivery(XMLObject, ImmobilisationDelivery, SimulableMixin,
So if the order is not in the catalog, getTotalPrice(fast=1)
will return 0, this is not a bug.
base_contribution must be a relative url of a category.
base_contribution
and use
must be a relative url of a category.
"""
result
=
None
if
not
fast
:
kw
.
setdefault
(
'portal_type'
,
self
.
getPortalDeliveryMovementTypeList
())
if
base_contribution
is
None
:
if
base_contribution
is
None
and
use
is
None
:
result
=
sum
([
line
.
getTotalPrice
(
fast
=
0
)
for
line
in
self
.
objectValues
(
**
kw
)
])
else
:
# Find amounts from movements in the delivery.
if
isinstance
(
base_contribution
,
(
tuple
,
list
)):
base_contribution_list
=
base_contribution
el
s
e
:
el
if
base_contribution
is
not
Non
e
:
base_contribution_list
=
(
base_contribution
,)
base_contribution_value_list
=
[]
else
:
base_contribution_list
=
[]
if
isinstance
(
use
,
(
tuple
,
list
)):
use_list
=
use
elif
use
is
not
None
:
use_list
=
(
use
,)
else
:
use_list
=
[]
portal_categories
=
self
.
portal_categories
base_contribution_value_list
=
[]
for
relative_url
in
base_contribution_list
:
base_contribution_value
=
portal_categories
.
getCategoryValue
(
relative_url
)
if
base_contribution_value
is
not
None
:
base_contribution_value_list
.
append
(
base_contribution_value
)
if
not
base_contribution_value_list
:
use_value_list
=
[]
for
relative_url
in
use_list
:
use_value
=
portal_categories
.
getCategoryValue
(
relative_url
)
if
use_value
is
not
None
:
use_value_list
.
append
(
use_value
)
if
(
base_contribution
is
not
None
and
not
base_contribution_value_list
)
\
or
(
use
is
not
None
and
not
use_value_list
):
# We cannot find any amount so that the result is 0.
result
=
0
else
:
matched_movement_list
=
[
movement
for
movement
in
self
.
getMovementList
()
if
set
(
movement
.
getBaseContributionValueList
()).
intersection
(
base_contribution_value_list
)]
if
set
(
movement
.
getBaseContributionValueList
()).
intersection
(
base_contribution_value_list
)
or
set
(
movement
.
getUseValueList
()).
intersection
(
use_value_list
)]
if
rounding
:
portal_roundings
=
self
.
portal_roundings
matched_movement_list
=
[
...
...
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