@@ -21,6 +21,10 @@ def setUpClass(cls, chart_template_ref=None):
2121 super ().setUpClass (chart_template_ref = chart_template_ref )
2222 cls .env = cls .env (context = dict (cls .env .context , ** DISABLED_MAIL_CONTEXT ))
2323 cls .company = cls .company_data ["company" ]
24+
25+ cls .env ["ir.config_parameter" ].sudo ().set_param (
26+ "account_payment_order.use_allow_out_payment" , True
27+ )
2428 cls .env .user .company_id = cls .company .id
2529 cls .partner = cls .env ["res.partner" ].create (
2630 {
@@ -29,9 +33,7 @@ def setUpClass(cls, chart_template_ref=None):
2933 (
3034 0 ,
3135 0 ,
32- {
33- "acc_number" : "TEST-NUMBER" ,
34- },
36+ {"acc_number" : "TEST-NUMBER" , "allow_out_payment" : True },
3537 )
3638 ],
3739 }
@@ -234,7 +236,7 @@ def order_creation(self, date_prefered):
234236 order .payment_line_ids .partner_bank_id .action_unarchive ()
235237 self .assertFalse (order .partner_banks_archive_msg )
236238 order .draft2open ()
237- self .assertEqual (order .payment_ids [0 ].partner_bank_id , self .partner .bank_ids )
239+ self .assertEqual (order .payment_ids [0 ].partner_bank_id , self .partner .bank_ids [ 0 ] )
238240 order .open2generated ()
239241 order .generated2uploaded ()
240242 self .assertEqual (order .move_ids [0 ].date , order .payment_ids [0 ].date )
@@ -247,6 +249,7 @@ def _line_creation(self, outbound_order):
247249 "currency_id" : outbound_order .payment_mode_id .company_id .currency_id .id ,
248250 "amount_currency" : 200.38 ,
249251 "move_line_id" : self .invoice .invoice_line_ids [0 ].id ,
252+ "partner_bank_id" : self .partner_bank .id ,
250253 }
251254 return self .env ["account.payment.line" ].create (vals )
252255
@@ -580,6 +583,7 @@ def test_action_open_business_document(self):
580583 self .assertEqual (invoice_action ["res_id" ], self .invoice .id )
581584 manual_line_action = order .payment_line_ids [1 ].action_open_business_doc ()
582585 self .assertFalse (manual_line_action )
586+
583587 def test_check_allow_out_payment (self ):
584588 """Check that, in case option "Send Money" is not enabled on
585589 the bank, out payments are not allowed.
@@ -589,9 +593,37 @@ def test_check_allow_out_payment(self):
589593
590594 # Do not allow out payments
591595 self .partner_bank .allow_out_payment = False
596+ for line in self .invoice .line_ids :
597+ for bank in line .partner_id .bank_ids :
598+ bank .allow_out_payment = False
592599
600+ self .env ["account.invoice.payment.line.multi" ].with_context (
601+ active_model = "account.move" , active_ids = self .invoice .ids
602+ ).create ({}).run ()
603+ payment_order = self .env ["account.payment.order" ].search (self .domain )
604+ payment_order .write ({"journal_id" : self .bank_journal .id })
593605 # Add to payment order using the wizard: error raised
594606 with self .assertRaises (UserError ):
595- self .env ["account.invoice.payment.line.multi" ].with_context (
596- active_model = "account.move" , active_ids = self .invoice .ids
597- ).create ({}).run ()
607+ payment_order .draft2open ()
608+
609+ def test_check_allow_out_payment_from_payment_order (self ):
610+ """Check that, in case option "Send Money" is not enabled on
611+ the bank, out payments are not allowed.
612+ """
613+ self .partner_bank .allow_out_payment = False
614+ outbound_order = self .env ["account.payment.order" ].create (
615+ {
616+ "date_prefered" : "due" ,
617+ "payment_type" : "outbound" ,
618+ "payment_mode_id" : self .mode .id ,
619+ "journal_id" : self .bank_journal .id ,
620+ "description" : "order with manual line" ,
621+ }
622+ )
623+ payment_line_1 = self ._line_creation (outbound_order )
624+
625+ payment_line_1 .partner_bank_id = self .partner_bank .id
626+
627+ # Add to payment order using the wizard: error raised
628+ with self .assertRaises (UserError ):
629+ outbound_order .draft2open ()
0 commit comments