[IMP] allow unreconciling bank statement lines by adding the cancel button

Since account_constraint forbids the deletion of account moves that
are linked to a bank statement, we add the possibility to delete them
from the bank statement itself, to provide a way to fix erroneous matches.
This commit is contained in:
Stéphane Bidoul
2014-10-24 19:26:24 +02:00
committed by Adrien Peiffer
parent b3544b026b
commit fcb6150d53
3 changed files with 31 additions and 1 deletions

View File

@@ -61,6 +61,7 @@ Summary of constraints are:
'website': 'http://www.camptocamp.com', 'website': 'http://www.camptocamp.com',
'data': [ 'data': [
'view/account_journal.xml', 'view/account_journal.xml',
'view/account_bank_statement.xml',
], ],
'installable': True, 'installable': True,
} }

View File

@@ -18,7 +18,7 @@
# #
############################################################################## ##############################################################################
from openerp import models, api from openerp import models, api, fields
class AccountBankStatement(models.Model): class AccountBankStatement(models.Model):
@@ -45,6 +45,14 @@ class AccountBankStatement(models.Model):
class AccountBankStatementLine(models.Model): class AccountBankStatementLine(models.Model):
_inherit = "account.bank.statement.line" _inherit = "account.bank.statement.line"
state = fields.Selection(string='Statement state',
related='statement_id.state')
@api.multi
def cancel(self):
self = self.with_context(from_parent_object=True)
return super(AccountBankStatementLine, self).cancel()
@api.multi @api.multi
def process_reconciliation(self, mv_line_dicts): def process_reconciliation(self, mv_line_dicts):
"""Add the from_parent_object key in context in order to be able """Add the from_parent_object key in context in order to be able

View File

@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<openerp>
<data>
<!--
Since account_constraint forbids the deletion of account moves that
are linked to a bank statement, we add the possibility to delete them
from the bank statement itself, to let the user fix erroneous reconciles.
-->
<record id="bank_statement_cancel_form_inherit" model="ir.ui.view">
<field name="name">bank.statement.cancel.form.inherit</field>
<field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account.view_bank_statement_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='bank_account_id']" position="after">
<field name="state" invisible="1"/>
<button name="cancel" attrs="{'invisible': ['|', ('journal_entry_id', '=', False), ('state', '=', 'confirm')]}" string="Cancel" type="object" icon="gtk-undo"/>
</xpath>
</field>
</record>
</data>
</openerp>