New account advanced protection features module #23

Open
mondot wants to merge 8 commits from new_account_advanced_protection_features into 16.0
5 changed files with 26 additions and 2 deletions
Showing only changes of commit 288e9dd7ea - Show all commits

View File

@@ -21,6 +21,7 @@
},
# always loaded
"data": [
"views/account_journal_views.xml"
],
# only loaded in demonstration mode
"demo": [],

View File

@@ -1 +1,2 @@
from . import account_move
from . import account_journal

View File

@@ -0,0 +1,6 @@
from odoo import models, fields
class AccountJournal(models.Model):
_inherit = "account.journal"
prevent_reset_to_draft_sent_invoice = fields.Boolean("Prevent to reset to draft a sent invoice")

View File

@@ -8,7 +8,7 @@ class AccountMove(models.Model):
def button_draft(self):
res = super(AccountMove, self).button_draft()
if self.sent_by_email:
if self.sent_by_email 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."
))

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_account_journal_form_inherit_prevent_reset_to_draft" model="ir.ui.view">
<field name="name">account.journal.form</field>
<field name="model">account.journal</field>
<field name="inherit_id" ref="account.view_account_journal_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='restrict_mode_hash_table']" position="after">
<field
name="prevent_reset_to_draft_sent_invoice"
attrs="{'invisible': [('type', '!=', 'sale')]}"
/>
</xpath>
</field>
</record>
</odoo>