[NEW] account_move_protect_reset_to_draft
This commit is contained in:
1
account_move_protect_reset_to_draft/models/__init__.py
Normal file
1
account_move_protect_reset_to_draft/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import account_move
|
15
account_move_protect_reset_to_draft/models/account_move.py
Normal file
15
account_move_protect_reset_to_draft/models/account_move.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from odoo import models, api, _, fields
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = 'account.move'
|
||||
|
||||
sent_by_email = fields.Boolean()
|
||||
|
||||
def button_draft(self):
|
||||
res = super(AccountMove, self).button_draft()
|
||||
if self.sent_by_email:
|
||||
raise UserError(_(
|
||||
"You cannot reset to draft this invoice because it has been sent by email."
|
||||
))
|
||||
return res
|
Reference in New Issue
Block a user