Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
1786 Vistas

To refund an invoice a credit note is created. However even after refund, there is an option of creating a credit note against that invoice. How to restrict creating a credit note against already refunded invoice?

Avatar
Descartar
Mejor respuesta

Hi,

Try this code:

from odoo import models,api
from odoo.exceptions import ValidationError


class AccountMove(models.Model):
    _inherit = 'account.move'

    @api.model
    def create(self, vals):
        credit = self.env['account.move'].search(
            [('reversed_entry_id', '=', self.id)])
        if credit and self.id:
            raise ValidationError(
                "Cannot create a credit note for an already refunded invoice.")
        return super(AccountMove, self).create(vals)


Hope it helps

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
abr 23
4716
0
mar 15
4007
1
mar 22
3254
2
jun 25
851
0
feb 24
1292