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.
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

LGTM

thanks for the contrib!

review: Approve (code review, no test)
Revision history for this message
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
Revision history for this message
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

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

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
Revision history for this message
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...

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :
review: Needs Resubmitting

Unmerged revisions

88. By Laurent Mignon (Acsone)

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