Merge lp:~camptocamp/banking-addons/bank-statement-reconcile-7.0-add-cancel-line-lep into lp:banking-addons/bank-statement-reconcile-70

Proposed by Leonardo Pistone
Status: Merged
Merged at revision: 158
Proposed branch: lp:~camptocamp/banking-addons/bank-statement-reconcile-7.0-add-cancel-line-lep
Merge into: lp:banking-addons/bank-statement-reconcile-70
Diff against target: 1235 lines (+1139/-0)
18 files modified
account_statement_cancel_line/__init__.py (+25/-0)
account_statement_cancel_line/__openerp__.py (+74/-0)
account_statement_cancel_line/i18n/account_statement_cancel_line.pot (+97/-0)
account_statement_cancel_line/i18n/fr.po (+97/-0)
account_statement_cancel_line/migrations/0.3/post-set-statement-line-state.py (+38/-0)
account_statement_cancel_line/statement.py (+118/-0)
account_statement_cancel_line/statement_line.py (+213/-0)
account_statement_cancel_line/statement_view.xml (+28/-0)
account_statement_cancel_line/test/cancel_line.yml (+80/-0)
account_statement_cancel_line/test/confirm_statement_no_double_moves.yml (+70/-0)
account_statement_cancel_line/test/test_confirm_last_line_balance_check.yml (+42/-0)
account_statement_cancel_line/test/test_confirm_last_line_no_balance_check.yml (+44/-0)
account_statement_cancel_line/wizard/__init__.py (+24/-0)
account_statement_cancel_line/wizard/cancel_line.py (+46/-0)
account_statement_cancel_line/wizard/cancel_statement.py (+51/-0)
account_statement_cancel_line/wizard/cancel_statement_line.py (+46/-0)
account_statement_cancel_line/wizard/cancel_statement_line_view.xml (+22/-0)
account_statement_cancel_line/wizard/cancel_statement_view.xml (+24/-0)
To merge this branch: bzr merge lp:~camptocamp/banking-addons/bank-statement-reconcile-7.0-add-cancel-line-lep
Reviewer Review Type Date Requested Status
Frederic Clementi - Camptocamp functional Approve
Nicolas Bessi - Camptocamp (community) no test, code review Approve
Leonardo Pistone Abstain
Stefan Rijnhart (Opener) Abstain
Joël Grand-Guillaume @ camptocamp code review, no tests Approve
Review via email: mp+202831@code.launchpad.net

Commit message

new module account_statement_cancel_line

Description of the change

New module account_statement_cancel_line. See __openep__.py for a description of what that does.

Thanks!

To post a comment you must log in.
Revision history for this message
Leonardo Pistone (lepistone) wrote :

After an internal review, I added french translations, and a migration file to set the state correctly on existing statements, and I also merged upstream.

Revision history for this message
Leonardo Pistone (lepistone) wrote :

I finished some fixes: an improved confirmation wizard, and a fix in the tests.

thanks!

Revision history for this message
Leonardo Pistone (lepistone) wrote :

I put this MP to 'work in progress' because I found a bug here. I'm doing a test and a fix.

Revision history for this message
Leonardo Pistone (lepistone) wrote :

I fixed the bug i'd found: if the last line in draft was confirmed and the statement confirmed, we were skipping the balance check.

I added two tests that show that.

Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

LGTM, Thank you Leonardo

review: Approve (code review, no tests)
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Thanks for considering account_banking for your naming! Having this module will certainly help in merging the projects.

I tried to test the module, and was confronted by the dependency on account_default_draft_move. This dependency enforces alternative accounting practises which may be required in your region, but not in ours and should not be part of this change IMHO. Would you consider making this module agnostic towards the cancelling draft moves? With this, I mean that when cancelling a bank statement line, you can simply attempt to cancel and remove the associated move line and do the constraints in the various modules do their work.

review: Needs Information
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

s/cancelling draft moves/cancelling *posted* moves/

obviously

Revision history for this message
Leonardo Pistone (lepistone) wrote :

Thanks for your review Stefan.

The point you raise makes sense to me. Speaking as a developer and not an accountant, making this module agnostic on account_default_draft_move would be probably feasible, but the integration test would break. That makes sense to me, since the business logic changes a bit.

In fact I would not feel at ease adapting the test, because the two workflows (with or without default_draft) seem like two scenarios that I'd like to test separately to be somewhat confident.

To do that properly, probably I would need to remove the dependency here, write new tests for the non-default-draft case, and then write a new module that depends on account_statement_cancel_line and account_default_draft_move, with the tests I have now.

So your proposal makes sense to me, but I am not prepared to do that right now - it does not cover my use case anyway.

I would be happy to review and accept such a change if someone does it.

Leo

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

OK. Abstain for now then.

review: Abstain
Revision history for this message
Leonardo Pistone (lepistone) wrote :

oops, we found that that bug:

- create a statement with two lines
- confirm the first one
- confirm the whole statement

Then the first line gets two moves. At the moment, I pushed a yaml test to expose it.

review: Disapprove
132. By Leonardo Pistone

[fix] duplicate moves when confirming a statement with a confirmed line

Add a test to expose the bug.
To reproduce: create a statement with two lines, confirm one, and then confirm
the whole statement. The first line has two associated moves.

Revision history for this message
Leonardo Pistone (lepistone) wrote :

The bug should now be fixed, and we are green again.

review: Abstain
Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

LGTM

review: Approve (no test, code review)
Revision history for this message
Frederic Clementi - Camptocamp (frederic-clementi) wrote :

Ok is fine.

Thanks leo

everything seems to work smoothly now.

