Commit 04e1dc0d authored by Jérome Perrin's avatar Jérome Perrin

accounting: enable "create related payment" action on Internal Invoice

No reason to limit this to sales or purchase invoices. The difference is
that the internal version creates an internal invoice.
parent f5acdc4c
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_action</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>create_related_payment</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>15.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Create Related Payment</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Invoice_viewCreateRelatedPaymentTransactionDialog</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -11,7 +11,12 @@ if date is None:
date = DateTime()
portal = context.getPortalObject()
is_source = context.AccountingTransaction_isSourceView()
transaction_portal_type = 'Payment Transaction'
line_portal_type = 'Accounting Transaction Line'
if context.getPortalType() == 'Internal Invoice Transaction':
transaction_portal_type = 'Internal Invoice Transaction'
line_portal_type = 'Internal Invoice Transaction Line'
# update selection params, because it'll be used in the selection dialog.
portal.portal_selections.setSelectionParamsFor(
......@@ -36,7 +41,7 @@ if sum(total_payable_price_details.values()) == 0:
return None
related_payment = portal.accounting_module.newContent(
portal_type="Payment Transaction",
portal_type=transaction_portal_type,
title=str(Base_translateString("Payment of ${invoice_title}",
mapping=dict(invoice_title=unicode((context.getReference() or
context.getTitle() or ''),
......
......@@ -66,6 +66,7 @@ Internal Invoice Transaction | add_internal_invoice_transaction_line
Internal Invoice Transaction | convert_destination_price
Internal Invoice Transaction | convert_source_price
Internal Invoice Transaction | create_new_file
Internal Invoice Transaction | create_related_payment
Internal Invoice Transaction | create_reversal
Internal Invoice Transaction | destination_asset
Internal Invoice Transaction | destination_view
......
......@@ -5782,6 +5782,47 @@ class TestInternalInvoiceTransaction(AccountingTestCase):
internal_invoice, 'stop_action')
self.assertEqual('stopped', internal_invoice.getSimulationState())
def test_internal_invoice_create_related_payment(self):
# 'Create Related Payment' is available on internal invoice transaction
internal_invoice = self.portal.accounting_module.newContent(
portal_type='Internal Invoice Transaction',
title='test invoice',
source_section_value=self.section,
destination_section_value=self.main_section,
start_date=DateTime(2015, 1, 1),
)
line_1, line_2 = internal_invoice.getMovementList()
line_1.edit(
source_value=self.portal.account_module.receivable,
source_debit=100)
line_2.edit(
source_value=self.portal.account_module.goods_sales,
source_credit=100)
self.commit()
self.portal.portal_workflow.doActionFor(
internal_invoice, 'start_action')
self.assertEqual('started', internal_invoice.getSimulationState())
payment_node = self.section.newContent(portal_type='Bank Account')
payment = internal_invoice.Invoice_createRelatedPaymentTransaction(
node=self.account_module.bank.getRelativeUrl(),
payment=payment_node.getRelativeUrl(),
payment_mode='check',
batch_mode=True)
# on internal invoice transaction, we create a payment transaction
self.assertEqual(
'Internal Invoice Transaction',
payment.getPortalType())
self.assertEqual(internal_invoice, payment.getCausalityValue())
self.assertItemsEqual(
[ (self.portal.account_module.bank, 100, 0),
(self.portal.account_module.receivable, 0, 100), ],
[ (line.getSourceValue(), line.getSourceDebit(), line.getSourceCredit())
for line in payment.getMovementList(
portal_type='Internal Invoice Transaction Line')])
class TestAccountingCodingStyle(CodingStyleTestCase, AccountingTestCase):
"""Runs CodingStyleTestCase checks on erp5_accounting
......
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