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

bank_reconciliation: use specific scripts to set/unset the bank reconciliation

To handle the case where an internal transaction line can be reconcilied
independently on source payment and destination payment.
parent b62da16d
"""Set the aggregate relation to a payment request on this line. """Adds the bank reconciliation to the already aggregated bank reconciliation on this line.
This script has a proxy role to be able to modify delivered lines This script has a proxy role to be able to modify delivered lines
""" """
...@@ -6,7 +6,10 @@ portal = context.getPortalObject() ...@@ -6,7 +6,10 @@ portal = context.getPortalObject()
assert context.getPortalType() in portal.getPortalAccountingMovementTypeList() assert context.getPortalType() in portal.getPortalAccountingMovementTypeList()
context.setAggregateValue(payment_request_value, portal_type='Bank Reconciliation') context.setAggregateSet(
context.getAggregateList(portal_type='Bank Reconciliation') + [bank_reconciliation_relative_url],
portal_type='Bank Reconciliation')
# for traceability # for traceability
portal.portal_workflow.doActionFor( portal.portal_workflow.doActionFor(
context.getParentValue(), context.getParentValue(),
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>payment_request_value, message</string> </value> <value> <string>bank_reconciliation_relative_url, message</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>AccountingTransactionLine_setBankReconciliation</string> </value> <value> <string>AccountingTransactionLine_addBankReconciliation</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
"""Adds the bank reconciliation to the already aggregated bank reconciliation on this line.
This script has a proxy role to be able to modify delivered lines
"""
portal = context.getPortalObject()
assert context.getPortalType() in portal.getPortalAccountingMovementTypeList()
bank_reconciliation_list = context.getAggregateList(portal_type='Bank Reconciliation')
bank_reconciliation_list.remove(bank_reconciliation_relative_url)
context.setAggregateList(
bank_reconciliation_list,
portal_type='Bank Reconciliation')
# for traceability
portal.portal_workflow.doActionFor(
context.getParentValue(),
"edit_action",
comment=message)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>bank_reconciliation_relative_url, message</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingTransactionLine_removeBankReconciliation</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -31,8 +31,9 @@ if mode == 'reconcile': ...@@ -31,8 +31,9 @@ if mode == 'reconcile':
'cancel_url': cancel_url, 'cancel_url': cancel_url,
'mode': mode, 'mode': mode,
'field_your_mode': mode}) 'field_your_mode': mode})
line.AccountingTransactionLine_setBankReconciliation(context, line.AccountingTransactionLine_addBankReconciliation(
message=translateString("Reconciling Bank Line")) context.getRelativeUrl(),
message=translateString("Reconciling Bank Line"))
return context.Base_redirect(dialog_id, keep_items={ return context.Base_redirect(dialog_id, keep_items={
'portal_status_message': translateString("Line Reconciled"), 'portal_status_message': translateString("Line Reconciled"),
'reset': 1, 'reset': 1,
...@@ -44,8 +45,9 @@ if mode == 'reconcile': ...@@ -44,8 +45,9 @@ if mode == 'reconcile':
assert mode == 'unreconcile' assert mode == 'unreconcile'
for line in portal.portal_catalog(uid=selection_uid_list or -1): for line in portal.portal_catalog(uid=selection_uid_list or -1):
line = line.getObject() line = line.getObject()
line.AccountingTransactionLine_setBankReconciliation(None, line.AccountingTransactionLine_removeBankReconciliation(
message=translateString("Reconciling Bank Line")) context.getRelativeUrl(),
message=translateString("Reconciling Bank Line"))
return context.Base_redirect(dialog_id, keep_items={ return context.Base_redirect(dialog_id, keep_items={
'portal_status_message': translateString("Lines Unreconciled"), 'portal_status_message': translateString("Lines Unreconciled"),
......
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
context.getPortalObject().setPlacelessDefaultReindexParameters(activate_kw=dict(tag=tag)) context.getPortalObject().setPlacelessDefaultReindexParameters(activate_kw=dict(tag=tag))
bank_reconciliation_relative_url = context.getRelativeUrl()
# XXX maybe we want to distribute this more. # XXX maybe we want to distribute this more.
# At the moment we cannot use searchAndActivate from Inventory API query # At the moment we cannot use searchAndActivate from Inventory API query
for line in context.BankReconciliation_getAccountingTransactionLineList(): for line in context.BankReconciliation_getAccountingTransactionLineList():
line.AccountingTransactionLine_setBankReconciliation(context, line.AccountingTransactionLine_addBankReconciliation(
bank_reconciliation_relative_url,
message=translateString("Select Non Reconciled Transactions")) message=translateString("Select Non Reconciled Transactions"))
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
portal = sci['object'].getPortalObject() portal = sci['object'].getPortalObject()
bank_reconciliation = sci['object']
# We activate after BankReconciliation_selectNonReconciledTransactionList, in # We activate after BankReconciliation_selectNonReconciledTransactionList, in
# case the user cancels just after using this action. # case the user cancels just after using this action.
portal.portal_catalog.activate( portal.portal_catalog.activate(
activity='SQLQueue', after_tag='BankReconciliation_selectNonReconciledTransactionList' activity='SQLQueue', after_tag='BankReconciliation_selectNonReconciledTransactionList'
).searchAndActivate( ).searchAndActivate(
portal_type=portal.getPortalAccountingMovementTypeList(), portal_type=portal.getPortalAccountingMovementTypeList(),
default_aggregate_uid=sci['object'].getUid(), default_aggregate_uid=bank_reconciliation.getUid(),
method_args=(None, translateString('Cancelling bank reconciliation')), method_args=(bank_reconciliation.getRelativeUrl(), translateString('Cancelling bank reconciliation')),
method_id='AccountingTransactionLine_setBankReconciliation' method_id='AccountingTransactionLine_removeBankReconciliation'
) )
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