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
- Księgowość
- Zapasy
- PoS
- Project
- MRP
To pytanie dostało ostrzeżenie
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
Podoba Ci się ta dyskusja? Dołącz do niej!
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj sięPowiązane posty | Odpowiedzi | Widoki | Czynność | |
---|---|---|---|---|
|
1
kwi 23
|
4738 | ||
|
0
mar 15
|
4023 | ||
|
1
mar 22
|
3268 | ||
|
2
cze 25
|
868 | ||
|
0
lut 24
|
1306 |