@@ -28,9 +28,7 @@ def setUpClass(cls, chart_template_ref=None):
2828 (
2929 0 ,
3030 0 ,
31- {
32- "acc_number" : "TEST-NUMBER" ,
33- },
31+ {"acc_number" : "TEST-NUMBER" , "allow_out_payment" : True },
3432 )
3533 ],
3634 }
@@ -239,6 +237,7 @@ def _line_creation(self, outbound_order):
239237 "currency_id" : outbound_order .payment_mode_id .company_id .currency_id .id ,
240238 "amount_currency" : 200.38 ,
241239 "move_line_id" : self .invoice .invoice_line_ids [0 ].id ,
240+ "partner_bank_id" : self .partner_bank .id ,
242241 }
243242 return self .env ["account.payment.line" ].create (vals )
244243
@@ -533,9 +532,37 @@ def test_check_allow_out_payment(self):
533532
534533 # Do not allow out payments
535534 self .partner_bank .allow_out_payment = False
535+ for line in self .invoice .line_ids :
536+ for bank in line .partner_id .bank_ids :
537+ bank .allow_out_payment = False
536538
539+ self .env ["account.invoice.payment.line.multi" ].with_context (
540+ active_model = "account.move" , active_ids = self .invoice .ids
541+ ).create ({}).run ()
542+ payment_order = self .env ["account.payment.order" ].search (self .domain )
543+ payment_order .write ({"journal_id" : self .bank_journal .id })
537544 # Add to payment order using the wizard: error raised
538545 with self .assertRaises (UserError ):
539- self .env ["account.invoice.payment.line.multi" ].with_context (
540- active_model = "account.move" , active_ids = self .invoice .ids
541- ).create ({}).run ()
546+ payment_order .draft2open ()
547+
548+ def test_check_allow_out_payment_from_payment_order (self ):
549+ """Check that, in case option "Send Money" is not enabled on
550+ the bank, out payments are not allowed.
551+ """
552+ self .partner_bank .allow_out_payment = False
553+ outbound_order = self .env ["account.payment.order" ].create (
554+ {
555+ "date_prefered" : "due" ,
556+ "payment_type" : "outbound" ,
557+ "payment_mode_id" : self .mode .id ,
558+ "journal_id" : self .bank_journal .id ,
559+ "description" : "order with manual line" ,
560+ }
561+ )
562+ payment_line_1 = self ._line_creation (outbound_order )
563+
564+ payment_line_1 .partner_bank_id = self .partner_bank .id
565+
566+ # Add to payment order using the wizard: error raised
567+ with self .assertRaises (UserError ):
568+ outbound_order .draft2open ()
0 commit comments