From 6a14d2c377d078b537e1149bade27da972dcb69e Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Thu, 24 Jun 2010 18:58:50 +0530 Subject: [PATCH 001/360] [REF] just remove _get_comapny default from common report wizard bzr revid: mra@mra-laptop-20100624132850-80y3py2ti7m1rzm3 --- .../account/wizard/account_common_report.py | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/addons/account/wizard/account_common_report.py b/addons/account/wizard/account_common_report.py index d38adf1cbcd..d87956b77a9 100644 --- a/addons/account/wizard/account_common_report.py +++ b/addons/account/wizard/account_common_report.py @@ -36,7 +36,7 @@ class account_common_report(osv.osv_memory): 'period_from': fields.many2one('account.period', 'Start period'), 'period_to': fields.many2one('account.period', 'End period'), - #not used. Do we really need it? 'period_ids': fields.many2many('account.period', 'ledger_period_rel', 'ledger_id', 'period_id', 'Periods'), + #not used. Do we really need it? 'period_ids': fields.many2many('account.period', 'ledger_period_rel', 'ledger_id', 'period_id', 'Periods'), 'journal_ids': fields.many2many('account.journal', 'account_common_journal_rel', 'account_id', 'journal_id', 'Journals', required=True), @@ -53,16 +53,16 @@ class account_common_report(osv.osv_memory): #'company_id': fields.many2one('res.company', 'Company', required=True), } - def _get_company(self, cr, uid, context=None): - user_obj = self.pool.get('res.users') - company_obj = self.pool.get('res.company') - if context is None: - context = {} - user = user_obj.browse(cr, uid, uid, context=context) - if user.company_id: - return user.company_id.id - else: - return company_obj.search(cr, uid, [('parent_id', '=', False)])[0] +# def _get_company(self, cr, uid, context=None): +# user_obj = self.pool.get('res.users') +# company_obj = self.pool.get('res.company') +# if context is None: +# context = {} +# user = user_obj.browse(cr, uid, uid, context=context) +# if user.company_id: +# return user.company_id.id +# else: +# return company_obj.search(cr, uid, [('parent_id', '=', False)])[0] def _get_account(self, cr, uid, context=None): tmp = self.pool.get('account.account').search(cr, uid, [], limit=1 ) From 41255ffacfd1eb78d16a18981694ad4842de21df Mon Sep 17 00:00:00 2001 From: "qdp-launchpad@tinyerp.com" <> Date: Thu, 24 Jun 2010 16:45:51 +0200 Subject: [PATCH 002/360] [IMP] account: bugfixed the use of period_from and period_to bzr revid: qdp-launchpad@tinyerp.com-20100624144551-e8o1uzhg2psbw9mw --- addons/account/wizard/account_common_report.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/wizard/account_common_report.py b/addons/account/wizard/account_common_report.py index d87956b77a9..ef02308dc48 100644 --- a/addons/account/wizard/account_common_report.py +++ b/addons/account/wizard/account_common_report.py @@ -102,8 +102,9 @@ class account_common_report(osv.osv_memory): result['date_from'] = data['form']['date_from'] result['date_to'] = data['form']['date_to'] elif data['form']['filter'] == 'filter_period': - period_date_start = period_obj.read(cr, uid, data['form']['period_from'], ['date_start'])[0]['date_start'] - period_date_stop = period_obj.read(cr, uid, data['form']['period_to'], ['date_stop'])[0]['date_stop'] + period_obj = self.pool.get('account.period') + period_date_start = period_obj.read(cr, uid, data['form']['period_from'], ['date_start'])['date_start'] + period_date_stop = period_obj.read(cr, uid, data['form']['period_to'], ['date_stop'])['date_stop'] cr.execute('SELECT id FROM account_period WHERE date_start >= %s AND date_stop <= %s', (period_date_start, period_date_stop)) result['periods'] = lambda x: x[0], cr.fetchall() return result @@ -118,8 +119,7 @@ class account_common_report(osv.osv_memory): data['model'] = context.get('active_model', 'ir.ui.menu') data['form'] = self.read(cr, uid, ids, ['date_from', 'date_to', 'fiscalyear_id', 'journal_ids', 'period_from', 'period_to', 'filter', 'chart_account_id'])[0] used_context = self._build_context(cr, uid, ids, data, context) - query_line = obj_acc_move_line._query_get(cr, uid, - obj='l', context=used_context) + query_line = obj_acc_move_line._query_get(cr, uid, obj='l', context=used_context) return self._print_report(cr, uid, ids, data, query_line, context) account_common_report() From 0c66d23915da2732dfd420e37c8ae81343db04e7 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Fri, 25 Jun 2010 16:52:16 +0530 Subject: [PATCH 003/360] [FIX] account: report with warning if the start and end period is not given in wizard bzr revid: mra@mra-laptop-20100625112216-bxuecavghwb7j364 --- addons/account/wizard/account_common_report.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/account/wizard/account_common_report.py b/addons/account/wizard/account_common_report.py index d87956b77a9..8ef94c5dfba 100644 --- a/addons/account/wizard/account_common_report.py +++ b/addons/account/wizard/account_common_report.py @@ -102,6 +102,8 @@ class account_common_report(osv.osv_memory): result['date_from'] = data['form']['date_from'] result['date_to'] = data['form']['date_to'] elif data['form']['filter'] == 'filter_period': + if data['form']['period_from'] == False or data['form']['period_to'] == False: + raise osv.except_osv(_('Error'),_('Select Start period and End period')) period_date_start = period_obj.read(cr, uid, data['form']['period_from'], ['date_start'])[0]['date_start'] period_date_stop = period_obj.read(cr, uid, data['form']['period_to'], ['date_stop'])[0]['date_stop'] cr.execute('SELECT id FROM account_period WHERE date_start >= %s AND date_stop <= %s', (period_date_start, period_date_stop)) From bc752eeb6ba75ccffd13114288eb8a75ae2f78dd Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Fri, 25 Jun 2010 17:16:06 +0530 Subject: [PATCH 004/360] [FIX] account: report small fix on common report bzr revid: mra@mra-laptop-20100625114606-lm2q5ly8wgy9cjqj --- addons/account/wizard/account_common_report.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/wizard/account_common_report.py b/addons/account/wizard/account_common_report.py index 8ef94c5dfba..333e8a897b8 100644 --- a/addons/account/wizard/account_common_report.py +++ b/addons/account/wizard/account_common_report.py @@ -104,8 +104,8 @@ class account_common_report(osv.osv_memory): elif data['form']['filter'] == 'filter_period': if data['form']['period_from'] == False or data['form']['period_to'] == False: raise osv.except_osv(_('Error'),_('Select Start period and End period')) - period_date_start = period_obj.read(cr, uid, data['form']['period_from'], ['date_start'])[0]['date_start'] - period_date_stop = period_obj.read(cr, uid, data['form']['period_to'], ['date_stop'])[0]['date_stop'] + period_date_start = period_obj.read(cr, uid, data['form']['period_from'], ['date_start'])['date_start'] + period_date_stop = period_obj.read(cr, uid, data['form']['period_to'], ['date_stop'])['date_stop'] cr.execute('SELECT id FROM account_period WHERE date_start >= %s AND date_stop <= %s', (period_date_start, period_date_stop)) result['periods'] = lambda x: x[0], cr.fetchall() return result From 2d0b2663440cf4b03d15a9e953b1a599510791d4 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Fri, 25 Jun 2010 17:28:36 +0530 Subject: [PATCH 005/360] [IMP] clean commont report class bzr revid: mra@mra-laptop-20100625115836-w9n3o6s9di3wfh2c --- .../account/wizard/account_common_report.py | 36 +++++++++---------- .../account/wizard/account_common_report.xml | 9 ++--- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/addons/account/wizard/account_common_report.py b/addons/account/wizard/account_common_report.py index 333e8a897b8..52c682500a2 100644 --- a/addons/account/wizard/account_common_report.py +++ b/addons/account/wizard/account_common_report.py @@ -26,22 +26,18 @@ import tools class account_common_report(osv.osv_memory): _name = "account.common.report" - _description = "Common Report" + _description = "Account Common Report" _columns = { - 'chart_account_id': fields.many2one('account.account', 'Chart of account', required=True, domain = [('parent_id','=',False)]), + 'chart_account_id': fields.many2one('account.account', 'Chart of account', help='Select Charts of Accounts', required=True, domain = [('parent_id','=',False)]), 'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal year', help='Keep empty for all open fiscal year'), - - 'filter': fields.selection([('filter_no','No filters'), ('filter_date','Date'), ('filter_period','Periods')],"Filter by:", required=True), - + 'filter': fields.selection([('filter_no', 'No filters'), ('filter_date', 'Date'), ('filter_period', 'Periods')], "Filter by:", required=True), 'period_from': fields.many2one('account.period', 'Start period'), 'period_to': fields.many2one('account.period', 'End period'), #not used. Do we really need it? 'period_ids': fields.many2many('account.period', 'ledger_period_rel', 'ledger_id', 'period_id', 'Periods'), - 'journal_ids': fields.many2many('account.journal', 'account_common_journal_rel', 'account_id', 'journal_id', 'Journals', required=True), - - 'date_from': fields.date("Start date"), - 'date_to': fields.date("End date"), + 'date_from': fields.date("Start Date"), + 'date_to': fields.date("End Date"), #'display_account': fields.selection([('bal_mouvement','With movements'), ('bal_all','All'), ('bal_solde','With balance is not equal to 0')],"Display accounts"), #'landscape': fields.boolean("Landscape Mode"), @@ -95,7 +91,9 @@ class account_common_report(osv.osv_memory): 'chart_account_id': _get_account, } - def _build_context(self, cr, uid, ids, data, context = None): + def _build_context(self, cr, uid, ids, data, context=None): + if context is None: + context = {} result = {} result['fiscalyear'] = data['form']['fiscalyear_id'] and data['form']['fiscalyear_id'] or False if data['form']['filter'] == 'filter_date': @@ -110,20 +108,22 @@ class account_common_report(osv.osv_memory): result['periods'] = lambda x: x[0], cr.fetchall() return result - def _print_report(self, cr, uid, ids, data, query_line, context): + def _print_report(self, cr, uid, ids, data, query_line, context=None): raise (_('Error'), _('not implemented')) def check_report(self, cr, uid, ids, context=None): - obj_acc_move_line = self.pool.get('account.move.line') + if context is None: + context = {} data = {} - data['ids'] = context.get('active_ids',[]) + data['ids'] = context.get('active_ids', []) data['model'] = context.get('active_model', 'ir.ui.menu') data['form'] = self.read(cr, uid, ids, ['date_from', 'date_to', 'fiscalyear_id', 'journal_ids', 'period_from', 'period_to', 'filter', 'chart_account_id'])[0] used_context = self._build_context(cr, uid, ids, data, context) - query_line = obj_acc_move_line._query_get(cr, uid, - obj='l', context=used_context) - return self._print_report(cr, uid, ids, data, query_line, context) + if used_context.get('periods', False): + data['form']['periods'] = used_context['periods'] + query_line = self.pool.get('account.move.line')._query_get(cr, uid, obj='l', context=used_context) + return self._print_report(cr, uid, ids, data, query_line, context=context) + account_common_report() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account/wizard/account_common_report.xml b/addons/account/wizard/account_common_report.xml index d138c8ec2de..ddbc1c365d2 100644 --- a/addons/account/wizard/account_common_report.xml +++ b/addons/account/wizard/account_common_report.xml @@ -1,19 +1,19 @@ + + Common Report account.common.report form
- - @@ -27,7 +27,6 @@ - - - - + \ No newline at end of file From 307d40f4b13c2f814468a460299a4412c9d501be Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Fri, 25 Jun 2010 17:53:07 +0530 Subject: [PATCH 006/360] [FIX] account common report bzr revid: mra@mra-laptop-20100625122307-95j5i6eon5m2s9pb --- addons/account/wizard/account_common_report.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/account/wizard/account_common_report.py b/addons/account/wizard/account_common_report.py index 52c682500a2..45f966c672d 100644 --- a/addons/account/wizard/account_common_report.py +++ b/addons/account/wizard/account_common_report.py @@ -100,8 +100,10 @@ class account_common_report(osv.osv_memory): result['date_from'] = data['form']['date_from'] result['date_to'] = data['form']['date_to'] elif data['form']['filter'] == 'filter_period': - if data['form']['period_from'] == False or data['form']['period_to'] == False: + if not data['form']['period_from'] or not data['form']['period_to']: raise osv.except_osv(_('Error'),_('Select Start period and End period')) + elif (data['form']['period_from'] > data['form']['period_to']): + raise osv.except_osv(_('Error'),_('Start period should be smaller then End period')) period_date_start = period_obj.read(cr, uid, data['form']['period_from'], ['date_start'])['date_start'] period_date_stop = period_obj.read(cr, uid, data['form']['period_to'], ['date_stop'])['date_stop'] cr.execute('SELECT id FROM account_period WHERE date_start >= %s AND date_stop <= %s', (period_date_start, period_date_stop)) From ffc09cf64da22df04fa159a44337cefcf6850d1b Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Fri, 25 Jun 2010 17:53:59 +0530 Subject: [PATCH 007/360] [IMP] account: General journal report update with osv memory (ref: PSI) bzr revid: mra@mra-laptop-20100625122359-ivvogx5pco2ov50n --- addons/account/report/general_journal.py | 11 +++-- .../account/report/wizard_general_journal.rml | 10 ++--- .../account/wizard/account_general_journal.py | 43 +++++++++++-------- .../wizard/account_general_journal_view.xml | 27 +++++++----- 4 files changed, 51 insertions(+), 40 deletions(-) diff --git a/addons/account/report/general_journal.py b/addons/account/report/general_journal.py index 631930ce3a7..781e2301171 100644 --- a/addons/account/report/general_journal.py +++ b/addons/account/report/general_journal.py @@ -36,14 +36,14 @@ class journal_print(report_sxw.rml_parse): 'sum_debit_period': self._sum_debit_period, 'sum_credit_period': self._sum_credit_period, 'sum_debit': self._sum_debit, - 'sum_credit': self._sum_credit + 'sum_credit': self._sum_credit, }) - def set_context(self, objects, data, ids, report_type = None): + def set_context(self, objects, data, ids, report_type=None): super(journal_print, self).set_context(objects, data, ids, report_type) self.cr.execute('SELECT period_id, journal_id ' - 'FROM account_journal_period ' - 'WHERE id IN %s', + 'FROM account_journal_period ' + 'WHERE id IN %s', (tuple(ids),)) res = self.cr.fetchall() self.period_ids, self.journal_ids = zip(*res) @@ -91,7 +91,6 @@ class journal_print(report_sxw.rml_parse): return lines_data if not self.journal_ids: return [] - self.cr.execute('SELECT j.code, j.name, ' 'SUM(l.debit) AS debit, SUM(l.credit) AS credit ' 'FROM account_move_line l ' @@ -146,7 +145,7 @@ class journal_print(report_sxw.rml_parse): 'AND state<>\'draft\'', (tuple(periods), tuple(journals))) return self.cr.fetchone()[0] or 0.0 -report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml', parser=journal_print) +report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml', parser=journal_print, header=False) report_sxw.report_sxw('report.account.general.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_general_journal.rml', parser=journal_print, header=False) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/wizard_general_journal.rml b/addons/account/report/wizard_general_journal.rml index aba1ad9c98c..cf0d058147f 100644 --- a/addons/account/report/wizard_general_journal.rml +++ b/addons/account/report/wizard_general_journal.rml @@ -178,10 +178,10 @@ - [[ formatLang(sum_debit(data['form']['period_id'][0][2],data['form']['journal_id'][0][2])) ]] + [[ formatLang(sum_debit(data['form']['periods'],data['form']['journal_ids'])) ]] - [[ formatLang(sum_credit(data['form']['period_id'][0][2],data['form']['journal_id'][0][2])) ]] + [[ formatLang(sum_credit(data['form']['periods'],data['form']['journal_ids'])) ]] @@ -191,7 +191,7 @@ - [[ repeatIn( lines( data['form']['period_id'][0][2], data['form']['journal_id'][0][2] ),'line')]] + [[ repeatIn( lines( data['form']['periods'], data['form']['journal_ids'] ),'line')]] @@ -208,10 +208,10 @@ - [[ formatLang(sum_debit_period( line[0]['pid'],data['form']['journal_id'][0][2])) ]] + [[ formatLang(sum_debit_period( line[0]['pid'],data['form']['journal_ids'])) ]] - [[ formatLang(sum_credit_period(line[0]['pid'],data['form']['journal_id'][0][2])) ]] + [[ formatLang(sum_credit_period(line[0]['pid'],data['form']['journal_ids'])) ]] diff --git a/addons/account/wizard/account_general_journal.py b/addons/account/wizard/account_general_journal.py index 8bd2913ae62..f50ab0b737f 100644 --- a/addons/account/wizard/account_general_journal.py +++ b/addons/account/wizard/account_general_journal.py @@ -22,23 +22,29 @@ from osv import osv, fields from tools.translate import _ class account_general_journal(osv.osv_memory): + _inherit = "account.common.report" _name = 'account.general.journal' _description = 'Account General Journal' - _columns = { - 'journal_id': fields.many2many('account.journal', 'account_journal_rel', 'account_id', 'journal_id', 'Journals', required=True), - 'period_id': fields.many2many('account.period', 'account_period_rel', 'account_id', 'period_id', 'Periods', required=True), - } + def _build_context(self, cr, uid, ids, data, context=None): + period_obj = self.pool.get('account.period') + result = super(account_general_journal, self)._build_context(cr, uid, ids, data, context=context) + if not data['form']['period_from'] or not data['form']['period_to']: + raise osv.except_osv(_('Error'),_('Select Start period and End period')) + elif (data['form']['period_from'] > data['form']['period_to']): + raise osv.except_osv(_('Error'),_('Start period should be smaller then End period')) + period_date_start = period_obj.read(cr, uid, data['form']['period_from'], ['date_start'])['date_start'] + period_date_stop = period_obj.read(cr, uid, data['form']['period_to'], ['date_stop'])['date_stop'] + cr.execute('SELECT id FROM account_period WHERE date_start >= %s AND date_stop <= %s', (period_date_start, period_date_stop)) + result.update({'periods': map(lambda x: x[0], cr.fetchall())}) + return result - def check_data(self, cr, uid, ids, context=None): + def _print_report(self, cr, uid, ids, data, query_line, context=None): + if context is None: + context = {} obj_jperiod = self.pool.get('account.journal.period') - datas = {} - datas['ids'] = [] - datas['model'] = 'account.journal.period' - datas['form'] = self.read(cr, uid, ids)[0] - period_id = datas['form']['period_id'] - journal_id = datas['form']['journal_id'] - + period_id = data['form']['periods'] + journal_id = data['form']['journal_ids'] if type(period_id)==type([]): ids_final = [] for journal in journal_id: @@ -48,12 +54,13 @@ class account_general_journal(osv.osv_memory): ids_final.append(ids_journal_period) if not ids_final: raise osv.except_osv(_('No Data Available'), _('No records found for your selection!')) - return { - 'type': 'ir.actions.report.xml', - 'report_name': 'account.general.journal', - 'datas': datas, - 'nodestroy':True, - } + data['ids'] = [] + data['form']['query_get'] = query_line + if data['model'] == 'ir.ui.menu': + return {'type': 'ir.actions.report.xml', 'report_name': 'account.general.journal.wiz', 'datas': data, 'nodestroy':True, } + else: + return {'type': 'ir.actions.report.xml', 'report_name': 'account.general.journal', 'datas': data, 'nodestroy':True, } account_general_journal() + #vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account/wizard/account_general_journal_view.xml b/addons/account/wizard/account_general_journal_view.xml index fc39300d390..0fd994ec707 100644 --- a/addons/account/wizard/account_general_journal_view.xml +++ b/addons/account/wizard/account_general_journal_view.xml @@ -7,17 +7,22 @@ account.general.journal form - - - - - - - -