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?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- 客戶關係
- e-Commerce
- 會計
- 庫存
- PoS
- Project
- MRP
此問題已被標幟
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 |