New account advanced protection features module #23

Open
mondot wants to merge 8 commits from new_account_advanced_protection_features into 16.0
3 changed files with 2 additions and 20 deletions
Showing only changes of commit 2bef8b4e0c - Show all commits

View File

@@ -4,15 +4,12 @@ from odoo.exceptions import UserError
class AccountMove(models.Model): class AccountMove(models.Model):
_inherit = 'account.move' _inherit = 'account.move'
sent_by_email = fields.Boolean()
def button_draft(self): def button_draft(self):
res = super(AccountMove, self).button_draft() if self.is_move_sent and self.journal_id.prevent_reset_to_draft_sent_invoice:
if self.sent_by_email and self.journal_id.prevent_reset_to_draft_sent_invoice:
raise UserError(_( raise UserError(_(
"You cannot reset to draft this invoice because it has been sent by email." "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) @api.ondelete(at_uninstall=False)
def _check_posted(self): def _check_posted(self):

View File

@@ -1 +0,0 @@
from . import account_invoice_send

View File

@@ -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()