[IMP] account_cancel: better handling of bank statement cancellation

Before this addition, cancelling a bank statement line was allowed even if the
bank statement was confirmed. However, when the bank statement is confirmed, it
is not possible to reconcile it afterwards. The consequence is that is was not
possible to reconcile this bank statement line without cancelling the whole
bank statement, and therefore forcing the user to do the complete
reconciliation process again.

With this addition, it is not possible to cancel a bank statement line if the
corresponding bank statement is confirmed. However, we offer the user the
possibility to reset the bank statement to draft through a new button. This new
button will only change the state of the bank statement, and will not modify
the state of the associated bank statement lines. The consequence is that the
user will be able to first set the bank statement to draft, then cancel the
bank statement lines he wants, and finally launch the reconciliation process
only on the lines which were cancelled.

opw-645903
This commit is contained in:
Nicolas Martinelli 2015-08-03 19:07:57 +02:00
parent 4d9cef5412
commit 6f355623f0
5 changed files with 61 additions and 4 deletions

View File

@ -19,5 +19,4 @@
#
##############################################################################
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
import models

View File

@ -34,6 +34,17 @@
</field>
</record>
<record id="bank_statement_draft_form_inherit" model="ir.ui.view">
<field name="name">bank.statement.draft.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="//button[@name='button_cancel']" position="after">
<button name="button_draft" states="confirm" string="Reset to New" type="object"/>
</xpath>
</field>
</record>
<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>

View File

@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-01-21 14:07+0000\n"
"PO-Revision-Date: 2015-01-21 14:07+0000\n"
"POT-Creation-Date: 2015-08-03 18:10+0000\n"
"PO-Revision-Date: 2015-08-03 18:10+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@ -15,6 +15,16 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: account_cancel
#: model:ir.model,name:account_cancel.model_account_bank_statement
msgid "Bank Statement"
msgstr ""
#. module: account_cancel
#: model:ir.model,name:account_cancel.model_account_bank_statement_line
msgid "Bank Statement Line"
msgstr ""
#. module: account_cancel
#: view:account.bank.statement:account_cancel.bank_statement_cancel_form_inherit
msgid "Cancel"
@ -26,3 +36,13 @@ msgstr ""
msgid "Cancel Invoice"
msgstr ""
#. module: account_cancel
#: code:addons/account_cancel/models/account_bank_statement.py:22
#, python-format
msgid "Please set the bank statement to New before canceling."
msgstr ""
#. module: account_cancel
#: view:account.bank.statement:account_cancel.bank_statement_draft_form_inherit
msgid "Reset to New"
msgstr ""

View File

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import account_bank_statement

View File

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp import models, api, _
from openerp.exceptions import Warning
class BankStatement(models.Model):
_inherit = 'account.bank.statement'
@api.multi
def button_draft(self):
self.state = 'draft'
class BankStatementLine(models.Model):
_inherit = 'account.bank.statement.line'
@api.multi
def cancel(self):
for line in self:
if line.statement_id.state == 'confirm':
raise Warning(_("Please set the bank statement to New before canceling."))
return super(BankStatementLine, self).cancel()