Commit fd215503 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 b015a671
"""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
"""
......@@ -6,7 +6,10 @@ portal = context.getPortalObject()
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
portal.portal_workflow.doActionFor(
context.getParentValue(),
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>payment_request_value, message</string> </value>
<value> <string>bank_reconciliation_relative_url, message</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......@@ -62,7 +62,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingTransactionLine_setBankReconciliation</string> </value>
<value> <string>AccountingTransactionLine_addBankReconciliation</string> </value>
</item>
</dictionary>
</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,7 +31,8 @@ if mode == 'reconcile':
'cancel_url': cancel_url,
'mode': mode,
'field_your_mode': mode})
line.AccountingTransactionLine_setBankReconciliation(context,
line.AccountingTransactionLine_addBankReconciliation(
context.getRelativeUrl(),
message=translateString("Reconciling Bank Line"))
return context.Base_redirect(dialog_id, keep_items={
'portal_status_message': translateString("Line Reconciled"),
......@@ -44,7 +45,8 @@ if mode == 'reconcile':
assert mode == 'unreconcile'
for line in portal.portal_catalog(uid=selection_uid_list or -1):
line = line.getObject()
line.AccountingTransactionLine_setBankReconciliation(None,
line.AccountingTransactionLine_removeBankReconciliation(
context.getRelativeUrl(),
message=translateString("Reconciling Bank Line"))
return context.Base_redirect(dialog_id, keep_items={
......
from Products.ERP5Type.Message import translateString
context.getPortalObject().setPlacelessDefaultReindexParameters(activate_kw=dict(tag=tag))
bank_reconciliation_relative_url = context.getRelativeUrl()
# XXX maybe we want to distribute this more.
# At the moment we cannot use searchAndActivate from Inventory API query
for line in context.BankReconciliation_getAccountingTransactionLineList():
line.AccountingTransactionLine_setBankReconciliation(context,
line.AccountingTransactionLine_addBankReconciliation(
bank_reconciliation_relative_url,
message=translateString("Select Non Reconciled Transactions"))
from Products.ERP5Type.Message import translateString
portal = sci['object'].getPortalObject()
bank_reconciliation = sci['object']
# We activate after BankReconciliation_selectNonReconciledTransactionList, in
# case the user cancels just after using this action.
......@@ -8,7 +9,7 @@ portal.portal_catalog.activate(
activity='SQLQueue', after_tag='BankReconciliation_selectNonReconciledTransactionList'
).searchAndActivate(
portal_type=portal.getPortalAccountingMovementTypeList(),
default_aggregate_uid=sci['object'].getUid(),
method_args=(None, translateString('Cancelling bank reconciliation')),
method_id='AccountingTransactionLine_setBankReconciliation'
default_aggregate_uid=bank_reconciliation.getUid(),
method_args=(bank_reconciliation.getRelativeUrl(), translateString('Cancelling bank reconciliation')),
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