Merge lp:~camptocamp/banking-addons/bank-statement-reconcile-70-fix-on-change-voucher into lp:banking-addons/bank-statement-reconcile-70

Proposed by Joël Grand-Guillaume @ camptocamp
Status: Merged
Approved by: Alexandre Fayolle - camptocamp
Approved revision: 85
Merged at revision: 80
Proposed branch: lp:~camptocamp/banking-addons/bank-statement-reconcile-70-fix-on-change-voucher
Merge into: lp:banking-addons/bank-statement-reconcile-70
Diff against target: 189 lines (+67/-27)
7 files modified
account_statement_ext/__init__.py (+1/-0)
account_statement_ext/__openerp__.py (+6/-3)
account_statement_ext/statement.py (+4/-2)
account_statement_ext/voucher.py (+49/-0)
account_statement_ext_voucher/__init__.py (+0/-2)
account_statement_ext_voucher/__openerp__.py (+7/-3)
account_statement_ext_voucher/statement_voucher_view.xml (+0/-17)
To merge this branch: bzr merge lp:~camptocamp/banking-addons/bank-statement-reconcile-70-fix-on-change-voucher
Reviewer Review Type Date Requested Status
Alexandre Fayolle - camptocamp code review, no test Approve
Joël Grand-Guillaume @ camptocamp Pending
Review via email: mp+146066@code.launchpad.net

This proposal supersedes a proposal from 2013-01-31.

Description of the change

Statement ext collide with voucher for some on change. As it almost impossible to have a finance installation without voucher, we may add voucher as a dependence on statement ext in order to fix on change, and silent unwanted voucher behavior.

We also add the right periode computation for each line in the voucher, as it was previously done in the account_statement_ext_voucher. We mark also this one as deprecated.

To post a comment you must log in.
Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote : Posted in a previous version of this proposal

If an other module has the same trouble the account_statement_ext addon onchange_partner_id is not "polite" and will not support the fact to have a None profile_id, maybe I should let the original signature

Nicolas

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote : Posted in a previous version of this proposal

I reindented the patch a little bit.

LGTM.

review: Approve (code review, no test)
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote : Posted in a previous version of this proposal

As discussed internally, we should always include the voucher as it depends on "sale". I suggest that I made the following modification:

- Mark the account_satement_ext_voucher as deprecated
- Take the little patch that is inside and add it to account_statement_ext
- Let the dependance on account_voucher in account_statement_ext

The thing is we can't get rid of the voucher anymore in version 7.0 :(

review: Needs Fixing
Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote : Posted in a previous version of this proposal

Missing voucher.py

81. By Joël Grand-Guillaume @ camptocamp

[ADD] Missing voucher.py file... Better with it, sorry.

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

account_statement_ext/__openerp__.py: you are changing the db model, please increment the version number.

l. 28: s/It also add/It also adds/

l. 66: are your sure about the copyright years?

l. 107-108: these lines can be removed as you are just passing the context to super().create

l. 145 and following: what are the effects of these changes on an instance with the module installed ?

review: Needs Fixing
82. By Nicolas Bessi - Camptocamp

[TYPO]

83. By Nicolas Bessi - Camptocamp

[FIX] version number

84. By Nicolas Bessi - Camptocamp

[IMP] dead code

85. By Nicolas Bessi - Camptocamp

[FIX] copyright year

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

Hello,

I have fixed the branch following remarks. Setting addons as not installable should not have functional impact as it as been merged in statement ext addon. I do not know how the server will managed the fact of an installed module set to uninstallable. It will probably do nothing, but it may prevent the unsinstall of the addon

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

LGTM :-)

