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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mikolaï Krol
erp5
Commits
b4d0d9ac
Commit
b4d0d9ac
authored
Feb 24, 2016
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
base: do not acquire stop date on currency exchange line
This allows defining an exchange rate without end date
parent
fe105274
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
175 additions
and
10 deletions
+175
-10
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/CurrencyExchangeCell_asPredicate.py
...ortal_skins/erp5_base/CurrencyExchangeCell_asPredicate.py
+1
-1
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/CurrencyExchangeLine_asPredicate.py
...ortal_skins/erp5_base/CurrencyExchangeLine_asPredicate.py
+1
-1
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/CurrencyExchangeLine_view/my_stop_date.xml
...kins/erp5_base/CurrencyExchangeLine_view/my_stop_date.xml
+26
-7
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Currency_view/listbox_stop_date.xml
...ortal_skins/erp5_base/Currency_view/listbox_stop_date.xml
+28
-1
product/ERP5/tests/testERP5CurrencyExchangeLine.py
product/ERP5/tests/testERP5CurrencyExchangeLine.py
+119
-0
No files found.
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/CurrencyExchangeCell_asPredicate.py
View file @
b4d0d9ac
...
@@ -2,7 +2,7 @@ currency_exchange_line = context.getParentValue()
...
@@ -2,7 +2,7 @@ currency_exchange_line = context.getParentValue()
currency
=
currency_exchange_line
.
getParentValue
()
currency
=
currency_exchange_line
.
getParentValue
()
return
context
.
asContext
(
_range_criterion
=
dict
(
start_date
=
(
currency_exchange_line
.
getStartDate
(),
return
context
.
asContext
(
_range_criterion
=
dict
(
start_date
=
(
currency_exchange_line
.
getStartDate
(),
currency_exchange_line
.
getStopDate
()
)),
currency_exchange_line
.
hasStopDate
()
and
currency_exchange_line
.
getStopDate
()
or
None
)),
membership_criterion_base_category
=
[
'price_currency'
,
'resource'
,
'currency_exchange_type'
],
membership_criterion_base_category
=
[
'price_currency'
,
'resource'
,
'currency_exchange_type'
],
membership_criterion_category
=
[
'resource/%s'
%
currency
.
getRelativeUrl
(),
membership_criterion_category
=
[
'resource/%s'
%
currency
.
getRelativeUrl
(),
currency_exchange_line
.
getPriceCurrency
(
base
=
True
),
currency_exchange_line
.
getPriceCurrency
(
base
=
True
),
...
...
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/CurrencyExchangeLine_asPredicate.py
View file @
b4d0d9ac
start_date
=
context
.
getStartDate
()
start_date
=
context
.
getStartDate
()
stop_date
=
context
.
getStopDate
()
stop_date
=
context
.
hasStopDate
()
and
context
.
getStopDate
()
or
None
identity_criterion
=
{
'start_date'
:(
start_date
,
stop_date
)}
identity_criterion
=
{
'start_date'
:(
start_date
,
stop_date
)}
return
context
.
asContext
(
_range_criterion
=
identity_criterion
,
return
context
.
asContext
(
_range_criterion
=
identity_criterion
,
membership_criterion_base_category
=
[
'price_currency'
,
'resource'
],
membership_criterion_base_category
=
[
'price_currency'
,
'resource'
],
...
...
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/CurrencyExchangeLine_view/my_stop_date.xml
View file @
b4d0d9ac
...
@@ -9,7 +9,9 @@
...
@@ -9,7 +9,9 @@
<item>
<item>
<key>
<string>
delegated_list
</string>
</key>
<key>
<string>
delegated_list
</string>
</key>
<value>
<value>
<list/>
<list>
<string>
default
</string>
</list>
</value>
</value>
</item>
</item>
<item>
<item>
...
@@ -50,6 +52,12 @@
...
@@ -50,6 +52,12 @@
<key>
<string>
tales
</string>
</key>
<key>
<string>
tales
</string>
</key>
<value>
<value>
<dictionary>
<dictionary>
<item>
<key>
<string>
default
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<item>
<key>
<string>
field_id
</string>
</key>
<key>
<string>
field_id
</string>
</key>
<value>
<string></string>
</value>
<value>
<string></string>
</value>
...
@@ -70,8 +78,10 @@
...
@@ -70,8 +78,10 @@
<value>
<value>
<dictionary>
<dictionary>
<item>
<item>
<key>
<string>
description
</string>
</key>
<key>
<string>
default
</string>
</key>
<value>
<string>
The end date for validity of the currency exchange rate.
</string>
</value>
<value>
<none/>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
field_id
</string>
</key>
<key>
<string>
field_id
</string>
</key>
...
@@ -85,14 +95,23 @@
...
@@ -85,14 +95,23 @@
<key>
<string>
target
</string>
</key>
<key>
<string>
target
</string>
</key>
<value>
<string>
Click to edit the target
</string>
</value>
<value>
<string>
Click to edit the target
</string>
</value>
</item>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Validity End Date
</string>
</value>
</item>
</dictionary>
</dictionary>
</value>
</value>
</item>
</item>
</dictionary>
</dictionary>
</pickle>
</pickle>
</record>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"TALESMethod"
module=
"Products.Formulator.TALESField"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_text
</string>
</key>
<value>
<string>
python: context.hasStopDate() and context.getStopDate() or None
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
</ZopeData>
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Currency_view/listbox_stop_date.xml
View file @
b4d0d9ac
...
@@ -9,7 +9,9 @@
...
@@ -9,7 +9,9 @@
<item>
<item>
<key>
<string>
delegated_list
</string>
</key>
<key>
<string>
delegated_list
</string>
</key>
<value>
<value>
<list/>
<list>
<string>
default
</string>
</list>
</value>
</value>
</item>
</item>
<item>
<item>
...
@@ -50,6 +52,12 @@
...
@@ -50,6 +52,12 @@
<key>
<string>
tales
</string>
</key>
<key>
<string>
tales
</string>
</key>
<value>
<value>
<dictionary>
<dictionary>
<item>
<key>
<string>
default
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<item>
<key>
<string>
field_id
</string>
</key>
<key>
<string>
field_id
</string>
</key>
<value>
<string></string>
</value>
<value>
<string></string>
</value>
...
@@ -69,6 +77,12 @@
...
@@ -69,6 +77,12 @@
<key>
<string>
values
</string>
</key>
<key>
<string>
values
</string>
</key>
<value>
<value>
<dictionary>
<dictionary>
<item>
<key>
<string>
default
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<item>
<key>
<string>
field_id
</string>
</key>
<key>
<string>
field_id
</string>
</key>
<value>
<string>
my_stop_date
</string>
</value>
<value>
<string>
my_stop_date
</string>
</value>
...
@@ -87,4 +101,17 @@
...
@@ -87,4 +101,17 @@
</dictionary>
</dictionary>
</pickle>
</pickle>
</record>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"TALESMethod"
module=
"Products.Formulator.TALESField"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_text
</string>
</key>
<value>
<string>
python: cell.hasStopDate() and cell.getStopDate() or None
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
</ZopeData>
product/ERP5/tests/testERP5CurrencyExchangeLine.py
View file @
b4d0d9ac
...
@@ -79,6 +79,12 @@ class CurrencyExchangeTestCase(AccountingTestCase):
...
@@ -79,6 +79,12 @@ class CurrencyExchangeTestCase(AccountingTestCase):
'erp5_simulation_test'
'erp5_simulation_test'
)
)
def
_getPriceContext
(
self
,
**
kw
):
"""Returns a temp movement that we can use for getPrice(context=
"""
from
Products.ERP5Type.Document
import
newTempMovement
return
newTempMovement
(
self
.
portal
,
'tmp'
,
**
kw
)
class
TestCurrencyExchangeLine
(
CurrencyExchangeTestCase
):
class
TestCurrencyExchangeLine
(
CurrencyExchangeTestCase
):
"""
"""
...
@@ -495,6 +501,51 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase):
...
@@ -495,6 +501,51 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase):
else
:
else
:
self
.
fail
(
'line not found'
)
self
.
fail
(
'line not found'
)
def
test_date_on_currency_exchange_line
(
self
):
euro
=
self
.
portal
.
currency_module
.
euro
usd
=
self
.
portal
.
currency_module
.
usd
euro_to_usd_before_2016
=
euro
.
newContent
(
portal_type
=
'Currency Exchange Line'
,
stop_date
=
DateTime
(
2015
,
12
,
31
,
23
,
59
),
base_price
=
0.5
,
price_currency_value
=
usd
)
euro_to_usd_before_2016
.
validate
()
euro_to_usd_2016
=
euro
.
newContent
(
portal_type
=
'Currency Exchange Line'
,
start_date
=
DateTime
(
2016
,
1
,
1
),
stop_date
=
DateTime
(
2016
,
12
,
31
,
23
,
59
),
base_price
=
0.6
,
price_currency_value
=
usd
)
euro_to_usd_2016
.
validate
()
euro_to_usd_after_2016
=
euro
.
newContent
(
portal_type
=
'Currency Exchange Line'
,
start_date
=
DateTime
(
2017
,
1
,
1
),
base_price
=
0.7
,
price_currency_value
=
usd
)
euro_to_usd_after_2016
.
validate
()
self
.
tic
()
context_2015
=
self
.
_getPriceContext
(
start_date
=
DateTime
(
2015
,
1
,
1
),
categories
=
[
'resource/currency_module/euro'
,
'price_currency/currency_module/usd'
])
self
.
assertEqual
(
0.5
,
euro
.
getPrice
(
context
=
context_2015
))
context_2016
=
self
.
_getPriceContext
(
start_date
=
DateTime
(
2016
,
1
,
1
),
categories
=
[
'resource/currency_module/euro'
,
'price_currency/currency_module/usd'
])
self
.
assertEqual
(
0.6
,
euro
.
getPrice
(
context
=
context_2016
))
context_2017
=
self
.
_getPriceContext
(
start_date
=
DateTime
(
2017
,
1
,
1
),
categories
=
[
'resource/currency_module/euro'
,
'price_currency/currency_module/usd'
])
self
.
assertEqual
(
0.7
,
euro
.
getPrice
(
context
=
context_2017
))
class
TestCurrencyExchangeCell
(
CurrencyExchangeTestCase
):
class
TestCurrencyExchangeCell
(
CurrencyExchangeTestCase
):
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
currency_exchange_type
=
\
currency_exchange_type
=
\
...
@@ -591,6 +642,74 @@ class TestCurrencyExchangeCell(CurrencyExchangeTestCase):
...
@@ -591,6 +642,74 @@ class TestCurrencyExchangeCell(CurrencyExchangeTestCase):
self
.
assertEqual
(
0.98
,
exchange_ratio
)
self
.
assertEqual
(
0.98
,
exchange_ratio
)
def
test_date_on_currency_exchange_cell
(
self
):
euro
=
self
.
portal
.
currency_module
.
euro
usd
=
self
.
portal
.
currency_module
.
usd
euro_to_usd_before_2016
=
euro
.
newContent
(
portal_type
=
'Currency Exchange Line'
,
stop_date
=
DateTime
(
2015
,
12
,
31
,
23
,
59
),
price_currency_value
=
usd
)
type_a_cell
=
euro_to_usd_before_2016
.
getCell
(
'currency_exchange_type/type_a'
,
'resource/%s'
%
euro
.
getRelativeUrl
(),
'price_currency/%s'
%
usd
.
getRelativeUrl
(),
base_id
=
'path'
)
type_a_cell
.
setBasePrice
(
0.5
)
euro_to_usd_before_2016
.
validate
()
euro_to_usd_2016
=
euro
.
newContent
(
portal_type
=
'Currency Exchange Line'
,
start_date
=
DateTime
(
2016
,
1
,
1
),
stop_date
=
DateTime
(
2016
,
12
,
31
,
23
,
59
),
price_currency_value
=
usd
)
type_a_cell
=
euro_to_usd_2016
.
getCell
(
'currency_exchange_type/type_a'
,
'resource/%s'
%
euro
.
getRelativeUrl
(),
'price_currency/%s'
%
usd
.
getRelativeUrl
(),
base_id
=
'path'
)
type_a_cell
.
setBasePrice
(
0.6
)
euro_to_usd_2016
.
validate
()
euro_to_usd_after_2016
=
euro
.
newContent
(
portal_type
=
'Currency Exchange Line'
,
start_date
=
DateTime
(
2017
,
1
,
1
),
price_currency_value
=
usd
)
type_a_cell
=
euro_to_usd_after_2016
.
getCell
(
'currency_exchange_type/type_a'
,
'resource/%s'
%
euro
.
getRelativeUrl
(),
'price_currency/%s'
%
usd
.
getRelativeUrl
(),
base_id
=
'path'
)
type_a_cell
.
setBasePrice
(
0.7
)
euro_to_usd_after_2016
.
validate
()
self
.
tic
()
context_2015
=
self
.
_getPriceContext
(
start_date
=
DateTime
(
2015
,
1
,
1
),
categories
=
[
'resource/currency_module/euro'
,
'price_currency/currency_module/usd'
,
'currency_exchange_type/type_a'
])
self
.
assertEqual
(
0.5
,
euro
.
getPrice
(
context
=
context_2015
,
portal_type
=
'Currency Exchange Cell'
))
context_2016
=
self
.
_getPriceContext
(
start_date
=
DateTime
(
2016
,
1
,
1
),
categories
=
[
'resource/currency_module/euro'
,
'price_currency/currency_module/usd'
,
'currency_exchange_type/type_a'
])
self
.
assertEqual
(
0.6
,
euro
.
getPrice
(
context
=
context_2016
,
portal_type
=
'Currency Exchange Cell'
))
context_2017
=
self
.
_getPriceContext
(
start_date
=
DateTime
(
2017
,
1
,
1
),
categories
=
[
'resource/currency_module/euro'
,
'price_currency/currency_module/usd'
,
'currency_exchange_type/type_a'
])
self
.
assertEqual
(
0.7
,
euro
.
getPrice
(
context
=
context_2017
,
portal_type
=
'Currency Exchange Cell'
))
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestCurrencyExchangeLine
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestCurrencyExchangeLine
))
...
...
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