跳至內容
選單
此問題已被標幟
1 回覆
1876 瀏覽次數

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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
4月 23
4816
0
3月 15
4063
1
3月 22
3331
2
6月 25
1023
0
2月 24
1387