Commit 890111da authored by Jérome Perrin's avatar Jérome Perrin

AccountingTransaction_createReversalTransaction:

  use the same portal type to create reversal transaction

AccountingTransaction_viewSourceAsset/listbox:
  was using a bad selection name



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12555 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c87347a3
...@@ -75,30 +75,16 @@ accounting_module = context.getPortalObject().accounting_module\n ...@@ -75,30 +75,16 @@ accounting_module = context.getPortalObject().accounting_module\n
is_source = context.AccountingTransaction_isSourceView()\n is_source = context.AccountingTransaction_isSourceView()\n
\n \n
if is_source:\n if is_source:\n
section = context.getSourceSection()\n
mirror_section = context.getDestinationSection()\n
payment = context.getSourcePayment()\n
mirror_payment = context.getDestinationPayment()\n
date = context.getStartDate()\n
mirror_date = context.getStopDate()\n
specific_reference = context.getSourceReference()\n specific_reference = context.getSourceReference()\n
else:\n else:\n
section = context.getDestinationSection()\n
mirror_section = context.getSourceSection()\n
payment = context.getDestinationPayment()\n
mirror_payment = context.getSourcePayment()\n
date = context.getStopDate()\n
mirror_date = context.getStartDate()\n
specific_reference = context.getDestinationReference()\n specific_reference = context.getDestinationReference()\n
\n \n
reversal = accounting_module.newContent (\n reversal = accounting_module.newContent (\n
portal_type=\'Accounting Transaction\',\n portal_type=context.getPortalType(),\n
source_section=section,\n source_section=context.getSourceSection(),\n
destination_section=mirror_section,\n destination_section=context.getDestinationSection(),\n
source_payment=payment,\n source_payment=context.getSourcePayment(),\n
destination_payment=mirror_payment,\n destination_payment=context.getDestinationPayment(),\n
start_date=date,\n
stop_date=mirror_date,\n
title = N_("Reversal Transaction for ${title}",\n title = N_("Reversal Transaction for ${title}",\n
mapping={\'title\': unicode(context.getTitleOrId(), \'utf8\')}),\n mapping={\'title\': unicode(context.getTitleOrId(), \'utf8\')}),\n
description = N_(\n description = N_(\n
...@@ -111,35 +97,41 @@ reversal = accounting_module.newContent (\n ...@@ -111,35 +97,41 @@ reversal = accounting_module.newContent (\n
created_by_builder=1 # XXX to prevent init script to create lines\n created_by_builder=1 # XXX to prevent init script to create lines\n
)\n )\n
\n \n
# use AccountingTransaction_getInvoiceTransactionLineList to keep a consistent\n # copy dates\n
# ordering\n if context.getStartDate():\n
line_list = context.AccountingTransaction_getInvoiceTransactionLineList(\n reversal.setStartDate(context.getStartDate())\n
\n
if context.getStopDate() != context.getStartDate():\n
# stop date is currently acquire from start date.\n
# we try not to set a stop date on the reversal if it wasn\'t set on the\n
# original\n
reversal.setStopDate(context.getStopDate())\n
\n
if context.getProperty(\'payment_mode\'):\n
reversal.setProperty(\'payment_mode\', context.getProperty(\'payment_mode\'))\n
\n
line_list = context.getMovementList(\n
portal_type=context.getPortalAccountingMovementTypeList())\n portal_type=context.getPortalAccountingMovementTypeList())\n
line_list.reverse()\n # guess portal_type to create lines\n
if line_list:\n
line_portal_type = line_list[0].getPortalType()\n
\n
for line in line_list:\n for line in line_list:\n
new_line = reversal.newContent( portal_type=\'Accounting Transaction Line\', )\n new_line = reversal.newContent( portal_type=\'Accounting Transaction Line\', )\n
if is_source:\n new_line.edit(\n
new_line.edit(\n id=line.getId(),\n
source=line.getSource(portal_type=\'Account\'),\n source=line.getSource(portal_type=\'Account\'),\n
destination=line.getDestination(portal_type=\'Account\'),\n destination=line.getDestination(portal_type=\'Account\'),\n
destination_section=line.getDestinationSection(),\n quantity= - line.getQuantity(),\n
source_payment=line.getSourcePayment(),\n source_total_asset_price= - (line.getSourceTotalAssetPrice() or 0),\n
destination_payment=line.getDestinationPayment(),\n destination_total_asset_price=\n
quantity= -line.getQuantity(),\n - (line.getDestinationTotalAssetPrice() or 0))\n
source_total_asset_price=line.getSourceTotalAssetPrice(),\n \n
destination_total_asset_price=line.getDestinationTotalAssetPrice()\n # copy some values if they are defined explicitly on line\n
)\n for prop in [ \'source_section\', \'destination_section\',\n
else:\n \'source_payment\', \'destination_payment\', ]:\n
new_line.edit(\n if line.getProperty(prop) != context.getProperty(prop):\n
source=line.getDestination(portal_type=\'Account\'),\n new_line.setProperty(prop, line.getProperty(prop))\n
destination=line.getSource(portal_type=\'Account\'),\n
destination_section=line.getSourceSection(),\n
source_payment=line.getDestinationPayment(),\n
destination_payment=line.getSourcePayment(),\n
quantity=line.getQuantity(),\n
source_total_asset_price=line.getDestinationTotalAssetPrice(),\n
destination_total_asset_price=line.getSourceTotalAssetPrice()\n
)\n
\n \n
return context.REQUEST.RESPONSE.redirect("%s/view?portal_status_message=%s" %\n return context.REQUEST.RESPONSE.redirect("%s/view?portal_status_message=%s" %\n
(reversal.getPath(),\n (reversal.getPath(),\n
...@@ -192,19 +184,16 @@ return context.REQUEST.RESPONSE.redirect("%s/view?portal_status_message=%s" %\n ...@@ -192,19 +184,16 @@ return context.REQUEST.RESPONSE.redirect("%s/view?portal_status_message=%s" %\n
<string>N_</string> <string>N_</string>
<string>accounting_module</string> <string>accounting_module</string>
<string>is_source</string> <string>is_source</string>
<string>section</string>
<string>mirror_section</string>
<string>payment</string>
<string>mirror_payment</string>
<string>date</string>
<string>mirror_date</string>
<string>specific_reference</string> <string>specific_reference</string>
<string>unicode</string> <string>unicode</string>
<string>reversal</string> <string>reversal</string>
<string>line_list</string> <string>line_list</string>
<string>_getitem_</string>
<string>line_portal_type</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>line</string> <string>line</string>
<string>new_line</string> <string>new_line</string>
<string>prop</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -495,7 +495,7 @@ ...@@ -495,7 +495,7 @@
</item> </item>
<item> <item>
<key> <string>selection_name</string> </key> <key> <string>selection_name</string> </key>
<value> <string>accounting_transaction_line_selection</string> </value> <value> <string>accounting_transaction_source_asset_selection</string> </value>
</item> </item>
<item> <item>
<key> <string>sort</string> </key> <key> <string>sort</string> </key>
......
174 177
\ No newline at end of file \ 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