review: Approve (functional)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'account_statement_cancel_line'
2=== added file 'account_statement_cancel_line/__init__.py'
3--- account_statement_cancel_line/__init__.py 1970-01-01 00:00:00 +0000
4+++ account_statement_cancel_line/__init__.py 2014-06-13 10:06:12 +0000
5@@ -0,0 +1,25 @@
6+# -*- coding: utf-8 -*-
7+###############################################################################
8+# #
9+# Author: Leonardo Pistone
10+# Copyright 2014 Camptocamp SA
11+# #
12+# This program is free software: you can redistribute it and/or modify #
13+# it under the terms of the GNU Affero General Public License as #
14+# published by the Free Software Foundation, either version 3 of the #
15+# License, or (at your option) any later version. #
16+# #
17+# This program is distributed in the hope that it will be useful, #
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
20+# GNU Affero General Public License for more details. #
21+# #
22+# You should have received a copy of the GNU Affero General Public License #
23+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
24+# #
25+###############################################################################
26+"""Account Statement Cancel Line."""
27+
28+import statement # noqa
29+import statement_line # noqa
30+import wizard # noqa
31
32=== added file 'account_statement_cancel_line/__openerp__.py'
33--- account_statement_cancel_line/__openerp__.py 1970-01-01 00:00:00 +0000
34+++ account_statement_cancel_line/__openerp__.py 2014-06-13 10:06:12 +0000
35@@ -0,0 +1,74 @@
36+# -*- coding: utf-8 -*-
37+###############################################################################
38+# #
39+# Author: Leonardo Pistone #
40+# Copyright 2014 Camptocamp SA #
41+# #
42+# Inspired by module account_banking by EduSense BV, Therp BV, Smile #
43+# #
44+# This program is free software: you can redistribute it and/or modify #
45+# it under the terms of the GNU Affero General Public License as #
46+# published by the Free Software Foundation, either version 3 of the #
47+# License, or (at your option) any later version. #
48+# #
49+# This program is distributed in the hope that it will be useful, #
50+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
51+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
52+# GNU Affero General Public License for more details. #
53+# #
54+# You should have received a copy of the GNU Affero General Public License #
55+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
56+# #
57+###############################################################################
58+{
59+ 'name': "Account Statement Cancel Line",
60+ 'version': '0.3',
61+ 'author': 'Camptocamp',
62+ 'maintainer': 'Camptocamp',
63+ 'category': 'Finance',
64+ 'complexity': 'normal',
65+ 'depends': [
66+ 'account',
67+ 'account_statement_ext',
68+ 'account_default_draft_move',
69+ 'account_statement_base_completion',
70+ ],
71+ 'description': """
72+ Account Statement Cancel Line
73+
74+ This module allows to cancel one line of the statement without
75+ cancelling the whole thing.
76+
77+ To do that, a state is added to the statement line.
78+
79+ When the user confirms or cancels the whole statement, we keep the
80+ previous functionality, and then we change the state in all statement
81+ lines. We also add a warning if any lines are reconciled. If no lines
82+ are reconciled, we show a generic warning because the operation could
83+ take a long time.
84+
85+ When the user confirms or cancels a statement line, we update the state
86+ of the line, and if necessary we update the state of the whole
87+ statement, too.
88+
89+ If the user tries to cancel a line that is reconciled, we ask for
90+ confirmation before proceeding.
91+ """,
92+ 'website': 'http://www.camptocamp.com',
93+ 'init_xml': [],
94+ 'update_xml': [
95+ 'statement_view.xml',
96+ 'wizard/cancel_statement_view.xml',
97+ 'wizard/cancel_statement_line_view.xml',
98+ ],
99+ 'demo_xml': [],
100+ 'test': [
101+ 'test/cancel_line.yml',
102+ 'test/test_confirm_last_line_balance_check.yml',
103+ 'test/test_confirm_last_line_no_balance_check.yml',
104+ 'test/confirm_statement_no_double_moves.yml',
105+ ],
106+ 'installable': True,
107+ 'images': [],
108+ 'license': 'AGPL-3',
109+}
110
111=== added directory 'account_statement_cancel_line/i18n'
112=== added file 'account_statement_cancel_line/i18n/account_statement_cancel_line.pot'
113--- account_statement_cancel_line/i18n/account_statement_cancel_line.pot 1970-01-01 00:00:00 +0000
114+++ account_statement_cancel_line/i18n/account_statement_cancel_line.pot 2014-06-13 10:06:12 +0000
115@@ -0,0 +1,97 @@
116+# Translation of OpenERP Server.
117+# This file contains the translation of the following modules:
118+# * account_statement_cancel_line
119+#
120+msgid ""
121+msgstr ""
122+"Project-Id-Version: OpenERP Server 7.0\n"
123+"Report-Msgid-Bugs-To: \n"
124+"POT-Creation-Date: 2014-02-17 16:46+0000\n"
125+"PO-Revision-Date: 2014-02-17 16:46+0000\n"
126+"Last-Translator: <>\n"
127+"Language-Team: \n"
128+"MIME-Version: 1.0\n"
129+"Content-Type: text/plain; charset=UTF-8\n"
130+"Content-Transfer-Encoding: \n"
131+"Plural-Forms: \n"
132+
133+#. module: account_statement_cancel_line
134+#: model:ir.model,name:account_statement_cancel_line.model_account_bank_statement_line
135+msgid "Bank Statement Line"
136+msgstr ""
137+
138+#. module: account_statement_cancel_line
139+#: view:wizard.cancel.statement:0
140+#: view:wizard.cancel.statement.line:0
141+msgid "Some entries are already reconciled. Do you want to unreconcile them and proceed?"
142+msgstr ""
143+
144+#. module: account_statement_cancel_line
145+#: view:account.bank.statement:0
146+msgid "Cancel transaction"
147+msgstr ""
148+
149+#. module: account_statement_cancel_line
150+#: model:ir.model,name:account_statement_cancel_line.model_wizard_cancel_statement
151+msgid "Cancel Statement"
152+msgstr ""
153+
154+#. module: account_statement_cancel_line
155+#: model:ir.model,name:account_statement_cancel_line.model_account_bank_statement
156+msgid "Bank Statement"
157+msgstr ""
158+
159+#. module: account_statement_cancel_line
160+#: model:ir.model,name:account_statement_cancel_line.model_wizard_cancel_statement_line
161+msgid "Cancel Statement Line"
162+msgstr ""
163+
164+#. module: account_statement_cancel_line
165+#: field:account.bank.statement.line,state:0
166+msgid "State"
167+msgstr ""
168+
169+#. module: account_statement_cancel_line
170+#: view:wizard.cancel.statement:0
171+#: view:wizard.cancel.statement.line:0
172+msgid "Reconciled Entries"
173+msgstr ""
174+
175+#. module: account_statement_cancel_line
176+#: selection:account.bank.statement.line,state:0
177+msgid "Draft"
178+msgstr ""
179+
180+#. module: account_statement_cancel_line
181+#: selection:account.bank.statement.line,state:0
182+msgid "Confirmed"
183+msgstr ""
184+
185+#. module: account_statement_cancel_line
186+#: view:wizard.cancel.statement:0
187+#: view:wizard.cancel.statement.line:0
188+msgid "Cancel"
189+msgstr ""
190+
191+#. module: account_statement_cancel_line
192+#: view:account.bank.statement:0
193+msgid "Confirm transaction"
194+msgstr ""
195+
196+#. module: account_statement_cancel_line
197+#: view:wizard.cancel.statement:0
198+#: view:wizard.cancel.statement.line:0
199+msgid "Unreconcile"
200+msgstr ""
201+
202+#. module: account_statement_cancel_line
203+#: view:wizard.cancel.statement:0
204+#: view:wizard.cancel.statement.line:0
205+msgid "or"
206+msgstr ""
207+
208+#. module: account_statement_cancel_line
209+#: view:wizard.cancel.statement:0
210+#: view:wizard.cancel.statement.line:0
211+msgid "Unreconciliation"
212+msgstr ""
213
214=== added file 'account_statement_cancel_line/i18n/fr.po'
215--- account_statement_cancel_line/i18n/fr.po 1970-01-01 00:00:00 +0000
216+++ account_statement_cancel_line/i18n/fr.po 2014-06-13 10:06:12 +0000
217@@ -0,0 +1,97 @@
218+# Translation of OpenERP Server.
219+# This file contains the translation of the following modules:
220+# * account_statement_cancel_line
221+#
222+msgid ""
223+msgstr ""
224+"Project-Id-Version: OpenERP Server 7.0\n"
225+"Report-Msgid-Bugs-To: \n"
226+"POT-Creation-Date: 2014-02-17 15:59+0000\n"
227+"PO-Revision-Date: 2014-02-17 15:59+0000\n"
228+"Last-Translator: <>\n"
229+"Language-Team: \n"
230+"MIME-Version: 1.0\n"
231+"Content-Type: text/plain; charset=UTF-8\n"
232+"Content-Transfer-Encoding: \n"
233+"Plural-Forms: \n"
234+
235+#. module: account_statement_cancel_line
236+#: model:ir.model,name:account_statement_cancel_line.model_account_bank_statement_line
237+msgid "Bank Statement Line"
238+msgstr "Ligne de relevé bancaire"
239+
240+#. module: account_statement_cancel_line
241+#: view:wizard.cancel.statement:0
242+#: view:wizard.cancel.statement.line:0
243+msgid "Some entries are already reconciled. Do you want to unreconcile them and proceed?"
244+msgstr "Certaines écritures sont déja léttrées. Voulez-vous annuler définitivement tout les léttrages et poursuivre?"
245+
246+#. module: account_statement_cancel_line
247+#: view:account.bank.statement:0
248+msgid "Cancel transaction"
249+msgstr "Annuler ligne"
250+
251+#. module: account_statement_cancel_line
252+#: model:ir.model,name:account_statement_cancel_line.model_wizard_cancel_statement
253+msgid "Cancel Statement"
254+msgstr "Annuler le relevé"
255+
256+#. module: account_statement_cancel_line
257+#: model:ir.model,name:account_statement_cancel_line.model_account_bank_statement
258+msgid "Bank Statement"
259+msgstr "Relevé bancaire"
260+
261+#. module: account_statement_cancel_line
262+#: model:ir.model,name:account_statement_cancel_line.model_wizard_cancel_statement_line
263+msgid "Cancel Statement Line"
264+msgstr "Annuler ligne de relevé"
265+
266+#. module: account_statement_cancel_line
267+#: field:account.bank.statement.line,state:0
268+msgid "State"
269+msgstr "Etat"
270+
271+#. module: account_statement_cancel_line
272+#: view:wizard.cancel.statement:0
273+#: view:wizard.cancel.statement.line:0
274+msgid "Reconciled Entries"
275+msgstr "Lignes léttrées"
276+
277+#. module: account_statement_cancel_line
278+#: selection:account.bank.statement.line,state:0
279+msgid "Draft"
280+msgstr "Brouillon"
281+
282+#. module: account_statement_cancel_line
283+#: selection:account.bank.statement.line,state:0
284+msgid "Confirmed"
285+msgstr "Confirmée"
286+
287+#. module: account_statement_cancel_line
288+#: view:wizard.cancel.statement:0
289+#: view:wizard.cancel.statement.line:0
290+msgid "Cancel"
291+msgstr "Annuler"
292+
293+#. module: account_statement_cancel_line
294+#: view:account.bank.statement:0
295+msgid "Confirm transaction"
296+msgstr "Confirmer ligne"
297+
298+#. module: account_statement_cancel_line
299+#: view:wizard.cancel.statement:0
300+#: view:wizard.cancel.statement.line:0
301+msgid "Unreconcile"
302+msgstr "Déléttrer"
303+
304+#. module: account_statement_cancel_line
305+#: view:wizard.cancel.statement:0
306+#: view:wizard.cancel.statement.line:0
307+msgid "or"
308+msgstr "ou"
309+
310+#. module: account_statement_cancel_line
311+#: view:wizard.cancel.statement:0
312+#: view:wizard.cancel.statement.line:0
313+msgid "Unreconciliation"
314+msgstr "Déléttrage"
315
316=== added directory 'account_statement_cancel_line/migrations'
317=== added directory 'account_statement_cancel_line/migrations/0.3'
318=== added file 'account_statement_cancel_line/migrations/0.3/post-set-statement-line-state.py'
319--- account_statement_cancel_line/migrations/0.3/post-set-statement-line-state.py 1970-01-01 00:00:00 +0000
320+++ account_statement_cancel_line/migrations/0.3/post-set-statement-line-state.py 2014-06-13 10:06:12 +0000
321@@ -0,0 +1,38 @@
322+# -*- coding: utf-8 -*-
323+###############################################################################
324+# #
325+# Author: Leonardo Pistone #
326+# Copyright 2014 Camptocamp SA #
327+# #
328+# Inspired by module account_banking by EduSense BV, Therp BV, Smile #
329+# #
330+# This program is free software: you can redistribute it and/or modify #
331+# it under the terms of the GNU Affero General Public License as #
332+# published by the Free Software Foundation, either version 3 of the #
333+# License, or (at your option) any later version. #
334+# #
335+# This program is distributed in the hope that it will be useful, #
336+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
337+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
338+# GNU Affero General Public License for more details. #
339+# #
340+# You should have received a copy of the GNU Affero General Public License #
341+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
342+# #
343+###############################################################################
344+
345+__name__ = ("account.bank.statement.line:: set new field 'state' to "
346+ "confirmed for all statement lines belonging to confirmed "
347+ "statements")
348+
349+
350+def migrate(cr, version):
351+ """This module adds the field state to the statement line. Here we set it
352+ correctly on existing statements. The names, and so this migration, are
353+ intentionally kept in sync with the account_banking module."""
354+ cr.execute("UPDATE account_bank_statement_line as sl "
355+ " SET state = 'confirmed'"
356+ " FROM account_bank_statement as s "
357+ " WHERE sl.statement_id = s.id "
358+ " AND s.state = 'confirm' "
359+ )
360
361=== added file 'account_statement_cancel_line/statement.py'
362--- account_statement_cancel_line/statement.py 1970-01-01 00:00:00 +0000
363+++ account_statement_cancel_line/statement.py 2014-06-13 10:06:12 +0000
364@@ -0,0 +1,118 @@
365+# -*- coding: utf-8 -*-
366+###############################################################################
367+# #
368+# Author: Leonardo Pistone
369+# Copyright 2014 Camptocamp SA
370+# #
371+# This program is free software: you can redistribute it and/or modify #
372+# it under the terms of the GNU Affero General Public License as #
373+# published by the Free Software Foundation, either version 3 of the #
374+# License, or (at your option) any later version. #
375+# #
376+# This program is distributed in the hope that it will be useful, #
377+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
378+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
379+# GNU Affero General Public License for more details. #
380+# #
381+# You should have received a copy of the GNU Affero General Public License #
382+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
383+# #
384+###############################################################################
385+"""Account Statement Cancel Line."""
386+
387+from openerp.osv import orm
388+
389+
390+class Statement(orm.Model):
391+
392+ """Bank Statement.
393+
394+ Minimal changes to allow cancelling single lines and checking if there are
395+ any lines that are already reconciled.
396+
397+ """
398+
399+ _inherit = "account.bank.statement"
400+
401+ def button_confirm_bank(self, cr, uid, ids, context=None):
402+ """If all lines are draft, change their state.
403+ Otherwise, confirm line by line to avoid duplicate moves.
404+ Return super.
405+
406+ """
407+ st_line_obj = self.pool['account.bank.statement.line']
408+
409+ statement_ids_fully_confirm = []
410+ for st in self.browse(cr, uid, ids, context=context):
411+ if all(l.state == 'draft' for l in st.line_ids):
412+ statement_ids_fully_confirm.append(st.id)
413+ st_line_obj.write(cr, uid, [l.id for l in st.line_ids], {
414+ 'state': 'confirmed'
415+ }, context=context)
416+ else:
417+ st_line_obj.confirm(cr, uid, [l.id for l in st.line_ids],
418+ context=context)
419+
420+ if statement_ids_fully_confirm:
421+ return super(Statement, self).button_confirm_bank(
422+ cr, uid, statement_ids_fully_confirm, context)
423+ else:
424+ return True
425+
426+ def button_cancel(self, cr, uid, ids, context=None):
427+ """Check if there is any reconciliation. Return action."""
428+ st_line_obj = self.pool['account.bank.statement.line']
429+ for statement in self.browse(cr, uid, ids, context=context):
430+ ctx = context.copy()
431+ ctx['default_reconcile_warning'] = st_line_obj.has_reconciliation(
432+ cr,
433+ uid,
434+ [line.id for line in statement.line_ids],
435+ context=context)
436+ return {
437+ 'type': 'ir.actions.act_window',
438+ 'res_model': 'wizard.cancel.statement',
439+ 'view_type': 'form',
440+ 'view_mode': 'form',
441+ 'target': 'new',
442+ 'context': ctx,
443+ }
444+
445+ self.do_cancel(cr, uid, ids, context=context)
446+
447+ def do_cancel(self, cr, uid, ids, context=None):
448+ """Change the state on the statement lines. Return super.
449+
450+ This method is called directly when there are no reconciliations, or
451+ from the warning wizard, if there are reconciliations.
452+
453+ """
454+ st_line_obj = self.pool['account.bank.statement.line']
455+ for st_data in self.read(cr, uid, ids, ['line_ids'], context=context):
456+ st_line_obj.write(cr, uid, st_data['line_ids'], {
457+ 'state': 'draft'
458+ }, context=context)
459+
460+ return super(Statement, self).button_cancel(
461+ cr, uid, ids, context)
462+
463+ def confirm_statement_from_lines(self, cr, uid, ids, context=None):
464+ """If all lines are confirmed, so is the whole statement.
465+
466+ Return True if we changed anything.
467+
468+ """
469+ need_to_update_view = False
470+ for statement in self.browse(cr, uid, ids, context=context):
471+ if all(line.state == 'confirmed' for line in statement.line_ids):
472+ self.write(cr, uid, [statement.id], {
473+ 'state': 'confirm'
474+ }, context=context)
475+ need_to_update_view = True
476+ self.balance_check(
477+ cr,
478+ uid,
479+ statement.id,
480+ journal_type=statement.journal_id.type,
481+ context=context)
482+ return need_to_update_view
483
484=== added file 'account_statement_cancel_line/statement_line.py'
485--- account_statement_cancel_line/statement_line.py 1970-01-01 00:00:00 +0000
486+++ account_statement_cancel_line/statement_line.py 2014-06-13 10:06:12 +0000
487@@ -0,0 +1,213 @@
488+# -*- coding: utf-8 -*-
489+###############################################################################
490+# #
491+# Author: Leonardo Pistone
492+# Copyright 2014 Camptocamp SA
493+# #
494+# This program is free software: you can redistribute it and/or modify #
495+# it under the terms of the GNU Affero General Public License as #
496+# published by the Free Software Foundation, either version 3 of the #
497+# License, or (at your option) any later version. #
498+# #
499+# This program is distributed in the hope that it will be useful, #
500+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
501+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
502+# GNU Affero General Public License for more details. #
503+# #
504+# You should have received a copy of the GNU Affero General Public License #
505+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
506+# #
507+###############################################################################
508+"""Account Statement Cancel Line."""
509+
510+from openerp.osv import fields, orm
511+
512+from openerp.tools.translate import _
513+
514+
515+class StatementLine(orm.Model):
516+
517+ """Add a state to the statement line."""
518+
519+ _inherit = "account.bank.statement.line"
520+
521+ _columns = {
522+ 'state': fields.selection(
523+ [('draft', 'Draft'), ('confirmed', 'Confirmed')],
524+ 'State',
525+ readonly=True,
526+ required=True
527+ ),
528+ }
529+
530+ _defaults = {
531+ 'state': 'draft',
532+ }
533+
534+ def confirm(self, cr, uid, ids, context=None):
535+ """Confirm just one statement line, return action.
536+
537+ The module account_banking does have a similar method, but at the
538+ moment it uses a different logic (for example, it uses vouchers, where
539+ the bank-statement-reconcile branch does not).
540+
541+ """
542+ if context is None:
543+ context = {}
544+ local_ctx = context.copy()
545+ # if account_constraints is installed, we need to tell it that moves
546+ # are being created by a statement, which is OK.
547+ # The module tries to prevent direct changes to the moves created by
548+ # bank statements.
549+ local_ctx['from_parent_object'] = True
550+
551+ statement_pool = self.pool.get('account.bank.statement')
552+ res = {}
553+
554+ for st_line in self.browse(cr, uid, ids, context):
555+ if st_line.state != 'draft':
556+ continue
557+ st = st_line.statement_id
558+ curr_id = st.journal_id.company_id.currency_id.id
559+
560+ st_number = st.name
561+ st_line_number = statement_pool.get_next_st_line_number(
562+ cr, uid, st_number, st_line, context)
563+
564+ # We pass the local_ctx so that account_constraints allows us to
565+ # work on the moves generated by the bank statement
566+ statement_pool.create_move_from_st_line(
567+ cr,
568+ uid,
569+ st_line.id,
570+ curr_id,
571+ st_line_number,
572+ local_ctx)
573+ self.write(cr, uid, st_line.id, {
574+ 'state': 'confirmed'
575+ }, context)
576+ if statement_pool.confirm_statement_from_lines(cr, uid, [st.id],
577+ context=context):
578+ # to see that the state of the statement has changed, we need
579+ # to update the whole view. Do that only if necessary.
580+ res = {
581+ 'type': 'ir.actions.client',
582+ 'tag': 'reload',
583+ }
584+
585+ return res
586+
587+ def has_reconciliation(self, cr, uid, ids, context=None):
588+ """Check if the line has some reconciliation. Return boolean."""
589+ if context is None:
590+ context = {}
591+
592+ for st_line in self.browse(cr, uid, ids, context=context):
593+ for move in st_line.move_ids:
594+ for move_line in move.line_id:
595+ if move_line.reconcile:
596+ # aha! we have some reconciliation!
597+ return True
598+
599+ # no reconciliation to worry about
600+ return False
601+
602+ def button_cancel(self, cr, uid, ids, context=None):
603+ """Check if a line is reconciled, and cancel it. Return action."""
604+ if context is None:
605+ context = {}
606+
607+ if self.has_reconciliation(cr, uid, ids, context=context):
608+ # ask confirmation, we have some reconciliation already
609+ return {
610+ 'type': 'ir.actions.act_window',
611+ 'res_model': 'wizard.cancel.statement.line',
612+ 'view_type': 'form',
613+ 'view_mode': 'form',
614+ 'target': 'new',
615+ 'context': context,
616+ }
617+
618+ # no reconciliation to worry about: we cancel our lines directly then
619+ return self.cancel(cr, uid, ids, context=context)
620+
621+ def cancel(self, cr, uid, ids, context=None):
622+ """Cancel one statement line, return action.
623+
624+ This is again similar to the method cancel in the account_banking
625+ module.
626+
627+ """
628+ if context is None:
629+ context = {}
630+ local_ctx = context.copy()
631+ # if account_constraints is installed, we need to tell it that moves
632+ # are being created by a statement, which is OK.
633+ # The module tries to prevent direct changes to the moves created by
634+ # bank statements.
635+ local_ctx['from_parent_object'] = True
636+
637+ move_pool = self.pool['account.move']
638+ statement_pool = self.pool['account.bank.statement']
639+
640+ st_line_ids = []
641+
642+ # to avoid duplicates if all lines come from the same statement
643+ statement_ids = set()
644+
645+ move_unlink_ids = []
646+ # harvest ids for various actions
647+ for st_line in self.browse(cr, uid, ids, context):
648+ if st_line.state != 'confirmed':
649+ continue
650+
651+ for move in st_line.move_ids:
652+ # We allow for people canceling and removing
653+ # the associated payments, which can lead to confirmed
654+ # statement lines without an associated move
655+ move_unlink_ids.append(move.id)
656+ # do we need to check that?
657+ if move.state != 'draft':
658+ raise orm.except_orm(
659+ _('Confirmed Journal Entry'),
660+ _('You cannot delete a confirmed Statement Line '
661+ 'associated to a Journal Entry that is posted.'))
662+ st_line_ids.append(st_line.id)
663+ if st_line.statement_id.state != 'draft':
664+ statement_ids.add(st_line.statement_id.id)
665+
666+ move_pool.button_cancel(
667+ cr, uid, move_unlink_ids, context=context)
668+
669+ move_pool.unlink(cr, uid, move_unlink_ids, context=local_ctx)
670+ self.write(cr, uid, st_line_ids, {
671+ 'state': 'draft',
672+ 'already_completed': False
673+ }, context=context)
674+ if statement_ids:
675+ # if we cancel one or more lines, the statement goes back to draft,
676+ # too
677+ statement_pool.write(cr, uid, list(statement_ids), {
678+ 'state': 'draft'
679+ }, context=context)
680+ # then we manually update the view of the statement
681+ return {
682+ 'type': 'ir.actions.client',
683+ 'tag': 'reload',
684+ }
685+ else:
686+ # no need to update the view then
687+ return {}
688+
689+ def unlink(self, cr, uid, ids, context=None):
690+ """Don't allow deletion of a confirmed statement line. Return super."""
691+ if type(ids) is int:
692+ ids = [ids]
693+ for line in self.browse(cr, uid, ids, context=context):
694+ if line.state == 'confirmed':
695+ raise orm.except_orm(
696+ _('Confirmed Statement Line'),
697+ _("You cannot delete a confirmed Statement Line"
698+ ": '%s'") % line.name)
699+ return super(StatementLine, self).unlink(
700+ cr, uid, ids, context=context)
701
702=== added file 'account_statement_cancel_line/statement_view.xml'
703--- account_statement_cancel_line/statement_view.xml 1970-01-01 00:00:00 +0000
704+++ account_statement_cancel_line/statement_view.xml 2014-06-13 10:06:12 +0000
705@@ -0,0 +1,28 @@
706+<?xml version="1.0" encoding="utf-8"?>
707+<openerp>
708+ <data>
709+
710+ <record id="view_bank_statement_form_cancel_line" model="ir.ui.view">
711+ <field name="name">account.bank.statement.form.</field>
712+ <field name="inherit_id" ref="account.view_bank_statement_form" />
713+ <field name="model">account.bank.statement</field>
714+ <field name="arch" type="xml">
715+ <data>
716+ <xpath expr="//field[@name='line_ids']/tree/field[@name='amount']"
717+ position="after">
718+ <field name="state"/>
719+ <button name="confirm" states="draft"
720+ string="Confirm transaction"
721+ icon="gtk-ok"
722+ type="object"/>
723+ <button name="button_cancel" states="confirmed"
724+ string="Cancel transaction"
725+ icon="gtk-cancel"
726+ type="object"/>
727+ </xpath>
728+ </data>
729+ </field>
730+ </record>
731+
732+ </data>
733+</openerp>
734
735=== added directory 'account_statement_cancel_line/test'
736=== added file 'account_statement_cancel_line/test/cancel_line.yml'
737--- account_statement_cancel_line/test/cancel_line.yml 1970-01-01 00:00:00 +0000
738+++ account_statement_cancel_line/test/cancel_line.yml 2014-06-13 10:06:12 +0000
739@@ -0,0 +1,80 @@
740+-
741+ In order to test the cancellation of statement lines, I need a statement
742+ profile.
743+-
744+ !record {model: account.statement.profile, id: profile_test}:
745+ name: Bank EUR Profile for automatic checks
746+ journal_id: account.bank_journal
747+ commission_account_id: account.a_expense
748+ company_id: base.main_company
749+-
750+ Now I create a statement. I create statment lines separately because I need
751+ to find each one by XML id
752+-
753+ !record {model: account.bank.statement, id: statement_test}:
754+ name: My Statement
755+ profile_id: profile_test
756+ company_id: base.main_company
757+-
758+ I create a first statement line
759+-
760+ !record {model: account.bank.statement.line, id: statement_line_1}:
761+ name: line1
762+ statement_id: statement_test
763+ ref: ref1
764+ date: '2014-01-20'
765+ amount: 100.0
766+-
767+ I create a second statement line
768+-
769+ !record {model: account.bank.statement.line, id: statement_line_2}:
770+ name: line2
771+ statement_id: statement_test
772+ ref: ref2
773+ date: '2014-01-25'
774+ amount: 200.0
775+-
776+ I check that the state of the statement is "Draft"
777+-
778+ !assert {model: account.bank.statement, id: statement_test}:
779+ - state == 'draft'
780+-
781+ I confirm the statement
782+-
783+ !python {model: account.bank.statement}: |
784+ result = self.button_confirm_bank(cr, uid, [ref("statement_test")])
785+-
786+ I check that the state of the statement is "Closed"
787+-
788+ !assert {model: account.bank.statement, id: statement_test}:
789+ - state == 'confirm'
790+-
791+ I check that the state of the statement line is "Confirmed"
792+-
793+ !assert {model: account.bank.statement.line, id: statement_line_1}:
794+ - state == 'confirmed'
795+-
796+ I check that a move was generated
797+-
798+ !assert {model: account.bank.statement.line, id: statement_line_1}:
799+ - move_ids
800+-
801+ Now I cancel a statement line
802+-
803+ !python {model: account.bank.statement.line}: |
804+ result = self.button_cancel(cr, uid, [ref("statement_line_1")])
805+-
806+ I check that the state of the statement went back to "Draft"
807+-
808+ !assert {model: account.bank.statement, id: statement_test}:
809+ - state == 'draft'
810+-
811+ I also check that the state of the statement line went back to "Draft"
812+-
813+ !assert {model: account.bank.statement.line, id: statement_line_1}:
814+ - state == 'draft'
815+-
816+ And the move is not there anymore
817+-
818+ !assert {model: account.bank.statement.line, id: statement_line_1}:
819+ - move_ids == []
820
821=== added file 'account_statement_cancel_line/test/confirm_statement_no_double_moves.yml'
822--- account_statement_cancel_line/test/confirm_statement_no_double_moves.yml 1970-01-01 00:00:00 +0000
823+++ account_statement_cancel_line/test/confirm_statement_no_double_moves.yml 2014-06-13 10:06:12 +0000
824@@ -0,0 +1,70 @@
825+-
826+ I want to check that if I confirm a line and then the whole statement,
827+ no duplicate moves are created.
828+ First, I need a statement profile.
829+-
830+ !record {model: account.statement.profile, id: profile_test_10}:
831+ name: Another Bank EUR Profile for automatic checks
832+ journal_id: account.bank_journal
833+ commission_account_id: account.a_expense
834+ company_id: base.main_company
835+-
836+ Now I create a statement. I create statment lines separately because I need
837+ to find each one by XML id
838+-
839+ !record {model: account.bank.statement, id: statement_test_10}:
840+ name: My Statement
841+ profile_id: profile_test_10
842+ company_id: base.main_company
843+-
844+ I create a first statement line
845+-
846+ !record {model: account.bank.statement.line, id: statement_line_11}:
847+ name: line11
848+ statement_id: statement_test_10
849+ ref: ref11
850+ date: '2014-01-20'
851+ amount: 100.0
852+-
853+ I create a second statement line
854+-
855+ !record {model: account.bank.statement.line, id: statement_line_12}:
856+ name: line12
857+ statement_id: statement_test_10
858+ ref: ref12
859+ date: '2014-01-25'
860+ amount: 200.0
861+-
862+ Now I confirm only the first statement line
863+-
864+ !python {model: account.bank.statement.line}: |
865+ result = self.confirm(cr, uid, [ref("statement_line_11")])
866+-
867+ I check that the state of the statement is still "Draft"
868+-
869+ !assert {model: account.bank.statement, id: statement_test_10}:
870+ - state == 'draft'
871+-
872+ I confirm the statement
873+-
874+ !python {model: account.bank.statement}: |
875+ result = self.button_confirm_bank(cr, uid, [ref("statement_test_10")])
876+-
877+ I check that the state of the statement is "Closed"
878+-
879+ !assert {model: account.bank.statement, id: statement_test_10}:
880+ - state == 'confirm'
881+-
882+ I check that a move was generated for the first statment line
883+ and that the state is confirmed
884+-
885+ !assert {model: account.bank.statement.line, id: statement_line_11}:
886+ - len(move_ids) == 1
887+ - state == 'confirmed'
888+-
889+ I check that a move was generated for the second statment line
890+ and that the state is confirmed
891+-
892+ !assert {model: account.bank.statement.line, id: statement_line_12}:
893+ - len(move_ids) == 1
894+ - state == 'confirmed'
895
896=== added file 'account_statement_cancel_line/test/test_confirm_last_line_balance_check.yml'
897--- account_statement_cancel_line/test/test_confirm_last_line_balance_check.yml 1970-01-01 00:00:00 +0000
898+++ account_statement_cancel_line/test/test_confirm_last_line_balance_check.yml 2014-06-13 10:06:12 +0000
899@@ -0,0 +1,42 @@
900+-
901+ I want to check that the behaviour when I confirm the only line of a
902+ statement that is draft.
903+-
904+ I start with a profile
905+-
906+ !record {model: account.statement.profile, id: profile_test3}:
907+ name: Profile for automatic checks
908+ balance_check: True
909+ journal_id: account.bank_journal
910+ commission_account_id: account.a_expense
911+-
912+ Now I create a statement.
913+-
914+ !record {model: account.bank.statement, id: statement_test3}:
915+ name: My Statement
916+ profile_id: profile_test3
917+ company_id: base.main_company
918+ balance_start: 100.0
919+ balance_end_real: 150.0
920+-
921+ I create a statement line
922+-
923+ !record {model: account.bank.statement.line, id: statement_line_3}:
924+ name: line1
925+ statement_id: statement_test3
926+ ref: line1
927+ date: '2014-01-20'
928+ amount: 10.0
929+-
930+ Now I confirm the statement line. That should not pass the balance check
931+-
932+ !python {model: account.bank.statement.line}: |
933+ # i.e. assertRaises
934+ from openerp.osv.osv import except_osv
935+ try:
936+ self.confirm(cr, uid, [ref("statement_line_3")])
937+ except except_osv as exc:
938+ print exc.args
939+ assert u'The statement balance is incorrect' in exc.args[1], 'We got an error which is not what we expected'
940+ else:
941+ raise AssertionError('Balance check should have blocked this.')
942
943=== added file 'account_statement_cancel_line/test/test_confirm_last_line_no_balance_check.yml'
944--- account_statement_cancel_line/test/test_confirm_last_line_no_balance_check.yml 1970-01-01 00:00:00 +0000
945+++ account_statement_cancel_line/test/test_confirm_last_line_no_balance_check.yml 2014-06-13 10:06:12 +0000
946@@ -0,0 +1,44 @@
947+-
948+ I want to check that the behaviour when I confirm the only line of a
949+ statement that is draft.
950+-
951+ I start with a profile
952+-
953+ !record {model: account.statement.profile, id: profile_test4}:
954+ name: Profile for automatic checks
955+ balance_check: False
956+ journal_id: account.bank_journal
957+ commission_account_id: account.a_expense
958+-
959+ Now I create a statement.
960+-
961+ !record {model: account.bank.statement, id: statement_test4}:
962+ name: My Statement
963+ profile_id: profile_test4
964+ company_id: base.main_company
965+ balance_start: 100.0
966+ balance_end_real: 150.0
967+-
968+ I create a statement line
969+-
970+ !record {model: account.bank.statement.line, id: statement_line_4}:
971+ name: line1
972+ statement_id: statement_test4
973+ ref: line1
974+ date: '2014-01-20'
975+ amount: 10.0
976+-
977+ Now I confirm the statement line
978+-
979+ !python {model: account.bank.statement.line}: |
980+ result = self.confirm(cr, uid, [ref("statement_line_4")])
981+-
982+ The line should be confirmed
983+-
984+ !assert {model: account.bank.statement.line, id: statement_line_4}:
985+ - state == 'confirmed'
986+-
987+ And the statement should be confirmed as well
988+-
989+ !assert {model: account.bank.statement, id: statement_test4}:
990+ - state == 'confirm'
991
992=== added directory 'account_statement_cancel_line/tests'
993=== added directory 'account_statement_cancel_line/wizard'
994=== added file 'account_statement_cancel_line/wizard/__init__.py'
995--- account_statement_cancel_line/wizard/__init__.py 1970-01-01 00:00:00 +0000
996+++ account_statement_cancel_line/wizard/__init__.py 2014-06-13 10:06:12 +0000
997@@ -0,0 +1,24 @@
998+# -*- coding: utf-8 -*-
999+###############################################################################
1000+# #
1001+# Author: Leonardo Pistone
1002+# Copyright 2014 Camptocamp SA
1003+# #
1004+# This program is free software: you can redistribute it and/or modify #
1005+# it under the terms of the GNU Affero General Public License as #
1006+# published by the Free Software Foundation, either version 3 of the #
1007+# License, or (at your option) any later version. #
1008+# #
1009+# This program is distributed in the hope that it will be useful, #
1010+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
1011+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
1012+# GNU Affero General Public License for more details. #
1013+# #
1014+# You should have received a copy of the GNU Affero General Public License #
1015+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
1016+# #
1017+###############################################################################
1018+"""Wizard for asking the confirmation when some move is reconciled."""
1019+
1020+import cancel_statement # noqa
1021+import cancel_statement_line # noqa
1022
1023=== added file 'account_statement_cancel_line/wizard/cancel_line.py'
1024--- account_statement_cancel_line/wizard/cancel_line.py 1970-01-01 00:00:00 +0000
1025+++ account_statement_cancel_line/wizard/cancel_line.py 2014-06-13 10:06:12 +0000
1026@@ -0,0 +1,46 @@
1027+# -*- coding: utf-8 -*-
1028+###############################################################################
1029+# #
1030+# Author: Leonardo Pistone
1031+# Copyright 2014 Camptocamp SA
1032+# #
1033+# This program is free software: you can redistribute it and/or modify #
1034+# it under the terms of the GNU Affero General Public License as #
1035+# published by the Free Software Foundation, either version 3 of the #
1036+# License, or (at your option) any later version. #
1037+# #
1038+# This program is distributed in the hope that it will be useful, #
1039+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
1040+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
1041+# GNU Affero General Public License for more details. #
1042+# #
1043+# You should have received a copy of the GNU Affero General Public License #
1044+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
1045+# #
1046+###############################################################################
1047+"""Wizard to Cancel a Statement Line."""
1048+
1049+from openerp.osv import orm
1050+
1051+
1052+class wizard_cancel_statement_line(orm.TransientModel):
1053+
1054+ """Wizard to Cancel a Statement Line."""
1055+
1056+ _name = "wizard.cancel.statement.line"
1057+ _description = "Cancel Statement Line"
1058+ _columns = {
1059+ }
1060+
1061+ def unreconcile(self, cr, uid, ids, context=None):
1062+ """Proceed and cancel the statement line, return Action.
1063+
1064+ This will delete the move.line and the reconciliation.
1065+
1066+ """
1067+ return self.pool['account.bank.statement.line'].cancel(
1068+ cr,
1069+ uid,
1070+ context['active_ids'],
1071+ context=context
1072+ )
1073
1074=== added file 'account_statement_cancel_line/wizard/cancel_statement.py'
1075--- account_statement_cancel_line/wizard/cancel_statement.py 1970-01-01 00:00:00 +0000
1076+++ account_statement_cancel_line/wizard/cancel_statement.py 2014-06-13 10:06:12 +0000
1077@@ -0,0 +1,51 @@
1078+# -*- coding: utf-8 -*-
1079+###############################################################################
1080+# #
1081+# Author: Leonardo Pistone
1082+# Copyright 2014 Camptocamp SA
1083+# #
1084+# This program is free software: you can redistribute it and/or modify #
1085+# it under the terms of the GNU Affero General Public License as #
1086+# published by the Free Software Foundation, either version 3 of the #
1087+# License, or (at your option) any later version. #
1088+# #
1089+# This program is distributed in the hope that it will be useful, #
1090+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
1091+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
1092+# GNU Affero General Public License for more details. #
1093+# #
1094+# You should have received a copy of the GNU Affero General Public License #
1095+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
1096+# #
1097+###############################################################################
1098+"""Wizard to Cancel a Statement."""
1099+
1100+from openerp.osv import orm, fields
1101+
1102+
1103+class wizard_cancel_statement(orm.TransientModel):
1104+
1105+ """Wizard to Cancel a Statement."""
1106+
1107+ _name = "wizard.cancel.statement"
1108+ _description = "Cancel Statement"
1109+ _columns = {
1110+ 'reconcile_warning': fields.boolean(
1111+ 'Show reconcile warning',
1112+ help='This is a hidden field set with a default in the context '
1113+ 'to choose between two different warning messages in the view.'
1114+ ),
1115+ }
1116+
1117+ def do_cancel_button(self, cr, uid, ids, context=None):
1118+ """Proceed and cancel the statement, return Action.
1119+
1120+ This will delete the move.line and the reconciliation.
1121+
1122+ """
1123+ return self.pool['account.bank.statement'].do_cancel(
1124+ cr,
1125+ uid,
1126+ context['active_ids'],
1127+ context=context
1128+ )
1129
1130=== added file 'account_statement_cancel_line/wizard/cancel_statement_line.py'
1131--- account_statement_cancel_line/wizard/cancel_statement_line.py 1970-01-01 00:00:00 +0000
1132+++ account_statement_cancel_line/wizard/cancel_statement_line.py 2014-06-13 10:06:12 +0000
1133@@ -0,0 +1,46 @@
1134+# -*- coding: utf-8 -*-
1135+###############################################################################
1136+# #
1137+# Author: Leonardo Pistone
1138+# Copyright 2014 Camptocamp SA
1139+# #
1140+# This program is free software: you can redistribute it and/or modify #
1141+# it under the terms of the GNU Affero General Public License as #
1142+# published by the Free Software Foundation, either version 3 of the #
1143+# License, or (at your option) any later version. #
1144+# #
1145+# This program is distributed in the hope that it will be useful, #
1146+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
1147+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
1148+# GNU Affero General Public License for more details. #
1149+# #
1150+# You should have received a copy of the GNU Affero General Public License #
1151+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
1152+# #
1153+###############################################################################
1154+"""Wizard to Cancel a Statement Line."""
1155+
1156+from openerp.osv import orm
1157+
1158+
1159+class wizard_cancel_statement_line(orm.TransientModel):
1160+
1161+ """Wizard to Cancel a Statement Line."""
1162+
1163+ _name = "wizard.cancel.statement.line"
1164+ _description = "Cancel Statement Line"
1165+ _columns = {
1166+ }
1167+
1168+ def unreconcile(self, cr, uid, ids, context=None):
1169+ """Proceed and cancel the statement line, return Action.
1170+
1171+ This will delete the move.line and the reconciliation.
1172+
1173+ """
1174+ return self.pool['account.bank.statement.line'].cancel(
1175+ cr,
1176+ uid,
1177+ context['active_ids'],
1178+ context=context
1179+ )
1180
1181=== added file 'account_statement_cancel_line/wizard/cancel_statement_line_view.xml'
1182--- account_statement_cancel_line/wizard/cancel_statement_line_view.xml 1970-01-01 00:00:00 +0000
1183+++ account_statement_cancel_line/wizard/cancel_statement_line_view.xml 2014-06-13 10:06:12 +0000
1184@@ -0,0 +1,22 @@
1185+<?xml version="1.0" encoding="utf-8"?>
1186+<openerp>
1187+ <data>
1188+
1189+ <record id="view_wizard_cancel_statement_line_form" model="ir.ui.view">
1190+ <field name="name">view.wizard.cancel.statement.line.form</field>
1191+ <field name="model">wizard.cancel.statement.line</field>
1192+ <field name="arch" type="xml">
1193+ <form string="Reconciled Entries" version="7.0">
1194+ <separator string="Unreconciliation"/>
1195+ <label string="Some entries are already reconciled. Do you want to unreconcile them and proceed?"/>
1196+ <footer>
1197+ <button name="unreconcile" string="Unreconcile" type="object" class="oe_highlight"/>
1198+ or
1199+ <button string="Cancel" class="oe_link" special="cancel"/>
1200+ </footer>
1201+ </form>
1202+ </field>
1203+ </record>
1204+
1205+ </data>
1206+</openerp>
1207
1208=== added file 'account_statement_cancel_line/wizard/cancel_statement_view.xml'
1209--- account_statement_cancel_line/wizard/cancel_statement_view.xml 1970-01-01 00:00:00 +0000
1210+++ account_statement_cancel_line/wizard/cancel_statement_view.xml 2014-06-13 10:06:12 +0000
1211@@ -0,0 +1,24 @@
1212+<?xml version="1.0" encoding="utf-8"?>
1213+<openerp>
1214+ <data>
1215+
1216+ <record id="view_wizard_cancel_statement_form" model="ir.ui.view">
1217+ <field name="name">view.wizard.cancel.statement.form</field>
1218+ <field name="model">wizard.cancel.statement</field>
1219+ <field name="arch" type="xml">
1220+ <form string="Reconciled Entries" version="7.0">
1221+ <separator string="Cancel statement"/>
1222+ <field name="reconcile_warning" invisible="1" />
1223+ <label attrs="{'invisible': [('reconcile_warning', '=', False)]}" string="Some entries are already reconciled. Do you want to unreconcile them and proceed?"/>
1224+ <label attrs="{'invisible': [('reconcile_warning', '=', True)]}" string="Cancelling the statement will delete the generated Journal Entries (if un posted) and could take a long time for a long statement. Do you want to proceed?"/>
1225+ <footer>
1226+ <button name="do_cancel_button" string="Proceed" type="object" class="oe_highlight"/>
1227+ or
1228+ <button string="Cancel" class="oe_link" special="cancel"/>
1229+ </footer>
1230+ </form>
1231+ </field>
1232+ </record>
1233+
1234+ </data>
1235+</openerp>

Subscribers

People subscribed via source and target branches