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

* add an update button on account statement, and reflect selection of section...

* add an update button on account statement, and reflect selection of section category in the list of possible third parties and bank account
* cleanup and document AccountModule_getBankAccountItemList
* extend a bit Account_zDistinctSectionList to support this

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34581 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a6df821b
......@@ -53,29 +53,34 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
<value> <string>"""Returns an item list of the acceptable bank accounts.\n
If `organisation` is passed, then we only show bank accounts available for that\n
organisation, using the following policy:\n
- if organisation contains bank accounts directly, only those bank accounts\n
can be selected\n
- if organisation higher in the group hierarchy contains bank accounts, bank\n
accounts from parent organisations can be selected\n
- it means a higher in the group cannot use bank account from organisations\n
below, maybe we\'ll want to change this ...\n
\n
if not organisation:\n
organisation = portal.portal_preferences\\\n
.getPreferredAccountingTransactionSourceSection()\n
\n
if not organisation:\n
return [(\'\', \'\')]\n
\n
organisation_value = portal.restrictedTraverse(organisation)\n
group_value = organisation_value.getGroupValue(None)\n
\n
search_kw = {\n
\'portal_type\': portal.getPortalPaymentNodeTypeList(),\n
}\n
If organisation is not passed, this script will return all bank accounts\n
applicable for section_category and section_category_strict_membership.\n
"""\n
portal = context.getPortalObject()\n
\n
search_kw = dict(portal_type=portal.getPortalPaymentNodeTypeList())\n
if skip_invalidated_bank_accounts:\n
search_kw[\'validation_state\'] = \'!=invalidated\'\n
\n
# if organisation contains bank accounts, only take into account those.\n
bank_account_list = organisation_value.searchFolder(**search_kw)\n
if organisation:\n
organisation_value = portal.restrictedTraverse(organisation)\n
\n
# if organisation contains bank accounts, only take into account those.\n
bank_account_list = organisation_value.searchFolder(**search_kw)\n
\n
if not bank_account_list:\n
# else we lookup in parent organisations\n
if not bank_account_list:\n
group_value = organisation_value.getGroupValue(None)\n
uid_list = []\n
while group_value.getPortalType() != \'Base Category\':\n
uid_list.append(group_value.getUid())\n
......@@ -84,6 +89,17 @@ if not bank_account_list:\n
search_kw[\'parent_portal_type\'] = \'Organisation\'\n
bank_account_list = portal.portal_catalog(**search_kw)\n
\n
else:\n
if section_category is None:\n
section_category = portal.portal_preferences\\\n
.getPreferredAccountingTransactionSectionCategory()\n
section_uid = portal.Base_getSectionUidListForSectionCategory(\n
section_category=section_category,\n
strict_membership=section_category_strict_membership)\n
search_kw[\'parent_uid\'] = section_uid\n
bank_account_list = portal.portal_catalog(**search_kw)\n
\n
\n
item_list = [(\'\', \'\')]\n
for bank in bank_account_list:\n
bank = bank.getObject()\n
......@@ -113,7 +129,7 @@ return item_list\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>organisation=None, skip_invalidated_bank_accounts=0</string> </value>
<value> <string>organisation=None, skip_invalidated_bank_accounts=0, section_category=None, section_category_strict_membership=False</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -133,7 +149,7 @@ return item_list\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>2</int> </value>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
......@@ -141,17 +157,21 @@ return item_list\n
<tuple>
<string>organisation</string>
<string>skip_invalidated_bank_accounts</string>
<string>section_category</string>
<string>section_category_strict_membership</string>
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
<string>organisation_value</string>
<string>None</string>
<string>group_value</string>
<string>dict</string>
<string>search_kw</string>
<string>_write_</string>
<string>organisation_value</string>
<string>_apply_</string>
<string>bank_account_list</string>
<string>None</string>
<string>group_value</string>
<string>uid_list</string>
<string>section_uid</string>
<string>item_list</string>
<string>_getiter_</string>
<string>bank</string>
......@@ -169,6 +189,8 @@ return item_list\n
<tuple>
<none/>
<int>0</int>
<none/>
<int>0</int>
</tuple>
</value>
</item>
......
......@@ -40,6 +40,16 @@
<key> <string>action</string> </key>
<value> <string>AccountModule_viewAccountStatementReport</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
......@@ -143,6 +153,10 @@
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string>AccountModule_viewAccountStatementReportDialog</string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
......
......@@ -269,11 +269,8 @@
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.TALESField</string>
<string>TALESMethod</string>
</tuple>
<none/>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
......@@ -288,18 +285,15 @@
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.TALESField</string>
<string>TALESMethod</string>
</tuple>
<none/>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python:here.Account_getDestinationSectionItemList(account = request.get(\'account\', \'\'))</string> </value>
<value> <string>python:here.Account_getDestinationSectionItemList(account=request.get(\'your_node\', \'\'), section_category=request.get(\'your_section_category\', preferences.getPreferredAccountingTransactionSectionCategory()), section_category_strict_membership=request.get(\'your_section_category_strict\'))</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -269,11 +269,8 @@
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.TALESField</string>
<string>TALESMethod</string>
</tuple>
<none/>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
......@@ -288,18 +285,15 @@
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.TALESField</string>
<string>TALESMethod</string>
</tuple>
<none/>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.AccountModule_getBankAccountItemList()</string> </value>
<value> <string>python: context.AccountModule_getBankAccountItemList( section_category=request.get(\'your_section_category\'), section_category_strict_membership=request.get(\'your_section_category_strict\'))</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -53,17 +53,15 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>account = None\n
if account == \'\' :\n
<value> <string>node_uid=None\n
if not account:\n
if (hasattr(context, \'getPortalType\') and context.getPortalType() == \'Account\') :\n
account = context\n
node_uid = context.getUid()\n
elif same_type(account, \'\') :\n
account = context.getPortalObject().restrictedTraverse(account)\n
\n
node_uid = None\n
if account is not None :\n
node_uid = account.getUid()\n
\n
\n
ptype_translated_dict = {}\n
def translatePortalType(ptype) :\n
"""Translate portal_type without retrieving the object from ZODB."""\n
......@@ -71,8 +69,15 @@ def translatePortalType(ptype) :\n
ptype_translated_dict[ptype] = context.Base_translateString(ptype)\n
return ptype_translated_dict[ptype]\n
\n
section_uid = []\n
if section_category:\n
section_uid = context.Base_getSectionUidListForSectionCategory(\n
section_category, strict_membership=section_category_strict_membership)\n
\n
\n
item_list = [("", "")]\n
for entity in context.Account_zDistinctSectionList(node_uid = node_uid):\n
for entity in context.Account_zDistinctSectionList(node_uid=node_uid,\n
section_uid=section_uid):\n
item_list.append(("%s (%s)" % ( entity[\'title\'],\n
translatePortalType(entity[\'portal_type\'])),\n
entity[\'relative_url\']))\n
......@@ -88,7 +93,7 @@ return item_list\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>account = \'\'</string> </value>
<value> <string>account=\'\', section_category=\'\', section_category_strict_membership=True</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -108,21 +113,24 @@ return item_list\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>account</string>
<string>section_category</string>
<string>section_category_strict_membership</string>
<string>None</string>
<string>node_uid</string>
<string>hasattr</string>
<string>context</string>
<string>_getattr_</string>
<string>same_type</string>
<string>node_uid</string>
<string>ptype_translated_dict</string>
<string>translatePortalType</string>
<string>section_uid</string>
<string>item_list</string>
<string>_getiter_</string>
<string>entity</string>
......@@ -140,6 +148,8 @@ return item_list\n
<value>
<tuple>
<string></string>
<string></string>
<int>1</int>
</tuple>
</value>
</item>
......@@ -149,7 +159,7 @@ return item_list\n
</item>
<item>
<key> <string>title</string> </key>
<value> <string>TODO: rename as Account_getMirrorSectionItemList</string> </value>
<value> <string>TODO: rename into AccountModule_getMirrorSectionItemList</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
......
......@@ -44,9 +44,14 @@
</value>
</item>
<item>
<key> <string>section_category</string> </key>
<key> <string>section_uid</string> </key>
<value>
<dictionary/>
<dictionary>
<item>
<key> <string>type</string> </key>
<value> <string>list</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
......@@ -69,7 +74,7 @@
<list>
<string>node_uid</string>
<string>at_date</string>
<string>section_category</string>
<string>section_uid</string>
<string>simulation_state</string>
</list>
</value>
......@@ -132,7 +137,7 @@
<key> <string>arguments_src</string> </key>
<value> <string>node_uid\r\n
at_date\r\n
section_category\r\n
section_uid:list\r\n
simulation_state:list</string> </value>
</item>
<item>
......@@ -195,11 +200,17 @@ WHERE\n
AND stock.date <= <dtml-sqlvar at_date type="datetime">\n
</dtml-if>\n
<dtml-if simulation_state>\n
AND ( <dtml-in simulation_state>\n
stock.simulation_state = <dtml-sqlvar sequence-item type="string">\n
<dtml-unless sequence-end>OR </dtml-unless>\n
</dtml-in> )\n
AND ( stock.simulation_state IN (<dtml-in simulation_state><dtml-sqlvar sequence-item type="string">\n
<dtml-unless sequence-end>, </dtml-unless></dtml-in>) )\n
</dtml-if>\n
\n
<dtml-if section_uid>\n
AND (\n
stock.section_uid IN ( <dtml-in section_uid><dtml-sqlvar sequence-item type="int">\n
<dtml-unless sequence-end>, </dtml-unless> </dtml-in> )\n
)\n
</dtml-if>\n
\n
AND stock.portal_type in ( <dtml-in getPortalAccountingMovementTypeList><dtml-sqlvar\n
sequence-item type="string"><dtml-unless sequence-end>, </dtml-unless></dtml-in> )\n
<dtml-if "query[\'where_expression\']">\n
......@@ -271,11 +282,17 @@ WHERE\n
AND stock.date <= <dtml-sqlvar at_date type="datetime">\n
</dtml-if>\n
<dtml-if simulation_state>\n
AND ( <dtml-in simulation_state>\n
stock.simulation_state = <dtml-sqlvar sequence-item type="string">\n
<dtml-unless sequence-end>OR </dtml-unless>\n
</dtml-in> )\n
AND ( stock.simulation_state IN (<dtml-in simulation_state><dtml-sqlvar sequence-item type="string">\n
<dtml-unless sequence-end>, </dtml-unless></dtml-in>) )\n
</dtml-if>\n
\n
<dtml-if section_uid>\n
AND (\n
stock.section_uid IN ( <dtml-in section_uid><dtml-sqlvar sequence-item type="int">\n
<dtml-unless sequence-end>, </dtml-unless> </dtml-in> )\n
)\n
</dtml-if>\n
\n
AND stock.portal_type in ( <dtml-in getPortalAccountingMovementTypeList><dtml-sqlvar\n
sequence-item type="string"><dtml-unless sequence-end>, </dtml-unless></dtml-in> )\n
<dtml-if "query[\'where_expression\']">\n
......
......@@ -267,18 +267,15 @@
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.TALESField</string>
<string>TALESMethod</string>
</tuple>
<none/>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>here/AccountModule_getBankAccountItemList</string> </value>
<value> <string>python: context.AccountModule_getBankAccountItemList( section_category=request.get(\'your_section_category\'), section_category_strict_membership=request.get(\'your_section_category_strict\'))</string> </value>
</item>
</dictionary>
</pickle>
......
1178
\ No newline at end of file
1181
\ No newline at end of file
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