From f7dc60e5bad55a23c5e224a33af30048a0cdf349 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Thu, 20 May 2010 11:05:34 +0200 Subject: [PATCH 01/33] account general ledger, landscape to use the same code as plain bzr revid: al@openerp.com-20100520090534-a8907qrm4ny9fv3v --- addons/account/report/__init__.py | 1 - addons/account/report/general_ledger.py | 3 + .../report/general_ledger_landscape.py | 396 ------------------ 3 files changed, 3 insertions(+), 397 deletions(-) delete mode 100644 addons/account/report/general_ledger_landscape.py diff --git a/addons/account/report/__init__.py b/addons/account/report/__init__.py index b411e404cac..5d1d7a33c97 100644 --- a/addons/account/report/__init__.py +++ b/addons/account/report/__init__.py @@ -30,7 +30,6 @@ import invoice import overdue import aged_trial_balance import tax_report -import general_ledger_landscape import account_tax_code import account_balance_landscape import compare_account_balance diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index 00031a77ed8..d1123263bdb 100644 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -51,6 +51,7 @@ class general_ledger(rml_parse.rml_parse): def __init__(self, cr, uid, name, context): super(general_ledger, self).__init__(cr, uid, name, context=context) + cr.sql_log=1 self.date_borne = {} self.query = "" self.child_ids = "" @@ -394,4 +395,6 @@ class general_ledger(rml_parse.rml_parse): report_sxw.report_sxw('report.account.general.ledger', 'account.account', 'addons/account/report/general_ledger.rml', parser=general_ledger, header=False) +report_sxw.report_sxw('report.account.general.ledger_landscape', 'account.account', 'addons/account/report/general_ledger_landscape.rml', parser=general_ledger, header=False) + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/general_ledger_landscape.py b/addons/account/report/general_ledger_landscape.py deleted file mode 100644 index 472f0675519..00000000000 --- a/addons/account/report/general_ledger_landscape.py +++ /dev/null @@ -1,396 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (c) 2005-2006 CamptoCamp -# -# WARNING: This program as such is intended to be used by professional -# programmers who take the whole responsability of assessing all potential -# consequences resulting from its eventual inadequacies and bugs -# End users who are looking for a ready-to-use solution with commercial -# garantees and support are strongly adviced to contract a Free Software -# Service Company -# -# This program is Free Software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################## - -import time -from report import report_sxw -import xml -import rml_parse -import pooler - -class general_ledger_landscape(rml_parse.rml_parse): - _name = 'report.account.general.ledger_landscape' - - - def set_context(self, objects, data, ids, report_type = None): - ## - self.borne_date = self.get_min_date(data['form']) - ## - new_ids = [] - if (data['model'] == 'account.account'): - new_ids = 'active_ids' in data['form']['context'] and data['form']['context']['active_ids'] or [] - else: - new_ids.append(data['form']['Account_list']) - objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) - super(general_ledger_landscape, self).set_context(objects, data, new_ids,report_type) - - def __init__(self, cr, uid, name, context): - super(general_ledger_landscape, self).__init__(cr, uid, name, context=context) - self.date_borne = {} - self.query = "" - self.child_ids = "" - self.tot_currency = 0.0 - self.period_sql = "" - self.sold_accounts = {} - self.localcontext.update( { - 'time': time, - 'lines': self.lines, - 'sum_debit_account': self._sum_debit_account, - 'sum_credit_account': self._sum_credit_account, - 'sum_solde_account': self._sum_solde_account, - 'sum_debit': self._sum_debit, - 'sum_credit': self._sum_credit, - 'sum_solde': self._sum_solde, - 'get_children_accounts': self.get_children_accounts, - 'sum_currency_amount_account': self._sum_currency_amount_account - }) - self.context = context - def _calc_contrepartie(self,cr,uid,ids, context={}): - result = {} - #for id in ids: - # result.setdefault(id, False) - - for account_line in self.pool.get('account.move.line').browse(cr, uid, ids, context): - # For avoid long text in the field we will limit it to 5 lines - # - # - # - result[account_line.id] = ' ' - num_id_move = account_line.move_id.id - num_id_line = account_line.id - account_id = account_line.account_id.id - # search the basic account - # We have the account ID we will search all account move line from now until this time - # We are in the case of we are on the top of the account move Line - cr.execute('SELECT distinct(ac.code) as code_rest,ac.name as name_rest from account_account AS ac, account_move_line mv\ - where ac.id = mv.account_id and mv.move_id = %s and mv.account_id <> %s' , (num_id_move,account_id,)) - res_mv = cr.dictfetchall() - # we need a result more than 2 line to make the test so we will made the the on 1 because we have exclude the current line - if (len(res_mv) >=1): - concat = '' - rup_id = 0 - for move_rest in res_mv: - concat = concat + move_rest['code_rest'] + '|' - result[account_line.id] = concat - if rup_id >5: - # we need to stop the computing and to escape but before we will add "..." - result[account_line.id] = concat + '...' - break - rup_id+=1 - return result - - def get_min_date(self,form): - - ## Get max born from account_fiscal year - # - sql = """ select min(fy.date_start) as start_date,max(fy.date_stop) as stop_date from account_fiscalyear - As fy where fy.state <> 'close' - """ - self.cr.execute(sql) - res = self.cr.dictfetchall() - borne_min = res[0]['start_date'] - borne_max = res[0]['stop_date'] - if form['state'] == 'byperiod': - ## This function will return the most aged date - periods = form['periods'] - if not periods: - self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s""" ,(form['fiscalyear'],)) - else: - self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) - - res = self.cr.dictfetchall() - borne_min = res[0]['start_date'] - borne_max = res[0]['stop_date'] - elif form['state'] == 'bydate': - borne_min = form['date_from'] - borne_max = form['date_to'] - elif form['state'] == 'all': - periods = form['periods'] - if not periods: - if form['fiscalyear'] == False: - fiscalyears = self.pool.get('account.fiscalyear').search(self.cr, self.uid, [('state', '=', 'draft')]) - else: - fiscalyears = [form['fiscalyear']] - self.cr.execute("select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id =ANY(%s)" ,(fiscalyears,)) - else: - self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) - res = self.cr.dictfetchall() - period_min = res[0]['start_date'] - period_max = res[0]['stop_date'] - date_min = form['date_from'] - date_max = form['date_to'] - if period_min=',child_account.id)], - context=ctx)) <> 0 : - res.append(child_account) - ## - if not len(res): - - return [account] - else: - ## We will now compute solde initiaux - for move in res: - self.cr.execute("""SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l \ - WHERE l.account_id = %s AND l.date < %s AND l.date > %s""",(move.id,self.borne_date['max_date'],self.borne_date['min_date'])) - resultat = self.cr.dictfetchall() - if resultat[0] : - if resultat[0]['sum_debit'] == None: - sum_debit = 0 - else: - sum_debit = resultat[0]['sum_debit'] - if resultat[0]['sum_credit'] == None: - sum_credit = 0 - else: - sum_credit = resultat[0]['sum_credit'] - - move.init_credit = sum_credit - move.init_debit = sum_debit - - else: - move.init_credit = 0 - move.init_debit = 0 - - - return res - - def lines(self, account, form): - inv_types = { - 'out_invoice': 'CI: ', - 'in_invoice': 'SI: ', - 'out_refund': 'OR: ', - 'in_refund': 'SR: ', - } - - if form['sortbydate'] == 'sort_date': - sorttag = 'l.date' - else: - sorttag = 'j.code' - sql = """ - SELECT l.id, l.date, j.code,c.code AS currency_code,l.amount_currency,l.ref, l.name , COALESCE(l.debit,0) as debit, COALESCE(l.credit,0) as credit, l.period_id - FROM account_move_line as l - LEFT JOIN res_currency c on (l.currency_id=c.id) - JOIN account_journal j on (l.journal_id=j.id) - AND account_id = %%s - AND %s - WHERE l.date<=%%s - AND l.date>=%%s - ORDER by %s""" % (self.query, sorttag) - - self.cr.execute(sql, (account.id, self.date_borne['max_date'], self.date_borne['min_date'],)) - - res = self.cr.dictfetchall() - sum = 0.0 - account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') - for l in res: - line = self.pool.get('account.move.line').browse(self.cr, self.uid, l['id']) - l['move'] = line.move_id.name - self.cr.execute('Select id from account_invoice where move_id =%s',(line.move_id.id,)) - tmpres = self.cr.dictfetchall() - if len(tmpres) > 0 : - inv = self.pool.get('account.invoice').browse(self.cr, self.uid, tmpres[0]['id']) - l['ref'] = inv_types[inv.type] + ': '+str(inv.number) - if line.partner_id : - l['partner'] = line.partner_id.name - else : - l['partner'] = '' - sum = l['debit'] - l ['credit'] -# c = time.strptime(l['date'],"%Y-%m-%d") -# l['date'] = time.strftime("%d-%m-%Y",c) - l['progress'] = sum - l['line_corresp'] = self._calc_contrepartie(self.cr,self.uid,[l['id']])[l['id']] - # Modification du amount Currency - if (l['credit'] > 0): - if l['amount_currency'] != None: - l['amount_currency'] = abs(l['amount_currency']) * -1 - - # - if l['amount_currency'] != None: - self.tot_currency = self.tot_currency + l['amount_currency'] - return res - - def _sum_debit_account(self, account, form): - - self.cr.execute("SELECT sum(debit) "\ - "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+self.query,(account.id,)) - ## Add solde init to the result - # - sum_debit = self.cr.fetchone()[0] or 0.0 - if form['soldeinit']: - sum_debit += account.init_debit - # - ## - return sum_debit - - def _sum_credit_account(self, account, form): - - self.cr.execute("SELECT sum(credit) "\ - "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+self.query,(account.id,)) - ## Add solde init to the result - # - sum_credit = self.cr.fetchone()[0] or 0.0 - if form['soldeinit']: - sum_credit += account.init_credit - # - ## - - return sum_credit - - def _sum_solde_account(self, account, form): - self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ - "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+self.query,(account.id,)) - sum_solde = self.cr.fetchone()[0] or 0.0 - if form.get('soldeinit',False): - sum_solde += account.init_debit - account.init_credit - - return sum_solde - - def _sum_debit(self, form): - if not self.ids: - return 0.0 - self.cr.execute("SELECT sum(debit) "\ - "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+self.query,(self.child_ids,)) - sum_debit = self.cr.fetchone()[0] or 0.0 - return sum_debit - - def _sum_credit(self, form): - if not self.ids: - return 0.0 - self.cr.execute("SELECT sum(credit) "\ - "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+self.query,(self.child_ids,)) - ## Add solde init to the result - # - sum_credit = self.cr.fetchone()[0] or 0.0 - return sum_credit - - def _sum_solde(self, form): - if not self.ids: - return 0.0 - self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ - "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+self.query,(self.child_ids,)) - sum_solde = self.cr.fetchone()[0] or 0.0 - return sum_solde - - def _set_get_account_currency_code(self, account_id): - self.cr.execute("SELECT c.code as code "\ - "FROM res_currency c,account_account as ac "\ - "WHERE ac.id = %s AND ac.currency_id = c.id",(account_id,)) - result = self.cr.fetchone() - if result: - self.account_currency = result[0] - else: - self.account_currency = False - - def _sum_currency_amount_account(self, account, form): - self._set_get_account_currency_code(account.id) - self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %s ", (account.id,)) - total = self.cr.fetchone() - - if self.account_currency: - return_field = str(total[0]) + self.account_currency - return return_field - else: - currency_total = self.tot_currency = 0.0 - return currency_total - -report_sxw.report_sxw('report.account.general.ledger_landscape', 'account.account', 'addons/account/report/general_ledger_landscape.rml', parser=general_ledger_landscape, header=False) -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 5356d960aa559315fedcca98a946c6710b99919e Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Thu, 20 May 2010 11:05:34 +0200 Subject: [PATCH 02/33] account general ledger, landscape to use the same code as plain bzr revid: al@openerp.com-20100520090534-2dx8cv5ha5f8nl97 --- addons/account/report/__init__.py | 1 - addons/account/report/general_ledger.py | 3 + .../report/general_ledger_landscape.py | 396 ------------------ 3 files changed, 3 insertions(+), 397 deletions(-) delete mode 100644 addons/account/report/general_ledger_landscape.py diff --git a/addons/account/report/__init__.py b/addons/account/report/__init__.py index 09ff866d1a8..37508b3d9a4 100644 --- a/addons/account/report/__init__.py +++ b/addons/account/report/__init__.py @@ -30,7 +30,6 @@ import invoice import overdue import aged_trial_balance import tax_report -import general_ledger_landscape import account_tax_code import account_balance_landscape import compare_account_balance diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index 00031a77ed8..d1123263bdb 100644 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -51,6 +51,7 @@ class general_ledger(rml_parse.rml_parse): def __init__(self, cr, uid, name, context): super(general_ledger, self).__init__(cr, uid, name, context=context) + cr.sql_log=1 self.date_borne = {} self.query = "" self.child_ids = "" @@ -394,4 +395,6 @@ class general_ledger(rml_parse.rml_parse): report_sxw.report_sxw('report.account.general.ledger', 'account.account', 'addons/account/report/general_ledger.rml', parser=general_ledger, header=False) +report_sxw.report_sxw('report.account.general.ledger_landscape', 'account.account', 'addons/account/report/general_ledger_landscape.rml', parser=general_ledger, header=False) + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/general_ledger_landscape.py b/addons/account/report/general_ledger_landscape.py deleted file mode 100644 index 472f0675519..00000000000 --- a/addons/account/report/general_ledger_landscape.py +++ /dev/null @@ -1,396 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (c) 2005-2006 CamptoCamp -# -# WARNING: This program as such is intended to be used by professional -# programmers who take the whole responsability of assessing all potential -# consequences resulting from its eventual inadequacies and bugs -# End users who are looking for a ready-to-use solution with commercial -# garantees and support are strongly adviced to contract a Free Software -# Service Company -# -# This program is Free Software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################## - -import time -from report import report_sxw -import xml -import rml_parse -import pooler - -class general_ledger_landscape(rml_parse.rml_parse): - _name = 'report.account.general.ledger_landscape' - - - def set_context(self, objects, data, ids, report_type = None): - ## - self.borne_date = self.get_min_date(data['form']) - ## - new_ids = [] - if (data['model'] == 'account.account'): - new_ids = 'active_ids' in data['form']['context'] and data['form']['context']['active_ids'] or [] - else: - new_ids.append(data['form']['Account_list']) - objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) - super(general_ledger_landscape, self).set_context(objects, data, new_ids,report_type) - - def __init__(self, cr, uid, name, context): - super(general_ledger_landscape, self).__init__(cr, uid, name, context=context) - self.date_borne = {} - self.query = "" - self.child_ids = "" - self.tot_currency = 0.0 - self.period_sql = "" - self.sold_accounts = {} - self.localcontext.update( { - 'time': time, - 'lines': self.lines, - 'sum_debit_account': self._sum_debit_account, - 'sum_credit_account': self._sum_credit_account, - 'sum_solde_account': self._sum_solde_account, - 'sum_debit': self._sum_debit, - 'sum_credit': self._sum_credit, - 'sum_solde': self._sum_solde, - 'get_children_accounts': self.get_children_accounts, - 'sum_currency_amount_account': self._sum_currency_amount_account - }) - self.context = context - def _calc_contrepartie(self,cr,uid,ids, context={}): - result = {} - #for id in ids: - # result.setdefault(id, False) - - for account_line in self.pool.get('account.move.line').browse(cr, uid, ids, context): - # For avoid long text in the field we will limit it to 5 lines - # - # - # - result[account_line.id] = ' ' - num_id_move = account_line.move_id.id - num_id_line = account_line.id - account_id = account_line.account_id.id - # search the basic account - # We have the account ID we will search all account move line from now until this time - # We are in the case of we are on the top of the account move Line - cr.execute('SELECT distinct(ac.code) as code_rest,ac.name as name_rest from account_account AS ac, account_move_line mv\ - where ac.id = mv.account_id and mv.move_id = %s and mv.account_id <> %s' , (num_id_move,account_id,)) - res_mv = cr.dictfetchall() - # we need a result more than 2 line to make the test so we will made the the on 1 because we have exclude the current line - if (len(res_mv) >=1): - concat = '' - rup_id = 0 - for move_rest in res_mv: - concat = concat + move_rest['code_rest'] + '|' - result[account_line.id] = concat - if rup_id >5: - # we need to stop the computing and to escape but before we will add "..." - result[account_line.id] = concat + '...' - break - rup_id+=1 - return result - - def get_min_date(self,form): - - ## Get max born from account_fiscal year - # - sql = """ select min(fy.date_start) as start_date,max(fy.date_stop) as stop_date from account_fiscalyear - As fy where fy.state <> 'close' - """ - self.cr.execute(sql) - res = self.cr.dictfetchall() - borne_min = res[0]['start_date'] - borne_max = res[0]['stop_date'] - if form['state'] == 'byperiod': - ## This function will return the most aged date - periods = form['periods'] - if not periods: - self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s""" ,(form['fiscalyear'],)) - else: - self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) - - res = self.cr.dictfetchall() - borne_min = res[0]['start_date'] - borne_max = res[0]['stop_date'] - elif form['state'] == 'bydate': - borne_min = form['date_from'] - borne_max = form['date_to'] - elif form['state'] == 'all': - periods = form['periods'] - if not periods: - if form['fiscalyear'] == False: - fiscalyears = self.pool.get('account.fiscalyear').search(self.cr, self.uid, [('state', '=', 'draft')]) - else: - fiscalyears = [form['fiscalyear']] - self.cr.execute("select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id =ANY(%s)" ,(fiscalyears,)) - else: - self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) - res = self.cr.dictfetchall() - period_min = res[0]['start_date'] - period_max = res[0]['stop_date'] - date_min = form['date_from'] - date_max = form['date_to'] - if period_min=',child_account.id)], - context=ctx)) <> 0 : - res.append(child_account) - ## - if not len(res): - - return [account] - else: - ## We will now compute solde initiaux - for move in res: - self.cr.execute("""SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l \ - WHERE l.account_id = %s AND l.date < %s AND l.date > %s""",(move.id,self.borne_date['max_date'],self.borne_date['min_date'])) - resultat = self.cr.dictfetchall() - if resultat[0] : - if resultat[0]['sum_debit'] == None: - sum_debit = 0 - else: - sum_debit = resultat[0]['sum_debit'] - if resultat[0]['sum_credit'] == None: - sum_credit = 0 - else: - sum_credit = resultat[0]['sum_credit'] - - move.init_credit = sum_credit - move.init_debit = sum_debit - - else: - move.init_credit = 0 - move.init_debit = 0 - - - return res - - def lines(self, account, form): - inv_types = { - 'out_invoice': 'CI: ', - 'in_invoice': 'SI: ', - 'out_refund': 'OR: ', - 'in_refund': 'SR: ', - } - - if form['sortbydate'] == 'sort_date': - sorttag = 'l.date' - else: - sorttag = 'j.code' - sql = """ - SELECT l.id, l.date, j.code,c.code AS currency_code,l.amount_currency,l.ref, l.name , COALESCE(l.debit,0) as debit, COALESCE(l.credit,0) as credit, l.period_id - FROM account_move_line as l - LEFT JOIN res_currency c on (l.currency_id=c.id) - JOIN account_journal j on (l.journal_id=j.id) - AND account_id = %%s - AND %s - WHERE l.date<=%%s - AND l.date>=%%s - ORDER by %s""" % (self.query, sorttag) - - self.cr.execute(sql, (account.id, self.date_borne['max_date'], self.date_borne['min_date'],)) - - res = self.cr.dictfetchall() - sum = 0.0 - account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') - for l in res: - line = self.pool.get('account.move.line').browse(self.cr, self.uid, l['id']) - l['move'] = line.move_id.name - self.cr.execute('Select id from account_invoice where move_id =%s',(line.move_id.id,)) - tmpres = self.cr.dictfetchall() - if len(tmpres) > 0 : - inv = self.pool.get('account.invoice').browse(self.cr, self.uid, tmpres[0]['id']) - l['ref'] = inv_types[inv.type] + ': '+str(inv.number) - if line.partner_id : - l['partner'] = line.partner_id.name - else : - l['partner'] = '' - sum = l['debit'] - l ['credit'] -# c = time.strptime(l['date'],"%Y-%m-%d") -# l['date'] = time.strftime("%d-%m-%Y",c) - l['progress'] = sum - l['line_corresp'] = self._calc_contrepartie(self.cr,self.uid,[l['id']])[l['id']] - # Modification du amount Currency - if (l['credit'] > 0): - if l['amount_currency'] != None: - l['amount_currency'] = abs(l['amount_currency']) * -1 - - # - if l['amount_currency'] != None: - self.tot_currency = self.tot_currency + l['amount_currency'] - return res - - def _sum_debit_account(self, account, form): - - self.cr.execute("SELECT sum(debit) "\ - "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+self.query,(account.id,)) - ## Add solde init to the result - # - sum_debit = self.cr.fetchone()[0] or 0.0 - if form['soldeinit']: - sum_debit += account.init_debit - # - ## - return sum_debit - - def _sum_credit_account(self, account, form): - - self.cr.execute("SELECT sum(credit) "\ - "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+self.query,(account.id,)) - ## Add solde init to the result - # - sum_credit = self.cr.fetchone()[0] or 0.0 - if form['soldeinit']: - sum_credit += account.init_credit - # - ## - - return sum_credit - - def _sum_solde_account(self, account, form): - self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ - "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+self.query,(account.id,)) - sum_solde = self.cr.fetchone()[0] or 0.0 - if form.get('soldeinit',False): - sum_solde += account.init_debit - account.init_credit - - return sum_solde - - def _sum_debit(self, form): - if not self.ids: - return 0.0 - self.cr.execute("SELECT sum(debit) "\ - "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+self.query,(self.child_ids,)) - sum_debit = self.cr.fetchone()[0] or 0.0 - return sum_debit - - def _sum_credit(self, form): - if not self.ids: - return 0.0 - self.cr.execute("SELECT sum(credit) "\ - "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+self.query,(self.child_ids,)) - ## Add solde init to the result - # - sum_credit = self.cr.fetchone()[0] or 0.0 - return sum_credit - - def _sum_solde(self, form): - if not self.ids: - return 0.0 - self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ - "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+self.query,(self.child_ids,)) - sum_solde = self.cr.fetchone()[0] or 0.0 - return sum_solde - - def _set_get_account_currency_code(self, account_id): - self.cr.execute("SELECT c.code as code "\ - "FROM res_currency c,account_account as ac "\ - "WHERE ac.id = %s AND ac.currency_id = c.id",(account_id,)) - result = self.cr.fetchone() - if result: - self.account_currency = result[0] - else: - self.account_currency = False - - def _sum_currency_amount_account(self, account, form): - self._set_get_account_currency_code(account.id) - self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %s ", (account.id,)) - total = self.cr.fetchone() - - if self.account_currency: - return_field = str(total[0]) + self.account_currency - return return_field - else: - currency_total = self.tot_currency = 0.0 - return currency_total - -report_sxw.report_sxw('report.account.general.ledger_landscape', 'account.account', 'addons/account/report/general_ledger_landscape.rml', parser=general_ledger_landscape, header=False) -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From fa63a050c325f83b3300d79096cc1ebe884d934b Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Thu, 20 May 2010 11:20:05 +0200 Subject: [PATCH 03/33] merge 5.0.10 changes bzr revid: al@openerp.com-20100520092005-i288j8eycd0tudhp --- addons/account/report/general_ledger.py | 60 ++++++++++++++----------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index d1123263bdb..747a643d598 100644 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -30,6 +30,8 @@ import xml import rml_parse import pooler +from mx.DateTime import * + class general_ledger(rml_parse.rml_parse): _name = 'report.account.general.ledger' @@ -41,7 +43,7 @@ class general_ledger(rml_parse.rml_parse): ## new_ids = [] if (data['model'] == 'account.account'): - new_ids = 'active_ids' in data['form']['context'] and data['form']['context']['active_ids'] or [] + new_ids = ids else: new_ids.append(data['form']['Account_list']) @@ -89,7 +91,7 @@ class general_ledger(rml_parse.rml_parse): # We have the account ID we will search all account move line from now until this time # We are in the case of we are on the top of the account move Line cr.execute('SELECT distinct(ac.code) as code_rest,ac.name as name_rest from account_account AS ac, account_move_line mv\ - where ac.id = mv.account_id and mv.move_id = %s and mv.account_id <> %s' ,(num_id_move,account_id,)) + where ac.id = mv.account_id and mv.move_id = ' + num_id_move +' and mv.account_id <> ' + account_id ) res_mv = cr.dictfetchall() # we need a result more than 2 line to make the test so we will made the the on 1 because we have exclude the current line if (len(res_mv) >=1): @@ -118,13 +120,17 @@ class general_ledger(rml_parse.rml_parse): borne_max = res[0]['stop_date'] if form['state'] == 'byperiod': ## This function will return the most aged date - periods = form['periods'] + periods = form['periods'][0][2] if not periods: - self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s""",(form['fiscalyear'],)) + sql = """ + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ + """ else: - self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) + periods_id = ','.join(map(str, periods)) + sql = """ + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """) + """ + self.cr.execute(sql) res = self.cr.dictfetchall() borne_min = res[0]['start_date'] borne_max = res[0]['stop_date'] @@ -132,16 +138,17 @@ class general_ledger(rml_parse.rml_parse): borne_min = form['date_from'] borne_max = form['date_to'] elif form['state'] == 'all': - periods = form['periods'] + periods = form['periods'][0][2] if not periods: - if form['fiscalyear'] == False: - fiscalyears = self.pool.get('account.fiscalyear').search(self.cr, self.uid, [('state', '=', 'draft')]) - else: - fiscalyears = [form['fiscalyear']] - self.cr.execute("select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id =ANY(%s)" ,(fiscalyears,)) + sql = """ + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ + """ else: - self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) + periods_id = ','.join(map(str, periods)) + sql = """ + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """) + """ + self.cr.execute(sql) res = self.cr.dictfetchall() period_min = res[0]['start_date'] period_max = res[0]['stop_date'] @@ -184,7 +191,7 @@ class general_ledger(rml_parse.rml_parse): ctx['state'] = form['context'].get('state','all') if form.has_key('fiscalyear'): ctx['fiscalyear'] = form['fiscalyear'] - ctx['periods'] = form['periods'] + ctx['periods'] = form['periods'][0][2] else: ctx['date_from'] = form['date_from'] ctx['date_to'] = form['date_to'] @@ -225,8 +232,8 @@ class general_ledger(rml_parse.rml_parse): else: ## We will now compute solde initiaux for move in res: - self.cr.execute("""SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l \ - WHERE l.account_id = %s AND l.date < %s AND l.date > %s""",(move.id,self.borne_date['max_date'],self.borne_date['min_date'])) + SOLDEINIT = "SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l WHERE l.account_id = " + str(move.id) + " AND l.date < '" + self.borne_date['max_date'] + "'" + " AND l.date > '" + self.borne_date['min_date'] + "'" + self.cr.execute(SOLDEINIT) resultat = self.cr.dictfetchall() if resultat[0] : if resultat[0]['sum_debit'] == None: @@ -279,7 +286,7 @@ class general_ledger(rml_parse.rml_parse): for l in res: line = self.pool.get('account.move.line').browse(self.cr, self.uid, l['id']) l['move'] = line.move_id.name - self.cr.execute('Select id from account_invoice where move_id =%s',(line.move_id.id,)) + self.cr.execute('Select id from account_invoice where move_id =%s'%(line.move_id.id)) tmpres = self.cr.dictfetchall() if len(tmpres) > 0 : inv = self.pool.get('account.invoice').browse(self.cr, self.uid, tmpres[0]['id']) @@ -307,7 +314,7 @@ class general_ledger(rml_parse.rml_parse): self.cr.execute("SELECT sum(debit) "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+self.query,(account.id,)) + "WHERE l.account_id = %s AND %s "%(account.id, self.query)) ## Add solde init to the result # sum_debit = self.cr.fetchone()[0] or 0.0 @@ -321,7 +328,7 @@ class general_ledger(rml_parse.rml_parse): self.cr.execute("SELECT sum(credit) "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+ self.query,(account.id,)) + "WHERE l.account_id = %s AND %s "%(account.id,self.query)) ## Add solde init to the result # sum_credit = self.cr.fetchone()[0] or 0.0 @@ -335,7 +342,7 @@ class general_ledger(rml_parse.rml_parse): def _sum_solde_account(self, account, form): self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+ self.query,(account.id,)) + "WHERE l.account_id = %s AND %s"%(account.id,self.query)) sum_solde = self.cr.fetchone()[0] or 0.0 if form.get('soldeinit', False): sum_solde += account.init_debit - account.init_credit @@ -347,7 +354,7 @@ class general_ledger(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT sum(debit) "\ "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+ self.query,(self.child_ids,)) + "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) sum_debit = self.cr.fetchone()[0] or 0.0 return sum_debit @@ -356,7 +363,7 @@ class general_ledger(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT sum(credit) "\ "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+ self.query,(self.child_ids,)) + "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) ## Add solde init to the result # sum_credit = self.cr.fetchone()[0] or 0.0 @@ -367,14 +374,14 @@ class general_ledger(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+ self.query,(self.child_ids,)) + "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) sum_solde = self.cr.fetchone()[0] or 0.0 return sum_solde def _set_get_account_currency_code(self, account_id): self.cr.execute("SELECT c.code as code "\ "FROM res_currency c,account_account as ac "\ - "WHERE ac.id = %s AND ac.currency_id = c.id",(account_id,)) + "WHERE ac.id = %s AND ac.currency_id = c.id"%(account_id)) result = self.cr.fetchone() if result: self.account_currency = result[0] @@ -393,7 +400,6 @@ class general_ledger(rml_parse.rml_parse): currency_total = self.tot_currency = 0.0 return currency_total - report_sxw.report_sxw('report.account.general.ledger', 'account.account', 'addons/account/report/general_ledger.rml', parser=general_ledger, header=False) report_sxw.report_sxw('report.account.general.ledger_landscape', 'account.account', 'addons/account/report/general_ledger_landscape.rml', parser=general_ledger, header=False) From 4a1964aeca77ac4a120e5920248ed724e2fb97e3 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Thu, 20 May 2010 11:20:05 +0200 Subject: [PATCH 04/33] merge 5.0.10 changes bzr revid: al@openerp.com-20100520092005-yw071p8gb3ejzr8b --- addons/account/report/general_ledger.py | 60 ++++++++++++++----------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index d1123263bdb..747a643d598 100644 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -30,6 +30,8 @@ import xml import rml_parse import pooler +from mx.DateTime import * + class general_ledger(rml_parse.rml_parse): _name = 'report.account.general.ledger' @@ -41,7 +43,7 @@ class general_ledger(rml_parse.rml_parse): ## new_ids = [] if (data['model'] == 'account.account'): - new_ids = 'active_ids' in data['form']['context'] and data['form']['context']['active_ids'] or [] + new_ids = ids else: new_ids.append(data['form']['Account_list']) @@ -89,7 +91,7 @@ class general_ledger(rml_parse.rml_parse): # We have the account ID we will search all account move line from now until this time # We are in the case of we are on the top of the account move Line cr.execute('SELECT distinct(ac.code) as code_rest,ac.name as name_rest from account_account AS ac, account_move_line mv\ - where ac.id = mv.account_id and mv.move_id = %s and mv.account_id <> %s' ,(num_id_move,account_id,)) + where ac.id = mv.account_id and mv.move_id = ' + num_id_move +' and mv.account_id <> ' + account_id ) res_mv = cr.dictfetchall() # we need a result more than 2 line to make the test so we will made the the on 1 because we have exclude the current line if (len(res_mv) >=1): @@ -118,13 +120,17 @@ class general_ledger(rml_parse.rml_parse): borne_max = res[0]['stop_date'] if form['state'] == 'byperiod': ## This function will return the most aged date - periods = form['periods'] + periods = form['periods'][0][2] if not periods: - self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s""",(form['fiscalyear'],)) + sql = """ + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ + """ else: - self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) + periods_id = ','.join(map(str, periods)) + sql = """ + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """) + """ + self.cr.execute(sql) res = self.cr.dictfetchall() borne_min = res[0]['start_date'] borne_max = res[0]['stop_date'] @@ -132,16 +138,17 @@ class general_ledger(rml_parse.rml_parse): borne_min = form['date_from'] borne_max = form['date_to'] elif form['state'] == 'all': - periods = form['periods'] + periods = form['periods'][0][2] if not periods: - if form['fiscalyear'] == False: - fiscalyears = self.pool.get('account.fiscalyear').search(self.cr, self.uid, [('state', '=', 'draft')]) - else: - fiscalyears = [form['fiscalyear']] - self.cr.execute("select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id =ANY(%s)" ,(fiscalyears,)) + sql = """ + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ + """ else: - self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) + periods_id = ','.join(map(str, periods)) + sql = """ + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """) + """ + self.cr.execute(sql) res = self.cr.dictfetchall() period_min = res[0]['start_date'] period_max = res[0]['stop_date'] @@ -184,7 +191,7 @@ class general_ledger(rml_parse.rml_parse): ctx['state'] = form['context'].get('state','all') if form.has_key('fiscalyear'): ctx['fiscalyear'] = form['fiscalyear'] - ctx['periods'] = form['periods'] + ctx['periods'] = form['periods'][0][2] else: ctx['date_from'] = form['date_from'] ctx['date_to'] = form['date_to'] @@ -225,8 +232,8 @@ class general_ledger(rml_parse.rml_parse): else: ## We will now compute solde initiaux for move in res: - self.cr.execute("""SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l \ - WHERE l.account_id = %s AND l.date < %s AND l.date > %s""",(move.id,self.borne_date['max_date'],self.borne_date['min_date'])) + SOLDEINIT = "SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l WHERE l.account_id = " + str(move.id) + " AND l.date < '" + self.borne_date['max_date'] + "'" + " AND l.date > '" + self.borne_date['min_date'] + "'" + self.cr.execute(SOLDEINIT) resultat = self.cr.dictfetchall() if resultat[0] : if resultat[0]['sum_debit'] == None: @@ -279,7 +286,7 @@ class general_ledger(rml_parse.rml_parse): for l in res: line = self.pool.get('account.move.line').browse(self.cr, self.uid, l['id']) l['move'] = line.move_id.name - self.cr.execute('Select id from account_invoice where move_id =%s',(line.move_id.id,)) + self.cr.execute('Select id from account_invoice where move_id =%s'%(line.move_id.id)) tmpres = self.cr.dictfetchall() if len(tmpres) > 0 : inv = self.pool.get('account.invoice').browse(self.cr, self.uid, tmpres[0]['id']) @@ -307,7 +314,7 @@ class general_ledger(rml_parse.rml_parse): self.cr.execute("SELECT sum(debit) "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+self.query,(account.id,)) + "WHERE l.account_id = %s AND %s "%(account.id, self.query)) ## Add solde init to the result # sum_debit = self.cr.fetchone()[0] or 0.0 @@ -321,7 +328,7 @@ class general_ledger(rml_parse.rml_parse): self.cr.execute("SELECT sum(credit) "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+ self.query,(account.id,)) + "WHERE l.account_id = %s AND %s "%(account.id,self.query)) ## Add solde init to the result # sum_credit = self.cr.fetchone()[0] or 0.0 @@ -335,7 +342,7 @@ class general_ledger(rml_parse.rml_parse): def _sum_solde_account(self, account, form): self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+ self.query,(account.id,)) + "WHERE l.account_id = %s AND %s"%(account.id,self.query)) sum_solde = self.cr.fetchone()[0] or 0.0 if form.get('soldeinit', False): sum_solde += account.init_debit - account.init_credit @@ -347,7 +354,7 @@ class general_ledger(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT sum(debit) "\ "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+ self.query,(self.child_ids,)) + "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) sum_debit = self.cr.fetchone()[0] or 0.0 return sum_debit @@ -356,7 +363,7 @@ class general_ledger(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT sum(credit) "\ "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+ self.query,(self.child_ids,)) + "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) ## Add solde init to the result # sum_credit = self.cr.fetchone()[0] or 0.0 @@ -367,14 +374,14 @@ class general_ledger(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+ self.query,(self.child_ids,)) + "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) sum_solde = self.cr.fetchone()[0] or 0.0 return sum_solde def _set_get_account_currency_code(self, account_id): self.cr.execute("SELECT c.code as code "\ "FROM res_currency c,account_account as ac "\ - "WHERE ac.id = %s AND ac.currency_id = c.id",(account_id,)) + "WHERE ac.id = %s AND ac.currency_id = c.id"%(account_id)) result = self.cr.fetchone() if result: self.account_currency = result[0] @@ -393,7 +400,6 @@ class general_ledger(rml_parse.rml_parse): currency_total = self.tot_currency = 0.0 return currency_total - report_sxw.report_sxw('report.account.general.ledger', 'account.account', 'addons/account/report/general_ledger.rml', parser=general_ledger, header=False) report_sxw.report_sxw('report.account.general.ledger_landscape', 'account.account', 'addons/account/report/general_ledger_landscape.rml', parser=general_ledger, header=False) From e7249de2b14e1ec8c2076b79e37527088db1a180 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Thu, 20 May 2010 16:43:10 +0200 Subject: [PATCH 05/33] account general ledger, reduce complexity to O(account number) from O(move_line number) bzr revid: al@openerp.com-20100520144310-jbwd0887380qig79 --- addons/account/report/general_ledger.py | 134 +++++++++--------------- 1 file changed, 52 insertions(+), 82 deletions(-) diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index 747a643d598..d85d082423f 100644 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -35,8 +35,6 @@ from mx.DateTime import * class general_ledger(rml_parse.rml_parse): _name = 'report.account.general.ledger' - - def set_context(self, objects, data, ids, report_type = None): ## self.borne_date = self.get_min_date(data['form']) @@ -73,39 +71,6 @@ class general_ledger(rml_parse.rml_parse): 'sum_currency_amount_account': self._sum_currency_amount_account }) self.context = context - def _calc_contrepartie(self,cr,uid,ids, context={}): - result = {} - #for id in ids: - # result.setdefault(id, False) - - for account_line in self.pool.get('account.move.line').browse(cr, uid, ids, context): - # For avoid long text in the field we will limit it to 5 lines - # - # - # - result[account_line.id] = ' ' - num_id_move = str(account_line.move_id.id) - num_id_line = str(account_line.id) - account_id = str(account_line.account_id.id) - # search the basic account - # We have the account ID we will search all account move line from now until this time - # We are in the case of we are on the top of the account move Line - cr.execute('SELECT distinct(ac.code) as code_rest,ac.name as name_rest from account_account AS ac, account_move_line mv\ - where ac.id = mv.account_id and mv.move_id = ' + num_id_move +' and mv.account_id <> ' + account_id ) - res_mv = cr.dictfetchall() - # we need a result more than 2 line to make the test so we will made the the on 1 because we have exclude the current line - if (len(res_mv) >=1): - concat = '' - rup_id = 0 - for move_rest in res_mv: - concat = concat + move_rest['code_rest'] + '|' - result[account_line.id] = concat - if rup_id >5: - # we need to stop the computing and to escape but before we will add "..." - result[account_line.id] = concat + '...' - break - rup_id+=1 - return result def get_min_date(self,form): @@ -120,7 +85,8 @@ class general_ledger(rml_parse.rml_parse): borne_max = res[0]['stop_date'] if form['state'] == 'byperiod': ## This function will return the most aged date - periods = form['periods'][0][2] + periods = form['periods'] + #periods = form['periods'][0][2] if not periods: sql = """ Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ @@ -138,7 +104,8 @@ class general_ledger(rml_parse.rml_parse): borne_min = form['date_from'] borne_max = form['date_to'] elif form['state'] == 'all': - periods = form['periods'][0][2] + periods = form['periods'] + #periods = form['periods'][0][2] if not periods: sql = """ Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ @@ -175,9 +142,6 @@ class general_ledger(rml_parse.rml_parse): } return self.date_borne - - - def get_children_accounts(self, account, form): self.child_ids = self.pool.get('account.account').search(self.cr, self.uid, @@ -191,7 +155,9 @@ class general_ledger(rml_parse.rml_parse): ctx['state'] = form['context'].get('state','all') if form.has_key('fiscalyear'): ctx['fiscalyear'] = form['fiscalyear'] - ctx['periods'] = form['periods'][0][2] + ctx['periods'] = form['periods'] + #ctx['periods'] = form['periods'][0][2] + else: ctx['date_from'] = form['date_from'] ctx['date_to'] = form['date_to'] @@ -256,56 +222,60 @@ class general_ledger(rml_parse.rml_parse): return res def lines(self, account, form): - inv_types = { - 'out_invoice': 'CI: ', - 'in_invoice': 'SI: ', - 'out_refund': 'OR: ', - 'in_refund': 'SR: ', - } + """ Return all the account_move_line of account with their account code counterparts """ - if form['sortbydate'] == 'sort_date': - sorttag = 'l.date' - else: - sorttag = 'j.code' + # First compute all counterpart strings for every move_id where this account appear sql = """ - SELECT l.id, l.date, j.code,c.code AS currency_code,l.amount_currency,l.ref, l.name , COALESCE(l.debit,0) as debit, COALESCE(l.credit,0) as credit, l.period_id - FROM account_move_line as l - LEFT JOIN res_currency c on (l.currency_id=c.id) - JOIN account_journal j on (l.journal_id=j.id) - AND account_id = %%s - AND %s - WHERE l.date<=%%s - AND l.date>=%%s - ORDER by %s""" % (self.query, sorttag) - - self.cr.execute(sql, (account.id, self.date_borne['max_date'], self.date_borne['min_date'],)) + SELECT m1.move_id, + array_to_string(ARRAY(SELECT DISTINCT a.code FROM account_move_line m2 LEFT JOIN account_account a ON (m2.account_id=a.id) WHERE m2.move_id = m1.move_id AND m2.account_id<>%%s), ', ') AS counterpart + FROM (SELECT move_id FROM account_move_line l WHERE %s AND l.account_id = %%s AND l.date<=%%s AND l.date>=%%s GROUP BY move_id) m1 + """ % self.query + self.cr.execute(sql, (account.id, account.id, self.date_borne['max_date'], self.date_borne['min_date'])) + counterpart_res = self.cr.dictfetchall() + counterpart_accounts = {} + for i in counterpart_res: + counterpart_accounts[i['move_id']]=i['counterpart'] + del counterpart_res + # Then select all account_move_line of this account + if form['sortbydate'] == 'sort_date': + sql_sort='l.date' + else: + sql_sort='j.code' + sql = """ + SELECT l.id, l.date, j.code, l.amount_currency,l.ref, l.name, COALESCE(l.debit,0) AS debit, COALESCE(l.credit,0) AS credit, l.period_id, l.partner_id, + m.name AS move_name, m.id AS move_id, + c.code AS currency_code, + i.id AS invoice_id, i.type AS invoice_type, i.number AS invoice_number, + p.name AS partner_name + FROM account_move_line l + LEFT JOIN account_move m on (l.move_id=m.id) + LEFT JOIN res_currency c on (l.currency_id=c.id) + LEFT JOIN res_partner p on (l.partner_id=p.id) + LEFT JOIN account_invoice i on (m.id =i.move_id) + JOIN account_journal j on (l.journal_id=j.id) + WHERE %s AND l.account_id = %%s AND l.date<=%%s AND l.date>=%%s ORDER by %s + """ % (self.query, sql_sort) + self.cr.execute(sql, (account.id, self.date_borne['max_date'], self.date_borne['min_date'])) res = self.cr.dictfetchall() - sum = 0.0 + account_sum = 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') + inv_types = { 'out_invoice': 'CI', 'in_invoice': 'SI', 'out_refund': 'OR', 'in_refund': 'SR', } + for l in res: - line = self.pool.get('account.move.line').browse(self.cr, self.uid, l['id']) - l['move'] = line.move_id.name - self.cr.execute('Select id from account_invoice where move_id =%s'%(line.move_id.id)) - tmpres = self.cr.dictfetchall() - if len(tmpres) > 0 : - inv = self.pool.get('account.invoice').browse(self.cr, self.uid, tmpres[0]['id']) - l['ref'] = inv_types[inv.type] + ': '+str(inv.number) - if line.partner_id : - l['partner'] = line.partner_id.name - else : - l['partner'] = '' - sum = l['debit'] - l ['credit'] -# c = time.strptime(l['date'],"%Y-%m-%d") -# l['date'] = time.strftime("%d-%m-%Y",c) - l['progress'] = sum - l['line_corresp'] = self._calc_contrepartie(self.cr,self.uid,[l['id']])[l['id']] + l['move']=l['move_name'] + if l['invoice_id']: + l['ref'] = '%s: %s'%(inv_types[l['invoice_type']],l['invoice_number']) + l['partner'] = l['partner_name'] or '' + account_sum = l['debit'] - l ['credit'] + #c = time.strptime(l['date'],"%Y-%m-%d") + #l['date'] = time.strftime("%d-%m-%Y",c) + l['progress'] = account_sum + l['line_corresp'] = counterpart_accounts[l['move_id']] # Modification du amount Currency - if (l['credit'] > 0): + if l['credit'] > 0: if l['amount_currency'] != None: l['amount_currency'] = abs(l['amount_currency']) * -1 - - # if l['amount_currency'] != None: self.tot_currency = self.tot_currency + l['amount_currency'] return res From 99192e62de5a8853113029aee9c04d11dc03cb64 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Thu, 20 May 2010 16:43:10 +0200 Subject: [PATCH 06/33] account general ledger, reduce complexity to O(account number) from O(move_line number) bzr revid: al@openerp.com-20100520144310-vo270dkectxzu26z --- addons/account/report/general_ledger.py | 134 +++++++++--------------- 1 file changed, 52 insertions(+), 82 deletions(-) diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index 747a643d598..d85d082423f 100644 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -35,8 +35,6 @@ from mx.DateTime import * class general_ledger(rml_parse.rml_parse): _name = 'report.account.general.ledger' - - def set_context(self, objects, data, ids, report_type = None): ## self.borne_date = self.get_min_date(data['form']) @@ -73,39 +71,6 @@ class general_ledger(rml_parse.rml_parse): 'sum_currency_amount_account': self._sum_currency_amount_account }) self.context = context - def _calc_contrepartie(self,cr,uid,ids, context={}): - result = {} - #for id in ids: - # result.setdefault(id, False) - - for account_line in self.pool.get('account.move.line').browse(cr, uid, ids, context): - # For avoid long text in the field we will limit it to 5 lines - # - # - # - result[account_line.id] = ' ' - num_id_move = str(account_line.move_id.id) - num_id_line = str(account_line.id) - account_id = str(account_line.account_id.id) - # search the basic account - # We have the account ID we will search all account move line from now until this time - # We are in the case of we are on the top of the account move Line - cr.execute('SELECT distinct(ac.code) as code_rest,ac.name as name_rest from account_account AS ac, account_move_line mv\ - where ac.id = mv.account_id and mv.move_id = ' + num_id_move +' and mv.account_id <> ' + account_id ) - res_mv = cr.dictfetchall() - # we need a result more than 2 line to make the test so we will made the the on 1 because we have exclude the current line - if (len(res_mv) >=1): - concat = '' - rup_id = 0 - for move_rest in res_mv: - concat = concat + move_rest['code_rest'] + '|' - result[account_line.id] = concat - if rup_id >5: - # we need to stop the computing and to escape but before we will add "..." - result[account_line.id] = concat + '...' - break - rup_id+=1 - return result def get_min_date(self,form): @@ -120,7 +85,8 @@ class general_ledger(rml_parse.rml_parse): borne_max = res[0]['stop_date'] if form['state'] == 'byperiod': ## This function will return the most aged date - periods = form['periods'][0][2] + periods = form['periods'] + #periods = form['periods'][0][2] if not periods: sql = """ Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ @@ -138,7 +104,8 @@ class general_ledger(rml_parse.rml_parse): borne_min = form['date_from'] borne_max = form['date_to'] elif form['state'] == 'all': - periods = form['periods'][0][2] + periods = form['periods'] + #periods = form['periods'][0][2] if not periods: sql = """ Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ @@ -175,9 +142,6 @@ class general_ledger(rml_parse.rml_parse): } return self.date_borne - - - def get_children_accounts(self, account, form): self.child_ids = self.pool.get('account.account').search(self.cr, self.uid, @@ -191,7 +155,9 @@ class general_ledger(rml_parse.rml_parse): ctx['state'] = form['context'].get('state','all') if form.has_key('fiscalyear'): ctx['fiscalyear'] = form['fiscalyear'] - ctx['periods'] = form['periods'][0][2] + ctx['periods'] = form['periods'] + #ctx['periods'] = form['periods'][0][2] + else: ctx['date_from'] = form['date_from'] ctx['date_to'] = form['date_to'] @@ -256,56 +222,60 @@ class general_ledger(rml_parse.rml_parse): return res def lines(self, account, form): - inv_types = { - 'out_invoice': 'CI: ', - 'in_invoice': 'SI: ', - 'out_refund': 'OR: ', - 'in_refund': 'SR: ', - } + """ Return all the account_move_line of account with their account code counterparts """ - if form['sortbydate'] == 'sort_date': - sorttag = 'l.date' - else: - sorttag = 'j.code' + # First compute all counterpart strings for every move_id where this account appear sql = """ - SELECT l.id, l.date, j.code,c.code AS currency_code,l.amount_currency,l.ref, l.name , COALESCE(l.debit,0) as debit, COALESCE(l.credit,0) as credit, l.period_id - FROM account_move_line as l - LEFT JOIN res_currency c on (l.currency_id=c.id) - JOIN account_journal j on (l.journal_id=j.id) - AND account_id = %%s - AND %s - WHERE l.date<=%%s - AND l.date>=%%s - ORDER by %s""" % (self.query, sorttag) - - self.cr.execute(sql, (account.id, self.date_borne['max_date'], self.date_borne['min_date'],)) + SELECT m1.move_id, + array_to_string(ARRAY(SELECT DISTINCT a.code FROM account_move_line m2 LEFT JOIN account_account a ON (m2.account_id=a.id) WHERE m2.move_id = m1.move_id AND m2.account_id<>%%s), ', ') AS counterpart + FROM (SELECT move_id FROM account_move_line l WHERE %s AND l.account_id = %%s AND l.date<=%%s AND l.date>=%%s GROUP BY move_id) m1 + """ % self.query + self.cr.execute(sql, (account.id, account.id, self.date_borne['max_date'], self.date_borne['min_date'])) + counterpart_res = self.cr.dictfetchall() + counterpart_accounts = {} + for i in counterpart_res: + counterpart_accounts[i['move_id']]=i['counterpart'] + del counterpart_res + # Then select all account_move_line of this account + if form['sortbydate'] == 'sort_date': + sql_sort='l.date' + else: + sql_sort='j.code' + sql = """ + SELECT l.id, l.date, j.code, l.amount_currency,l.ref, l.name, COALESCE(l.debit,0) AS debit, COALESCE(l.credit,0) AS credit, l.period_id, l.partner_id, + m.name AS move_name, m.id AS move_id, + c.code AS currency_code, + i.id AS invoice_id, i.type AS invoice_type, i.number AS invoice_number, + p.name AS partner_name + FROM account_move_line l + LEFT JOIN account_move m on (l.move_id=m.id) + LEFT JOIN res_currency c on (l.currency_id=c.id) + LEFT JOIN res_partner p on (l.partner_id=p.id) + LEFT JOIN account_invoice i on (m.id =i.move_id) + JOIN account_journal j on (l.journal_id=j.id) + WHERE %s AND l.account_id = %%s AND l.date<=%%s AND l.date>=%%s ORDER by %s + """ % (self.query, sql_sort) + self.cr.execute(sql, (account.id, self.date_borne['max_date'], self.date_borne['min_date'])) res = self.cr.dictfetchall() - sum = 0.0 + account_sum = 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') + inv_types = { 'out_invoice': 'CI', 'in_invoice': 'SI', 'out_refund': 'OR', 'in_refund': 'SR', } + for l in res: - line = self.pool.get('account.move.line').browse(self.cr, self.uid, l['id']) - l['move'] = line.move_id.name - self.cr.execute('Select id from account_invoice where move_id =%s'%(line.move_id.id)) - tmpres = self.cr.dictfetchall() - if len(tmpres) > 0 : - inv = self.pool.get('account.invoice').browse(self.cr, self.uid, tmpres[0]['id']) - l['ref'] = inv_types[inv.type] + ': '+str(inv.number) - if line.partner_id : - l['partner'] = line.partner_id.name - else : - l['partner'] = '' - sum = l['debit'] - l ['credit'] -# c = time.strptime(l['date'],"%Y-%m-%d") -# l['date'] = time.strftime("%d-%m-%Y",c) - l['progress'] = sum - l['line_corresp'] = self._calc_contrepartie(self.cr,self.uid,[l['id']])[l['id']] + l['move']=l['move_name'] + if l['invoice_id']: + l['ref'] = '%s: %s'%(inv_types[l['invoice_type']],l['invoice_number']) + l['partner'] = l['partner_name'] or '' + account_sum = l['debit'] - l ['credit'] + #c = time.strptime(l['date'],"%Y-%m-%d") + #l['date'] = time.strftime("%d-%m-%Y",c) + l['progress'] = account_sum + l['line_corresp'] = counterpart_accounts[l['move_id']] # Modification du amount Currency - if (l['credit'] > 0): + if l['credit'] > 0: if l['amount_currency'] != None: l['amount_currency'] = abs(l['amount_currency']) * -1 - - # if l['amount_currency'] != None: self.tot_currency = self.tot_currency + l['amount_currency'] return res From 7bbc9e1d4daca5c96d5dc405bb02d2a925851e27 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Fri, 21 May 2010 15:14:19 +0200 Subject: [PATCH 07/33] fix the row height to avoid the computation by reportlab/platypus/tables.py _calc_height bzr revid: al@openerp.com-20100521131419-e7rj80zd84mlkxf5 --- addons/account/report/general_ledger.py | 6 ++---- addons/account/report/general_ledger.rml | 4 ++-- addons/account/report/general_ledger_landscape.rml | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index d85d082423f..e2c24fe96d2 100644 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -30,8 +30,6 @@ import xml import rml_parse import pooler -from mx.DateTime import * - class general_ledger(rml_parse.rml_parse): _name = 'report.account.general.ledger' @@ -41,7 +39,8 @@ class general_ledger(rml_parse.rml_parse): ## new_ids = [] if (data['model'] == 'account.account'): - new_ids = ids + new_ids = 'active_ids' in data['form']['context'] and data['form']['context']['active_ids'] or [] + #new_ids = ids else: new_ids.append(data['form']['Account_list']) @@ -51,7 +50,6 @@ class general_ledger(rml_parse.rml_parse): def __init__(self, cr, uid, name, context): super(general_ledger, self).__init__(cr, uid, name, context=context) - cr.sql_log=1 self.date_borne = {} self.query = "" self.child_ids = "" diff --git a/addons/account/report/general_ledger.rml b/addons/account/report/general_ledger.rml index 75cb086b343..c711934639d 100644 --- a/addons/account/report/general_ledger.rml +++ b/addons/account/report/general_ledger.rml @@ -105,7 +105,7 @@
[[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] - [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] + [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] @@ -156,7 +156,7 @@
[[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] - [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] + [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] diff --git a/addons/account/report/general_ledger_landscape.rml b/addons/account/report/general_ledger_landscape.rml index 9e937a72baf..ced60e69c8b 100644 --- a/addons/account/report/general_ledger_landscape.rml +++ b/addons/account/report/general_ledger_landscape.rml @@ -104,7 +104,7 @@ [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] - [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] + [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] @@ -165,7 +165,7 @@ [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] - [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] + [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] From 84830accf59d5cada276919684fe767f46a1eb70 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Fri, 21 May 2010 15:14:19 +0200 Subject: [PATCH 08/33] fix the row height to avoid the computation by reportlab/platypus/tables.py _calc_height bzr revid: al@openerp.com-20100521131419-alu3izs3v2oxf9eo --- addons/account/report/general_ledger.py | 6 ++---- addons/account/report/general_ledger.rml | 4 ++-- addons/account/report/general_ledger_landscape.rml | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index d85d082423f..e2c24fe96d2 100644 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -30,8 +30,6 @@ import xml import rml_parse import pooler -from mx.DateTime import * - class general_ledger(rml_parse.rml_parse): _name = 'report.account.general.ledger' @@ -41,7 +39,8 @@ class general_ledger(rml_parse.rml_parse): ## new_ids = [] if (data['model'] == 'account.account'): - new_ids = ids + new_ids = 'active_ids' in data['form']['context'] and data['form']['context']['active_ids'] or [] + #new_ids = ids else: new_ids.append(data['form']['Account_list']) @@ -51,7 +50,6 @@ class general_ledger(rml_parse.rml_parse): def __init__(self, cr, uid, name, context): super(general_ledger, self).__init__(cr, uid, name, context=context) - cr.sql_log=1 self.date_borne = {} self.query = "" self.child_ids = "" diff --git a/addons/account/report/general_ledger.rml b/addons/account/report/general_ledger.rml index 75cb086b343..c711934639d 100644 --- a/addons/account/report/general_ledger.rml +++ b/addons/account/report/general_ledger.rml @@ -105,7 +105,7 @@
[[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] - [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] + [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] @@ -156,7 +156,7 @@
[[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] - [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] + [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] diff --git a/addons/account/report/general_ledger_landscape.rml b/addons/account/report/general_ledger_landscape.rml index 9e937a72baf..ced60e69c8b 100644 --- a/addons/account/report/general_ledger_landscape.rml +++ b/addons/account/report/general_ledger_landscape.rml @@ -104,7 +104,7 @@ [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] - [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] + [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] @@ -165,7 +165,7 @@ [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] - [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] + [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] From 42dbaa3952e7d6c248fc98703526205366ca579b Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Wed, 26 May 2010 12:24:21 +0530 Subject: [PATCH 09/33] [IMP]:hr_evaluation:improved the SQL report. bzr revid: apa@tinyerp.com-20100526065421-tuy6sw96apgkz22b --- .../report/hr_evaluation_report_view.xml | 54 ++++++++++--------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/addons/hr_evaluation/report/hr_evaluation_report_view.xml b/addons/hr_evaluation/report/hr_evaluation_report_view.xml index 921d8b43a2b..6b2e6ead15f 100644 --- a/addons/hr_evaluation/report/hr_evaluation_report_view.xml +++ b/addons/hr_evaluation/report/hr_evaluation_report_view.xml @@ -42,35 +42,42 @@ - - + + + string=" 7 Days " + separator="1" + domain="[('create_date','<=', time.strftime('%%Y-%%m-%%d')), ('create_date','>',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]" + help="Tasks during last 7 days"/> + icon="terp-hr" + domain="[('state','=','draft')]" + help = "Draft Evaluations"/> + icon="terp-hr" + domain="[('state', '=' ,'wait')]" + help = "In progress Evaluations"/> + icon="terp-hr" + domain="[('state','=','progress')]" + help = "Final Validation Evaluations"/> + + +<<<<<<< TREE + +======= @@ -91,13 +98,12 @@ string="Cancelled" domain="[('state','=','cancel')]"/> +>>>>>>> MERGE-SOURCE - - - - + + From 115b74cf8acfc303545196c59e4bc6ac7c0d13cf Mon Sep 17 00:00:00 2001 From: "Jni (Open ERP)" Date: Wed, 26 May 2010 16:15:44 +0530 Subject: [PATCH 10/33] [IMP]:account:Changed the spelling for statistic bzr revid: jni@tinyerp.co.in-20100526104544-nm2x5rujey8pp1ex --- addons/account/account_menuitem.xml | 2 +- addons/account/report/account_account_report_view.xml | 2 +- addons/account/report/account_analytic_entries_report_view.xml | 2 +- addons/account/report/account_entries_report_view.xml | 2 +- addons/account/report/account_invoice_report_view.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/account/account_menuitem.xml b/addons/account/account_menuitem.xml index a2d18095618..4cdcb7787b6 100644 --- a/addons/account/account_menuitem.xml +++ b/addons/account/account_menuitem.xml @@ -22,7 +22,7 @@ groups="group_account_user"/> - + diff --git a/addons/account/report/account_account_report_view.xml b/addons/account/report/account_account_report_view.xml index f2d6338c951..efdb4567935 100644 --- a/addons/account/report/account_account_report_view.xml +++ b/addons/account/report/account_account_report_view.xml @@ -87,7 +87,7 @@ - + diff --git a/addons/account/report/account_analytic_entries_report_view.xml b/addons/account/report/account_analytic_entries_report_view.xml index e1cd7967b8d..84dca63f440 100644 --- a/addons/account/report/account_analytic_entries_report_view.xml +++ b/addons/account/report/account_analytic_entries_report_view.xml @@ -107,7 +107,7 @@ - + diff --git a/addons/account/report/account_entries_report_view.xml b/addons/account/report/account_entries_report_view.xml index 625d98fa9cb..f07de0cdf8d 100644 --- a/addons/account/report/account_entries_report_view.xml +++ b/addons/account/report/account_entries_report_view.xml @@ -122,6 +122,6 @@ {'search_default_This Month':1,'search_default_Journal':1,'group_by_no_leaf':1,'group_by':[]} - + diff --git a/addons/account/report/account_invoice_report_view.xml b/addons/account/report/account_invoice_report_view.xml index ae00608b164..7acd0c332b1 100644 --- a/addons/account/report/account_invoice_report_view.xml +++ b/addons/account/report/account_invoice_report_view.xml @@ -151,7 +151,7 @@ - + From 0c9201fd9963f898afff18a8b6d01be957cb1d7f Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Wed, 26 May 2010 18:21:05 +0530 Subject: [PATCH 11/33] [IMP]:sale:Reverted SQL report changes applied at Revision ID: hmo@hmo-20100525163303-0la5uyj7e23dgvk9 bzr revid: apa@tinyerp.com-20100526125105-za72ql0p1tdr5sd2 --- addons/sale/report/sale_report.py | 3 +++ addons/sale/report/sale_report_view.xml | 27 ++++++------------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/addons/sale/report/sale_report.py b/addons/sale/report/sale_report.py index e713c479f72..ec8be2160a0 100644 --- a/addons/sale/report/sale_report.py +++ b/addons/sale/report/sale_report.py @@ -36,6 +36,7 @@ class sale_report(osv.osv): ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True), 'day': fields.char('Day', size=128, readonly=True), 'product_id':fields.many2one('product.product', 'Product', readonly=True), + 'uom_id': fields.many2one('product.uom', 'Default Unit Of Measure', readonly=True), 'product_qty':fields.float('# of Qty', readonly=True), 'partner_id':fields.many2one('res.partner', 'Partner', readonly=True), 'shop_id':fields.many2one('sale.shop', 'Shop', readonly=True), @@ -71,6 +72,7 @@ class sale_report(osv.osv): to_char(s.date_order, 'MM') as month, to_char(s.date_order, 'YYYY-MM-DD') as day, l.product_id as product_id, + pt.uom_id as uom_id, sum(l.product_uom_qty * u.factor) as product_qty, s.partner_id as partner_id, s.user_id as user_id, @@ -96,6 +98,7 @@ class sale_report(osv.osv): l.product_uom, s.user_id, pt.categ_id, + pt.uom_id, s.state, s.shop_id, s.company_id, diff --git a/addons/sale/report/sale_report_view.xml b/addons/sale/report/sale_report_view.xml index 2fca6dedd5a..0891efee88b 100644 --- a/addons/sale/report/sale_report_view.xml +++ b/addons/sale/report/sale_report_view.xml @@ -17,6 +17,7 @@ + @@ -86,7 +87,7 @@ - + @@ -99,28 +100,12 @@ - - - + + - - - - - - - - - - - - - - - - - + + From 335d3ce95c0fa664ac35423a3b5aeaef267e0404 Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Wed, 26 May 2010 18:26:38 +0530 Subject: [PATCH 12/33] [IMP]:account:improved menus. bzr revid: apa@tinyerp.com-20100526125638-rpcu5iyapi2imnli --- addons/account/report/account_analytic_report_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/report/account_analytic_report_view.xml b/addons/account/report/account_analytic_report_view.xml index 0d05d5f0d76..9a7c02ff8e7 100644 --- a/addons/account/report/account_analytic_report_view.xml +++ b/addons/account/report/account_analytic_report_view.xml @@ -139,7 +139,7 @@ {'search_default_This Month':1,'search_default_User':1,'group_by_no_leaf':1,'group_by':[]} - + From 9be38e6ed277b2fda2540ee5afc21d4fd2dfacf7 Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Wed, 26 May 2010 18:36:02 +0530 Subject: [PATCH 13/33] [IMP]:project:improved SQL report.(Tasks Analysis) bzr revid: apa@tinyerp.com-20100526130602-0o370fizfv0iy3od --- addons/project/report/project_report_view.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/project/report/project_report_view.xml b/addons/project/report/project_report_view.xml index a978587e232..4eac32fb284 100644 --- a/addons/project/report/project_report_view.xml +++ b/addons/project/report/project_report_view.xml @@ -103,6 +103,7 @@ domain="[('project_id','=',context.get('project_id', False)]"/> + @@ -248,6 +249,6 @@ graph,tree - + From ee2637fe9ed07c7f0c295245f8658210bb136579 Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Wed, 26 May 2010 18:51:37 +0530 Subject: [PATCH 14/33] [IMP]:hr_recruitment:Resolved conflicts bzr revid: apa@tinyerp.com-20100526132137-88wnjs0mog14xr69 --- .../report/hr_evaluation_report_view.xml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/addons/hr_evaluation/report/hr_evaluation_report_view.xml b/addons/hr_evaluation/report/hr_evaluation_report_view.xml index 6b2e6ead15f..44c20ebbe16 100644 --- a/addons/hr_evaluation/report/hr_evaluation_report_view.xml +++ b/addons/hr_evaluation/report/hr_evaluation_report_view.xml @@ -75,9 +75,6 @@ -<<<<<<< TREE - -======= @@ -91,14 +88,6 @@ - - - ->>>>>>> MERGE-SOURCE From 7e47dbd1cdecfc2cec961fcc630ee7c21531efdf Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Thu, 27 May 2010 11:52:02 +0530 Subject: [PATCH 15/33] [IMP]:account:Improved SQL reports(Invoice Analysis and Entries Analysis). bzr revid: apa@tinyerp.com-20100527062202-p926f650dwok9h9f --- .../report/account_entries_report_view.xml | 71 +++++++++---------- .../report/account_invoice_report_view.xml | 35 ++++----- 2 files changed, 54 insertions(+), 52 deletions(-) diff --git a/addons/account/report/account_entries_report_view.xml b/addons/account/report/account_entries_report_view.xml index f07de0cdf8d..b31d3bbfd0a 100644 --- a/addons/account/report/account_entries_report_view.xml +++ b/addons/account/report/account_entries_report_view.xml @@ -6,7 +6,7 @@ account.entries.report tree - + @@ -37,7 +37,7 @@ account.entries.report graph - + @@ -48,15 +48,15 @@ account.entries.report search - + - - + + help="Entries of last 30 days"/> + help = "Draft entries"/> + - - - - + + + + + - - - - - + + + + + + + - - + - - - - - - - - - + + + + + + + - - + - - + - Entries + Entries Analysis account.entries.report form tree,graph diff --git a/addons/account/report/account_invoice_report_view.xml b/addons/account/report/account_invoice_report_view.xml index 7acd0c332b1..b8b0b09490b 100644 --- a/addons/account/report/account_invoice_report_view.xml +++ b/addons/account/report/account_invoice_report_view.xml @@ -6,7 +6,7 @@ account.invoice.report tree - + @@ -42,7 +42,7 @@ account.invoice.report graph - + @@ -54,7 +54,7 @@ account.invoice.report search - + + help = "Draft Invoices"/> + help = "Pro-forma Invoices"/> + help = "open Invoices"/> + help = "Done Invoices"/> + string="My Invoices" + help="My Invoices" + domain="[('user_id','=',uid)]"/> + @@ -119,6 +120,9 @@ + + + @@ -127,27 +131,26 @@ + + - + - - - - Invoices + Invoices Analysis account.invoice.report form tree,graph - {'search_default_month':1,'search_default_User':1,'group_by_no_leaf':1,'group_by':[],'search_default_user_id':uid} + {'search_default_month':1,'search_default_User':1,'group_by_no_leaf':1,'group_by':[]} From 15620422fdb9866942e12fb71edab585bfbb4181 Mon Sep 17 00:00:00 2001 From: "Vir (Open ERP)" Date: Thu, 27 May 2010 13:09:17 +0530 Subject: [PATCH 16/33] [ADD] project_issue : added crm in dependency bzr revid: vir@tinyerp.com-20100527073917-sx03s5k2i0c99m19 --- addons/project_issue/__openerp__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/project_issue/__openerp__.py b/addons/project_issue/__openerp__.py index 513bae085bd..2bf67d47191 100644 --- a/addons/project_issue/__openerp__.py +++ b/addons/project_issue/__openerp__.py @@ -31,6 +31,7 @@ 'author': 'Tiny', 'website': 'http://www.openerp.com', 'depends': [ + 'crm', 'project', 'hr_timesheet_sheet', ], From 7d98e5914bc900c6bc3a2e9be46c4d7ce1654569 Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Thu, 27 May 2010 15:21:37 +0530 Subject: [PATCH 17/33] [FIX] Report_intrastat : size of char should be given in integer format bzr revid: jvo@tinyerp.com-20100527095137-oaigevsb9ztpfh26 --- addons/report_intrastat/report_intrastat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/report_intrastat/report_intrastat.py b/addons/report_intrastat/report_intrastat.py index 8d986aa4c64..3bf58ea034e 100644 --- a/addons/report_intrastat/report_intrastat.py +++ b/addons/report_intrastat/report_intrastat.py @@ -66,7 +66,7 @@ class report_intrastat(osv.osv): ('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')],'Month',readonly=True), 'supply_units':fields.float('Supply Units', readonly=True), 'ref':fields.char('Source document',size=64, readonly=True), - 'code': fields.char('Country code', size="2", readonly=True), + 'code': fields.char('Country code', size=2, readonly=True), 'intrastat_id': fields.many2one('report.intrastat.code', 'Intrastat code', readonly=True), 'weight': fields.float('Weight', readonly=True), 'value': fields.float('Value', readonly=True), From 7267797d805653848b780921ea8445154f78204c Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Thu, 27 May 2010 15:27:03 +0530 Subject: [PATCH 18/33] [REF] Project: Minor modifs bzr revid: jvo@tinyerp.com-20100527095703-2vocgaymbrkuddtc --- addons/project/project.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index a6c703657d0..bdf7e30837e 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -47,6 +47,8 @@ class project(osv.osv): _inherits = {'account.analytic.account':"category_id"} def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): + if context is None: + context = {} if user == 1: return super(project, self).search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count) if context and context.has_key('user_prefence') and context['user_prefence']: @@ -266,13 +268,11 @@ class task(osv.osv): hours = dict(cr.fetchall()) for task in self.browse(cr, uid, ids, context=context): res[task.id] = {'effective_hours': hours.get(task.id, 0.0), 'total_hours': task.remaining_hours + hours.get(task.id, 0.0)} + res[task.id]['progress'] = 0.0 if (task.remaining_hours + hours.get(task.id, 0.0)): - if task.state =='done': - res[task.id]['progress'] = 100.0 - else: + if task.state != 'done': res[task.id]['progress'] = round(min(100.0 * hours.get(task.id, 0.0) / res[task.id]['total_hours'], 99.99),2) - else: - res[task.id]['progress'] = 0.0 + if task.state in ('done','cancel'): res[task.id]['progress'] = 100.0 res[task.id]['delay_hours'] = res[task.id]['total_hours'] - task.planned_hours @@ -559,6 +559,8 @@ class config_compute_remaining(osv.osv_memory): } def compute_hours(self, cr, uid, ids, context=None): + if context is None: + context = {} task_obj = self.pool.get('project.task') request = self.pool.get('res.request') if 'active_id' in context: From bd3885749af619b46768ee75fb76dde5a901ecea Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Thu, 27 May 2010 15:30:31 +0530 Subject: [PATCH 19/33] [FIX/REF] Project_issue and Project_long_term bzr revid: jvo@tinyerp.com-20100527100031-efjpuaas23niu1kd --- addons/project_issue/__openerp__.py | 1 + addons/project_issue/project_issue.py | 2 -- addons/project_issue/project_issue_view.xml | 18 +++++++----------- addons/project_long_term/__openerp__.py | 8 ++++---- addons/project_long_term/project_long_term.py | 4 ++-- 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/addons/project_issue/__openerp__.py b/addons/project_issue/__openerp__.py index 2bf67d47191..982d1688014 100644 --- a/addons/project_issue/__openerp__.py +++ b/addons/project_issue/__openerp__.py @@ -34,6 +34,7 @@ 'crm', 'project', 'hr_timesheet_sheet', + 'project_long_term', ], 'init_xml': [ 'project_issue_data.xml' diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index f67986526cd..b67ef6a849a 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -113,7 +113,6 @@ class project_issue(osv.osv, crm.crm_case): 'thread_id': fields.many2one('mailgate.thread', 'Thread', required=False), 'id': fields.integer('ID'), 'name': fields.char('Name', size=128, required=True), - 'active': fields.boolean('Active', required=False), 'create_date': fields.datetime('Creation Date' , readonly=True), 'write_date': fields.datetime('Update Date' , readonly=True), 'date_deadline': fields.date('Deadline'), @@ -173,7 +172,6 @@ class project_issue(osv.osv, crm.crm_case): return False _defaults = { - 'active': lambda *a: 1, 'user_id': crm.crm_case._get_default_user, 'partner_id': crm.crm_case._get_default_partner, 'partner_address_id': crm.crm_case._get_default_partner_address, diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml index 8b2b14c1cb7..27b72e459ef 100644 --- a/addons/project_issue/project_issue_view.xml +++ b/addons/project_issue/project_issue_view.xml @@ -82,11 +82,8 @@ - - - @@ -143,6 +140,7 @@ + @@ -155,6 +153,7 @@ states="open,draft,pending,done,cancel" /> +