# -*- coding: utf-8 -*-
##############################################################################
#
#    Odoo, Open Source Management Solution
#    Copyright (C) 2016-TODAY Prime Consulting SA, Cape Verde (<http://prime.cv>).
#
##############################################################################
from odoo import models, fields, api

class AccountInvoiceRefund(models.TransientModel):
    _inherit = "account.invoice.refund"

    @api.multi
    def compute_refund(self, mode='refund'):
    	context = self.env.context or {}
    	res = super(AccountInvoiceRefund, self).compute_refund(mode)
    	if mode == 'cancel':
    		for inv in self.env['account.invoice'].browse(context.get('active_ids')):
    			inv.write({'state': 'cancel'})
    	return res