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
|
4780 | ||
|
0
3月 15
|
4050 | ||
|
1
3月 22
|
3303 | ||
|
2
6月 25
|
985 | ||
|
0
2月 24
|
1369 |