mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
[imp] cancel statement line: add reconciliation check also when cancelling all of the statement
This commit is contained in:
@@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
When the user confirms or cancels the whole statement, we keep the
|
When the user confirms or cancels the whole statement, we keep the
|
||||||
previous functionality, and then we change the state in all statement
|
previous functionality, and then we change the state in all statement
|
||||||
lines.
|
lines. We also add a warning if any lines are reconciled.
|
||||||
|
|
||||||
When the user confirms or cancels a statement line, we update the state
|
When the user confirms or cancels a statement line, we update the state
|
||||||
of the line, and if necessary we update the state of the whole
|
of the line, and if necessary we update the state of the whole
|
||||||
@@ -56,7 +56,8 @@
|
|||||||
'init_xml': [],
|
'init_xml': [],
|
||||||
'update_xml': [
|
'update_xml': [
|
||||||
'statement_view.xml',
|
'statement_view.xml',
|
||||||
'wizard/cancel_line_view.xml',
|
'wizard/cancel_statement_view.xml',
|
||||||
|
'wizard/cancel_statement_line_view.xml',
|
||||||
],
|
],
|
||||||
'demo_xml': [],
|
'demo_xml': [],
|
||||||
'test': [
|
'test': [
|
||||||
|
|||||||
@@ -45,7 +45,33 @@ class Statement(orm.Model):
|
|||||||
cr, uid, ids, context)
|
cr, uid, ids, context)
|
||||||
|
|
||||||
def button_cancel(self, cr, uid, ids, context=None):
|
def button_cancel(self, cr, uid, ids, context=None):
|
||||||
"""Change the state on the statement lines. Return super."""
|
"""Check if there is any reconciliation. Return action."""
|
||||||
|
st_line_obj = self.pool['account.bank.statement.line']
|
||||||
|
for statement in self.browse(cr, uid, ids, context=context):
|
||||||
|
if st_line_obj.has_reconciliation(
|
||||||
|
cr,
|
||||||
|
uid,
|
||||||
|
[line.id for line in statement.line_ids],
|
||||||
|
context=context):
|
||||||
|
# ask confirmation, we have some reconciliation already
|
||||||
|
return {
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'res_model': 'wizard.cancel.statement',
|
||||||
|
'view_type': 'form',
|
||||||
|
'view_mode': 'form',
|
||||||
|
'target': 'new',
|
||||||
|
'context': context,
|
||||||
|
}
|
||||||
|
|
||||||
|
self.do_cancel(cr, uid, ids, context=context)
|
||||||
|
|
||||||
|
def do_cancel(self, cr, uid, ids, context=None):
|
||||||
|
"""Change the state on the statement lines. Return super.
|
||||||
|
|
||||||
|
This method is called directly when there are no reconciliations, or
|
||||||
|
from the warning wizard, if there are reconciliations.
|
||||||
|
|
||||||
|
"""
|
||||||
st_line_obj = self.pool['account.bank.statement.line']
|
st_line_obj = self.pool['account.bank.statement.line']
|
||||||
for st_data in self.read(cr, uid, ids, ['line_ids'], context=context):
|
for st_data in self.read(cr, uid, ids, ['line_ids'], context=context):
|
||||||
st_line_obj.write(cr, uid, st_data['line_ids'], {
|
st_line_obj.write(cr, uid, st_data['line_ids'], {
|
||||||
|
|||||||
@@ -97,8 +97,8 @@ class StatementLine(orm.Model):
|
|||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def button_cancel(self, cr, uid, ids, context=None):
|
def has_reconciliation(self, cr, uid, ids, context=None):
|
||||||
"""Check if a line is reconciled, and cancel it. Return action."""
|
"""Check if the line has some reconciliation. Return boolean."""
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
|
|
||||||
@@ -106,15 +106,27 @@ class StatementLine(orm.Model):
|
|||||||
for move in st_line.move_ids:
|
for move in st_line.move_ids:
|
||||||
for move_line in move.line_id:
|
for move_line in move.line_id:
|
||||||
if move_line.reconcile:
|
if move_line.reconcile:
|
||||||
# ask confirmation, we have some reconciliation already
|
# aha! we have some reconciliation!
|
||||||
return {
|
return True
|
||||||
'type': 'ir.actions.act_window',
|
|
||||||
'res_model': 'wizard.cancel.line',
|
# no reconciliation to worry about
|
||||||
'view_type': 'form',
|
return False
|
||||||
'view_mode': 'form',
|
|
||||||
'target': 'new',
|
def button_cancel(self, cr, uid, ids, context=None):
|
||||||
'context': context,
|
"""Check if a line is reconciled, and cancel it. Return action."""
|
||||||
}
|
if context is None:
|
||||||
|
context = {}
|
||||||
|
|
||||||
|
if self.has_reconciliation(cr, uid, ids, context=context):
|
||||||
|
# ask confirmation, we have some reconciliation already
|
||||||
|
return {
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'res_model': 'wizard.cancel.statement.line',
|
||||||
|
'view_type': 'form',
|
||||||
|
'view_mode': 'form',
|
||||||
|
'target': 'new',
|
||||||
|
'context': context,
|
||||||
|
}
|
||||||
|
|
||||||
# no reconciliation to worry about: we cancel our lines directly then
|
# no reconciliation to worry about: we cancel our lines directly then
|
||||||
return self.cancel(cr, uid, ids, context=context)
|
return self.cancel(cr, uid, ids, context=context)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
|
||||||
# #
|
# #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
"""Account Statement Cancel Line."""
|
"""Wizard for asking the confirmation when some move is reconciled."""
|
||||||
|
|
||||||
import cancel_line # noqa
|
import cancel_statement # noqa
|
||||||
|
import cancel_statement_line # noqa
|
||||||
|
|||||||
@@ -23,12 +23,12 @@
|
|||||||
from openerp.osv import orm
|
from openerp.osv import orm
|
||||||
|
|
||||||
|
|
||||||
class wizard_cancel_line(orm.TransientModel):
|
class wizard_cancel_statement_line(orm.TransientModel):
|
||||||
|
|
||||||
"""Wizard to Cancel a Statement Line."""
|
"""Wizard to Cancel a Statement Line."""
|
||||||
|
|
||||||
_name = "wizard.cancel.line"
|
_name = "wizard.cancel.statement.line"
|
||||||
_description = "Cancel Line"
|
_description = "Cancel Statement Line"
|
||||||
_columns = {
|
_columns = {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
<openerp>
|
<openerp>
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<record id="view_wizard_cancel_line_form" model="ir.ui.view">
|
<record id="view_wizard_cancel_statement_line_form" model="ir.ui.view">
|
||||||
<field name="name">view.wizard.cancel.line.form</field>
|
<field name="name">view.wizard.cancel.statement.line.form</field>
|
||||||
<field name="model">wizard.cancel.line</field>
|
<field name="model">wizard.cancel.statement.line</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Reconciled Entries" version="7.0">
|
<form string="Reconciled Entries" version="7.0">
|
||||||
<separator string="Unreconciliation"/>
|
<separator string="Unreconciliation"/>
|
||||||
Reference in New Issue
Block a user