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:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
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
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Apr 23
|
4706 | ||
|
0
Mar 15
|
4004 | ||
|
1
Mar 22
|
3242 | ||
|
2
Jun 25
|
844 | ||
|
0
Feb 24
|
1286 |