Skip to content

Commit

Permalink
[IMP] account_cancel: better handling of bank statement cancellation
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nim-odoo committed Aug 5, 2015
1 parent 4d9cef5 commit 6f35562
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 4 deletions.
3 changes: 1 addition & 2 deletions addons/account_cancel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@
#
##############################################################################

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

import models
11 changes: 11 additions & 0 deletions addons/account_cancel/account_cancel_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
24 changes: 22 additions & 2 deletions addons/account_cancel/i18n/account_cancel.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,25 @@ 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"
"Content-Type: text/plain; charset=UTF-8\n"
"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"
Expand All @@ -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 ""
4 changes: 4 additions & 0 deletions addons/account_cancel/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

import account_bank_statement
23 changes: 23 additions & 0 deletions addons/account_cancel/models/account_bank_statement.py
Original file line number Diff line number Diff line change
@@ -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()

3 comments on commit 6f35562

@ahu-odoo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Nicolas,

Could you check the following please: #8410
Maybe not perfect in terms of naming conventions (although I kept the number "2" at the end of the view names)

Goal of this view is to add the same feature on cash registers, otherwise you can never reset it to new.

@nim-odoo
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

@feketemihai
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nim-odoo Could we add the same..the Cancel button in cash register lines for easier cancelling of only one line, not the whole cash register?

Please sign in to comment.