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

use getInventoryAssetPrice instead of getInventory


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5606 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 305ff3e9
...@@ -81,14 +81,21 @@ LOG = lambda msg : context.getPortalObject().log(\n ...@@ -81,14 +81,21 @@ LOG = lambda msg : context.getPortalObject().log(\n
\n \n
from_date = kw.get(\'from_date\', DateTime(\'1970/01/01\'))\n from_date = kw.get(\'from_date\', DateTime(\'1970/01/01\'))\n
simulation_state = kw[\'transaction_simulation_state\']\n simulation_state = kw[\'transaction_simulation_state\']\n
section_category = kw[\'transaction_section_category\']\n
at_date = kw[\'at_date\']\n at_date = kw[\'at_date\']\n
kw[\'accounting_transaction_line_currency\'] = \'TODO\'\n
\n \n
# extra arguments for getInventory :\n
extra_kw = {}\n
\n
# get a list of section uids. \n
section_category = kw[\'transaction_section_category\']\n
section_object = context.portal_categories.restrictedTraverse(\n
section_category )\n
organisation_list = section_object.getGroupRelatedValueList(\n
portal_type=\'Organisation\')\n
section_uid_list = [section_object.getUid()] + [\n
x.getUid() for x in organisation_list]\n
extra_kw[\'stock.section_uid\'] = section_uid_list\n
\n \n
getInventory = context.getPortalObject().portal_simulation.getInventory\n
getInventoryList = context.getPortalObject().portal_simulation.getInventoryList\n
\n
# wether we should or not expand accounts into virtual accounts \n # wether we should or not expand accounts into virtual accounts \n
# (payable & receivable with other parties / bank with bank account)\n # (payable & receivable with other parties / bank with bank account)\n
expand_accounts = kw.get("expand_accounts", 1)\n expand_accounts = kw.get("expand_accounts", 1)\n
...@@ -96,10 +103,10 @@ expand_accounts = kw.get("expand_accounts", 1)\n ...@@ -96,10 +103,10 @@ expand_accounts = kw.get("expand_accounts", 1)\n
# the gap tree to use\n # the gap tree to use\n
gap_root = kw["gap_root"]\n gap_root = kw["gap_root"]\n
\n \n
# extra arguments for getInventory :\n # inventory methods\n
extra_kw = {}\n getInventory = context.getPortalObject().portal_simulation\\\n
if kw.get(\'from_date\', None) is not None:\n .getInventoryAssetPrice\n
extra_from_date = from_date\n getInventoryList = context.getPortalObject().portal_simulation.getInventoryList\n
\n \n
# shall we display a summary line for expanded accounts ?\n # shall we display a summary line for expanded accounts ?\n
display_summary_account_line = 0\n display_summary_account_line = 0\n
...@@ -133,38 +140,33 @@ def formatValues(dict) :\n ...@@ -133,38 +140,33 @@ def formatValues(dict) :\n
dict[k]\n dict[k]\n
return dict \n return dict \n
\n \n
# organisations for expandBankAccountsForAccount\n def getDefaultColumnValues(node_uid = 0, **kw):\n
organisations = context.portal_categories.restrictedTraverse(\n
section_category\n
).getGroupRelatedValueList(portal_type=\'Organisation\')\n
\n
\n
def getDefaultColumnValues(node_uid = 0, **kw): \n
""" returns then opening balance, debit movements sum, credit movements\n """ returns then opening balance, debit movements sum, credit movements\n
sum and closing balance using defaults categories. """\n sum and closing balance using defaults categories. """\n
values = {}\n values = {}\n
get_inventory_kw = extra_kw.copy()\n
get_inventory_kw.update(kw)\n
\n
values[\'opening_balance\'] = getInventory( node_uid = node_uid,\n values[\'opening_balance\'] = getInventory( node_uid = node_uid,\n
to_date = from_date,\n to_date = from_date,\n
simulation_state = simulation_state,\n simulation_state = simulation_state,\n
omit_simulation = 1,\n omit_simulation = 1,\n
# TODOcurrency = kw[\'accounting_transaction_line_currency\'],\n **get_inventory_kw )\n
**kw )\n \n
values[\'debit_movement\'] = getInventory( node_uid = node_uid,\n values[\'debit_movement\'] = getInventory( node_uid = node_uid,\n
from_date = from_date,\n from_date = from_date,\n
at_date = at_date,\n at_date = at_date,\n
simulation_state = simulation_state,\n simulation_state = simulation_state,\n
omit_simulation = 1,\n omit_simulation = 1,\n
omit_output = 1,\n omit_output = 1,\n
# TODOcurrency = kw[\'accounting_transaction_line_currency\'],\n **get_inventory_kw )\n
**kw )\n
values[\'credit_movement\'] = - getInventory( node_uid = node_uid,\n values[\'credit_movement\'] = - getInventory( node_uid = node_uid,\n
from_date = from_date,\n from_date = from_date,\n
at_date = at_date,\n at_date = at_date,\n
simulation_state = simulation_state,\n simulation_state = simulation_state,\n
omit_simulation = 1,\n omit_simulation = 1,\n
omit_input = 1,\n omit_input = 1,\n
# TODOcurrency = kw[\'accounting_transaction_line_currency\'],\n **get_inventory_kw )\n
**kw )\n
values[\'closing_balance\'] = values[\'opening_balance\'] + \\\n values[\'closing_balance\'] = values[\'opening_balance\'] + \\\n
values[\'debit_movement\'] - \\\n values[\'debit_movement\'] - \\\n
values[\'credit_movement\']\n values[\'credit_movement\']\n
...@@ -173,9 +175,11 @@ def getDefaultColumnValues(node_uid = 0, **kw): \n ...@@ -173,9 +175,11 @@ def getDefaultColumnValues(node_uid = 0, **kw): \n
def expandBankAccountsForAccount(account, **kw) :\n def expandBankAccountsForAccount(account, **kw) :\n
tmp_accounts = []\n tmp_accounts = []\n
orga_and_banks = []\n orga_and_banks = []\n
for orga in organisations :\n for orga in organisation_list :\n
orga_and_banks += [(orga, o.getObject()) for o in \\\n orga_and_banks += [(orga, o.getObject()) for o in \\\n
orga.searchFolder(portal_type=[\'Bank Account\', \'Cash Register\'])]\n orga.searchFolder(portal_type=[ \'Bank Account\',\n
\'Cash Register\',\n
\'Credit Card\'])]\n
for orga ,bank in orga_and_banks :\n for orga ,bank in orga_and_banks :\n
this_tmp_account = {\n this_tmp_account = {\n
\'uid\' : account.getUid(),\n \'uid\' : account.getUid(),\n
...@@ -192,16 +196,17 @@ def expandBankAccountsForAccount(account, **kw) :\n ...@@ -192,16 +196,17 @@ def expandBankAccountsForAccount(account, **kw) :\n
this_tmp_account[\'credit_movement\'] != 0 or \n this_tmp_account[\'credit_movement\'] != 0 or \n
this_tmp_account[\'debit_movement\'] != 0 or\n this_tmp_account[\'debit_movement\'] != 0 or\n
this_tmp_account[\'closing_balance\'] != 0 ) :\n this_tmp_account[\'closing_balance\'] != 0 ) :\n
tmp_accounts.append( account.asContext( **formatValues(this_tmp_account) ) )\n tmp_accounts.append( account.asContext(\n
**formatValues(this_tmp_account) ) )\n
return tmp_accounts\n return tmp_accounts\n
\n \n
def expandThirdPartiesForAccount(account, **kw) :\n def expandThirdPartiesForAccount(account, **kw) :\n
tmp_accounts = []\n tmp_accounts = []\n
# get all entities that are destination section related to this account.\n # get all entities that are destination section related to this account.\n
entities = [o.getObject() for o in \\\n entities = [o.getObject() for o in \\\n
context.Account_zDistinctSectionList( node_uid = account.getUid(), \n context.Account_zDistinctSectionList( node_uid = account.getUid(),\n
at_date = at_date,\n at_date = at_date,\n
simulation_state = simulation_state)]\n simulation_state = simulation_state)]\n
for entity in entities :\n for entity in entities :\n
this_tmp_account = {\n this_tmp_account = {\n
\'uid\' : account.getUid(),\n \'uid\' : account.getUid(),\n
...@@ -216,10 +221,12 @@ def expandThirdPartiesForAccount(account, **kw) :\n ...@@ -216,10 +221,12 @@ def expandThirdPartiesForAccount(account, **kw) :\n
if ( this_tmp_account[\'opening_balance\'] != 0 or\n if ( this_tmp_account[\'opening_balance\'] != 0 or\n
this_tmp_account[\'credit_movement\'] != 0 or \n this_tmp_account[\'credit_movement\'] != 0 or \n
this_tmp_account[\'debit_movement\'] != 0 ) :\n this_tmp_account[\'debit_movement\'] != 0 ) :\n
tmp_accounts.append( account.asContext( **formatValues(this_tmp_account) ) )\n tmp_accounts.append( account.asContext(\n
**formatValues(this_tmp_account) ) )\n
return tmp_accounts\n return tmp_accounts\n
\n \n
accounts = [ o.getObject() for o in context.portal_catalog(**kw) ]\n accounts = [ o.getObject() for o in \n
context.account_module.objectValues(portal_type=\'Account\') ]\n
accounts = filter(lambda account: account.getGapId() is not None, accounts )\n accounts = filter(lambda account: account.getGapId() is not None, accounts )\n
\n \n
def gap_sort_func(a, b) :\n def gap_sort_func(a, b) :\n
...@@ -257,7 +264,8 @@ for account in accounts_to_expand_by_bank_accounts :\n ...@@ -257,7 +264,8 @@ for account in accounts_to_expand_by_bank_accounts :\n
report_items = []\n report_items = []\n
results = []\n results = []\n
for account in accounts :\n for account in accounts :\n
if expand_accounts and account.getId() in accounts_to_expand_by_third_parties_dict :\n if expand_accounts and account.getId() \\\n
in accounts_to_expand_by_third_parties_dict :\n
# get all organisations with this account\n # get all organisations with this account\n
# and create a "virtual-Account" for each organisation\n # and create a "virtual-Account" for each organisation\n
virtual_accounts = expandThirdPartiesForAccount(account, **kw)\n virtual_accounts = expandThirdPartiesForAccount(account, **kw)\n
...@@ -279,7 +287,8 @@ for account in accounts :\n ...@@ -279,7 +287,8 @@ for account in accounts :\n
\n \n
report_items.append( account.asContext( **formatValues(item) ) )\n report_items.append( account.asContext( **formatValues(item) ) )\n
\n \n
elif expand_accounts and account.getId() in accounts_to_expand_by_bank_accounts_dict :\n elif expand_accounts and account.getId()\\\n
in accounts_to_expand_by_bank_accounts_dict :\n
virtual_accounts = expandBankAccountsForAccount(account, **kw)\n virtual_accounts = expandBankAccountsForAccount(account, **kw)\n
report_items += virtual_accounts\n report_items += virtual_accounts\n
if display_summary_account_line or not len(virtual_accounts) :\n if display_summary_account_line or not len(virtual_accounts) :\n
...@@ -297,7 +306,7 @@ for account in accounts :\n ...@@ -297,7 +306,7 @@ for account in accounts :\n
item[\'debit_movement\'] - \\\n item[\'debit_movement\'] - \\\n
item[\'credit_movement\']\n item[\'credit_movement\']\n
\n \n
report_items.append(account.asContext(**formatValues(item))) \n report_items.append(account.asContext(**formatValues(item)))\n
else :\n else :\n
item = { \'id\' : account.getGapId(),\n item = { \'id\' : account.getGapId(),\n
\'title\': account.getTitle(), }\n \'title\': account.getTitle(), }\n
...@@ -324,7 +333,7 @@ return report_items\n ...@@ -324,7 +333,7 @@ return report_items\n
</item> </item>
<item> <item>
<key> <string>_filepath</string> </key> <key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_skins/erp5_accounting/AccountModule_getAccountListForTrialBalance</string> </value> <value> <string>Script (Python):/erp5/portal_skins/erp5_accounting/AccountModule_getAccountListForTrialBalance</string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
...@@ -363,27 +372,27 @@ return report_items\n ...@@ -363,27 +372,27 @@ return report_items\n
<string>from_date</string> <string>from_date</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>simulation_state</string> <string>simulation_state</string>
<string>section_category</string>
<string>at_date</string> <string>at_date</string>
<string>_write_</string> <string>extra_kw</string>
<string>section_category</string>
<string>context</string> <string>context</string>
<string>getInventory</string> <string>section_object</string>
<string>getInventoryList</string> <string>organisation_list</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>x</string>
<string>section_uid_list</string>
<string>_write_</string>
<string>expand_accounts</string> <string>expand_accounts</string>
<string>gap_root</string> <string>gap_root</string>
<string>extra_kw</string> <string>getInventory</string>
<string>None</string> <string>getInventoryList</string>
<string>extra_from_date</string>
<string>display_summary_account_line</string> <string>display_summary_account_line</string>
<string>formatValues</string> <string>formatValues</string>
<string>organisations</string>
<string>getDefaultColumnValues</string> <string>getDefaultColumnValues</string>
<string>expandBankAccountsForAccount</string> <string>expandBankAccountsForAccount</string>
<string>expandThirdPartiesForAccount</string> <string>expandThirdPartiesForAccount</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>_apply_</string>
<string>o</string> <string>o</string>
<string>accounts</string> <string>accounts</string>
<string>filter</string> <string>filter</string>
...@@ -395,6 +404,7 @@ return report_items\n ...@@ -395,6 +404,7 @@ return report_items\n
<string>accounts_to_expand_by_bank_accounts_dict</string> <string>accounts_to_expand_by_bank_accounts_dict</string>
<string>report_items</string> <string>report_items</string>
<string>results</string> <string>results</string>
<string>_apply_</string>
<string>virtual_accounts</string> <string>virtual_accounts</string>
<string>len</string> <string>len</string>
<string>item</string> <string>item</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