Merge lp:~luc-demeyer/account-financial-report/7.0-account_financial_report_webkit-GL-fix into lp:~account-report-core-editor/account-financial-report/7.0

Proposed by Luc De Meyer (Noviat)
Status: Work in progress
Proposed branch: lp:~luc-demeyer/account-financial-report/7.0-account_financial_report_webkit-GL-fix
Merge into: lp:~account-report-core-editor/account-financial-report/7.0
Diff against target: 125 lines (+78/-2)
4 files modified
account_financial_report_webkit/__init__.py (+1/-0)
account_financial_report_webkit/account_period.py (+37/-0)
account_financial_report_webkit/report/common_reports.py (+19/-2)
account_financial_report_webkit/report/general_ledger.py (+21/-0)
To merge this branch: bzr merge lp:~luc-demeyer/account-financial-report/7.0-account_financial_report_webkit-GL-fix
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza Needs Resubmitting
Yannick Vaucher @ Camptocamp Needs Information
Review via email: mp+193709@code.launchpad.net

Description of the change

General Ledger should include accounting move lines in close & opening periods.

To post a comment you must log in.

Is there a bug report about this issue?
If it does can you link it?
If not can you create it?

l.64 + l.81 + l.104 + l.110 + l.114

Just a note about credits, your user name will be in the commit if someone really wants to know who wrote a specific line of code for exemple with bzr blame.

If you want to show you contributed to a module, please only add this in __openerp__.py under Contributors in description. It will even be better for your Company as it will be visible on apps.openerp.com and not only hidden somewhere in the code.

https://doc.openerp.com/contribute/05_developing_modules/#modules-description

Here is an exemple

http://bazaar.launchpad.net/~stock-logistic-core-editors/carriers-deliveries/7.0/view/head:/base_delivery_carrier_label/__openerp__.py

review: Needs Information

Hello,

As there was no activity on this MP I'll set it as Work in progress.
Feel free to set it back to Need reviews

Cheers

Luc De Meyer (Noviat) (luc-demeyer) wrote :

There is no bug report since imho the 'Description of Change' is clear : "General Ledger should include accounting move lines in close & opening periods."
Without this fix, you don't get a complete history of all moves in a certain fiscal year.

Regards,
Luc

www.noviat.com
Rusatiralaan 1, 1083 Brussel
+32 2 808 86 38

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Yannick Vaucher @ Camptocamp
Sent: vrijdag 31 januari 2014 10:48
To: <email address hidden>
Subject: Re: [Merge] lp:~luc-demeyer/account-financial-report/7.0-account_financial_report_webkit-GL-fix into lp:account-financial-report

Review: Needs Information

Is there a bug report about this issue?
If it does can you link it?
If not can you create it?

l.64 + l.81 + l.104 + l.110 + l.114

Just a note about credits, your user name will be in the commit if someone really wants to know who wrote a specific line of code for exemple with bzr blame.

If you want to show you contributed to a module, please only add this in __openerp__.py under Contributors in description. It will even be better for your Company as it will be visible on apps.openerp.com and not only hidden somewhere in the code.

https://doc.openerp.com/contribute/05_developing_modules/#modules-description

Here is an exemple

http://bazaar.launchpad.net/~stock-logistic-core-editors/carriers-deliveries/7.0/view/head:/base_delivery_carrier_label/__openerp__.py

--
https://code.launchpad.net/~luc-demeyer/account-financial-report/7.0-account_financial_report_webkit-GL-fix/+merge/193709
You are the owner of lp:~luc-demeyer/account-financial-report/7.0-account_financial_report_webkit-GL-fix.

Stéphane Bidoul (Acsone) (sbi) wrote :

Is this MP related to bug lp:1172779 ?

If yes, the discussion in the merge proposals linked to that bug might be of interest.

Luc De Meyer (Noviat) (luc-demeyer) wrote :

Stephane,

bug lp:1172779 indeed describes the same problem as the one for which I made the merge proposal.

I think the error description is clear. The patch is only a few lines of code and runs at all our customers hence it is tested and stable.

