From 7b07dcf568f4ab516fbc0f9109471227c33c94f4 Mon Sep 17 00:00:00 2001 From: Andrea Stirpe Date: Tue, 21 Nov 2023 12:20:15 +0100 Subject: [PATCH] [IMP] account_payment_mode: add test --- .../tests/test_payment_order_outbound.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/account_payment_order/tests/test_payment_order_outbound.py b/account_payment_order/tests/test_payment_order_outbound.py index 681616243ffb..ce6615b914d1 100644 --- a/account_payment_order/tests/test_payment_order_outbound.py +++ b/account_payment_order/tests/test_payment_order_outbound.py @@ -61,6 +61,13 @@ def setUpClass(cls, chart_template_ref=None): ("company_id", "=", cls.env.user.company_id.id), ] cls.env["account.payment.order"].search(cls.domain).unlink() + cls.partner_bank = cls.env["res.partner.bank"].create( + { + "acc_number": "1234", + "partner_id": cls.partner.id, + "allow_out_payment": True, + } + ) def _create_supplier_invoice(self, ref): invoice = self.env["account.move"].create( @@ -451,3 +458,19 @@ def test_supplier_manual_refund(self): self.assertEqual(len(payment_order.payment_line_ids), 1) self.assertEqual("F1242 R1234", payment_order.payment_line_ids.communication) + + def test_check_allow_out_payment(self): + """Check that, in case option "Send Money" is not enabled on + the bank, out payments are not allowed. + """ + # Open invoice + self.invoice.action_post() + + # Do not allow out payments + self.partner_bank.allow_out_payment = False + + # Add to payment order using the wizard: error raised + with self.assertRaises(UserError): + self.env["account.invoice.payment.line.multi"].with_context( + active_model="account.move", active_ids=self.invoice.ids + ).create({}).run()