Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
1836 Weergaven

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
Annuleer
Beste antwoord

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
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
apr. 23
4775
0
mrt. 15
4047
1
mrt. 22
3302
2
jun. 25
966
0
feb. 24
1353