From 7ca85ffbba1e42d37cdf1e855e0fe2761e24b477 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Thu, 23 May 2013 14:27:56 +0200 Subject: [PATCH] [FIX] account: exclude company_id from build_ctx_periods()'s criteria to allow printing consolidated reports bzr revid: qdp-launchpad@openerp.com-20130523122756-tpkc268q107hiqvy --- addons/account/account.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 58c4cf447ef..cfcb52a03b9 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1065,10 +1065,14 @@ class account_period(osv.osv): raise osv.except_osv(_('Error!'), _('You should choose the periods that belong to the same company.')) if period_date_start > period_date_stop: raise osv.except_osv(_('Error!'), _('Start period should precede then end period.')) + + # /!\ We do not include a criterion on the company_id field below, to allow producing consolidated reports + # on multiple companies. It will only work when start/end periods are selected and no fiscal year is chosen. + #for period from = january, we want to exclude the opening period (but it has same date_from, so we have to check if period_from is special or not to include that clause or not in the search). if period_from.special: - return self.search(cr, uid, [('date_start', '>=', period_date_start), ('date_stop', '<=', period_date_stop), ('company_id', '=', company1_id)]) - return self.search(cr, uid, [('date_start', '>=', period_date_start), ('date_stop', '<=', period_date_stop), ('company_id', '=', company1_id), ('special', '=', False)]) + return self.search(cr, uid, [('date_start', '>=', period_date_start), ('date_stop', '<=', period_date_stop)]) + return self.search(cr, uid, [('date_start', '>=', period_date_start), ('date_stop', '<=', period_date_stop), ('special', '=', False)]) account_period()