@@ -185,32 +185,6 @@ def month_check(self, invoice_date_due, all_date_due):
185185 return False
186186
187187 def _post (self , soft = True ):
188- inv_riba_no_bank = self .filtered (
189- lambda x : x .is_riba_payment
190- and x .move_type == "out_invoice"
191- and not x .riba_partner_bank_id
192- )
193- if inv_riba_no_bank :
194- inv_details = (
195- self .env ._ (
196- 'Invoice %(name)s for customer "%(customer_name)s", '
197- "total %(amount)s" ,
198- name = inv .display_name ,
199- customer_name = inv .partner_id .display_name ,
200- amount = inv .amount_total ,
201- )
202- for inv in inv_riba_no_bank
203- )
204- raise UserError (
205- self .env ._ (
206- "Cannot post invoices with C/O payments without bank. "
207- "Please check the following invoices:\n \n - "
208- + "\n - " .join (inv_details )
209- )
210- )
211- return super ()._post (soft = soft )
212-
213- def action_post (self ):
214188 for invoice in self :
215189 # ---- Add a line with collection fees for each due date only for first due
216190 # ---- date of the month
@@ -284,8 +258,30 @@ def action_post(self):
284258 invoice ._sync_dynamic_lines (
285259 container = {"records" : invoice , "self" : invoice }
286260 )
287- res = super ().action_post ()
288-
261+ inv_riba_no_bank = self .filtered (
262+ lambda x : x .is_riba_payment
263+ and x .move_type == "out_invoice"
264+ and not x .riba_partner_bank_id
265+ )
266+ if inv_riba_no_bank :
267+ inv_details = (
268+ self .env ._ (
269+ 'Invoice %(name)s for customer "%(customer_name)s", '
270+ "total %(amount)s" ,
271+ name = inv .display_name ,
272+ customer_name = inv .partner_id .display_name ,
273+ amount = inv .amount_total ,
274+ )
275+ for inv in inv_riba_no_bank
276+ )
277+ raise UserError (
278+ self .env ._ (
279+ "Cannot post invoices with C/O payments without bank. "
280+ "Please check the following invoices:\n \n - "
281+ + "\n - " .join (inv_details )
282+ )
283+ )
284+ res = super ()._post (soft = soft )
289285 # Automatic reconciliation for RiBa credit moves
290286 # When a credit move is posted and there are related RiBa slips,
291287 # we need to reconcile the acceptance and credit move lines
0 commit comments