I’m trying to update the tenancy.rent.schedule records when an invoice is fully or partially paid in Odoo 16. I have overridden the action_post method in account.payment to check if the invitation is paid and update the paid and move_check fields in the rent schedule. However, howver the issue is that rent.invc_id.payment_state does not fetch the latest state even after making the payment. It still shows not_paid even when the invitation is marked as paid. Here is my code: class AccountPayment(models.Model): _inherit = 'account.payment' def action_post(self) """ Override to update rent schedules when an invoice is fully or partially paid. """ res = super().action_post() print("Context in action_post:", self.env.context) if self.env.context.get('asset') or self.env.context.get('openinvoice'): print(" 'openinvoice' is in the context!") tenancy = self.env['property.tenancy'] active_id = self.env.context.get('active_id') print('active id :', active_id) if not active_id: return res # No active tenancy, skip execution tenancy_record = tenancy.browse(active_id) print('tenancy_record :', tenancy_record) if tenancy_record: rent_schedules = self.env['tenancy.rent.schedule'].search( [('invc_id', '=', tenancy_record.id)] ) print('rent schedule : ', rent_schedules) for rent in rent_schedules: print('Invoice: ', rent.invc_id) print('rent.invc_id.payment_state :', rent.invc_id.payment_state) if rent.invc_id.payment_state == 'paid': rent.paid = True rent.move_check = True # Update hanging amount (pen_amt) rent.pen_amt = rent.invc_id.amount_residual return res based on the payment_state rent.paid = True rent.move_check = True these should be True based on the " if rent.invc_id.payment_state == 'paid': Continue reading...