I hope someone at C2C finds to the time to review and merge so that we stop applying this patch every time we install this module.

Regards,
Luc

www.noviat.com
Rusatiralaan 1, 1083 Brussel
+32 2 808 86 38

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Stéphane Bidoul (Acsone)
Sent: dinsdag 25 februari 2014 9:28
To: <email address hidden>
Subject: Re: [Merge] lp:~luc-demeyer/account-financial-report/7.0-account_financial_report_webkit-GL-fix into lp:account-financial-report

Is this MP related to bug lp:1172779 ?

If yes, the discussion in the merge proposals linked to that bug might be of interest.

--
https://code.launchpad.net/~luc-demeyer/account-financial-report/7.0-account_financial_report_webkit-GL-fix/+merge/193709
You are the owner of lp:~luc-demeyer/account-financial-report/7.0-account_financial_report_webkit-GL-fix.

Stéphane Bidoul (Acsone) (sbi) wrote :

At the time, there was debate about showing the detail or a summary of opening moves.

https://code.launchpad.net/~sbi/account-financial-report/account-financial-report-bug1172779/+merge/160949/comments/361722

Luc De Meyer (Noviat) (luc-demeyer) wrote :

I missed that debate but I believe we should show all lines and not the sum (except for the accounts configured as 'centralized').

www.noviat.com
Rusatiralaan 1, 1083 Brussel
+32 2 808 86 38

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Stéphane Bidoul (Acsone)
Sent: vrijdag 28 februari 2014 19:24
To: <email address hidden>
Subject: Re: [Merge] lp:~luc-demeyer/account-financial-report/7.0-account_financial_report_webkit-GL-fix into lp:account-financial-report

At the time, there was debate about showing the detail or a summary of opening moves.

https://code.launchpad.net/~sbi/account-financial-report/account-financial-report-bug1172779/+merge/160949/comments/361722

--
https://code.launchpad.net/~luc-demeyer/account-financial-report/7.0-account_financial_report_webkit-GL-fix/+merge/193709
You are the owner of lp:~luc-demeyer/account-financial-report/7.0-account_financial_report_webkit-GL-fix.

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

Unmerged revisions

57. By Luc De Meyer on 2013-11-03

