diff --git a/account_advanced_protection_features/models/account_move.py b/account_advanced_protection_features/models/account_move.py index 7c8f09b..417e5af 100644 --- a/account_advanced_protection_features/models/account_move.py +++ b/account_advanced_protection_features/models/account_move.py @@ -4,15 +4,12 @@ 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 and self.journal_id.prevent_reset_to_draft_sent_invoice: + if self.is_move_sent and self.journal_id.prevent_reset_to_draft_sent_invoice: raise UserError(_( "You cannot reset to draft this invoice because it has been sent by email." )) - return res + return super(AccountMove, self).button_draft() @api.ondelete(at_uninstall=False) def _check_posted(self): diff --git a/account_advanced_protection_features/wizard/__init__.py b/account_advanced_protection_features/wizard/__init__.py deleted file mode 100644 index 641fd38..0000000 --- a/account_advanced_protection_features/wizard/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import account_invoice_send \ No newline at end of file diff --git a/account_advanced_protection_features/wizard/account_invoice_send.py b/account_advanced_protection_features/wizard/account_invoice_send.py deleted file mode 100644 index 8724798..0000000 --- a/account_advanced_protection_features/wizard/account_invoice_send.py +++ /dev/null @@ -1,14 +0,0 @@ -# -*- coding: utf-8 -*- - -from odoo import api, fields, models, _ - - -class AccountInvoiceSend(models.TransientModel): - _inherit = 'account.invoice.send' - - def send_and_print_action(self): - if self.model == "account.move": - move = self.env[self.model].browse(self.res_id) - move.sent_by_email = True - - return super(AccountInvoiceSend, self).send_and_print_action()