Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
1853 Представления

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?

Аватар
Отменить
Лучший ответ

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

Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
апр. 23
4791
0
мар. 15
4056
1
мар. 22
3317
2
июн. 25
1003
0
февр. 24
1378