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 @@ ...@@ -102,7 +102,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <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> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -102,7 +102,7 @@ ...@@ -102,7 +102,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <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> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -76,7 +76,7 @@ if organisation is None : \n ...@@ -76,7 +76,7 @@ if organisation is None : \n
\n \n
organisation = portal.restrictedTraverse(organisation)\n organisation = portal.restrictedTraverse(organisation)\n
item_list = [(\'\', \'\')]\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 item_list.append((bank.getTitle(), bank.getRelativeUrl()))\n
\n \n
return item_list\n return item_list\n
......
...@@ -68,61 +68,46 @@ ...@@ -68,61 +68,46 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string>"""Create a related payment transaction, using the account `node`, the payment\n
`payment`, and setting the payment mode `payment_mode`.\n
"""Create a related payment transaction, using the account `node`, and setting\n
the payment mode `payment_mode`.\n
"""\n """\n
\n
from Products.ERP5Type.Message import Message\n from Products.ERP5Type.Message import Message\n
N_ = lambda msg, **kw: Message(\'erp5_ui\', msg, **kw)\n N_ = lambda msg, **kw: Message(\'erp5_ui\', msg, **kw)\n
\n \n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
accounting_module = portal.accounting_module\n
bank_account = None\n
payment_dict = {}\n payment_dict = {}\n
is_source = context.getPortalTypeName() in ( \'Sale Invoice Transaction\',\n is_source = context.AccountingTransaction_isSourceView()\n
\'Accounting Transaction\' )\n line_portal_type = \'Accounting Transaction Line\'\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
\n \n
portal_type_mapping = {\n related_payement = portal.accounting_module.newContent(\n
\'Purchase Invoice Transaction\': \'Purchase Payment Transaction\',\n portal_type="Payment Transaction",\n
\'Sale Invoice Transaction\': \'Payment Transaction\',\n title = str(N_("Payment of ${invoice_title}",\n
}\n mapping=dict(invoice_title=unicode((context.getReference() or\n
\n context.getTitle() or \'\'),\n
related_payement = accounting_module.newContent(\n \'utf8\', \'repr\')))),\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
source_section=context.getSourceSection(),\n source_section=context.getSourceSection(),\n
destination_section=context.getDestinationSection(),\n destination_section=context.getDestinationSection(),\n
stop_date=context.getStopDate(),\n stop_date=context.getStopDate(),\n
start_date=context.getStartDate(),\n start_date=context.getStartDate(),\n
resource=context.getResource(),\n resource=context.getResource(),\n
causality_value=context,\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_mode=payment_mode,\n
**payment_dict\n
)\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 \n
bank = related_payement.newContent(\n bank = related_payement.newContent(\n
portal_type=\'Accounting Transaction Line\',\n portal_type=line_portal_type,\n
id=\'bank\',\n id=\'bank\',\n
)\n )\n
\n \n
bank_quantity = 0\n bank_quantity = 0\n
\n
for line in context.objectValues(\n for line in context.objectValues(\n
portal_type=portal.getPortalAccountingMovementTypeList()):\n portal_type=portal.getPortalAccountingMovementTypeList()):\n
if is_source:\n if is_source:\n
...@@ -133,9 +118,10 @@ for line in context.objectValues(\n ...@@ -133,9 +118,10 @@ for line in context.objectValues(\n
if account is not None and account.getAccountTypeId() in (\n if account is not None and account.getAccountTypeId() in (\n
\'payable\', \'receivable\'):\n \'payable\', \'receivable\'):\n
related_payement.newContent(\n related_payement.newContent(\n
source = line.getSource(),\n portal_type=line_portal_type,\n
destination = line.getDestination(),\n source=line.getSource(),\n
quantity = - line.getQuantity())\n destination=line.getDestination(),\n
quantity= - line.getQuantity())\n
bank_quantity += line.getQuantity()\n bank_quantity += line.getQuantity()\n
\n \n
if is_source:\n if is_source:\n
...@@ -145,15 +131,14 @@ else:\n ...@@ -145,15 +131,14 @@ else:\n
bank.edit( destination=node,\n bank.edit( destination=node,\n
quantity=bank_quantity )\n quantity=bank_quantity )\n
\n \n
# maybe stop is a bit too much ?\n
related_payement.stop()\n related_payement.stop()\n
\n \n
if not batch_mode:\n if not batch_mode:\n
return context.REQUEST.RESPONSE.redirect(\n return context.REQUEST.RESPONSE.redirect(\n
"%s/view?portal_status_message=%s" % (\n "%s/view?portal_status_message=%s" % (\n
related_payement.absolute_url(), N_(\'Related Payment Created\')))\n related_payement.absolute_url(), N_(\'Related Payment Created\')))\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -175,7 +160,7 @@ if not batch_mode:\n ...@@ -175,7 +160,7 @@ if not batch_mode:\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -195,7 +180,7 @@ if not batch_mode:\n ...@@ -195,7 +180,7 @@ if not batch_mode:\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>3</int> </value> <value> <int>4</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
...@@ -203,6 +188,7 @@ if not batch_mode:\n ...@@ -203,6 +188,7 @@ if not batch_mode:\n
<tuple> <tuple>
<string>node</string> <string>node</string>
<string>payment_mode</string> <string>payment_mode</string>
<string>payment</string>
<string>batch_mode</string> <string>batch_mode</string>
<string>Products.ERP5Type.Message</string> <string>Products.ERP5Type.Message</string>
<string>Message</string> <string>Message</string>
...@@ -210,23 +196,19 @@ if not batch_mode:\n ...@@ -210,23 +196,19 @@ if not batch_mode:\n
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>portal</string> <string>portal</string>
<string>accounting_module</string>
<string>None</string>
<string>bank_account</string>
<string>payment_dict</string> <string>payment_dict</string>
<string>is_source</string> <string>is_source</string>
<string>organisation</string> <string>line_portal_type</string>
<string>len</string> <string>str</string>
<string>_getitem_</string> <string>dict</string>
<string>_write_</string> <string>unicode</string>
<string>portal_type_mapping</string>
<string>_apply_</string>
<string>related_payement</string> <string>related_payement</string>
<string>bank</string> <string>bank</string>
<string>bank_quantity</string> <string>bank_quantity</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>line</string> <string>line</string>
<string>account</string> <string>account</string>
<string>None</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -239,6 +221,7 @@ if not batch_mode:\n ...@@ -239,6 +221,7 @@ if not batch_mode:\n
<key> <string>func_defaults</string> </key> <key> <string>func_defaults</string> </key>
<value> <value>
<tuple> <tuple>
<string></string>
<int>0</int> <int>0</int>
</tuple> </tuple>
</value> </value>
......
...@@ -97,6 +97,7 @@ ...@@ -97,6 +97,7 @@
<list> <list>
<string>your_node</string> <string>your_node</string>
<string>your_payment_mode</string> <string>your_payment_mode</string>
<string>your_payment</string>
</list> </list>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.StandardFields</string>
<string>ListField</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>your_payment</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
<item>
<key> <string>required_not_found</string> </key>
<value> <string>Input is required but no input given.</string> </value>
</item>
<item>
<key> <string>unknown_selection</string> </key>
<value> <string>You selected an item that was not in the list.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>first_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>first_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>first_item</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Bank Account</string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.TALESField</string>
<string>TALESMethod</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>here/AccountModule_getBankAccountItemList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
65 66
\ 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