Commit b2458545 authored by Tomáš Peterka's avatar Tomáš Peterka

[erp5_accouting] Allow more Actions - the ones using Selections and URL parameters

parent 7d5f7a57
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_button</string> <string>action_type/object_jio_button</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_button</string> </value> <value> <string>object_jio_button</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_exchange</string> <string>action_type/object_jio_exchange</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_exchange</string> </value> <value> <string>object_jio_exchange</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_exchange</string> <string>action_type/object_jio_exchange</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_exchange</string> </value> <value> <string>object_jio_exchange</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_exchange</string> <string>action_type/object_jio_exchange</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_exchange</string> </value> <value> <string>object_jio_exchange</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_action</string> <string>action_type/object_jio_action</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_action</string> </value> <value> <string>object_jio_action</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_action</string> <string>action_type/object_jio_action</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_action</string> </value> <value> <string>object_jio_action</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_exchange</string> <string>action_type/object_jio_exchange</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_exchange</string> </value> <value> <string>object_jio_exchange</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_button</string> <string>action_type/object_jio_button</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_button</string> </value> <value> <string>object_jio_button</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_exchange</string> <string>action_type/object_jio_exchange</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_exchange</string> </value> <value> <string>object_jio_exchange</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_exchange</string> <string>action_type/object_jio_exchange</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_exchange</string> </value> <value> <string>object_jio_exchange</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_exchange</string> <string>action_type/object_jio_exchange</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_exchange</string> </value> <value> <string>object_jio_exchange</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_report</string> <string>action_type/object_jio_report</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_report</string> </value> <value> <string>object_jio_report</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_exchange</string> <string>action_type/object_jio_exchange</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_exchange</string> </value> <value> <string>object_jio_exchange</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_report</string> <string>action_type/object_jio_report</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_report</string> </value> <value> <string>object_jio_report</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_button</string> <string>action_type/object_jio_button</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_button</string> </value> <value> <string>object_jio_button</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_exchange</string> <string>action_type/object_jio_exchange</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_exchange</string> </value> <value> <string>object_jio_exchange</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_report</string> <string>action_type/object_jio_report</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_report</string> </value> <value> <string>object_jio_report</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_exchange</string> <string>action_type/object_jio_exchange</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_exchange</string> </value> <value> <string>object_jio_exchange</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_report</string> <string>action_type/object_jio_report</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_report</string> </value> <value> <string>object_jio_report</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_button</string> <string>action_type/object_jio_button</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_button</string> </value> <value> <string>object_jio_button</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_action</string> <string>action_type/object_jio_action</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_action</string> </value> <value> <string>object_jio_action</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>action_type/object_action</string> <string>action_type/object_jio_action</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_action</string> </value> <value> <string>object_jio_action</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
......
...@@ -175,7 +175,7 @@ ...@@ -175,7 +175,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: list(context.getPortalItemTypeList()) + (\'Payment Transaction Group\', )</string> </value> <value> <string>python: list(context.getPortalItemTypeList()) + [\'Payment Transaction Group\', ]</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -4,9 +4,13 @@ portal = context.getPortalObject() ...@@ -4,9 +4,13 @@ portal = context.getPortalObject()
countMessage = portal.portal_activities.countMessage countMessage = portal.portal_activities.countMessage
invoice_type_list = portal.getPortalInvoiceTypeList() invoice_type_list = portal.getPortalInvoiceTypeList()
portal.portal_selections.updateSelectionCheckedUidList(selection_name, listbox_uid, uids) if selection_name:
selection_uid_list = portal.portal_selections.getSelectionCheckedUidsFor( portal.portal_selections.updateSelectionCheckedUidList(selection_name, listbox_uid, uids)
selection_name) selection_uid_list = portal.portal_selections.getSelectionCheckedUidsFor(
selection_name)
else:
selection_uid_list = uids
if selection_uid_list: if selection_uid_list:
object_list = [brain.getObject() for brain in portal.portal_catalog(uid=selection_uid_list)] object_list = [brain.getObject() for brain in portal.portal_catalog(uid=selection_uid_list)]
else: else:
...@@ -20,10 +24,9 @@ portal.portal_selections.setSelectionParamsFor('accounting_create_related_paymen ...@@ -20,10 +24,9 @@ portal.portal_selections.setSelectionParamsFor('accounting_create_related_paymen
# XXX prevent to call this on the whole module: # XXX prevent to call this on the whole module:
if len(object_list) >= 1000: if len(object_list) >= 1000:
return context.Base_redirect( return context.Base_renderMessage(
form_id, translateString('Refusing to process more than 1000 objects, check your selection.'),
keep_items={'portal_status_message': translateString( 'warning')
'Refusing to process more than 1000 objects, check your selection.')})
tag = 'payment_creation_%s' % random.randint(0, 1000) tag = 'payment_creation_%s' % random.randint(0, 1000)
activated = 0 activated = 0
...@@ -51,6 +54,7 @@ if not activated: ...@@ -51,6 +54,7 @@ if not activated:
'No invoice in your selection.')}) 'No invoice in your selection.')})
# activate something on the folder # activate something on the folder
# Kato: Why?
context.activate(after_tag=tag).getTitle() context.activate(after_tag=tag).getTitle()
return context.Base_redirect( return context.Base_redirect(
......
...@@ -3,9 +3,13 @@ from zExceptions import Redirect ...@@ -3,9 +3,13 @@ from zExceptions import Redirect
portal = context.getPortalObject() portal = context.getPortalObject()
countMessage = portal.portal_activities.countMessage countMessage = portal.portal_activities.countMessage
portal.portal_selections.updateSelectionCheckedUidList(selection_name, listbox_uid, uids) if selection_name:
selection_uid_list = portal.portal_selections.getSelectionCheckedUidsFor( portal.portal_selections.updateSelectionCheckedUidList(selection_name, listbox_uid, uids)
selection_name) selection_uid_list = portal.portal_selections.getSelectionCheckedUidsFor(
selection_name)
else:
selection_uid_list = uids
if selection_uid_list: if selection_uid_list:
object_list = [brain.getObject() for brain in portal.portal_catalog(uid=selection_uid_list)] object_list = [brain.getObject() for brain in portal.portal_catalog(uid=selection_uid_list)]
else: else:
...@@ -24,9 +28,9 @@ for obj in object_list: ...@@ -24,9 +28,9 @@ for obj in object_list:
obj = obj.getObject() obj = obj.getObject()
if countMessage(path=obj.getPath(), if countMessage(path=obj.getPath(),
method_id='AccountingTransaction_createReversalTransaction'): method_id='AccountingTransaction_createReversalTransaction'):
raise Redirect, "%s/view?portal_status_message=%s" % ( return context.Base_renderMessage(
context.absolute_url(), translateString( translateString('Reversal creation already in progress, abandon.'),
'Reversal creation already in progress, abandon.')) level='error')
obj.activate(tag=tag).AccountingTransaction_createReversalTransaction( obj.activate(tag=tag).AccountingTransaction_createReversalTransaction(
cancellation_amount=cancellation_amount, cancellation_amount=cancellation_amount,
date=date, date=date,
...@@ -34,11 +38,11 @@ for obj in object_list: ...@@ -34,11 +38,11 @@ for obj in object_list:
activated += 1 activated += 1
if not activated: if not activated:
return context.Base_redirect(form_id, return context.Base_renderMessage(
keep_items=dict(portal_status_message= translateString('No valid transaction in your selection.'), 'error')
translateString('No valid transaction in your selection.')))
# activate something on the folder # activate something on the folder
# Kato: ehm ... why?
context.activate(after_tag=tag).getTitle() context.activate(after_tag=tag).getTitle()
return context.Base_redirect(form_id, return context.Base_redirect(form_id,
......
...@@ -114,6 +114,7 @@ params['select_dict'] = select_dict ...@@ -114,6 +114,7 @@ params['select_dict'] = select_dict
if not params.get('accounting_transaction.section_uid'): if not params.get('accounting_transaction.section_uid'):
params.setdefault('group_by', ('uid',)) params.setdefault('group_by', ('uid',))
# Kato: Be explicit! You have no idea what is in the **params!
if stat: if stat:
return context.countFolder(**params) return context.countFolder(**params)
return context.searchFolder(**params) return context.searchFolder(**params)
...@@ -8,11 +8,13 @@ psm = Base_translateString('Nothing matches.') ...@@ -8,11 +8,13 @@ psm = Base_translateString('Nothing matches.')
request = container.REQUEST request = container.REQUEST
# update selected uids # update selected uids
portal.portal_selections.updateSelectionCheckedUidList( if list_selection_name:
list_selection_name, uids=uids, listbox_uid=listbox_uid, REQUEST=request) portal.portal_selections.updateSelectionCheckedUidList(
uids = portal.portal_selections.getSelectionCheckedUidsFor(list_selection_name) list_selection_name, uids=uids, listbox_uid=listbox_uid, REQUEST=request)
uids = portal.portal_selections.getSelectionCheckedUidsFor(list_selection_name)
# XXX when should it be validated ? # XXX when should it be validated ?
# Kato: It is already validated because this is Form Dialog script
if node == '': if node == '':
node = context.REQUEST.get('field_your_node', node) node = context.REQUEST.get('field_your_node', node)
if mirror_section == '': if mirror_section == '':
...@@ -22,13 +24,13 @@ if grouping == '': ...@@ -22,13 +24,13 @@ if grouping == '':
grouping = request.get('your_grouping', grouping = request.get('your_grouping',
request.get('field_your_grouping', request.get('field_your_grouping',
grouping)) grouping))
if list_selection_name:
# edit selection for dialog parameters # edit selection for dialog parameters
portal.portal_selections.setSelectionParamsFor( portal.portal_selections.setSelectionParamsFor(
'grouping_reference_fast_input_selection', 'grouping_reference_fast_input_selection',
params=dict(node=node, params=dict(node=node,
grouping=grouping, grouping=grouping,
mirror_section=mirror_section)) mirror_section=mirror_section))
# calculate total selected amount # calculate total selected amount
total_selected_amount = 0 total_selected_amount = 0
...@@ -42,9 +44,8 @@ if uids: ...@@ -42,9 +44,8 @@ if uids:
request.set('total_selected_amount', total_selected_amount) request.set('total_selected_amount', total_selected_amount)
if update: if update:
request.set('portal_status_message', Base_translateString('Updated')) return context.Base_renderForm('AccountingTransactionModule_viewGroupingFastInputDialog')
return context.AccountingTransactionModule_viewGroupingFastInputDialog(request)
# otherwise, try to group... # otherwise, try to group...
if grouping == 'grouping': if grouping == 'grouping':
...@@ -53,9 +54,9 @@ if grouping == 'grouping': ...@@ -53,9 +54,9 @@ if grouping == 'grouping':
if grouped_line_list: if grouped_line_list:
psm = Base_translateString('${grouped_line_count} lines grouped.', psm = Base_translateString('${grouped_line_count} lines grouped.',
mapping=dict(grouped_line_count=len(grouped_line_list))) mapping=dict(grouped_line_count=len(grouped_line_list)))
if list_selection_name:
# make sure nothing will be checked next time # make sure nothing will be checked next time
portal.portal_selections.setSelectionCheckedUidsFor(list_selection_name, []) portal.portal_selections.setSelectionCheckedUidsFor(list_selection_name, [])
# we check if we can mark some transaction as payed. # we check if we can mark some transaction as payed.
transaction_list = {} transaction_list = {}
...@@ -119,8 +120,9 @@ else: ...@@ -119,8 +120,9 @@ else:
psm = Base_translateString('${ungrouped_line_count} lines ungrouped.', psm = Base_translateString('${ungrouped_line_count} lines ungrouped.',
mapping=dict(ungrouped_line_count=len(ungrouped_line_list))) mapping=dict(ungrouped_line_count=len(ungrouped_line_list)))
# make sure nothing will be checked next time if list_selection_name:
portal.portal_selections.setSelectionCheckedUidsFor(list_selection_name, []) # make sure nothing will be checked next time
portal.portal_selections.setSelectionCheckedUidsFor(list_selection_name, [])
request.set('portal_status_message', psm) request.set('portal_status_message', psm)
return context.AccountingTransactionModule_viewGroupingFastInputDialog(request) return context.Base_renderForm('AccountingTransactionModule_viewGroupingFastInputDialog')
...@@ -223,7 +223,7 @@ ...@@ -223,7 +223,7 @@
</item> </item>
<item> <item>
<key> <string>first_item</string> </key> <key> <string>first_item</string> </key>
<value> <int>0</int> </value> <value> <int>1</int> </value>
</item> </item>
<item> <item>
<key> <string>hidden</string> </key> <key> <string>hidden</string> </key>
......
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