Commit 74e74dc6 authored by Jérome Perrin's avatar Jérome Perrin Committed by Arnaud Fontaine

accounting py3

parent 2e2f5218
...@@ -43,22 +43,12 @@ class InventoryKey(UserDict): ...@@ -43,22 +43,12 @@ class InventoryKey(UserDict):
self.data = {} self.data = {}
self.data.update(kw) self.data.update(kw)
def clear(self): def _raise_immutable(self, *args, **kw):
raise TypeError('InventoryKey are immutable') raise TypeError('InventoryKey are immutable')
def pop(self, keys, *args): clear = pop = update = __delitem__ = __setitem__ = _raise_immutable
raise TypeError('InventoryKey are immutable')
def update(self, dict=None, **kwargs): # pylint: disable=redefined-builtin
raise TypeError('InventoryKey are immutable')
def __delitem__(self, key):
raise TypeError('InventoryKey are immutable')
def __setitem__(self, key, item):
raise TypeError('InventoryKey are immutable')
def setdefault(self, key, failobj=None): def setdefault(self, key, default=None):
if key in self.data: if key in self.data:
return self.data[key] return self.data[key]
raise TypeError('InventoryKey are immutable') raise TypeError('InventoryKey are immutable')
...@@ -440,7 +430,7 @@ class BalanceTransaction(AccountingTransaction, Inventory): ...@@ -440,7 +430,7 @@ class BalanceTransaction(AccountingTransaction, Inventory):
return factory return factory
def _immediateReindexObject(self, **kw): def _immediateReindexObject(self, *args, **kw):
"""Reindexes the object. """Reindexes the object.
This is different indexing that the default Inventory indexing, because This is different indexing that the default Inventory indexing, because
we want to take into account that lines in this balance transaction to we want to take into account that lines in this balance transaction to
......
...@@ -2,12 +2,8 @@ import six ...@@ -2,12 +2,8 @@ import six
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
from Products.ERP5Form.Report import ReportSection from Products.ERP5Form.Report import ReportSection
if six.PY2: def translate(*args, **kw):
def translate(*args, **kw): return six.text_type(translateString(*args, **kw))
return unicode(translateString(*args, **kw))
else:
def translate(*args, **kw):
return str(translateString(*args, **kw))
request = container.REQUEST request = container.REQUEST
section_category = request['section_category'] section_category = request['section_category']
......
...@@ -28,14 +28,14 @@ for line in transaction_lines: ...@@ -28,14 +28,14 @@ for line in transaction_lines:
line.getDestinationSectionValue(portal_type=section_portal_type_list), line.getDestinationSectionValue(portal_type=section_portal_type_list),
line.getSourcePaymentValue(portal_type=bank_account_portal_type), line.getSourcePaymentValue(portal_type=bank_account_portal_type),
lambda: (x[1] for x in getBankAccountItemList( lambda: (x[1] for x in getBankAccountItemList(
organisation=line.getSourceSection(portal_type=section_portal_type_list))), organisation=line.getSourceSection(portal_type=section_portal_type_list))), # pylint:disable=cell-var-from-loop
), ),
( (
line.getDestinationValue(portal_type='Account'), line.getDestinationValue(portal_type='Account'),
line.getSourceSectionValue(portal_type=section_portal_type_list), line.getSourceSectionValue(portal_type=section_portal_type_list),
line.getDestinationPaymentValue(portal_type=bank_account_portal_type), line.getDestinationPaymentValue(portal_type=bank_account_portal_type),
lambda: (x[1] for x in getBankAccountItemList( lambda: (x[1] for x in getBankAccountItemList(
organisation=line.getDestinationSection(portal_type=section_portal_type_list))), organisation=line.getDestinationSection(portal_type=section_portal_type_list))), # pylint:disable=cell-var-from-loop
), ),
): ):
if account is not None and account.getValidationState() != 'validated': if account is not None and account.getValidationState() != 'validated':
......
...@@ -21,17 +21,14 @@ if accounting_module.getProperty('current_content_script', ...@@ -21,17 +21,14 @@ if accounting_module.getProperty('current_content_script',
'') == current_script_data_id: '') == current_script_data_id:
return "Accounting Transactions Created." return "Accounting Transactions Created."
# first, cleanup accounting module # first, cleanup modules
# XXX should be done in an external script / tool, because we have to for module_id in ['accounting_module',
# workaround some security checks 'sale_packing_list_module',
if 1: 'portal_simulation', ]:
for module_id in ['accounting_module', module = portal[module_id]
'sale_packing_list_module', if len(module) > 200:
'portal_simulation', ]: raise ValueError("Do not run this on production !!!")
module = portal[module_id] module.manage_delObjects(list(module.objectIds()))
if len(module) > 200:
raise ValueError("Do not run this on production !!!")
module.manage_delObjects(list(module.objectIds()))
# if `set_ledger`is true, allow all test ledgers in accounting types. # if `set_ledger`is true, allow all test ledgers in accounting types.
for accounting_type_id in portal.getPortalAccountingTransactionTypeList(): for accounting_type_id in portal.getPortalAccountingTransactionTypeList():
......
...@@ -16,10 +16,7 @@ if accounting_module.getProperty('current_content_script', ...@@ -16,10 +16,7 @@ if accounting_module.getProperty('current_content_script',
return "Accounting Transactions Created." return "Accounting Transactions Created."
# first, cleanup accounting module # first, cleanup accounting module
# XXX should be done in an external script / tool, because we have to accounting_module.manage_delObjects(list(accounting_module.objectIds()))
# workaround some security checks
if 1:
accounting_module.manage_delObjects(list(accounting_module.objectIds()))
# XXX copy & paste # XXX copy & paste
def getAccountByTitle(title): def getAccountByTitle(title):
......
...@@ -15,15 +15,12 @@ if accounting_module.getProperty('current_content_script', ...@@ -15,15 +15,12 @@ if accounting_module.getProperty('current_content_script',
return "Accounting Transactions Created." return "Accounting Transactions Created."
# first, cleanup accounting module # first, cleanup modules
# XXX should be done in an external script / tool, because we have to for module_id in ['accounting_module',
# workaround some security checks 'sale_packing_list_module',
if 1: 'portal_simulation', ]:
for module_id in ['accounting_module', module = portal[module_id]
'sale_packing_list_module', module.manage_delObjects(list(module.objectIds()))
'portal_simulation', ]:
module = portal[module_id]
module.manage_delObjects(list(module.objectIds()))
# XXX copy & paste # XXX copy & paste
def getAccountByTitle(title): def getAccountByTitle(title):
......
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