review: Approve (code review, no test)
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) :
review: Approve (code review, no test)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_statement_ext/__init__.py'
2--- account_statement_ext/__init__.py 2012-12-20 13:37:01 +0000
3+++ account_statement_ext/__init__.py 2013-02-04 15:23:22 +0000
4@@ -22,3 +22,4 @@
5 import statement
6 import report
7 import account
8+import voucher
9\ No newline at end of file
10
11=== modified file 'account_statement_ext/__openerp__.py'
12--- account_statement_ext/__openerp__.py 2012-12-20 13:37:01 +0000
13+++ account_statement_ext/__openerp__.py 2013-02-04 15:23:22 +0000
14@@ -2,7 +2,7 @@
15 ##############################################################################
16 #
17 # Author: Nicolas Bessi, Joel Grand-Guillaume
18-# Copyright 2011-2012 Camptocamp SA
19+# Copyright 2011-2013 Camptocamp SA
20 #
21 # This program is free software: you can redistribute it and/or modify
22 # it under the terms of the GNU Affero General Public License as
23@@ -20,14 +20,15 @@
24 ##############################################################################
25
26 {'name': "Bank statement extension and profiles",
27- 'version': '1.1',
28+ 'version': '1.2.0',
29 'author': 'Camptocamp',
30 'maintainer': 'Camptocamp',
31 'category': 'Finance',
32 'complexity': 'normal',
33 'depends': [
34 'account',
35- 'report_webkit'
36+ 'report_webkit',
37+ 'account_voucher'
38 ],
39 'description': """
40 Improve the basic bank statement, by adding various new features,
41@@ -62,6 +63,8 @@
42 all the erronous line in a same popup instead of raising and crashing on every step.
43
44 4) Remove the period on the bank statement, and compute it for each line based on their date instead.
45+ It also adds this feature in the voucher in order to compute the period correctly.
46+
47
48 5) Cancelling a bank statement is much more easy and will cancel all related entries, unreconcile them,
49 and finally delete them.
50
51=== modified file 'account_statement_ext/statement.py'
52--- account_statement_ext/statement.py 2013-01-28 09:48:10 +0000
53+++ account_statement_ext/statement.py 2013-02-04 15:23:22 +0000
54@@ -551,7 +551,7 @@
55 res['account_id'] = receiv_account
56 return res
57
58- def onchange_partner_id(self, cr, uid, ids, partner_id, profile_id, context=None):
59+ def onchange_partner_id(self, cr, uid, ids, partner_id, profile_id=None, context=None):
60 """
61 Override of the basic method as we need to pass the profile_id in the on_change_type
62 call.
63@@ -571,7 +571,9 @@
64 type = 'customer'
65 res_type = self.onchange_type(cr, uid, ids, partner_id, type, profile_id, context=context) # Chg
66 if res_type['value'] and res_type['value'].get('account_id', False):
67- return {'value': {'type': type, 'account_id': res_type['value']['account_id']}}
68+ return {'value': {'type': type,
69+ 'account_id': res_type['value']['account_id'],
70+ 'voucher_id': False}}
71 return {'value': {'type': type}}
72
73 def onchange_type(self, cr, uid, line_id, partner_id, type, profile_id, context=None):
74
75=== added file 'account_statement_ext/voucher.py'
76--- account_statement_ext/voucher.py 1970-01-01 00:00:00 +0000
77+++ account_statement_ext/voucher.py 2013-02-04 15:23:22 +0000
78@@ -0,0 +1,49 @@
79+# -*- coding: utf-8 -*-
80+##############################################################################
81+#
82+# Author: Joel Grand-Guillaume
83+# Copyright 2011-2013 Camptocamp SA
84+#
85+# This program is free software: you can redistribute it and/or modify
86+# it under the terms of the GNU Affero General Public License as
87+# published by the Free Software Foundation, either version 3 of the
88+# License, or (at your option) any later version.
89+#
90+# This program is distributed in the hope that it will be useful,
91+# but WITHOUT ANY WARRANTY; without even the implied warranty of
92+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
93+# GNU Affero General Public License for more details.
94+#
95+# You should have received a copy of the GNU Affero General Public License
96+# along with this program. If not, see <http://www.gnu.org/licenses/>.
97+#
98+##############################################################################
99+
100+from openerp.osv.orm import Model
101+
102+
103+class AccountVoucher(Model):
104+
105+ _inherit = 'account.voucher'
106+
107+ def _get_period(self, cr, uid, context=None):
108+ """If period not in context, take it from the move lines"""
109+ if not context.get('period_id') and context.get('move_line_ids'):
110+ res = self.pool.get('account.move.line').browse(
111+ cr, uid, context.get('move_line_ids'), context=context)[0].period_id.id
112+ context['period_id'] = res
113+ elif context.get('date'):
114+ periods = self.pool.get('account.period').find(
115+ cr, uid, dt=context['date'], context=context)
116+ if periods:
117+ context['period_id'] = periods[0]
118+ return super(AccountVoucher, self)._get_period(cr, uid, context)
119+
120+ def create(self, cr, uid, values, context=None):
121+ """If no period defined in values, ask it from moves."""
122+ if context is None:
123+ context = {}
124+ if not values.get('period_id'):
125+ ctx = dict(context, date=values.get('date'))
126+ values['period_id'] = self._get_period(cr, uid, ctx)
127+ return super(AccountVoucher, self).create(cr, uid, values, context)
128
129=== modified file 'account_statement_ext_voucher/__init__.py'
130--- account_statement_ext_voucher/__init__.py 2012-06-20 14:10:01 +0000
131+++ account_statement_ext_voucher/__init__.py 2013-02-04 15:23:22 +0000
132@@ -18,5 +18,3 @@
133 # along with this program. If not, see <http://www.gnu.org/licenses/>.
134 #
135 ##############################################################################
136-
137-import statement_voucher
138
139=== modified file 'account_statement_ext_voucher/__openerp__.py'
140--- account_statement_ext_voucher/__openerp__.py 2013-01-10 15:09:55 +0000
141+++ account_statement_ext_voucher/__openerp__.py 2013-02-04 15:23:22 +0000
142@@ -30,8 +30,12 @@
143 'account_voucher'
144 ],
145 'description': """
146- This module is only needed when using account_bank_statement_ext with voucher in order to compute the period
147+ This module is deprecated. It was only needed when using account_bank_statement_ext with voucher in order to compute the period
148 correctly. This is mainly because with account_bank_statement_ext, the period is computed for each line.
149+
150+ Now, we include this in the account_statement_ext module and added a dependencies on account_voucher (mainly cause we can't get
151+ rid of the voucher in version 7.0).
152+
153 """,
154 'website': 'http://www.camptocamp.com',
155 'init_xml': [],
156@@ -40,9 +44,9 @@
157 ],
158 'demo_xml': [],
159 'test': [],
160- 'installable': True,
161+ 'installable': False,
162 'images': [],
163- 'auto_install': True,
164+ 'auto_install': False,
165 'license': 'AGPL-3',
166
167 }
168
169=== removed file 'account_statement_ext_voucher/statement_voucher_view.xml'
170--- account_statement_ext_voucher/statement_voucher_view.xml 2012-07-04 11:51:39 +0000
171+++ account_statement_ext_voucher/statement_voucher_view.xml 1970-01-01 00:00:00 +0000
172@@ -1,17 +0,0 @@
173-<?xml version="1.0" encoding="UTF-8"?>
174-<openerp>
175- <data>
176-
177- <record id="account_voucher.view_bank_statement_form_invoice" model="ir.ui.view">
178- <field name="name">account.bank.statement.invoice.form.inherit</field>
179- <field name="model">account.bank.statement</field>
180- <field name="type">form</field>
181- <field name="inherit_id" ref="account.view_bank_statement_form"/>
182- <field name="arch" type="xml">
183- <field name="currency" invisible="1" position="after">
184- </field>
185- </field>
186- </record>
187-
188- </data>
189-</openerp>

Subscribers

People subscribed via source and target branches