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

*: refactor with a modified 2to3's numliterals fixer

this used a modified numliterals that:
 - do not rewrite 1L as 1
 - rewrite 01 as 1 and only rewrite as 0o1 when more than 2 digits,
because we had mostly dates written as DateTime(2019, 01, 10) that we
want to rewrite as DateTime(2019, 1, 10), not DateTime(2019, 0o1, 10)
parent 6d0d0fcb
...@@ -6,7 +6,7 @@ section_title = 'My Organisation' ...@@ -6,7 +6,7 @@ section_title = 'My Organisation'
portal = context.getPortalObject() portal = context.getPortalObject()
accounting_module = portal.accounting_module accounting_module = portal.accounting_module
year = 2005 year = 2005
default_date = DateTime(year, 01, 01) default_date = DateTime(year, 1, 1)
business_process = portal.portal_catalog.getResultValue( business_process = portal.portal_catalog.getResultValue(
reference=('default_erp5_business_process', # erp5_configurator reference=('default_erp5_business_process', # erp5_configurator
......
...@@ -101,8 +101,8 @@ for month in range(1, month_count + 1): ...@@ -101,8 +101,8 @@ for month in range(1, month_count + 1):
source_payment=getBankAccountByTitle('My default bank account'), source_payment=getBankAccountByTitle('My default bank account'),
destination_section=getOrganisationByTitle(client_title), destination_section=getOrganisationByTitle(client_title),
created_by_builder=1, created_by_builder=1,
start_date=DateTime(year, month, day, 01, 01) + 10, start_date=DateTime(year, month, day, 1, 1) + 10,
stop_date=DateTime(year, month, day, 01, 01) + 10, stop_date=DateTime(year, month, day, 1, 1) + 10,
causality_value=tr, causality_value=tr,
resource=euro_resource, resource=euro_resource,
) )
......
...@@ -52,7 +52,7 @@ class TestDSNSocialDeclarationReport(ERP5TypeTestCase): ...@@ -52,7 +52,7 @@ class TestDSNSocialDeclarationReport(ERP5TypeTestCase):
""" """
self.portal = self.getPortalObject() self.portal = self.getPortalObject()
self.dsn_module = self.portal.getDefaultModuleValue("DSN Monthly Report") self.dsn_module = self.portal.getDefaultModuleValue("DSN Monthly Report")
self.pinDateTime(DateTime(2015, 12, 01)) self.pinDateTime(DateTime(2015, 12, 1))
# Create the id_group 'dsn_event_counter' # Create the id_group 'dsn_event_counter'
self.portal.portal_ids.generateNewId(id_group='dsn_event_counter', id_generator='continuous_integer_increasing') self.portal.portal_ids.generateNewId(id_group='dsn_event_counter', id_generator='continuous_integer_increasing')
......
...@@ -58,7 +58,7 @@ class OscommerceERP5NodeConduit(TioSafeBaseConduit): ...@@ -58,7 +58,7 @@ class OscommerceERP5NodeConduit(TioSafeBaseConduit):
destination=object.getRelativeUrl(), destination=object.getRelativeUrl(),
destination_decision=object.getRelativeUrl(), destination_decision=object.getRelativeUrl(),
destination_administration=object.getRelativeUrl(), destination_administration=object.getRelativeUrl(),
version=001) version=0o01)
stc.validate() stc.validate()
def afterCreateMethod(self, object, **kw): def afterCreateMethod(self, object, **kw):
......
...@@ -40,7 +40,7 @@ class ERP5DeliveredNodeConduit(ERP5NodeConduit): ...@@ -40,7 +40,7 @@ class ERP5DeliveredNodeConduit(ERP5NodeConduit):
stc = object.getPortalObject().sale_trade_condition_module.newContent(title="%s %s" %(site.getReference(), object.getTitle()), stc = object.getPortalObject().sale_trade_condition_module.newContent(title="%s %s" %(site.getReference(), object.getTitle()),
specialise=default_stc, specialise=default_stc,
destination=object.getRelativeUrl(), destination=object.getRelativeUrl(),
version=001) version=0o01)
stc.validate() stc.validate()
def _updateSaleTradeCondition(self, object, **kw): def _updateSaleTradeCondition(self, object, **kw):
......
...@@ -42,7 +42,7 @@ class ERP5InvoicedNodeConduit(ERP5NodeConduit): ...@@ -42,7 +42,7 @@ class ERP5InvoicedNodeConduit(ERP5NodeConduit):
specialise=default_stc, specialise=default_stc,
destination_decision=object.getRelativeUrl(), destination_decision=object.getRelativeUrl(),
destination_administration=object.getRelativeUrl(), destination_administration=object.getRelativeUrl(),
version=001) version=0o01)
stc.validate() stc.validate()
def _updateSaleTradeCondition(self, object, **kw): def _updateSaleTradeCondition(self, object, **kw):
......
...@@ -40,7 +40,7 @@ class ERP5DeliveredNodeConduit(ERP5NodeConduit): ...@@ -40,7 +40,7 @@ class ERP5DeliveredNodeConduit(ERP5NodeConduit):
stc = object.getPortalObject().sale_trade_condition_module.newContent(title="%s %s" %(site.getReference(), object.getTitle()), stc = object.getPortalObject().sale_trade_condition_module.newContent(title="%s %s" %(site.getReference(), object.getTitle()),
specialise=default_stc, specialise=default_stc,
destination=object.getRelativeUrl(), destination=object.getRelativeUrl(),
version=001) version=0o01)
stc.validate() stc.validate()
def _updateSaleTradeCondition(self, object, **kw): def _updateSaleTradeCondition(self, object, **kw):
......
...@@ -42,7 +42,7 @@ class ERP5InvoicedNodeConduit(ERP5NodeConduit): ...@@ -42,7 +42,7 @@ class ERP5InvoicedNodeConduit(ERP5NodeConduit):
specialise=default_stc, specialise=default_stc,
destination_decision=object.getRelativeUrl(), destination_decision=object.getRelativeUrl(),
destination_administration=object.getRelativeUrl(), destination_administration=object.getRelativeUrl(),
version=001) version=0o01)
stc.validate() stc.validate()
def _updateSaleTradeCondition(self, object, **kw): def _updateSaleTradeCondition(self, object, **kw):
......
...@@ -113,7 +113,7 @@ class FTPConnector(XMLObject): ...@@ -113,7 +113,7 @@ class FTPConnector(XMLObject):
finally: finally:
conn.logout() conn.logout()
def createDirectory(self, path, mode=0777): def createDirectory(self, path, mode=0o777):
"""Create a directory `path`, with file mode `mode`. """Create a directory `path`, with file mode `mode`.
The directory is created immediatly, even if transaction is aborted. The directory is created immediatly, even if transaction is aborted.
......
...@@ -278,7 +278,7 @@ class SlapOSControler(object): ...@@ -278,7 +278,7 @@ class SlapOSControler(object):
partition_path = os.path.join(instance_root, partition_reference) partition_path = os.path.join(instance_root, partition_reference)
if not(os.path.exists(partition_path)): if not(os.path.exists(partition_path)):
os.mkdir(partition_path) os.mkdir(partition_path)
os.chmod(partition_path, 0750) os.chmod(partition_path, 0o750)
computer.updateConfiguration(xml_marshaller.xml_marshaller.dumps({ computer.updateConfiguration(xml_marshaller.xml_marshaller.dumps({
'address': config['ipv4_address'], 'address': config['ipv4_address'],
'instance_root': instance_root, 'instance_root': instance_root,
......
...@@ -196,7 +196,7 @@ class CertificateAuthorityTool(BaseTool): ...@@ -196,7 +196,7 @@ class CertificateAuthorityTool(BaseTool):
cert = os.path.join(self.certificate_authority_path, 'certs', cert = os.path.join(self.certificate_authority_path, 'certs',
new_id + '.crt') new_id + '.crt')
try: try:
os.close(os.open(key, os.O_CREAT | os.O_EXCL, 0600)) os.close(os.open(key, os.O_CREAT | os.O_EXCL, 0o600))
popenCommunicate([self.openssl_binary, 'req', '-utf8', '-nodes', '-config', popenCommunicate([self.openssl_binary, 'req', '-utf8', '-nodes', '-config',
self.openssl_config, '-new', '-keyout', key, '-out', csr, '-days', self.openssl_config, '-new', '-keyout', key, '-out', csr, '-days',
'3650'], '%s\n' % common_name, stdin=subprocess.PIPE) '3650'], '%s\n' % common_name, stdin=subprocess.PIPE)
......
...@@ -541,8 +541,8 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): ...@@ -541,8 +541,8 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase):
id = 'empty_invoice', id = 'empty_invoice',
portal_type = self.invoice_portal_type, portal_type = self.invoice_portal_type,
resource = currency.getRelativeUrl(), resource = currency.getRelativeUrl(),
stop_date = DateTime(2004, 01, 01), stop_date = DateTime(2004, 1, 1),
start_date = DateTime(2004, 01, 01), start_date = DateTime(2004, 1, 1),
source_section = vendor.getRelativeUrl(), source_section = vendor.getRelativeUrl(),
destination_section = client.getRelativeUrl(), destination_section = client.getRelativeUrl(),
created_by_builder = 1, created_by_builder = 1,
...@@ -572,8 +572,8 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): ...@@ -572,8 +572,8 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase):
portal_type = self.invoice_portal_type, portal_type = self.invoice_portal_type,
resource = currency.getRelativeUrl(), resource = currency.getRelativeUrl(),
price_currency = currency.getRelativeUrl(), price_currency = currency.getRelativeUrl(),
stop_date = DateTime(2004, 01, 01), stop_date = DateTime(2004, 1, 1),
start_date = DateTime(2004, 01, 01), start_date = DateTime(2004, 1, 1),
source_section = vendor.getRelativeUrl(), source_section = vendor.getRelativeUrl(),
destination_section = client.getRelativeUrl(), destination_section = client.getRelativeUrl(),
created_by_builder = 1, created_by_builder = 1,
...@@ -610,8 +610,8 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): ...@@ -610,8 +610,8 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase):
id = 'other_simple_invoice', id = 'other_simple_invoice',
portal_type = self.invoice_portal_type, portal_type = self.invoice_portal_type,
resource = currency.getRelativeUrl(), resource = currency.getRelativeUrl(),
stop_date = DateTime(2004, 01, 01), stop_date = DateTime(2004, 1, 1),
start_date = DateTime(2004, 01, 01), start_date = DateTime(2004, 1, 1),
source_section = vendor.getRelativeUrl(), source_section = vendor.getRelativeUrl(),
destination_section = client.getRelativeUrl(), destination_section = client.getRelativeUrl(),
created_by_builder = 1, created_by_builder = 1,
...@@ -693,8 +693,8 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): ...@@ -693,8 +693,8 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase):
id = 'simple_invoice_two_lines', id = 'simple_invoice_two_lines',
portal_type = self.invoice_portal_type, portal_type = self.invoice_portal_type,
resource = currency.getRelativeUrl(), resource = currency.getRelativeUrl(),
stop_date = DateTime(2004, 01, 01), stop_date = DateTime(2004, 1, 1),
start_date = DateTime(2004, 01, 01), start_date = DateTime(2004, 1, 1),
source_section = vendor.getRelativeUrl(), source_section = vendor.getRelativeUrl(),
destination_section = client.getRelativeUrl(), destination_section = client.getRelativeUrl(),
created_by_builder = 1, created_by_builder = 1,
...@@ -738,8 +738,8 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): ...@@ -738,8 +738,8 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase):
id = 'simple_invoice_two_cells', id = 'simple_invoice_two_cells',
portal_type = self.invoice_portal_type, portal_type = self.invoice_portal_type,
resource = currency.getRelativeUrl(), resource = currency.getRelativeUrl(),
stop_date = DateTime(2004, 01, 01), stop_date = DateTime(2004, 1, 1),
start_date = DateTime(2004, 01, 01), start_date = DateTime(2004, 1, 1),
source_section = vendor.getRelativeUrl(), source_section = vendor.getRelativeUrl(),
destination_section = client.getRelativeUrl(), destination_section = client.getRelativeUrl(),
created_by_builder = 1, created_by_builder = 1,
...@@ -815,8 +815,8 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): ...@@ -815,8 +815,8 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase):
portal_type = self.invoice_portal_type, portal_type = self.invoice_portal_type,
resource = currency.getRelativeUrl(), resource = currency.getRelativeUrl(),
price_currency = currency.getRelativeUrl(), price_currency = currency.getRelativeUrl(),
stop_date = DateTime(2004, 01, 01), stop_date = DateTime(2004, 1, 1),
start_date = DateTime(2004, 01, 01), start_date = DateTime(2004, 1, 1),
source_section = vendor.getRelativeUrl(), source_section = vendor.getRelativeUrl(),
destination_section = client.getRelativeUrl(), destination_section = client.getRelativeUrl(),
created_by_builder = 1, created_by_builder = 1,
......
...@@ -142,7 +142,7 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -142,7 +142,7 @@ class TestAlarm(ERP5TypeTestCase):
right_first_date = DateTime(self.date_format % (2006,10,6,15,00,00)) right_first_date = DateTime(self.date_format % (2006,10,6,15,00,00))
now = DateTime(self.date_format % (2006,10,6,15,00,00)) now = DateTime(self.date_format % (2006,10,6,15,00,00))
right_second_date = DateTime(self.date_format % (2006,10,6,21,00,00)) right_second_date = DateTime(self.date_format % (2006,10,6,21,00,00))
right_third_date = DateTime(self.date_format % (2006,10,7,06,00,00)) right_third_date = DateTime(self.date_format % (2006,10,7,6,00,00))
right_fourth_date = DateTime(self.date_format % (2006,10,7,10,00,00)) right_fourth_date = DateTime(self.date_format % (2006,10,7,10,00,00))
alarm = self.newAlarm(enabled=True) alarm = self.newAlarm(enabled=True)
hour_list = (6,10,15,21) hour_list = (6,10,15,21)
...@@ -239,8 +239,8 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -239,8 +239,8 @@ class TestAlarm(ERP5TypeTestCase):
def test_09_SomeMonthDaysSomeHours(self): def test_09_SomeMonthDaysSomeHours(self):
"""- every 1st and 15th every month, at 12 and 14""" """- every 1st and 15th every month, at 12 and 14"""
right_first_date = DateTime(self.date_format % (2006,10,01,12,00,00)) right_first_date = DateTime(self.date_format % (2006,10,1,12,00,00))
right_second_date = DateTime(self.date_format % (2006,10,01,14,00,00)) right_second_date = DateTime(self.date_format % (2006,10,1,14,00,00))
right_third_date = DateTime(self.date_format % (2006,10,15,12,00,00)) right_third_date = DateTime(self.date_format % (2006,10,15,12,00,00))
right_fourth_date = DateTime(self.date_format % (2006,10,15,14,00,00)) right_fourth_date = DateTime(self.date_format % (2006,10,15,14,00,00))
alarm = self.newAlarm(enabled=True) alarm = self.newAlarm(enabled=True)
...@@ -252,9 +252,9 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -252,9 +252,9 @@ class TestAlarm(ERP5TypeTestCase):
def test_10_OnceEvery2Month(self): def test_10_OnceEvery2Month(self):
"""- every 1st day of every 2 month, at 6""" """- every 1st day of every 2 month, at 6"""
right_first_date = DateTime(self.date_format % (2006,10,01,6,00,00)) right_first_date = DateTime(self.date_format % (2006,10,1,6,00,00))
right_second_date = DateTime(self.date_format % (2006,12,01,6,00,00)) right_second_date = DateTime(self.date_format % (2006,12,1,6,00,00))
right_third_date = DateTime(self.date_format % (2007,2,01,6,00,00)) right_third_date = DateTime(self.date_format % (2007,2,1,6,00,00))
alarm = self.newAlarm(enabled=True) alarm = self.newAlarm(enabled=True)
alarm.setPeriodicityStartDate(right_first_date) alarm.setPeriodicityStartDate(right_first_date)
alarm.setPeriodicityMonthDayList((1,)) alarm.setPeriodicityMonthDayList((1,))
......
...@@ -815,7 +815,7 @@ class TestERP5Base(ERP5TypeTestCase): ...@@ -815,7 +815,7 @@ class TestERP5Base(ERP5TypeTestCase):
"""Tests dates on Person objects. """Tests dates on Person objects.
""" """
pers = self.getPersonModule().newContent(portal_type='Person') pers = self.getPersonModule().newContent(portal_type='Person')
birthday = DateTime(1999, 01, 01) birthday = DateTime(1999, 1, 1)
now = DateTime() now = DateTime()
pers.edit(birthday = birthday) pers.edit(birthday = birthday)
self.assertEqual(birthday, pers.getBirthday()) self.assertEqual(birthday, pers.getBirthday())
...@@ -830,7 +830,7 @@ class TestERP5Base(ERP5TypeTestCase): ...@@ -830,7 +830,7 @@ class TestERP5Base(ERP5TypeTestCase):
"""Tests dates on Organisation objects. """Tests dates on Organisation objects.
""" """
org = self.getOrganisationModule().newContent(portal_type='Organisation') org = self.getOrganisationModule().newContent(portal_type='Organisation')
start_date = DateTime(1999, 01, 01) start_date = DateTime(1999, 1, 1)
now = DateTime() now = DateTime()
org.edit(start_date = start_date) org.edit(start_date = start_date)
self.assertEqual(start_date, org.getStartDate()) self.assertEqual(start_date, org.getStartDate())
...@@ -980,7 +980,7 @@ class TestERP5Base(ERP5TypeTestCase): ...@@ -980,7 +980,7 @@ class TestERP5Base(ERP5TypeTestCase):
subordination_value=first_organisation, subordination_value=first_organisation,
start_date=DateTime(1996, 9, 9)) start_date=DateTime(1996, 9, 9))
another_cancelled_career.cancel() another_cancelled_career.cancel()
self.assertEqual(DateTime(2001, 01, 01), self.assertEqual(DateTime(2001, 1, 1),
person.Person_getCareerStartDate( person.Person_getCareerStartDate(
subordination_relative_url=first_organisation.getRelativeUrl())) subordination_relative_url=first_organisation.getRelativeUrl()))
......
...@@ -1936,94 +1936,94 @@ class TestMovementHistoryList(InventoryAPITestCase): ...@@ -1936,94 +1936,94 @@ class TestMovementHistoryList(InventoryAPITestCase):
def test_FromDate(self): def test_FromDate(self):
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
for date in [DateTime(2006, 01, day) for day in range(1, 4)]: for date in [DateTime(2006, 1, day) for day in range(1, 4)]:
self._makeMovement(quantity=100, self._makeMovement(quantity=100,
start_date=date, start_date=date,
stop_date=date+1) stop_date=date+1)
# from_date takes all movements >= # from_date takes all movements >=
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2006, 01, 03), from_date=DateTime(2006, 1, 3),
section_uid=self.section.getUid())), 2) section_uid=self.section.getUid())), 2)
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2006, 01, 02), from_date=DateTime(2006, 1, 2),
section_uid=self.mirror_section.getUid())), 2) section_uid=self.mirror_section.getUid())), 2)
def test_AtDate(self): def test_AtDate(self):
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
for date in [DateTime(2006, 01, day) for day in range(1, 4)]: for date in [DateTime(2006, 1, day) for day in range(1, 4)]:
self._makeMovement(quantity=100, self._makeMovement(quantity=100,
start_date=date, start_date=date,
stop_date=date+1) stop_date=date+1)
# at_date takes all movements <= # at_date takes all movements <=
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
at_date=DateTime(2006, 01, 03), at_date=DateTime(2006, 1, 3),
section_uid=self.section.getUid())), 2) section_uid=self.section.getUid())), 2)
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
at_date=DateTime(2006, 01, 02), at_date=DateTime(2006, 1, 2),
section_uid=self.mirror_section.getUid())), 2) section_uid=self.mirror_section.getUid())), 2)
def test_ToDate(self): def test_ToDate(self):
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
for date in [DateTime(2006, 01, day) for day in range(1, 4)]: for date in [DateTime(2006, 1, day) for day in range(1, 4)]:
self._makeMovement(quantity=100, self._makeMovement(quantity=100,
start_date=date, start_date=date,
stop_date=date+1) stop_date=date+1)
# to_date takes all movements < # to_date takes all movements <
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
to_date=DateTime(2006, 01, 03), to_date=DateTime(2006, 1, 3),
section_uid=self.section.getUid())), 1) section_uid=self.section.getUid())), 1)
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
to_date=DateTime(2006, 01, 02), to_date=DateTime(2006, 1, 2),
section_uid=self.mirror_section.getUid())), 1) section_uid=self.mirror_section.getUid())), 1)
def test_FromDateAtDate(self): def test_FromDateAtDate(self):
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
for date in [DateTime(2006, 01, day) for day in range(1, 4)]: for date in [DateTime(2006, 1, day) for day in range(1, 4)]:
self._makeMovement(quantity=100, self._makeMovement(quantity=100,
start_date=date, start_date=date,
stop_date=date+1) stop_date=date+1)
# both from_date and at_date # both from_date and at_date
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2006, 01, 03), from_date=DateTime(2006, 1, 3),
at_date=DateTime(2006, 01, 03), at_date=DateTime(2006, 1, 3),
section_uid=self.section.getUid())), 1) section_uid=self.section.getUid())), 1)
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2006, 01, 02), from_date=DateTime(2006, 1, 2),
at_date=DateTime(2006, 01, 03), at_date=DateTime(2006, 1, 3),
section_uid=self.section.getUid())), 2) section_uid=self.section.getUid())), 2)
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2005, 01, 02), from_date=DateTime(2005, 1, 2),
at_date=DateTime(2006, 01, 03), at_date=DateTime(2006, 1, 3),
section_uid=self.section.getUid())), 2) section_uid=self.section.getUid())), 2)
# from other side # from other side
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2006, 01, 02), from_date=DateTime(2006, 1, 2),
at_date=DateTime(2006, 01, 03), at_date=DateTime(2006, 1, 3),
section_uid=self.mirror_section.getUid())), 2) section_uid=self.mirror_section.getUid())), 2)
def test_FromDateToDate(self): def test_FromDateToDate(self):
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
for date in [DateTime(2006, 01, day) for day in range(1, 4)]: for date in [DateTime(2006, 1, day) for day in range(1, 4)]:
self._makeMovement(quantity=100, self._makeMovement(quantity=100,
start_date=date, start_date=date,
stop_date=date+1) stop_date=date+1)
# both from_date and to_date # both from_date and to_date
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2006, 01, 03), from_date=DateTime(2006, 1, 3),
to_date=DateTime(2006, 01, 03), to_date=DateTime(2006, 1, 3),
section_uid=self.section.getUid())), 0) section_uid=self.section.getUid())), 0)
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2006, 01, 02), from_date=DateTime(2006, 1, 2),
to_date=DateTime(2006, 01, 03), to_date=DateTime(2006, 1, 3),
section_uid=self.section.getUid())), 1) section_uid=self.section.getUid())), 1)
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2005, 01, 02), from_date=DateTime(2005, 1, 2),
to_date=DateTime(2007, 01, 02), to_date=DateTime(2007, 1, 2),
section_uid=self.section.getUid())), 3) section_uid=self.section.getUid())), 3)
# from other side # from other side
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2006, 01, 02), from_date=DateTime(2006, 1, 2),
to_date=DateTime(2006, 01, 03), to_date=DateTime(2006, 1, 3),
section_uid=self.mirror_section.getUid())), 1) section_uid=self.mirror_section.getUid())), 1)
...@@ -2061,7 +2061,7 @@ class TestMovementHistoryList(InventoryAPITestCase): ...@@ -2061,7 +2061,7 @@ class TestMovementHistoryList(InventoryAPITestCase):
def test_SortOnDate(self): def test_SortOnDate(self):
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
date_list = [DateTime(2006, 01, day) for day in range(1, 10)] date_list = [DateTime(2006, 1, day) for day in range(1, 10)]
reverse_date_list = date_list[:] reverse_date_list = date_list[:]
reverse_date_list.reverse() reverse_date_list.reverse()
...@@ -2170,7 +2170,7 @@ class TestMovementHistoryList(InventoryAPITestCase): ...@@ -2170,7 +2170,7 @@ class TestMovementHistoryList(InventoryAPITestCase):
"""Test that a running_total_quantity attribute is set on brains """Test that a running_total_quantity attribute is set on brains
""" """
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
date_and_qty_list = [(DateTime(2006, 01, day), day) for day in range(1, 10)] date_and_qty_list = [(DateTime(2006, 1, day), day) for day in range(1, 10)]
for date, quantity in date_and_qty_list: for date, quantity in date_and_qty_list:
self._makeMovement(stop_date=date, quantity=quantity) self._makeMovement(stop_date=date, quantity=quantity)
movement_history_list = getMovementHistoryList( movement_history_list = getMovementHistoryList(
...@@ -2189,7 +2189,7 @@ class TestMovementHistoryList(InventoryAPITestCase): ...@@ -2189,7 +2189,7 @@ class TestMovementHistoryList(InventoryAPITestCase):
"""Test that a running_total_price attribute is set on brains """Test that a running_total_price attribute is set on brains
""" """
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
date_and_price_list = [(DateTime(2006, 01, day), day) for day in range(1, 10)] date_and_price_list = [(DateTime(2006, 1, day), day) for day in range(1, 10)]
for date, price in date_and_price_list: for date, price in date_and_price_list:
self._makeMovement(stop_date=date, quantity=1, price=price) self._makeMovement(stop_date=date, quantity=1, price=price)
movement_history_list = getMovementHistoryList( movement_history_list = getMovementHistoryList(
...@@ -2209,7 +2209,7 @@ class TestMovementHistoryList(InventoryAPITestCase): ...@@ -2209,7 +2209,7 @@ class TestMovementHistoryList(InventoryAPITestCase):
value. value.
""" """
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
date_and_qty_list = [(DateTime(2006, 01, day), day) for day in range(1, 10)] date_and_qty_list = [(DateTime(2006, 1, day), day) for day in range(1, 10)]
for date, quantity in date_and_qty_list: for date, quantity in date_and_qty_list:
self._makeMovement(stop_date=date, price=quantity, quantity=quantity) self._makeMovement(stop_date=date, price=quantity, quantity=quantity)
initial_running_total_price=100 initial_running_total_price=100
......
...@@ -627,7 +627,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase): ...@@ -627,7 +627,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
specialise=self.business_process, specialise=self.business_process,
source_value = from_organisation, source_value = from_organisation,
destination_value = organisation, destination_value = organisation,
start_date=DateTime(2019, 02, 20), start_date=DateTime(2019, 2, 20),
) )
resource_value = sequence.get('resource') resource_value = sequence.get('resource')
delivery.newContent( portal_type='Internal Packing List Line', delivery.newContent( portal_type='Internal Packing List Line',
...@@ -649,7 +649,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase): ...@@ -649,7 +649,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
self.assertEqual(2, getInventoryQuantity()) self.assertEqual(2, getInventoryQuantity())
inventory = self.getInventoryModule().newContent() inventory = self.getInventoryModule().newContent()
inventory.edit(start_date=DateTime(2019, 02, 21), inventory.edit(start_date=DateTime(2019, 2, 21),
destination_value=organisation, destination_value=organisation,
full_inventory=True) full_inventory=True)
inventory.deliver() inventory.deliver()
...@@ -694,7 +694,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase): ...@@ -694,7 +694,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
self.assertEqual(2, getInventoryQuantity()) self.assertEqual(2, getInventoryQuantity())
inventory = self.getInventoryModule().newContent() inventory = self.getInventoryModule().newContent()
inventory.edit(start_date=DateTime(2019, 02, 21), inventory.edit(start_date=DateTime(2019, 2, 21),
destination_value=organisation, destination_value=organisation,
full_inventory=True) full_inventory=True)
inventory_line = inventory.newContent(portal_type='Inventory Line', inventory_line = inventory.newContent(portal_type='Inventory Line',
......
...@@ -1359,16 +1359,16 @@ class TestInvoice(TestInvoiceMixin): ...@@ -1359,16 +1359,16 @@ class TestInvoice(TestInvoiceMixin):
self.assertEqual(other_resource, self.assertEqual(other_resource,
invoice_movement.getResourceValue()) invoice_movement.getResourceValue())
order_line.setStartDate(DateTime(2001, 02, 03)) order_line.setStartDate(DateTime(2001, 2, 3))
self.tic() self.tic()
invoice_movement = invoice_applied_rule.contentValues()[0] invoice_movement = invoice_applied_rule.contentValues()[0]
self.assertEqual(DateTime(2001, 02, 03), self.assertEqual(DateTime(2001, 2, 3),
invoice_movement.getStartDate()) invoice_movement.getStartDate())
order_line.setStopDate(DateTime(2002, 03, 04)) order_line.setStopDate(DateTime(2002, 3, 4))
self.tic() self.tic()
invoice_movement = invoice_applied_rule.contentValues()[0] invoice_movement = invoice_applied_rule.contentValues()[0]
self.assertEqual(DateTime(2002, 03, 04), self.assertEqual(DateTime(2002, 3, 4),
invoice_movement.getStopDate()) invoice_movement.getStopDate())
@newSimulationExpectedFailure @newSimulationExpectedFailure
...@@ -1556,20 +1556,20 @@ class TestInvoice(TestInvoiceMixin): ...@@ -1556,20 +1556,20 @@ class TestInvoice(TestInvoiceMixin):
self.assertEqual(456, self.assertEqual(456,
invoice_transaction_movement.getQuantity()) invoice_transaction_movement.getQuantity())
order_line.setStartDate(DateTime(2001, 02, 03)) order_line.setStartDate(DateTime(2001, 2, 3))
self.tic() self.tic()
self.assertEqual(3, len(invoice_transaction_applied_rule)) self.assertEqual(3, len(invoice_transaction_applied_rule))
invoice_transaction_movement = getIncomeSimulationMovement( invoice_transaction_movement = getIncomeSimulationMovement(
invoice_transaction_applied_rule) invoice_transaction_applied_rule)
self.assertEqual(DateTime(2001, 02, 03), self.assertEqual(DateTime(2001, 2, 3),
invoice_transaction_movement.getStartDate()) invoice_transaction_movement.getStartDate())
order_line.setStopDate(DateTime(2002, 03, 04)) order_line.setStopDate(DateTime(2002, 3, 4))
self.tic() self.tic()
self.assertEqual(3, len(invoice_transaction_applied_rule)) self.assertEqual(3, len(invoice_transaction_applied_rule))
invoice_transaction_movement = getIncomeSimulationMovement( invoice_transaction_movement = getIncomeSimulationMovement(
invoice_transaction_applied_rule) invoice_transaction_applied_rule)
self.assertEqual(DateTime(2002, 03, 04), self.assertEqual(DateTime(2002, 3, 4),
invoice_transaction_movement.getStopDate()) invoice_transaction_movement.getStopDate())
def test_Invoice_viewAsODT(self): def test_Invoice_viewAsODT(self):
......
...@@ -321,7 +321,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -321,7 +321,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
employee = sequence.get('employee') employee = sequence.get('employee')
model.edit(destination_section_value=employer, model.edit(destination_section_value=employer,
source_section_value=employee, source_section_value=employee,
effective_date=DateTime(2009,01,01), effective_date=DateTime(2009,1,1),
expiration_date=DateTime(2009,12,31), expiration_date=DateTime(2009,12,31),
version='001', version='001',
reference='basic_model', reference='basic_model',
...@@ -557,8 +557,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -557,8 +557,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
source_section_value=sequence.get('employee'), source_section_value=sequence.get('employee'),
destination_section_value=sequence.get('employer'), destination_section_value=sequence.get('employer'),
resource_value=sequence.get('price_currency'), resource_value=sequence.get('price_currency'),
start_date=DateTime(2009,06,01), start_date=DateTime(2009,6,1),
stop_date=DateTime(2009,06,30)) stop_date=DateTime(2009,6,30))
sequence.edit(paysheet = paysheet) sequence.edit(paysheet = paysheet)
def createPaysheetLine(self, document, **kw): def createPaysheetLine(self, document, **kw):
...@@ -1028,7 +1028,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1028,7 +1028,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
model.edit(\ model.edit(\
price_currency_value=currency, price_currency_value=currency,
default_payment_condition_trade_date='custom', default_payment_condition_trade_date='custom',
default_payment_condition_payment_date=DateTime(2009,05,25), default_payment_condition_payment_date=DateTime(2009,5,25),
work_time_annotation_line_quantity=151.67, work_time_annotation_line_quantity=151.67,
work_time_annotation_line_quantity_unit='time/hours', work_time_annotation_line_quantity_unit='time/hours',
) )
...@@ -1049,7 +1049,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1049,7 +1049,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
self.assertEqual(paysheet.getPriceCurrencyValue(), currency) self.assertEqual(paysheet.getPriceCurrencyValue(), currency)
self.assertEqual(paysheet.getDefaultPaymentConditionTradeDate(), 'custom') self.assertEqual(paysheet.getDefaultPaymentConditionTradeDate(), 'custom')
self.assertEqual(paysheet.getDefaultPaymentConditionPaymentDate(), self.assertEqual(paysheet.getDefaultPaymentConditionPaymentDate(),
DateTime(2009,05,25)) DateTime(2009,5,25))
self.assertEqual(paysheet.getWorkTimeAnnotationLineQuantity(), 151.67) self.assertEqual(paysheet.getWorkTimeAnnotationLineQuantity(), 151.67)
self.assertEqual(paysheet.getWorkTimeAnnotationLineQuantityUnit(), self.assertEqual(paysheet.getWorkTimeAnnotationLineQuantityUnit(),
'time/hours') 'time/hours')
...@@ -1639,14 +1639,14 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1639,14 +1639,14 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
variation_settings_category_list=['salary_range/france',], variation_settings_category_list=['salary_range/france',],
reference='fabien_model_2009', reference='fabien_model_2009',
effective_date=DateTime(2009, 1, 1), effective_date=DateTime(2009, 1, 1),
expiration_date=DateTime(2009, 06, 30)) expiration_date=DateTime(2009, 6, 30))
model_2 = self.getPortalObject().paysheet_model_module.newContent( \ model_2 = self.getPortalObject().paysheet_model_module.newContent( \
specialise_value=sequence.get('business_process'), specialise_value=sequence.get('business_process'),
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
variation_settings_category_list=['salary_range/france',], variation_settings_category_list=['salary_range/france',],
reference='fabien_model_2009', reference='fabien_model_2009',
effective_date=DateTime(2009, 07, 1), effective_date=DateTime(2009, 7, 1),
expiration_date=DateTime(2009, 12, 31)) expiration_date=DateTime(2009, 12, 31))
model_line_3 = self.createModelLine(model_1) model_line_3 = self.createModelLine(model_1)
...@@ -1676,8 +1676,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1676,8 +1676,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
paysheet = self.portal.accounting_module.newContent( paysheet = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction', portal_type='Pay Sheet Transaction',
specialise_value=model_1, specialise_value=model_1,
start_date=DateTime(2009, 07, 1), start_date=DateTime(2009, 7, 1),
stop_date=DateTime(2009, 07, 31), stop_date=DateTime(2009, 7, 31),
price_currency_value=eur) price_currency_value=eur)
paysheet.PaySheetTransaction_applyModel() paysheet.PaySheetTransaction_applyModel()
self.tic() self.tic()
...@@ -1706,8 +1706,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1706,8 +1706,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
variation_settings_category_list=['salary_range/france',], variation_settings_category_list=['salary_range/france',],
reference='fabien_model_2009', reference='fabien_model_2009',
effective_date=DateTime(2009, 01, 1), effective_date=DateTime(2009, 1, 1),
expiration_date=DateTime(2009, 02, 28), expiration_date=DateTime(2009, 2, 28),
specialise_value=sequence.get('business_process')) specialise_value=sequence.get('business_process'))
# define two models with same references and same dates # define two models with same references and same dates
...@@ -1716,7 +1716,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1716,7 +1716,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
variation_settings_category_list=['salary_range/france',], variation_settings_category_list=['salary_range/france',],
reference='fabien_model_2009', reference='fabien_model_2009',
effective_date=DateTime(2009, 07, 1), effective_date=DateTime(2009, 7, 1),
expiration_date=DateTime(2009, 12, 31), expiration_date=DateTime(2009, 12, 31),
version='002', version='002',
specialise_value=sequence.get('business_process')) specialise_value=sequence.get('business_process'))
...@@ -1725,7 +1725,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1725,7 +1725,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
variation_settings_category_list=['salary_range/france',], variation_settings_category_list=['salary_range/france',],
reference='fabien_model_2009', reference='fabien_model_2009',
effective_date=DateTime(2009, 07, 1), effective_date=DateTime(2009, 7, 1),
expiration_date=DateTime(2009, 12, 31), expiration_date=DateTime(2009, 12, 31),
version='001', version='001',
specialise_value=sequence.get('business_process')) specialise_value=sequence.get('business_process'))
...@@ -1735,8 +1735,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1735,8 +1735,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
paysheet = self.portal.accounting_module.newContent( paysheet = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction', portal_type='Pay Sheet Transaction',
specialise_value=model_1, specialise_value=model_1,
start_date=DateTime(2009, 07, 1), start_date=DateTime(2009, 7, 1),
stop_date=DateTime(2009, 07, 31), stop_date=DateTime(2009, 7, 31),
price_currency_value=eur) price_currency_value=eur)
paysheet.PaySheetTransaction_applyModel() paysheet.PaySheetTransaction_applyModel()
self.tic() self.tic()
...@@ -1798,8 +1798,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1798,8 +1798,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
specialise_value=sequence.get('business_process'), specialise_value=sequence.get('business_process'),
reference='fabien_model_2009', reference='fabien_model_2009',
effective_date=DateTime(2009, 01, 1), effective_date=DateTime(2009, 1, 1),
expiration_date=DateTime(2009, 02, 28)) expiration_date=DateTime(2009, 2, 28))
model_line_1 = self.createModelLine(model_1) model_line_1 = self.createModelLine(model_1)
model_line_1.edit( model_line_1.edit(
resource_value=labour, resource_value=labour,
...@@ -1813,7 +1813,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1813,7 +1813,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
specialise_value=sequence.get('business_process'), specialise_value=sequence.get('business_process'),
reference='fabien_model_2009', reference='fabien_model_2009',
effective_date=DateTime(2009, 07, 1), effective_date=DateTime(2009, 7, 1),
expiration_date=DateTime(2009, 12, 31), expiration_date=DateTime(2009, 12, 31),
version='002') version='002')
model_line_2 = self.createModelLine(model_2) model_line_2 = self.createModelLine(model_2)
...@@ -1827,7 +1827,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1827,7 +1827,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
specialise_value=sequence.get('business_process'), specialise_value=sequence.get('business_process'),
reference='fabien_model_2009', reference='fabien_model_2009',
effective_date=DateTime(2009, 07, 1), effective_date=DateTime(2009, 7, 1),
expiration_date=DateTime(2009, 12, 31), expiration_date=DateTime(2009, 12, 31),
version='001') version='001')
model_line_3 = self.createModelLine(model_3) model_line_3 = self.createModelLine(model_3)
...@@ -1843,8 +1843,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1843,8 +1843,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
specialise_value=sequence.get('business_process'), specialise_value=sequence.get('business_process'),
reference='fabien_model_level_2_2009', reference='fabien_model_level_2_2009',
effective_date=DateTime(2009, 01, 1), effective_date=DateTime(2009, 1, 1),
expiration_date=DateTime(2009, 06, 30), expiration_date=DateTime(2009, 6, 30),
version='002') version='002')
model_line_4 = self.createModelLine(model_4) model_line_4 = self.createModelLine(model_4)
model_line_4.edit( model_line_4.edit(
...@@ -1857,7 +1857,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1857,7 +1857,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
specialise_value=sequence.get('business_process'), specialise_value=sequence.get('business_process'),
reference='fabien_model_level_2_2009', reference='fabien_model_level_2_2009',
effective_date=DateTime(2009, 07, 1), effective_date=DateTime(2009, 7, 1),
expiration_date=DateTime(2009, 12, 31), expiration_date=DateTime(2009, 12, 31),
version='001') version='001')
model_line_5 = self.createModelLine(model_5) model_line_5 = self.createModelLine(model_5)
...@@ -1873,8 +1873,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1873,8 +1873,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
specialise_value=sequence.get('business_process'), specialise_value=sequence.get('business_process'),
reference='fabien_model_level_3_2009', reference='fabien_model_level_3_2009',
effective_date=DateTime(2009, 01, 1), effective_date=DateTime(2009, 1, 1),
expiration_date=DateTime(2009, 06, 30), expiration_date=DateTime(2009, 6, 30),
version='002') version='002')
model_line_6 = self.createModelLine(model_6) model_line_6 = self.createModelLine(model_6)
model_line_6.edit( model_line_6.edit(
...@@ -1887,7 +1887,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1887,7 +1887,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
specialise_value=sequence.get('business_process'), specialise_value=sequence.get('business_process'),
reference='fabien_model_level_3_2009', reference='fabien_model_level_3_2009',
effective_date=DateTime(2009, 07, 1), effective_date=DateTime(2009, 7, 1),
expiration_date=DateTime(2009, 12, 31), expiration_date=DateTime(2009, 12, 31),
version='001') version='001')
model_line_7 = self.createModelLine(model_7) model_line_7 = self.createModelLine(model_7)
...@@ -1903,8 +1903,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1903,8 +1903,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
paysheet = self.portal.accounting_module.newContent( paysheet = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction', portal_type='Pay Sheet Transaction',
specialise_value=model_1, specialise_value=model_1,
start_date=DateTime(2009, 07, 1), start_date=DateTime(2009, 7, 1),
stop_date=DateTime(2009, 07, 31), stop_date=DateTime(2009, 7, 31),
price_currency_value=eur) price_currency_value=eur)
specialise_value = paysheet.getSpecialiseValue() specialise_value = paysheet.getSpecialiseValue()
......
...@@ -162,10 +162,10 @@ class TestApplyTradeCondition(TradeConditionTestCase): ...@@ -162,10 +162,10 @@ class TestApplyTradeCondition(TradeConditionTestCase):
def test_apply_trade_condition_with_payment_conditions(self): def test_apply_trade_condition_with_payment_conditions(self):
self.trade_condition.setPaymentConditionTradeDate('custom') self.trade_condition.setPaymentConditionTradeDate('custom')
self.trade_condition.setPaymentConditionPaymentDate(DateTime(2001, 01, 01)) self.trade_condition.setPaymentConditionPaymentDate(DateTime(2001, 1, 1))
self.order.setSpecialiseValue(self.trade_condition) self.order.setSpecialiseValue(self.trade_condition)
self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date')) self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date'))
self.assertEqual(DateTime(2001, 01, 01), self.assertEqual(DateTime(2001, 1, 1),
self.order.asComposedDocument().getProperty('payment_condition_payment_date')) self.order.asComposedDocument().getProperty('payment_condition_payment_date'))
def test_apply_trade_condition_with_payment_conditions_with_hierarchy(self): def test_apply_trade_condition_with_payment_conditions_with_hierarchy(self):
...@@ -174,12 +174,12 @@ class TestApplyTradeCondition(TradeConditionTestCase): ...@@ -174,12 +174,12 @@ class TestApplyTradeCondition(TradeConditionTestCase):
title='Other Trade Condition') title='Other Trade Condition')
other_trade_condition.setPaymentConditionTradeDate('custom') other_trade_condition.setPaymentConditionTradeDate('custom')
other_trade_condition.setPaymentConditionPaymentDate( other_trade_condition.setPaymentConditionPaymentDate(
DateTime(2001, 01, 01)) DateTime(2001, 1, 1))
self.trade_condition.setSpecialiseValue(other_trade_condition) self.trade_condition.setSpecialiseValue(other_trade_condition)
self.order.setSpecialiseValue(self.trade_condition) self.order.setSpecialiseValue(self.trade_condition)
self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date')) self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date'))
self.assertEqual(DateTime(2001, 01, 01), self.assertEqual(DateTime(2001, 1, 1),
self.order.asComposedDocument().getProperty('payment_condition_payment_date')) self.order.asComposedDocument().getProperty('payment_condition_payment_date'))
def test_apply_trade_condition_twice_update_order(self): def test_apply_trade_condition_twice_update_order(self):
...@@ -189,7 +189,7 @@ class TestApplyTradeCondition(TradeConditionTestCase): ...@@ -189,7 +189,7 @@ class TestApplyTradeCondition(TradeConditionTestCase):
self.trade_condition.setDestinationValue(self.client) self.trade_condition.setDestinationValue(self.client)
self.trade_condition.setPriceCurrencyValue(self.currency) self.trade_condition.setPriceCurrencyValue(self.currency)
self.trade_condition.setPaymentConditionTradeDate('custom') self.trade_condition.setPaymentConditionTradeDate('custom')
self.trade_condition.setPaymentConditionPaymentDate(DateTime(2001, 01, 01)) self.trade_condition.setPaymentConditionPaymentDate(DateTime(2001, 1, 1))
self.order.setSpecialiseValue(self.trade_condition) self.order.setSpecialiseValue(self.trade_condition)
self.order.Order_applyTradeCondition(self.trade_condition, force=1) self.order.Order_applyTradeCondition(self.trade_condition, force=1)
...@@ -201,7 +201,7 @@ class TestApplyTradeCondition(TradeConditionTestCase): ...@@ -201,7 +201,7 @@ class TestApplyTradeCondition(TradeConditionTestCase):
self.assertEqual(self.client, self.order.getDestinationValue()) self.assertEqual(self.client, self.order.getDestinationValue())
self.assertEqual(self.currency, self.order.getPriceCurrencyValue()) self.assertEqual(self.currency, self.order.getPriceCurrencyValue())
self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date')) self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date'))
self.assertEqual(DateTime(2001, 01, 01), self.assertEqual(DateTime(2001, 1, 1),
self.order.asComposedDocument().getProperty('payment_condition_payment_date')) self.order.asComposedDocument().getProperty('payment_condition_payment_date'))
new_vendor = self.portal.organisation_module.newContent( new_vendor = self.portal.organisation_module.newContent(
...@@ -221,7 +221,7 @@ class TestApplyTradeCondition(TradeConditionTestCase): ...@@ -221,7 +221,7 @@ class TestApplyTradeCondition(TradeConditionTestCase):
self.assertEqual(self.client, self.order.getDestinationValue()) self.assertEqual(self.client, self.order.getDestinationValue())
self.assertEqual(self.currency, self.order.getPriceCurrencyValue()) self.assertEqual(self.currency, self.order.getPriceCurrencyValue())
self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date')) self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date'))
self.assertEqual(DateTime(2002, 02, 02), self.assertEqual(DateTime(2002, 2, 2),
self.order.asComposedDocument().getProperty('payment_condition_payment_date')) self.order.asComposedDocument().getProperty('payment_condition_payment_date'))
......
...@@ -817,7 +817,7 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase): ...@@ -817,7 +817,7 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
group='my_group') group='my_group')
accounting_period = organisation.newContent( accounting_period = organisation.newContent(
portal_type='Accounting Period', portal_type='Accounting Period',
start_date=DateTime(2001, 01, 01), start_date=DateTime(2001, 1, 1),
stop_date=DateTime(2002, 12, 31)) stop_date=DateTime(2002, 12, 31))
self.assertEqual(accounting_period.getSimulationState(), 'draft') self.assertEqual(accounting_period.getSimulationState(), 'draft')
...@@ -1049,8 +1049,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase): ...@@ -1049,8 +1049,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
def stepAccountingTransaction(self, sequence=None, sequence_list=None, **kw): def stepAccountingTransaction(self, sequence=None, sequence_list=None, **kw):
transaction = self.portal.accounting_module.newContent( transaction = self.portal.accounting_module.newContent(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime(2001, 01, 01), start_date=DateTime(2001, 1, 1),
stop_date=DateTime(2001, 01, 01)) stop_date=DateTime(2001, 1, 1))
self.assertEqual('draft', transaction.getSimulationState()) self.assertEqual('draft', transaction.getSimulationState())
for user_id in self._getUserIdList(self.all_username_list): for user_id in self._getUserIdList(self.all_username_list):
self.assertUserCanViewDocument(user_id, transaction) self.assertUserCanViewDocument(user_id, transaction)
...@@ -1181,8 +1181,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase): ...@@ -1181,8 +1181,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
def stepSaleInvoiceTransaction(self, sequence=None, sequence_list=None, **kw): def stepSaleInvoiceTransaction(self, sequence=None, sequence_list=None, **kw):
transaction = self.portal.accounting_module.newContent( transaction = self.portal.accounting_module.newContent(
portal_type='Sale Invoice Transaction', portal_type='Sale Invoice Transaction',
start_date=DateTime(2001, 01, 01), start_date=DateTime(2001, 1, 1),
stop_date=DateTime(2001, 01, 01)) stop_date=DateTime(2001, 1, 1))
self.assertEqual('draft', transaction.getSimulationState()) self.assertEqual('draft', transaction.getSimulationState())
for user_id in self._getUserIdList(self.all_username_list): for user_id in self._getUserIdList(self.all_username_list):
self.assertUserCanViewDocument(user_id, transaction) self.assertUserCanViewDocument(user_id, transaction)
...@@ -1324,8 +1324,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase): ...@@ -1324,8 +1324,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
def stepPurchaseInvoiceTransaction(self, sequence=None, sequence_list=None, **kw): def stepPurchaseInvoiceTransaction(self, sequence=None, sequence_list=None, **kw):
transaction = self.portal.accounting_module.newContent( transaction = self.portal.accounting_module.newContent(
portal_type='Purchase Invoice Transaction', portal_type='Purchase Invoice Transaction',
start_date=DateTime(2001, 01, 01), start_date=DateTime(2001, 1, 1),
stop_date=DateTime(2001, 01, 01)) stop_date=DateTime(2001, 1, 1))
self.assertEqual('draft', transaction.getSimulationState()) self.assertEqual('draft', transaction.getSimulationState())
for user_id in self._getUserIdList(self.all_username_list): for user_id in self._getUserIdList(self.all_username_list):
self.assertUserCanViewDocument(user_id, transaction) self.assertUserCanViewDocument(user_id, transaction)
...@@ -1471,8 +1471,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase): ...@@ -1471,8 +1471,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
def stepPaymentTransaction(self, sequence=None, sequence_list=None, **kw): def stepPaymentTransaction(self, sequence=None, sequence_list=None, **kw):
transaction = self.portal.accounting_module.newContent( transaction = self.portal.accounting_module.newContent(
portal_type='Payment Transaction', portal_type='Payment Transaction',
start_date=DateTime(2001, 01, 01), start_date=DateTime(2001, 1, 1),
stop_date=DateTime(2001, 01, 01)) stop_date=DateTime(2001, 1, 1))
self.assertEqual('draft', transaction.getSimulationState()) self.assertEqual('draft', transaction.getSimulationState())
for user_id in self._getUserIdList(self.all_username_list): for user_id in self._getUserIdList(self.all_username_list):
self.assertUserCanViewDocument(user_id, transaction) self.assertUserCanViewDocument(user_id, transaction)
...@@ -1616,29 +1616,29 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase): ...@@ -1616,29 +1616,29 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
accounting_transaction_x_related_to_a = self.portal.\ accounting_transaction_x_related_to_a = self.portal.\
accounting_module.newContent( accounting_module.newContent(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime(2010, 06, 01), start_date=DateTime(2010, 6, 1),
stop_date=DateTime(2010, 06, 01)) stop_date=DateTime(2010, 6, 1))
accounting_transaction_y_related_to_a = self.portal.\ accounting_transaction_y_related_to_a = self.portal.\
accounting_module.newContent( accounting_module.newContent(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime(2010, 06, 01), start_date=DateTime(2010, 6, 1),
stop_date=DateTime(2010, 06, 01)) stop_date=DateTime(2010, 6, 1))
accounting_transaction_a = self.portal.accounting_module.newContent( accounting_transaction_a = self.portal.accounting_module.newContent(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime(2010, 06, 01), start_date=DateTime(2010, 6, 1),
stop_date=DateTime(2010, 06, 01)) stop_date=DateTime(2010, 6, 1))
accounting_transaction_b = self.portal.accounting_module.newContent( accounting_transaction_b = self.portal.accounting_module.newContent(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime(2010, 06, 01), start_date=DateTime(2010, 6, 1),
stop_date=DateTime(2010, 06, 01)) stop_date=DateTime(2010, 6, 1))
accounting_transaction_c = self.portal.accounting_module.newContent( accounting_transaction_c = self.portal.accounting_module.newContent(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime(2010, 06, 01), start_date=DateTime(2010, 6, 1),
stop_date=DateTime(2010, 06, 01)) stop_date=DateTime(2010, 6, 1))
accounting_transaction_x_related_to_a.setCausalityValue(\ accounting_transaction_x_related_to_a.setCausalityValue(\
accounting_transaction_a) accounting_transaction_a)
......
...@@ -382,7 +382,7 @@ class TestDateTimeField(ERP5TypeTestCase): ...@@ -382,7 +382,7 @@ class TestDateTimeField(ERP5TypeTestCase):
.xpath('%s/text()' % ODG_XML_WRAPPING_XPATH, namespaces=NSMAP)[0]) .xpath('%s/text()' % ODG_XML_WRAPPING_XPATH, namespaces=NSMAP)[0])
def test_render_odt_variable(self): def test_render_odt_variable(self):
value = DateTime(2010, 12, 06, 10, 23, 32, 'GMT+5') value = DateTime(2010, 12, 6, 10, 23, 32, 'GMT+5')
self.field.values['default'] = value self.field.values['default'] = value
node = self.field.render_odt_variable(as_string=False) node = self.field.render_odt_variable(as_string=False)
self.assertEqual(node.get('{%s}value-type' % NSMAP['office']), 'date') self.assertEqual(node.get('{%s}value-type' % NSMAP['office']), 'date')
......
...@@ -275,7 +275,7 @@ class TestPreferences(PropertySheetTestCase): ...@@ -275,7 +275,7 @@ class TestPreferences(PropertySheetTestCase):
portal_workflow.doActionFor( portal_workflow.doActionFor(
person1, 'enable_action', wf_id='preference_workflow') person1, 'enable_action', wf_id='preference_workflow')
self.assertEqual(person1.getPreferenceState(), 'enabled') self.assertEqual(person1.getPreferenceState(), 'enabled')
person1.setPreferredAccountingTransactionAtDate(DateTime(2005, 01, 01)) person1.setPreferredAccountingTransactionAtDate(DateTime(2005, 1, 1))
pref_tool.setPreference( pref_tool.setPreference(
'preferred_accounting_transaction_at_date', DateTime(2004, 12, 31)) 'preferred_accounting_transaction_at_date', DateTime(2004, 12, 31))
self.tic() self.tic()
...@@ -315,7 +315,7 @@ class TestPreferences(PropertySheetTestCase): ...@@ -315,7 +315,7 @@ class TestPreferences(PropertySheetTestCase):
# create a pref for user_b # create a pref for user_b
user_b_1 = portal_preferences.newContent( user_b_1 = portal_preferences.newContent(
id='user_b_1', portal_type='Preference') id='user_b_1', portal_type='Preference')
user_b_1.setPreferredAccountingTransactionAtDate(DateTime(2002, 02, 02)) user_b_1.setPreferredAccountingTransactionAtDate(DateTime(2002, 2, 2))
self.tic() self.tic()
# enable this preference # enable this preference
......
...@@ -61,7 +61,7 @@ class ERP5NodeConduit(TioSafeBaseConduit): ...@@ -61,7 +61,7 @@ class ERP5NodeConduit(TioSafeBaseConduit):
destination=object.getRelativeUrl(), destination=object.getRelativeUrl(),
destination_decision=object.getRelativeUrl(), destination_decision=object.getRelativeUrl(),
destination_administration=object.getRelativeUrl(), destination_administration=object.getRelativeUrl(),
version=001) version=0o01)
stc.validate() stc.validate()
def _updateSaleTradeCondition(self, object, **kw): def _updateSaleTradeCondition(self, object, **kw):
......
...@@ -81,7 +81,7 @@ class ERP5PaymentTransactionConduit(TioSafeBaseConduit): ...@@ -81,7 +81,7 @@ class ERP5PaymentTransactionConduit(TioSafeBaseConduit):
# Create the STC # Create the STC
stc = object.getPortalObject().sale_trade_condition_module.newContent(title=stc_title, stc = object.getPortalObject().sale_trade_condition_module.newContent(title=stc_title,
specialise=default_stc, specialise=default_stc,
version=001) version=0o01)
stc.validate() stc.validate()
return stc return stc
......
...@@ -171,7 +171,7 @@ class SFTPConnection: ...@@ -171,7 +171,7 @@ class SFTPConnection:
raise SFTPError('%s while trying to rename "%s" to "%s" on %s.' % \ raise SFTPError('%s while trying to rename "%s" to "%s" on %s.' % \
(str(msg), old_path, new_path, self.url)) (str(msg), old_path, new_path, self.url))
def createDirectory(self, path, mode=0777): def createDirectory(self, path, mode=0o777):
"""Create a directory `path` with mode `mode`. """Create a directory `path` with mode `mode`.
""" """
return self.conn.mkdir(path, mode) return self.conn.mkdir(path, mode)
......
...@@ -447,7 +447,7 @@ def convertDateToHour(date=None): ...@@ -447,7 +447,7 @@ def convertDateToHour(date=None):
# and this provides the use of toordinal method. # and this provides the use of toordinal method.
formatted_creation_date = datetime(creation_date_dict['year'],creation_date_dict['month'],creation_date_dict['day']) formatted_creation_date = datetime(creation_date_dict['year'],creation_date_dict['month'],creation_date_dict['day'])
# reference date which is the first day of creation date year # reference date which is the first day of creation date year
reference_date = datetime(creation_date_dict['year'], 01, 1) reference_date = datetime(creation_date_dict['year'], 1, 1)
# calculate the ordinal date of the creation date and the reference date # calculate the ordinal date of the creation date and the reference date
ordinal_date = datetime.toordinal(formatted_creation_date) ordinal_date = datetime.toordinal(formatted_creation_date)
ordinal_reference_date = datetime.toordinal(reference_date) ordinal_reference_date = datetime.toordinal(reference_date)
......
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