@@ -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
@@ -239,12 +213,13 @@ def action_post(self):
239213 # ---- Get date
240214 previous_date_due = move_line .mapped ("date_maturity" )
241215 pterm = self .env ["account.payment.term" ].browse (
242- self .invoice_payment_term_id .id
216+ invoice .invoice_payment_term_id .id
243217 )
218+
244219 pterm_list = pterm ._compute_terms (
245- date_ref = self .invoice_date ,
246- currency = self .currency_id ,
247- company = self .company_id ,
220+ date_ref = invoice .invoice_date ,
221+ currency = invoice .currency_id ,
222+ company = invoice .company_id ,
248223 tax_amount = 1 ,
249224 tax_amount_currency = 1 ,
250225 untaxed_amount = 0 ,
@@ -284,8 +259,30 @@ def action_post(self):
284259 invoice ._sync_dynamic_lines (
285260 container = {"records" : invoice , "self" : invoice }
286261 )
287- res = super ().action_post ()
288-
262+ inv_riba_no_bank = self .filtered (
263+ lambda x : x .is_riba_payment
264+ and x .move_type == "out_invoice"
265+ and not x .riba_partner_bank_id
266+ )
267+ if inv_riba_no_bank :
268+ inv_details = (
269+ self .env ._ (
270+ 'Invoice %(name)s for customer "%(customer_name)s", '
271+ "total %(amount)s" ,
272+ name = inv .display_name ,
273+ customer_name = inv .partner_id .display_name ,
274+ amount = inv .amount_total ,
275+ )
276+ for inv in inv_riba_no_bank
277+ )
278+ raise UserError (
279+ self .env ._ (
280+ "Cannot post invoices with C/O payments without bank. "
281+ "Please check the following invoices:\n \n - "
282+ + "\n - " .join (inv_details )
283+ )
284+ )
285+ res = super ()._post (soft = soft )
289286 # Automatic reconciliation for RiBa credit moves
290287 # When a credit move is posted and there are related RiBa slips,
291288 # we need to reconcile the acceptance and credit move lines
0 commit comments