[MERGE] forward port branch 8.0 up to 2a65b8156d

This commit is contained in:
Christophe Simonis
2017-04-26 19:38:17 +02:00
3 changed files with 13 additions and 8 deletions
+4 -4
View File
@@ -188,7 +188,7 @@ class resource_calendar(osv.osv):
def get_weekdays(self, cr, uid, id, default_weekdays=None, context=None):
""" Return the list of weekdays that contain at least one working interval.
If no id is given (no calendar), return default weekdays. """
if id is None:
if not id:
return default_weekdays if default_weekdays is not None else [0, 1, 2, 3, 4]
calendar = self.browse(cr, uid, id, context=None)
weekdays = set()
@@ -338,7 +338,7 @@ class resource_calendar(osv.osv):
work_dt = start_dt.replace(hour=0, minute=0, second=0)
# no calendar: try to use the default_interval, then return directly
if id is None:
if not id:
working_interval = []
if default_interval:
working_interval = (start_dt.replace(hour=default_interval[0], minute=0, second=0),
@@ -462,7 +462,7 @@ class resource_calendar(osv.osv):
working_intervals = self.get_working_intervals_of_day(cr, uid, id, **call_args)
if id is None and not working_intervals: # no calendar -> consider working 8 hours
if not id and not working_intervals: # no calendar -> consider working 8 hours
remaining_hours -= 8.0
elif working_intervals:
if backwards:
@@ -556,7 +556,7 @@ class resource_calendar(osv.osv):
compute_leaves=compute_leaves, resource_id=resource_id,
default_interval=default_interval,
context=context)
if id is None or working_intervals: # no calendar -> no working hours, but day is considered as worked
if not id or working_intervals: # no calendar -> no working hours, but day is considered as worked
planned_days += 1
intervals += working_intervals
# get next day
+5
View File
@@ -9,6 +9,7 @@ from lxml.builder import E
from psycopg2 import IntegrityError
from openerp.osv.orm import modifiers_tests
from openerp.exceptions import ValidationError
from openerp.tests import common
import openerp.tools
@@ -857,6 +858,10 @@ class test_views(ViewCase):
string="Replacement title", version="7.0"
))
def test_modifiers(self):
# implemeted elsewhere...
modifiers_tests()
class ViewModeField(ViewCase):
"""
This should probably, eventually, be folded back into other test case
+4 -4
View File
@@ -118,13 +118,13 @@ def test_modifiers(what, expected):
node = etree.fromstring(what)
transfer_node_to_modifiers(node, modifiers)
simplify_modifiers(modifiers)
json = simplejson.dumps(modifiers)
assert json == expected, "%s != %s" % (json, expected)
dumped = simplejson.dumps(modifiers)
assert dumped == expected, "%s != %s" % (dumped, expected)
elif isinstance(what, dict):
transfer_field_to_modifiers(what, modifiers)
simplify_modifiers(modifiers)
json = simplejson.dumps(modifiers)
assert json == expected, "%s != %s" % (json, expected)
dumped = simplejson.dumps(modifiers)
assert dumped == expected, "%s != %s" % (dumped, expected)
# To use this test: