Skip to Content
मेन्यू
This question has been flagged
1 Reply
1804 Views

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
Discard
Best Answer

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
Discard
Related Posts Replies Views Activity
1
अप्रैल 23
4743
0
मार्च 15
4026
1
मार्च 22
3268
2
जून 25
872
0
फ़र॰ 24
1308