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
214ff439
Commit
214ff439
authored
Dec 26, 2018
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Movement: improve code
only calculate exchange rate if necessary use transaction cache
parent
94b5fe63
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
19 deletions
+22
-19
product/ERP5/Document/Movement.py
product/ERP5/Document/Movement.py
+22
-19
No files found.
product/ERP5/Document/Movement.py
View file @
214ff439
...
@@ -42,6 +42,7 @@ from Products.ERP5Type.UnrestrictedMethod import unrestricted_apply
...
@@ -42,6 +42,7 @@ from Products.ERP5Type.UnrestrictedMethod import unrestricted_apply
from
Products.ERP5.mixin.amount_generator
import
AmountGeneratorMixin
from
Products.ERP5.mixin.amount_generator
import
AmountGeneratorMixin
from
Products.ERP5.mixin.composition
import
CompositionMixin
from
Products.ERP5.mixin.composition
import
CompositionMixin
from
Products.ERP5.Document.Amount
import
Amount
from
Products.ERP5.Document.Amount
import
Amount
from
Products.ERP5Type.Cache
import
transactional_cached
from
zLOG
import
LOG
,
WARNING
from
zLOG
import
LOG
,
WARNING
...
@@ -501,28 +502,30 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
...
@@ -501,28 +502,30 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
return
self
.
_getAssetPrice
(
section
=
self
.
getDestinationSectionValue
())
return
self
.
_getAssetPrice
(
section
=
self
.
getDestinationSectionValue
())
def
_getAssetPrice
(
self
,
section
):
def
_getAssetPrice
(
self
,
section
):
from
Products.ERP5Type.Document
import
newTempAccountingTransactionLine
price
=
self
.
getPrice
()
price
=
self
.
getPrice
()
source_currency
=
self
.
getPriceCurrencyValue
()
if
section
is
None
or
not
price
:
section_source_currency
=
section
.
getPriceCurrency
(
base
=
True
)
return
price
if
source_currency
and
section_source_currency
:
source_currency_value
=
self
.
getPriceCurrencyValue
()
temp_transaction
=
newTempAccountingTransactionLine
(
if
source_currency_value
:
self
.
getPortalObject
(),
section_currency
=
section
.
getPriceCurrency
()
"accounting_line"
,
if
section_currency
and
source_currency_value
.
getRelativeUrl
()
!=
section_currency
:
source_section
=
section
.
getRelativeUrl
(),
exchange_rate
=
self
.
_getExchangeRate
(
resource
=
source_currency
.
getRelativeUrl
(),
source_currency_value
,
section_currency
,
self
.
getStartDate
())
start_date
=
self
.
getStartDate
(),
if
exchange_rate
:
)
return
exchange_rate
*
price
exchange_rate
=
source_currency
.
getPrice
(
context
=
temp_transaction
.
asContext
(
categories
=
[
temp_transaction
.
getResource
(
base
=
True
),
section_source_currency
],
)
)
if
exchange_rate
and
price
:
return
exchange_rate
*
price
return
price
return
price
@
transactional_cached
(
lambda
self
,
*
args
:
args
)
def
_getExchangeRate
(
self
,
source_currency_value
,
section_currency
,
start_date
):
from
Products.ERP5Type.Document
import
newTempAccountingTransactionLine
return
source_currency_value
.
getPrice
(
context
=
newTempAccountingTransactionLine
(
self
.
getPortalObject
(),
"accounting_line"
,
resource
=
source_currency_value
.
getRelativeUrl
(),
start_date
=
start_date
,
price_currency
=
section_currency
))
# Causality computation
# Causality computation
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'isConvergent'
)
'isConvergent'
)
...
...
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