Merge lp:~acsone-openerp/account-financial-report/7.0-bug-1312732-lmi into lp:~account-report-core-editor/account-financial-report/7.0

Proposed by Laurent Mignon (Acsone)
Status: Needs review
Proposed branch: lp:~acsone-openerp/account-financial-report/7.0-bug-1312732-lmi
Merge into: lp:~account-report-core-editor/account-financial-report/7.0
Diff against target: 74 lines (+39/-18)
2 files modified
account_financial_report_webkit/account_move_line.py (+0/-18)
account_financial_report_webkit/migrations/7.0.1.0.2/post-migration.py (+39/-0)
To merge this branch: bzr merge lp:~acsone-openerp/account-financial-report/7.0-bug-1312732-lmi
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza Needs Resubmitting
Yannick Vaucher @ Camptocamp Needs Information
Review via email: mp+217240@code.launchpad.net

Description of the change

[FIX] lp:1312732
Use the migration machinery to launch the initialization of the newly created column on account_move_line only on the first installation of the module account_financial_report_webkit

To post a comment you must log in.

LGTM

thanks for the contrib!

review: Approve (code review, no test)
Pedro Manuel Baeza (pedro.baeza) wrote :

This method has been removed from 8.0 version, so I'm wondering if it's convenient to change this in 7 to revert back again on 8.

Regards.

review: Needs Information
Laurent Mignon (Acsone) (lmi) wrote :

HI,

Finally not sure if it's the right way to solve our problem since Odoo has decided to remove the call to migration scripts on first install of a module.... :( https://bugs.launchpad.net/openobject-server/+bug/1314680

Regards,

lmi

You are right forgot that sudden move from Odoo

At least it fixes this issue in 7.0 but this would be more effort when porting to 8.0.

Thus I revert my review as we need to find an other way of ensuring values are defined.

BTW shouldn't store be computed when adding the column on install?

review: Needs Information
Laurent Mignon (Acsone) (lmi) wrote :

Hi,
s
Following a discussion with Christophe Simonis at Opendays, an alternative to the migration script for fresh install has been implemented (https://github.com/odoo/odoo/commit/4105b5f0285821d8056c721b5fd50b9cae902988and) and merged for V8. For V7 the system will remain unchanged. It's now probably safe to merge this MP for V7 and use the new post_init_hook in the future V8 branch...

Pedro Manuel Baeza (pedro.baeza) wrote :
review: Needs Resubmitting

Unmerged revisions

88. By Laurent Mignon (Acsone) on 2014-04-25

Use the migration machinery to launch the initialization of the newly created column on account_move_line only on the first installation of the module account_financial_report_webkit

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_financial_report_webkit/account_move_line.py'
2--- account_financial_report_webkit/account_move_line.py 2012-12-11 16:32:26 +0000
3+++ account_financial_report_webkit/account_move_line.py 2014-04-25 13:34:20 +0000
4@@ -28,24 +28,6 @@
5 Last rec date is the date of the last reconciliation (full or partial) account move line"""
6 _inherit = 'account.move.line'
7
8- def init(self, cr):
9- ##We do not want to catch error as if sql is not run it will give invalid data
10- cr.execute("UPDATE account_move_line as acm "
11- " SET last_rec_date ="
12- " (SELECT date from account_move_line"
13- " WHERE reconcile_id = acm.reconcile_id"
14- " AND reconcile_id IS NOT NULL"
15- " ORDER BY date DESC LIMIT 1)"
16- " WHERE last_rec_date is null;")
17-
18- cr.execute("UPDATE account_move_line as acm "
19- " SET last_rec_date ="
20- " (SELECT date from account_move_line"
21- " WHERE reconcile_partial_id = acm.reconcile_partial_id"
22- " AND reconcile_partial_id IS NOT NULL"
23- " ORDER BY date DESC LIMIT 1)"
24- " WHERE last_rec_date is null;")
25-
26 def _get_move_line_from_line_rec(self, cr, uid, ids, context=None):
27 moves = []
28 for reconcile in self.pool.get('account.move.reconcile').browse(cr, uid, ids, context=context):
29
30=== added directory 'account_financial_report_webkit/migrations'
31=== added directory 'account_financial_report_webkit/migrations/7.0.1.0.2'
32=== added file 'account_financial_report_webkit/migrations/7.0.1.0.2/post-migration.py'
33--- account_financial_report_webkit/migrations/7.0.1.0.2/post-migration.py 1970-01-01 00:00:00 +0000
34+++ account_financial_report_webkit/migrations/7.0.1.0.2/post-migration.py 2014-04-25 13:34:20 +0000
35@@ -0,0 +1,39 @@
36+# -*- encoding: utf-8 -*-
37+##############################################################################
38+#
39+# Author: Nicolas Bessi.
40+# Copyright Camptocamp SA 2011
41+#
42+# This program is free software: you can redistribute it and/or modify
43+# it under the terms of the GNU General Public License as published by
44+# the Free Software Foundation, either version 3 of the License, or
45+# (at your option) any later version.
46+#
47+# This program is distributed in the hope that it will be useful,
48+# but WITHOUT ANY WARRANTY; without even the implied warranty of
49+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50+# GNU General Public License for more details.
51+#
52+# You should have received a copy of the GNU General Public License
53+# along with this program. If not, see <http://www.gnu.org/licenses/>.
54+#
55+##############################################################################
56+
57+def migrate(cr, version):
58+ if not version:
59+ # only run at first install
60+ cr.execute("UPDATE account_move_line as acm "
61+ " SET last_rec_date ="
62+ " (SELECT date from account_move_line"
63+ " WHERE reconcile_id = acm.reconcile_id"
64+ " AND reconcile_id IS NOT NULL"
65+ " ORDER BY date DESC LIMIT 1)"
66+ " WHERE last_rec_date is null;")
67+
68+ cr.execute("UPDATE account_move_line as acm "
69+ " SET last_rec_date ="
70+ " (SELECT date from account_move_line"
71+ " WHERE reconcile_partial_id = acm.reconcile_partial_id"
72+ " AND reconcile_partial_id IS NOT NULL"
73+ " ORDER BY date DESC LIMIT 1)"
74+ " WHERE last_rec_date is null;")