Merge lp:~camptocamp/account-financial-tools/account_cancel_invoice_check_voucher into lp:~account-core-editors/account-financial-tools/7.0

Proposed by Vincent Renaville@camptocamp
Status: Superseded
Proposed branch: lp:~camptocamp/account-financial-tools/account_cancel_invoice_check_voucher
Merge into: lp:~account-core-editors/account-financial-tools/7.0
Diff against target: 123 lines (+107/-0)
3 files modified
account_cancel_invoice_check_voucher/__init__.py (+23/-0)
account_cancel_invoice_check_voucher/__openerp__.py (+32/-0)
account_cancel_invoice_check_voucher/account_invoice.py (+52/-0)
To merge this branch: bzr merge lp:~camptocamp/account-financial-tools/account_cancel_invoice_check_voucher
Reviewer Review Type Date Requested Status
Nicolas Bessi - Camptocamp (community) Needs Fixing
Guewen Baconnier @ Camptocamp Needs Fixing
Review via email: mp+143308@code.launchpad.net

This proposal has been superseded by a proposal from 2013-01-28.

Description of the change

[ADD] account_cancel_invoice_check_voucher : contraint to not be able to cancel an invoice already import in bank statement with a voucher

To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :
review: Needs Fixing
98. By Vincent Renaville@camptocamp

[FIX] correction regarding Guewen Baconnier @ Camptocamp comments

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

Hello,

It seems you did not take the corrected description form other branch in __openerp__.py.
You should avoid one character variable, i is not meaningful inv is a better name.
Line 113 is too long.

Nicolas

review: Needs Fixing
99. By Alexandre Fayolle - camptocamp

[IMP] a few points:

* typos in strings
* capitalize all SQL keywords in the query
* fixed prototype of action_cancel in 7.0

100. By Vincent Renaville@camptocamp

[FIX] improve sql query

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'account_cancel_invoice_check_voucher'
2=== added file 'account_cancel_invoice_check_voucher/__init__.py'
3--- account_cancel_invoice_check_voucher/__init__.py 1970-01-01 00:00:00 +0000
4+++ account_cancel_invoice_check_voucher/__init__.py 2013-01-16 09:09:27 +0000
5@@ -0,0 +1,23 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# Author Vincent Renaville. Copyright 2012 Camptocamp SA
10+#
11+# This program is free software: you can redistribute it and/or modify
12+# it under the terms of the GNU Affero General Public License as
13+# published by the Free Software Foundation, either version 3 of the
14+# License, or (at your option) any later version.
15+#
16+# This program is distributed in the hope that it will be useful,
17+# but WITHOUT ANY WARRANTY; without even the implied warranty of
18+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+# GNU Affero General Public License for more details.
20+#
21+# You should have received a copy of the GNU Affero General Public License
22+# along with this program. If not, see <http://www.gnu.org/licenses/>.
23+#
24+##############################################################################
25+
26+from . import account_invoice
27+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
28+
29
30=== added file 'account_cancel_invoice_check_voucher/__openerp__.py'
31--- account_cancel_invoice_check_voucher/__openerp__.py 1970-01-01 00:00:00 +0000
32+++ account_cancel_invoice_check_voucher/__openerp__.py 2013-01-16 09:09:27 +0000
33@@ -0,0 +1,32 @@
34+# -*- coding: utf-8 -*-
35+##############################################################################
36+#
37+# Author Vincent Renaville. Copyright 2012 Camptocamp SA
38+#
39+# This program is free software: you can redistribute it and/or modify
40+# it under the terms of the GNU Affero General Public License as
41+# published by the Free Software Foundation, either version 3 of the
42+# License, or (at your option) any later version.
43+#
44+# This program is distributed in the hope that it will be useful,
45+# but WITHOUT ANY WARRANTY; without even the implied warranty of
46+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47+# GNU Affero General Public License for more details.
48+#
49+# You should have received a copy of the GNU Affero General Public License
50+# along with this program. If not, see <http://www.gnu.org/licenses/>.
51+#
52+##############################################################################
53+{
54+ "name" : "Cancel invoice, check on bank statement",
55+ "version" : "1.0",
56+ "depends" : ["base", "account","account_voucher","account_cancel"],
57+ "author" : "Camptocamp",
58+ "description": """Contraint to not be able to cancel an invoice already import in bank statement with a voucher
59+ """,
60+ 'website': 'http://www.camptocamp.com',
61+ 'date' : [],
62+ 'installable': True,
63+ 'active': False,
64+}
65+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
66
67=== added file 'account_cancel_invoice_check_voucher/account_invoice.py'
68--- account_cancel_invoice_check_voucher/account_invoice.py 1970-01-01 00:00:00 +0000
69+++ account_cancel_invoice_check_voucher/account_invoice.py 2013-01-16 09:09:27 +0000
70@@ -0,0 +1,52 @@
71+# -*- coding: utf-8 -*-
72+##############################################################################
73+#
74+# Copyright (c) 2012 Camptocamp (http://www.camptocamp.com)
75+# All Right Reserved
76+#
77+# Author : Vincent Renaville (Camptocamp)
78+#
79+# This program is free software: you can redistribute it and/or modify
80+# it under the terms of the GNU Affero General Public License as
81+# published by the Free Software Foundation, either version 3 of the
82+# License, or (at your option) any later version.
83+#
84+# This program is distributed in the hope that it will be useful,
85+# but WITHOUT ANY WARRANTY; without even the implied warranty of
86+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
87+# GNU Affero General Public License for more details.
88+#
89+# You should have received a copy of the GNU Affero General Public License
90+# along with this program. If not, see <http://www.gnu.org/licenses/>.
91+#
92+##############################################################################
93+
94+from openerp.tools.translate import _
95+from openerp.osv import osv, orm
96+
97+class account_invoice(orm.TransientModel):
98+ _inherit = "account.invoice"
99+
100+ def action_cancel(self, cr, uid, ids, *args):
101+ invoices = self.read(cr, uid, ids, ['move_id', 'payment_ids'])
102+ for i in invoices:
103+ if i['move_id']:
104+ ## This invoice have a move line, we search move_line concerned by this move
105+ cr.execute("""SELECT abs.name as statement_name,
106+ abs.date as statement_date,
107+ absl.name
108+ FROM account_bank_statement_line as absl
109+ INNER JOIN account_bank_statement as abs
110+ ON absl.statement_id = abs.id
111+ WHERE voucher_id in
112+ ( SELECT voucher_id FROM account_voucher_line WHERE move_line_id in
113+ (SELECT id FROM account_move_line WHERE move_id = %s )) limit 1""", (i['move_id'][0],))
114+ statement_lines = cr.dictfetchone()
115+ if statement_lines:
116+ raise osv.except_osv(_('Error !'),
117+ _('Invoice already import in bank statment (%s) at %s on line %s'
118+ % (statement_lines['statement_name'],
119+ statement_lines['statement_date'],
120+ statement_lines['name'],)))
121+
122+ return super(account_invoice,self).action_cancel(cr, uid, ids, *args)
123\ No newline at end of file

Subscribers

People subscribed via source and target branches