Commit b35b8d44 authored by Jérome Perrin's avatar Jérome Perrin

Merge remote-tracking branch 'origin/master' into zope4py2

parents 64e9f5d8 8148bdab
maileva_connector = context.portal_catalog.getResultValue( maileva_connector = context.portal_catalog.getResultValue(
portal_type='Maileva SOAP Connector',
reference=reference, reference=reference,
validation_state='validated') validation_state='validated')
if not maileva_connector: if not maileva_connector:
......
...@@ -67,10 +67,7 @@ ...@@ -67,10 +67,7 @@
<item> <item>
<key> <string>workflow_managed_permission</string> </key> <key> <string>workflow_managed_permission</string> </key>
<value> <value>
<tuple> <tuple/>
<string>Modify portal content</string>
<string>Add portal content</string>
</tuple>
</value> </value>
</item> </item>
</dictionary> </dictionary>
......
...@@ -9,10 +9,7 @@ ...@@ -9,10 +9,7 @@
<item> <item>
<key> <string>acquire_permission</string> </key> <key> <string>acquire_permission</string> </key>
<value> <value>
<tuple> <tuple/>
<string>Modify portal content</string>
<string>Add portal content</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -67,42 +64,7 @@ ...@@ -67,42 +64,7 @@
<item> <item>
<key> <string>data</string> </key> <key> <string>data</string> </key>
<value> <value>
<dictionary> <dictionary/>
<item>
<key> <string>Add portal content</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Authenticated</string>
<string>Associate</string>
<string>Author</string>
<string>Member</string>
<string>Assignee</string>
<string>Manager</string>
<string>Auditor</string>
<string>Owner</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
<item>
<key> <string>Modify portal content</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Authenticated</string>
<string>Author</string>
<string>Associate</string>
<string>Member</string>
<string>Assignee</string>
<string>Manager</string>
<string>Auditor</string>
<string>Owner</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
</dictionary>
</value> </value>
</item> </item>
</dictionary> </dictionary>
......
...@@ -9,10 +9,7 @@ ...@@ -9,10 +9,7 @@
<item> <item>
<key> <string>acquire_permission</string> </key> <key> <string>acquire_permission</string> </key>
<value> <value>
<tuple> <tuple/>
<string>Modify portal content</string>
<string>Add portal content</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -66,42 +63,7 @@ ...@@ -66,42 +63,7 @@
<item> <item>
<key> <string>data</string> </key> <key> <string>data</string> </key>
<value> <value>
<dictionary> <dictionary/>
<item>
<key> <string>Add portal content</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Authenticated</string>
<string>Associate</string>
<string>Author</string>
<string>Member</string>
<string>Assignee</string>
<string>Manager</string>
<string>Auditor</string>
<string>Owner</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
<item>
<key> <string>Modify portal content</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Authenticated</string>
<string>Author</string>
<string>Associate</string>
<string>Member</string>
<string>Assignee</string>
<string>Manager</string>
<string>Auditor</string>
<string>Owner</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
</dictionary>
</value> </value>
</item> </item>
</dictionary> </dictionary>
......
...@@ -9,10 +9,7 @@ ...@@ -9,10 +9,7 @@
<item> <item>
<key> <string>acquire_permission</string> </key> <key> <string>acquire_permission</string> </key>
<value> <value>
<tuple> <tuple/>
<string>Modify portal content</string>
<string>Add portal content</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -66,42 +63,7 @@ ...@@ -66,42 +63,7 @@
<item> <item>
<key> <string>data</string> </key> <key> <string>data</string> </key>
<value> <value>
<dictionary> <dictionary/>
<item>
<key> <string>Add portal content</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Authenticated</string>
<string>Associate</string>
<string>Author</string>
<string>Member</string>
<string>Assignee</string>
<string>Manager</string>
<string>Auditor</string>
<string>Owner</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
<item>
<key> <string>Modify portal content</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Authenticated</string>
<string>Author</string>
<string>Associate</string>
<string>Member</string>
<string>Assignee</string>
<string>Manager</string>
<string>Auditor</string>
<string>Owner</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
</dictionary>
</value> </value>
</item> </item>
</dictionary> </dictionary>
......
...@@ -9,10 +9,7 @@ ...@@ -9,10 +9,7 @@
<item> <item>
<key> <string>acquire_permission</string> </key> <key> <string>acquire_permission</string> </key>
<value> <value>
<tuple> <tuple/>
<string>Modify portal content</string>
<string>Add portal content</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -57,42 +54,7 @@ ...@@ -57,42 +54,7 @@
<item> <item>
<key> <string>data</string> </key> <key> <string>data</string> </key>
<value> <value>
<dictionary> <dictionary/>
<item>
<key> <string>Add portal content</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Authenticated</string>
<string>Associate</string>
<string>Author</string>
<string>Member</string>
<string>Assignee</string>
<string>Manager</string>
<string>Auditor</string>
<string>Owner</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
<item>
<key> <string>Modify portal content</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Authenticated</string>
<string>Author</string>
<string>Associate</string>
<string>Member</string>
<string>Assignee</string>
<string>Manager</string>
<string>Auditor</string>
<string>Owner</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
</dictionary>
</value> </value>
</item> </item>
</dictionary> </dictionary>
......
...@@ -28,6 +28,8 @@ from __future__ import absolute_import ...@@ -28,6 +28,8 @@ from __future__ import absolute_import
# #
############################################################################## ##############################################################################
import datetime
from DateTime import DateTime
from .TargetSolver import TargetSolver from .TargetSolver import TargetSolver
class CopyToTarget(TargetSolver): class CopyToTarget(TargetSolver):
...@@ -60,13 +62,11 @@ class CopyToTarget(TargetSolver): ...@@ -60,13 +62,11 @@ class CopyToTarget(TargetSolver):
quantity_ratio = 0 quantity_ratio = 0
if old_quantity not in (None,0.0): # XXX: What if quantity happens to be an integer ? if old_quantity not in (None,0.0): # XXX: What if quantity happens to be an integer ?
quantity_ratio = new_quantity / old_quantity quantity_ratio = new_quantity / old_quantity
start_date_delta = 0 stop_date_delta = start_date_delta = datetime.timedelta()
stop_date_delta = 0
# get the date delta in milliseconds, to prevent rounding issues
if new_start_date is not None and old_start_date is not None: if new_start_date is not None and old_start_date is not None:
start_date_delta = new_start_date.millis() - old_start_date.millis() start_date_delta = new_start_date.asdatetime() - old_start_date.asdatetime()
if new_stop_date is not None and old_stop_date is not None: if new_stop_date is not None and old_stop_date is not None:
stop_date_delta = new_stop_date.millis() - old_stop_date.millis() stop_date_delta = new_stop_date.asdatetime() - old_stop_date.asdatetime()
return { return {
'quantity_ratio': quantity_ratio, 'quantity_ratio': quantity_ratio,
'start_date_delta': start_date_delta, 'start_date_delta': start_date_delta,
...@@ -87,15 +87,14 @@ class CopyToTarget(TargetSolver): ...@@ -87,15 +87,14 @@ class CopyToTarget(TargetSolver):
""" """
Generate values to save on simulation movement. Generate values to save on simulation movement.
""" """
from erp5.component.module.DateUtils import createDateTimeFromMillis
value_dict = {} value_dict = {}
# Modify quantity, start_date, stop_date # Modify quantity, start_date, stop_date
start_date = simulation_movement.getStartDate() start_date = simulation_movement.getStartDate()
if start_date is not None: if start_date is not None:
value_dict['start_date'] = createDateTimeFromMillis(start_date.millis() + start_date_delta) value_dict['start_date'] = DateTime(start_date.asdatetime() + start_date_delta)
stop_date = simulation_movement.getStopDate() stop_date = simulation_movement.getStopDate()
if stop_date is not None: if stop_date is not None:
value_dict['stop_date'] = createDateTimeFromMillis(stop_date.millis() + stop_date_delta) value_dict['stop_date'] = DateTime(stop_date.asdatetime() + stop_date_delta)
value_dict['quantity'] = simulation_movement.getQuantity() * quantity_ratio value_dict['quantity'] = simulation_movement.getQuantity() * quantity_ratio
return value_dict return value_dict
......
...@@ -453,30 +453,6 @@ def convertDateToHour(date=None): ...@@ -453,30 +453,6 @@ def convertDateToHour(date=None):
hour_ = (ordinal_date - ordinal_reference_date) * number_of_hours_in_day + number_of_hours_in_day + date.hour() hour_ = (ordinal_date - ordinal_reference_date) * number_of_hours_in_day + number_of_hours_in_day + date.hour()
return int(hour_) return int(hour_)
def createDateTimeFromMillis(millis): # pylint: disable=redefined-outer-name
"""
Returns a DateTime object, build from the number of milliseconds since epoch.
Parameter should be a int or long.
This one should be used by solvers, as DateTime.__cmp__ actually only
compares the _millis parameter of the two DateTime objects.
This is currently not perfect: DateTime only supports creating a new object
from a floating point number of seconds since epoch, so a rounding issue is
still possible, that's why _millis is explicitely set to the same value
after the DateTime object has been created from (millis / 1000.)
A better way would be to compute (yr,mo,dy,hr,mn,sc,tz,t,d,s,millisecs) from
millis, and then create the DateTime object from it (see "elif ac == 11:" in
DateTime._parse_args).
Another solution would be a DateTime implementation that relies exclusively
on integer values internally.
"""
millis = long(millis)
date = DateTime(millis / 1000.)
date._millis = millis
return date
def getNumberOfDayInMonth(date): def getNumberOfDayInMonth(date):
month = date.month() month = date.month()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment