Commit 641d9313 authored by Jérome Perrin's avatar Jérome Perrin

Allow to choose the Bank Account when creating the related payment. Clean up

creation script.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10559 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4976984c
......@@ -102,7 +102,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python: object.getCausalityRelatedValueList(portal_type=\'Payment Transaction\')</string> </value>
<value> <string>python: not object.getCausalityRelatedValueList(portal_type=\'Payment Transaction\')</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -102,7 +102,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python: object.getCausalityRelatedValueList(portal_type=\'Payment Transaction\')</string> </value>
<value> <string>python: not object.getCausalityRelatedValueList(portal_type=\'Payment Transaction\')</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -76,7 +76,7 @@ if organisation is None : \n
\n
organisation = portal.restrictedTraverse(organisation)\n
item_list = [(\'\', \'\')]\n
for bank in organisation.objectValues(portal_type = [\'Bank Account\', \'Cash Register\']):\n
for bank in organisation.objectValues(portal_type=portal.getPortalPaymentNodeTypeList()):\n
item_list.append((bank.getTitle(), bank.getRelativeUrl()))\n
\n
return item_list\n
......
......@@ -68,61 +68,46 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
"""Create a related payment transaction, using the account `node`, and setting\n
the payment mode `payment_mode`.\n
<value> <string>"""Create a related payment transaction, using the account `node`, the payment\n
`payment`, and setting the payment mode `payment_mode`.\n
"""\n
\n
from Products.ERP5Type.Message import Message\n
N_ = lambda msg, **kw: Message(\'erp5_ui\', msg, **kw)\n
\n
portal = context.getPortalObject()\n
accounting_module = portal.accounting_module\n
bank_account = None\n
payment_dict = {}\n
is_source = context.getPortalTypeName() in ( \'Sale Invoice Transaction\',\n
\'Accounting Transaction\' )\n
if is_source:\n
organisation = context.getDestinationSectionValue()\n
if len(organisation.objectValues(portal_type = [\'Bank Account\'])) > 0 :\n
bank_account = organisation.objectValues(portal_type = [\'Bank Account\'])[0].getRelativeUrl()\n
payment_dict[\'destination_payment_value\'] = bank_account\n
payment_dict[\'source_payment_value\'] = context.getSourcePayment()\n
else:\n
organisation = context.getSourceSectionValue()\n
if len(organisation.objectValues(portal_type = [\'Bank Account\'])) > 0 :\n
bank_account = organisation.objectValues(portal_type = [\'Bank Account\'])[0].getRelativeUrl()\n
payment_dict[\'destination_payment_value\'] = bank_account\n
payment_dict[\'source_payment_value\'] = context.getSourcePayment()\n
is_source = context.AccountingTransaction_isSourceView()\n
line_portal_type = \'Accounting Transaction Line\'\n
\n
portal_type_mapping = {\n
\'Purchase Invoice Transaction\': \'Purchase Payment Transaction\',\n
\'Sale Invoice Transaction\': \'Payment Transaction\',\n
}\n
\n
related_payement = accounting_module.newContent(\n
portal_type=portal_type_mapping.get(\n
context.getPortalTypeName(), "Payment Transaction"),\n
title = "R\xc3\xa9glement de %s" % (context.getReference() or context.getTitle()),\n
related_payement = portal.accounting_module.newContent(\n
portal_type="Payment Transaction",\n
title = str(N_("Payment of ${invoice_title}",\n
mapping=dict(invoice_title=unicode((context.getReference() or\n
context.getTitle() or \'\'),\n
\'utf8\', \'repr\')))),\n
source_section=context.getSourceSection(),\n
destination_section=context.getDestinationSection(),\n
stop_date=context.getStopDate(),\n
start_date=context.getStartDate(),\n
resource=context.getResource(),\n
causality_value=context,\n
created_by_builder=1,\n
created_by_builder=1, # XXX this prevent init script from creating lines.\n
payment_mode=payment_mode,\n
**payment_dict\n
)\n
if is_source:\n
related_payement.edit(destination_payment=context.getDestinationPayment(),\n
source_payment=payment)\n
else:\n
related_payement.edit(destination_payment=payment,\n
source_payment=context.getSourcePayment())\n
\n
\n
bank = related_payement.newContent(\n
portal_type=\'Accounting Transaction Line\',\n
id=\'bank\',\n
portal_type=line_portal_type,\n
id=\'bank\',\n
)\n
\n
bank_quantity = 0\n
\n
for line in context.objectValues(\n
portal_type=portal.getPortalAccountingMovementTypeList()):\n
if is_source:\n
......@@ -133,9 +118,10 @@ for line in context.objectValues(\n
if account is not None and account.getAccountTypeId() in (\n
\'payable\', \'receivable\'):\n
related_payement.newContent(\n
source = line.getSource(),\n
destination = line.getDestination(),\n
quantity = - line.getQuantity())\n
portal_type=line_portal_type,\n
source=line.getSource(),\n
destination=line.getDestination(),\n
quantity= - line.getQuantity())\n
bank_quantity += line.getQuantity()\n
\n
if is_source:\n
......@@ -145,15 +131,14 @@ else:\n
bank.edit( destination=node,\n
quantity=bank_quantity )\n
\n
# maybe stop is a bit too much ?\n
related_payement.stop()\n
\n
if not batch_mode:\n
return context.REQUEST.RESPONSE.redirect(\n
"%s/view?portal_status_message=%s" % (\n
related_payement.absolute_url(), N_(\'Related Payment Created\')))\n
]]></string> </value>
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
......@@ -175,7 +160,7 @@ if not batch_mode:\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>node, payment_mode, batch_mode=0</string> </value>
<value> <string>node, payment_mode, payment=\'\', batch_mode=0</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -195,7 +180,7 @@ if not batch_mode:\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>3</int> </value>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
......@@ -203,6 +188,7 @@ if not batch_mode:\n
<tuple>
<string>node</string>
<string>payment_mode</string>
<string>payment</string>
<string>batch_mode</string>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
......@@ -210,23 +196,19 @@ if not batch_mode:\n
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
<string>accounting_module</string>
<string>None</string>
<string>bank_account</string>
<string>payment_dict</string>
<string>is_source</string>
<string>organisation</string>
<string>len</string>
<string>_getitem_</string>
<string>_write_</string>
<string>portal_type_mapping</string>
<string>_apply_</string>
<string>line_portal_type</string>
<string>str</string>
<string>dict</string>
<string>unicode</string>
<string>related_payement</string>
<string>bank</string>
<string>bank_quantity</string>
<string>_getiter_</string>
<string>line</string>
<string>account</string>
<string>None</string>
</tuple>
</value>
</item>
......@@ -239,6 +221,7 @@ if not batch_mode:\n
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<string></string>
<int>0</int>
</tuple>
</value>
......
......@@ -97,6 +97,7 @@
<list>
<string>your_node</string>
<string>your_payment_mode</string>
<string>your_payment</string>
</list>
</value>
</item>
......
65
\ No newline at end of file
66
\ 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