From 2bef8b4e0c76e889ec2e3d2557cc8d91fe71c717 Mon Sep 17 00:00:00 2001 From: Quentin Mondot Date: Fri, 29 Aug 2025 09:26:42 +0200 Subject: [PATCH] [IMP] account_advanced_protection_features: use is_move_sent field to prevent_reset_to_draft_sent_invoice --- .../models/account_move.py | 7 ++----- .../wizard/__init__.py | 1 - .../wizard/account_invoice_send.py | 14 -------------- 3 files changed, 2 insertions(+), 20 deletions(-) delete mode 100644 account_advanced_protection_features/wizard/__init__.py delete mode 100644 account_advanced_protection_features/wizard/account_invoice_send.py 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()