add open/close entries to GL

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_financial_report_webkit/__init__.py'
2--- account_financial_report_webkit/__init__.py 2012-03-06 09:13:59 +0000
3+++ account_financial_report_webkit/__init__.py 2013-11-03 20:44:40 +0000
4@@ -18,6 +18,7 @@
5 #
6 ##############################################################################
7 import account
8+from . import account_period
9 from . import wizard
10 from . import report
11 from . import account_move_line
12\ No newline at end of file
13
14=== added file 'account_financial_report_webkit/account_period.py'
15--- account_financial_report_webkit/account_period.py 1970-01-01 00:00:00 +0000
16+++ account_financial_report_webkit/account_period.py 2013-11-03 20:44:40 +0000
17@@ -0,0 +1,37 @@
18+# -*- encoding: utf-8 -*-
19+##############################################################################
20+#
21+# OpenERP, Open Source Management Solution
22+#
23+# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
24+#
25+# This program is free software: you can redistribute it and/or modify
26+# it under the terms of the GNU Affero General Public License as
27+# published by the Free Software Foundation, either version 3 of the
28+# License, or (at your option) any later version.
29+#
30+# This program is distributed in the hope that it will be useful,
31+# but WITHOUT ANY WARRANTY; without even the implied warranty of
32+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33+# GNU Affero General Public License for more details.
34+#
35+# You should have received a copy of the GNU Affero General Public License
36+# along with this program. If not, see <http://www.gnu.org/licenses/>.
37+#
38+##############################################################################
39+
40+from openerp.osv import orm
41+
42+class account_period(orm.Model):
43+ _inherit = 'account.period'
44+
45+ def build_ctx_periods(self, cr, uid, period_from_id, period_to_id):
46+ """ add close periods """
47+ period_ids = super(account_period, self).build_ctx_periods(cr, uid, period_from_id, period_to_id)
48+ period_to = self.browse(cr, uid, period_to_id)
49+ period_date_stop = period_to.date_stop
50+ close_period_ids = self.search(cr, uid, [('date_stop', '=', period_date_stop), ('special', '=', True), ('company_id', '=', period_to.company_id.id)])
51+ for p in close_period_ids:
52+ if p not in period_ids:
53+ period_ids.append(p)
54+ return period_ids
55
56=== modified file 'account_financial_report_webkit/report/common_reports.py'
57--- account_financial_report_webkit/report/common_reports.py 2013-09-12 20:53:27 +0000
58+++ account_financial_report_webkit/report/common_reports.py 2013-11-03 20:44:40 +0000
59@@ -217,7 +217,15 @@
60
61 def exclude_opening_periods(self, period_ids):
62 period_obj = self.pool.get('account.period')
63- return period_obj.search(self.cr, self.uid, [['special', '=', False], ['id', 'in', period_ids]])
64+ # FIX by Noviat: close periods should be included
65+ self.cr.execute("SELECT p.id " \
66+ "FROM account_period p " \
67+ "INNER JOIN account_fiscalyear f ON p.fiscalyear_id = f.id " \
68+ "WHERE (special = FALSE or (special = TRUE AND p.date_stop = f.date_stop)) " \
69+ "AND p.id IN %s", (tuple(period_ids),))
70+ period_ids = self.cr.fetchall()
71+ period_ids = [x[0] for x in period_ids]
72+ return period_ids
73
74 def get_included_opening_period(self, period):
75 """Return the opening included in normal period we use the assumption
76@@ -384,7 +392,16 @@
77 if pnl_periods_ids and not opening_period_selected:
78 res[acc.id] = self._compute_init_balance(acc.id, pnl_periods_ids)
79 else:
80- res[acc.id] = self._compute_init_balance(acc.id, bs_period_ids)
81+ # FIX by Noviat
82+ if not bs_period_ids:
83+ res[acc.id] = {
84+ 'debit': 0.0,
85+ 'credit': 0.0,
86+ 'init_balance': 0.0,
87+ 'init_balance_currency': 0.0,
88+ 'state': 'computed'}
89+ else:
90+ res[acc.id] = self._compute_init_balance(acc.id, bs_period_ids)
91 return res
92
93 ####################Account move retrieval helper ##########################
94
95=== modified file 'account_financial_report_webkit/report/general_ledger.py'
96--- account_financial_report_webkit/report/general_ledger.py 2013-05-08 14:03:48 +0000
97+++ account_financial_report_webkit/report/general_ledger.py 2013-11-03 20:44:40 +0000
98@@ -207,6 +207,27 @@
99 line['counterparts'] = counter_parts.get(line.get('move_id'), '')
100 return res
101
102+ def _get_move_ids_from_periods(self, account_id, period_start, period_stop, target_move):
103+ """
104+ Change by Noviat: override this methods since we want to include the opening entries in the general ledger
105+ """
106+ move_line_obj = self.pool.get('account.move.line')
107+ period_obj = self.pool.get('account.period')
108+ periods = period_obj.build_ctx_periods(self.cursor, self.uid, period_start.id, period_stop.id)
109+
110+ #>>> change Noviat
111+ special = period_obj.search(self.cursor, self.uid, [('date_start', '>=', period_start.date_start), ('date_stop', '<=', period_stop.date_stop),
112+ ('company_id', '=', period_start.company_id.id), ('special', '=', True)])
113+ periods += special
114+ #<<< change Noviat
115+
116+ if not periods:
117+ return []
118+
119+ search = [('period_id', 'in', periods), ('account_id', '=', account_id)]
120+ if target_move == 'posted':
121+ search += [('move_id.state', '=', 'posted')]
122+ return move_line_obj.search(self.cursor, self.uid, search)
123
124 HeaderFooterTextWebKitParser('report.account.account_report_general_ledger_webkit',
125 'account.account',