Commit 600dece0 authored by Kevin Deldycke's avatar Kevin Deldycke

Add a flag in the request to identofy the context as an accounting_report.

Take care of selection (not finished yet).
Don't use "getUid" any longer.
Use where_expression instead of my previous hack.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6693 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1abe5384
...@@ -66,26 +66,33 @@ ...@@ -66,26 +66,33 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>src__ = 0\n <value> <string>src__ = False\n
if kw.has_key(\'src__\'): src__ = kw[\'src__\']\n if kw.has_key(\'src__\'): src__ = kw[\'src__\']\n
precision = context.Base_getPreferredPrecision()\n precision = context.Base_getPreferredPrecision()\n
r_ = lambda x: context.Base_getRoundValue(x, precision)\n r_ = lambda x: context.Base_getRoundValue(x, precision)\n
\n \n
# TODO: Selection override Preferences.\n
# Thanks to this, we can generate accounting reports based on generic listbox: from the ERP5 html view, no selection are set, so preferences are get as parameters to get the list of accounting lines. In case of accounting report (like AccountModule_getGeneralLedgerReportSectionList) we set the selection to pass parameters to the listbox.\n
selection_kw = {}\n
if selection != None:\n
selection_kw = selection.getParams()\n
context.log("Selection must overide preference here for AccountModule_getGeneralLedgerReportSectionList !", repr(selection_kw))\n
\n
if selection_kw.has_key(\'is_accounting_report\'):\n
request = context.REQUEST\n
request.set(\'is_accounting_report\', True)\n
\n
# Read settings from user preference\n # Read settings from user preference\n
preference = context.getPortalObject().portal_preferences\n preference = context.getPortalObject().portal_preferences\n
simulation_state = kw.get(\'simulation_state\', \n simulation_state = kw.get(\'simulation_state\', preference.getPreferredAccountingTransactionSimulationStateList())\n
preference.getPreferredAccountingTransactionSimulationStateList())\n section_category = kw.get(\'section_category\', preference.getPreferredAccountingTransactionSectionCategory())\n
section_category = kw.get(\'section_category\', \n from_date = kw.get(\'from_date\', preference.getPreferredAccountingTransactionFromDate())\n
preference.getPreferredAccountingTransactionSectionCategory())\n at_date = kw.get(\'at_date\', preference.getPreferredAccountingTransactionAtDate())\n
from_date = kw.get(\'from_date\',\n
preference.getPreferredAccountingTransactionFromDate())\n
at_date = kw.get(\'at_date\',\n
preference.getPreferredAccountingTransactionAtDate())\n
\n \n
# Build the common inventory dict\n # Build the common inventory dict\n
params = {}\n params = {}\n
\n \n
if kw.get(\'no_from_date\', 0): from_date = None\n if kw.get(\'no_from_date\', False): from_date = None\n
\n \n
if simulation_state: params[\'simulation_state\'] = simulation_state\n if simulation_state: params[\'simulation_state\'] = simulation_state\n
if section_category: params[\'section_category\'] = section_category\n if section_category: params[\'section_category\'] = section_category\n
...@@ -93,23 +100,20 @@ if section_category: params[\'section_category\'] = section_category\n ...@@ -93,23 +100,20 @@ if section_category: params[\'section_category\'] = section_category\n
# Get payment and mirror related parameters\n # Get payment and mirror related parameters\n
MARKER = []\n MARKER = []\n
no_payment_uid = kw.get(\'no_payment_uid\', MARKER)\n no_payment_uid = kw.get(\'no_payment_uid\', MARKER)\n
payment_uid = kw.get( \'payment_uid\', MARKER)\n payment_uid = kw.get(\'payment_uid\', MARKER)\n
no_mirror_section_uid = kw.get(\'no_mirror_section_uid\', MARKER)\n no_mirror_section_uid = kw.get(\'no_mirror_section_uid\', MARKER)\n
mirror_section_uid = kw.get( \'mirror_section_uid\', MARKER)\n mirror_section_uid = kw.get(\'mirror_section_uid\', MARKER)\n
# Try alternate method to get payment_uid\n # Try alternate method to get payment_uid\n
if no_payment_uid is MARKER: no_payment_uid = kw.get(\'no_source_uid\', MARKER)\n if no_payment_uid is MARKER: no_payment_uid = kw.get(\'no_source_uid\', MARKER)\n
if payment_uid is MARKER: payment_uid = kw.get( \'source_uid\', MARKER)\n if payment_uid is MARKER: payment_uid = kw.get(\'source_uid\', MARKER)\n
# Save results in the dict\n # Save results in the dict\n
if no_payment_uid is not MARKER: params[\'no_payment_uid\'] = 1\n if no_payment_uid is not MARKER: params[\'no_payment_uid\'] = True\n
if payment_uid is not MARKER: params[ \'payment_uid\'] = payment_uid\n if payment_uid is not MARKER: params[\'payment_uid\'] = payment_uid\n
if no_mirror_section_uid is not MARKER: params[\'no_mirror_section_uid\'] = 1\n if no_mirror_section_uid is not MARKER: params[\'no_mirror_section_uid\'] = True\n
if mirror_section_uid is not MARKER: params[ \'mirror_section_uid\'] = mirror_section_uid\n if mirror_section_uid is not MARKER: params[\'mirror_section_uid\'] = mirror_section_uid\n
\n \n
# Get node_uid parameters\n # Get node_uid parameters\n
node_uid = kw.get(\'node_uid\', MARKER)\n params[\'node_uid\'] = kw.get(\'node_uid\', context.getUid())\n
if node_uid is not MARKER:\n
params[\'node_uid\'] = node_uid\n
params[\'getUid\'] = node_uid # Account_zGetAccountingTransactionList compat\n
\n \n
# Create the related accouting line list\n # Create the related accouting line list\n
new_result = []\n new_result = []\n
...@@ -117,15 +121,13 @@ net_balance = 0.0\n ...@@ -117,15 +121,13 @@ net_balance = 0.0\n
\n \n
# Create a new parameter list to get the previous balance\n # Create a new parameter list to get the previous balance\n
get_inventory_kw = params.copy()\n get_inventory_kw = params.copy()\n
get_inventory_kw.update({ \'omit_simulation\' : 1\n get_inventory_kw.update({ \'omit_simulation\' : True\n
, \'to_date\' : from_date\n , \'to_date\' : from_date\n
, \'section_portal_type_list\': [\'Organisation\']\n , \'where_expression\': " section.portal_type = \'Organisation\' "\n
, \'stat\' : 1\n , \'stat\' : True\n
})\n })\n
get_inventory_kw[\'node_uid\'] = kw.get(\'node_uid\', context.getUid())\n
\n \n
# Get previous debit and credit\n # Get previous debit and credit\n
# Get previous debit and credit\n
getInventoryAssetPrice = context.getPortalObject().portal_simulation.getInventoryAssetPrice\n getInventoryAssetPrice = context.getPortalObject().portal_simulation.getInventoryAssetPrice\n
previous_total_debit = getInventoryAssetPrice(omit_output=True, **get_inventory_kw)\n previous_total_debit = getInventoryAssetPrice(omit_output=True, **get_inventory_kw)\n
previous_total_credit = getInventoryAssetPrice(omit_input =True, **get_inventory_kw)\n previous_total_credit = getInventoryAssetPrice(omit_input =True, **get_inventory_kw)\n
...@@ -237,32 +239,36 @@ return new_result\n ...@@ -237,32 +239,36 @@ return new_result\n
<value> <value>
<tuple> <tuple>
<string>kw</string> <string>kw</string>
<string>False</string>
<string>src__</string> <string>src__</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>context</string> <string>context</string>
<string>precision</string> <string>precision</string>
<string>r_</string> <string>r_</string>
<string>selection_kw</string>
<string>selection</string>
<string>None</string>
<string>repr</string>
<string>request</string>
<string>True</string>
<string>preference</string> <string>preference</string>
<string>simulation_state</string> <string>simulation_state</string>
<string>section_category</string> <string>section_category</string>
<string>from_date</string> <string>from_date</string>
<string>at_date</string> <string>at_date</string>
<string>params</string> <string>params</string>
<string>None</string>
<string>_write_</string> <string>_write_</string>
<string>MARKER</string> <string>MARKER</string>
<string>no_payment_uid</string> <string>no_payment_uid</string>
<string>payment_uid</string> <string>payment_uid</string>
<string>no_mirror_section_uid</string> <string>no_mirror_section_uid</string>
<string>mirror_section_uid</string> <string>mirror_section_uid</string>
<string>node_uid</string>
<string>new_result</string> <string>new_result</string>
<string>net_balance</string> <string>net_balance</string>
<string>get_inventory_kw</string> <string>get_inventory_kw</string>
<string>getInventoryAssetPrice</string> <string>getInventoryAssetPrice</string>
<string>_apply_</string> <string>_apply_</string>
<string>True</string>
<string>previous_total_debit</string> <string>previous_total_debit</string>
<string>previous_total_credit</string> <string>previous_total_credit</string>
<string>Products.ERP5Type.Document</string> <string>Products.ERP5Type.Document</string>
......
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