diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getDestinationPaymentItemList.py b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getDestinationPaymentItemList.py index 5bbabefaf1a0dcb0e54dbc89aa150bc3b2f6d878..1d12ebcf33686b85772e241f1366c4a7f48d6e77 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getDestinationPaymentItemList.py +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getDestinationPaymentItemList.py @@ -1,3 +1,6 @@ -return context.AccountModule_getBankAccountItemList( - organisation=context.getDestinationSection(), +section = context.getDestinationSection() +if section: + return context.AccountModule_getBankAccountItemList( + organisation=section, base_category='destination_payment') +return [('', '')] diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getSourcePaymentItemList.py b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getSourcePaymentItemList.py index 6482d40160b161b06b64ccf77aebd6a84fab7deb..3667a2a08b49d968a0b9dbc41849433eb2ae8f25 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getSourcePaymentItemList.py +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getSourcePaymentItemList.py @@ -1,3 +1,6 @@ -return context.AccountModule_getBankAccountItemList( - organisation=context.getSourceSection(), +section = context.getSourceSection() +if section: + return context.AccountModule_getBankAccountItemList( + organisation=section, base_category='source_payment') +return [('', '')] diff --git a/bt5/erp5_accounting/TestTemplateItem/portal_components/test.erp5.testAccounting.py b/bt5/erp5_accounting/TestTemplateItem/portal_components/test.erp5.testAccounting.py index 6323abfee1f793e9f3d8abe7a129912865e58e75..06ded9efec49690192e4a59929f088a7454b4ed8 100644 --- a/bt5/erp5_accounting/TestTemplateItem/portal_components/test.erp5.testAccounting.py +++ b/bt5/erp5_accounting/TestTemplateItem/portal_components/test.erp5.testAccounting.py @@ -4644,6 +4644,28 @@ class TestTransactions(AccountingTestCase): ('BA-1', bank_account.getRelativeUrl()), at.AccountingTransaction_getDestinationPaymentItemList()) + def test_AccountingTransaction_getSourcePaymentItemList_no_section(self): + bank_account = self.section.newContent( + portal_type='Bank Account', + reference='BA-1' + ) + bank_account.validate() + self.tic() + + at = self._makeOne( + portal_type='Payment Transaction', + destination_section_value=self.organisation_module.client_1, + lines=(dict(source_value=self.account_module.goods_purchase, + source_debit=500), + dict(source_value=self.account_module.receivable, + source_credit=500))) + at.setSourceSectionValue(None) + at.setDestinationSectionValue(None) + self.assertEqual( + at.AccountingTransaction_getSourcePaymentItemList(), [('', '')]) + self.assertEqual( + at.AccountingTransaction_getDestinationPaymentItemList(), [('', '')]) + def test_AccountingTransaction_getSourcePaymentItemList_parent_section(self): # AccountingTransaction_getSourcePaymentItemList and AccountingTransaction_getDestinationPaymentItemList # allows to select bank accounts from parent groups of source section