# -*- coding: utf-8 -*-# Copyright (C) 2016-Today: La Louve (<http://www.lalouve.fr/>)# @author: La Louve# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.htmlfromopenerpimportmodels,fields,apiclassAccountMoveReversal(models.TransientModel):_inherit='account.move.reversal'@api.multidefreverse_moves(self):payment_id=self._context.get('payment_id',False)account_move_ids=self._context.get('active_ids',False)# Get move line to unreconcile automaticlyaccount_moves=self.env['account.move'].browse(account_move_ids)lines_reconciled=account_moves.mapped('line_ids').filtered(lambdal:l.reconciled)iflines_reconciled:lines_reconciled.remove_move_reconcile()res=super(AccountMoveReversal,self).reverse_moves()# If exist payment, change state to cancelledpayment=self.env['account.payment'].browse(payment_id)ifpayment:payment.state='cancelled'return{'type':'ir.actions.act_window_close'}returnres