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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
erp5
Commits
8a0c9241
Commit
8a0c9241
authored
Mar 28, 2013
by
Rafael Monnerat
Committed by
Xiaowu Zhang
Feb 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-implement Order.getTotalPrice when base_contribution is provided.
parent
6024c4e3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
23 deletions
+21
-23
product/ERP5/Document/Order.py
product/ERP5/Document/Order.py
+21
-23
No files found.
product/ERP5/Document/Order.py
View file @
8a0c9241
...
@@ -69,20 +69,13 @@ class Order(Delivery):
...
@@ -69,20 +69,13 @@ class Order(Delivery):
def
getTotalPrice
(
self
,
**
kw
)
:
def
getTotalPrice
(
self
,
**
kw
)
:
"""Returns the total price for this Order. """
"""Returns the total price for this Order. """
rounding
=
kw
.
get
(
'rounding'
)
rounding
=
kw
.
get
(
'rounding'
)
if
kw
.
get
(
'base_contribution'
)
is
None
:
if
kw
.
get
(
'base_contribution'
)
is
None
:
kw
.
setdefault
(
'portal_type'
,
self
.
getPortalOrderMovementTypeList
())
kw
.
setdefault
(
'portal_type'
,
self
.
getPortalOrderMovementTypeList
())
return
Delivery
.
getTotalPrice
(
self
,
**
kw
)
return
Delivery
.
getTotalPrice
(
self
,
**
kw
)
else
:
else
:
# Find amounts from the result of getAggregatedAmountList.
# Call getAggregatedAmountList and sum all the amounts which
# base_contribution category is matched with.
from
Products.ERP5Type.Document
import
newTempTradeModelLine
from
Products.ERP5.PropertySheet.TradeModelLine
import
TARGET_LEVEL_MOVEMENT
trade_condition
=
self
.
getSpecialiseValue
()
if
trade_condition
is
None
:
# We cannot find any amount so that the result is 0.
return
0
base_contribution
=
kw
.
get
(
'base_contribution'
)
base_contribution
=
kw
.
get
(
'base_contribution'
)
# Find amounts from movements in the delivery.
if
isinstance
(
base_contribution
,
(
tuple
,
list
)):
if
isinstance
(
base_contribution
,
(
tuple
,
list
)):
base_contribution_list
=
base_contribution
base_contribution_list
=
base_contribution
else
:
else
:
...
@@ -96,20 +89,25 @@ class Order(Delivery):
...
@@ -96,20 +89,25 @@ class Order(Delivery):
if
not
base_contribution_value_list
:
if
not
base_contribution_value_list
:
# We cannot find any amount so that the result is 0.
# We cannot find any amount so that the result is 0.
return
0
return
0
current_aggregated_amount_list
=
trade_condition
.
getAggregatedAmountList
(
self
,
rounding
=
rounding
,
force_create_line
=
True
)
trade_model_line
=
newTempTradeModelLine
(
movement_list
=
self
.
getMovementList
()
self
,
'_temp_'
+
self
.
getId
(),
notify_workflow
=
False
)
# prevent invoking interaction workflows.
trade_model_line
.
portal_type
=
''
if
rounding
:
trade_model_line
.
edit
(
target_level
=
TARGET_LEVEL_MOVEMENT
,
price
=
1
,
portal_roundings
=
self
.
portal_roundings
efficiency
=
1
,
quantity
=
None
,
movement_list
=
[
base_application_value_list
=
base_contribution_value_list
)
portal_roundings
.
getRoundingProxy
(
movement
)
aggregated_amount_list
=
trade_model_line
.
_getAggregatedAmountList
(
for
movement
in
movement_list
]
self
,
movement_list
=
self
.
getMovementList
(),
trade_model_line_list
=
self
.
getAggregatedAmountList
(
rounding
=
rounding
)
current_aggregated_amount_list
=
current_aggregated_amount_list
,
matched_model_line_list
=
[
line
for
line
in
trade_model_line_list
rounding
=
rounding
)
if
set
(
line
.
getBaseApplicationValueList
()).
intersection
(
base_contribution_value_list
)]
return
aggregated_amount_list
.
getTotalPrice
()
result
=
sum
([
movement
.
getTotalPrice
()
for
movement
in
movement_list
])
result
+=
sum
([
line
.
getTotalPrice
()
for
line
in
matched_model_line_list
])
return
result
def
getTotalQuantity
(
self
,
**
kw
)
:
def
getTotalQuantity
(
self
,
**
kw
)
:
"""Returns the total quantity for this Order. """
"""Returns the total quantity for this Order. """
...
...
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