← Back to team overview

openerp-community-reviewer team mailing list archive

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

 

Luc De Meyer (Noviat) has proposed merging lp:~luc-demeyer/account-financial-report/7.0-account_financial_report_webkit-GL-fix into lp:account-financial-report.

Requested reviews:
  Account Report Core Editors (account-report-core-editor)

For more details, see:
https://code.launchpad.net/~luc-demeyer/account-financial-report/7.0-account_financial_report_webkit-GL-fix/+merge/193709

General Ledger should include accounting move lines in close & opening periods.
-- 
https://code.launchpad.net/~luc-demeyer/account-financial-report/7.0-account_financial_report_webkit-GL-fix/+merge/193709
Your team Account Report Core Editors is requested to review the proposed merge of lp:~luc-demeyer/account-financial-report/7.0-account_financial_report_webkit-GL-fix into lp:account-financial-report.
=== modified file 'account_financial_report_webkit/__init__.py'
--- account_financial_report_webkit/__init__.py	2012-03-06 09:13:59 +0000
+++ account_financial_report_webkit/__init__.py	2013-11-03 20:44:40 +0000
@@ -18,6 +18,7 @@
 #
 ##############################################################################
 import account
+from . import account_period
 from . import wizard
 from . import report
 from . import account_move_line
\ No newline at end of file

=== added file 'account_financial_report_webkit/account_period.py'
--- account_financial_report_webkit/account_period.py	1970-01-01 00:00:00 +0000
+++ account_financial_report_webkit/account_period.py	2013-11-03 20:44:40 +0000
@@ -0,0 +1,37 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#
+#    Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import orm
+
+class account_period(orm.Model):
+    _inherit = 'account.period'
+
+    def build_ctx_periods(self, cr, uid, period_from_id, period_to_id):
+        """ add close periods """
+        period_ids = super(account_period, self).build_ctx_periods(cr, uid, period_from_id, period_to_id)
+        period_to = self.browse(cr, uid, period_to_id)
+        period_date_stop = period_to.date_stop
+        close_period_ids = self.search(cr, uid, [('date_stop', '=', period_date_stop), ('special', '=', True), ('company_id', '=', period_to.company_id.id)])
+        for p in close_period_ids:
+            if p not in period_ids:
+                period_ids.append(p)
+        return period_ids

=== modified file 'account_financial_report_webkit/report/common_reports.py'
--- account_financial_report_webkit/report/common_reports.py	2013-09-12 20:53:27 +0000
+++ account_financial_report_webkit/report/common_reports.py	2013-11-03 20:44:40 +0000
@@ -217,7 +217,15 @@
 
     def exclude_opening_periods(self, period_ids):
         period_obj = self.pool.get('account.period')
-        return period_obj.search(self.cr, self.uid, [['special', '=', False], ['id', 'in', period_ids]])
+        # FIX by Noviat: close periods should be included
+        self.cr.execute("SELECT p.id " \
+                    "FROM account_period p " \
+                    "INNER JOIN account_fiscalyear f ON p.fiscalyear_id = f.id " \
+                    "WHERE (special = FALSE or (special = TRUE AND p.date_stop = f.date_stop)) " \
+                    "AND p.id IN %s", (tuple(period_ids),))
+        period_ids = self.cr.fetchall()
+        period_ids = [x[0] for x in period_ids]
+        return period_ids
 
     def get_included_opening_period(self, period):
         """Return the opening included in normal period we use the assumption
@@ -384,7 +392,16 @@
                 if pnl_periods_ids and not opening_period_selected:
                     res[acc.id] = self._compute_init_balance(acc.id, pnl_periods_ids)
             else:
-                res[acc.id] = self._compute_init_balance(acc.id, bs_period_ids)
+                # FIX by Noviat
+                if not bs_period_ids:
+                    res[acc.id] = {
+                        'debit': 0.0,
+                        'credit': 0.0,
+                        'init_balance': 0.0,
+                        'init_balance_currency': 0.0,
+                        'state': 'computed'}
+                else:
+                    res[acc.id] = self._compute_init_balance(acc.id, bs_period_ids)
         return res
 
     ####################Account move retrieval helper ##########################

=== modified file 'account_financial_report_webkit/report/general_ledger.py'
--- account_financial_report_webkit/report/general_ledger.py	2013-05-08 14:03:48 +0000
+++ account_financial_report_webkit/report/general_ledger.py	2013-11-03 20:44:40 +0000
@@ -207,6 +207,27 @@
             line['counterparts'] = counter_parts.get(line.get('move_id'), '')
         return res
 
+    def _get_move_ids_from_periods(self, account_id, period_start, period_stop, target_move):
+        """
+        Change by Noviat: override this methods since we want to include the opening entries in the general ledger
+        """
+        move_line_obj = self.pool.get('account.move.line')
+        period_obj = self.pool.get('account.period')
+        periods = period_obj.build_ctx_periods(self.cursor, self.uid, period_start.id, period_stop.id)
+
+        #>>> change Noviat
+        special = period_obj.search(self.cursor, self.uid, [('date_start', '>=', period_start.date_start), ('date_stop', '<=', period_stop.date_stop), 
+            ('company_id', '=', period_start.company_id.id), ('special', '=', True)])
+        periods += special
+        #<<< change Noviat
+
+        if not periods:
+            return []
+        
+        search = [('period_id', 'in', periods), ('account_id', '=', account_id)]
+        if target_move == 'posted':
+            search += [('move_id.state', '=', 'posted')]
+        return move_line_obj.search(self.cursor, self.uid, search)
 
 HeaderFooterTextWebKitParser('report.account.account_report_general_ledger_webkit',
                              'account.account',


Follow ups