From 7a397943e43868b80c104f039d306abe0f79d7c9 Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Wed, 19 May 2010 20:39:39 +0530 Subject: [PATCH 01/75] [REF] bzr revid: jvo@tinyerp.com-20100519150939-mf955huyjiflenth --- addons/account/invoice.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 7c2f3542833..4fd7fde0f43 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -23,12 +23,7 @@ import time import decimal_precision as dp import netsvc -<<<<<<< TREE -from osv import fields, osv -from osv.orm import except_orm -======= from osv import fields, osv, orm ->>>>>>> MERGE-SOURCE import pooler from tools import config from tools.translate import _ @@ -337,11 +332,7 @@ class account_invoice(osv.osv): raise orm.except_orm(_('Configuration Error!'), _('There is no Accounting Journal of type Sale/Purchase defined!')) else: -<<<<<<< TREE - raise except_orm(_('UnknownError'), str(e)) -======= - raise ->>>>>>> MERGE-SOURCE + raise orm.except_orm(_('UnknownError'), str(e)) def unlink(self, cr, uid, ids, context=None): invoices = self.read(cr, uid, ids, ['state']) From f7dc60e5bad55a23c5e224a33af30048a0cdf349 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Thu, 20 May 2010 11:05:34 +0200 Subject: [PATCH 02/75] 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 03/75] 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 04/75] 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 05/75] 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 06/75] 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 07/75] 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 da9fc29dbcd1b1ff09f6b08917e94fffe84db043 Mon Sep 17 00:00:00 2001 From: vra Date: Fri, 21 May 2010 14:47:39 +0530 Subject: [PATCH 08/75] [MERGE] MErged from main branch bzr revid: vra@tinyerp.com-20100521091739-a6m659ghorwfg5c8 --- addons/account/account_analytic_line.py | 2 +- addons/account/account_bank_statement.py | 2 +- addons/account/i18n/th.po | 11 +- addons/auction/__openerp__.py | 2 + addons/auction/wizard/__init__.py | 2 + addons/auction/wizard/auction_aie_send.py | 223 ++++++++ .../auction/wizard/auction_aie_send_result.py | 139 +++++ .../wizard/auction_aie_send_result_view.xml | 58 +++ .../auction/wizard/auction_aie_send_view.xml | 63 +++ .../auction/wizard/auction_lots_numerotate.py | 184 +++++++ .../wizard/auction_lots_numerotate_view.xml | 132 +++++ addons/auction/wizard/wizard_aie_send.py | 232 --------- .../auction/wizard/wizard_aie_send_result.py | 137 ----- .../auction/wizard/wizard_lots_numerotate.py | 154 ------ addons/crm/crm_lead.py | 4 +- addons/delivery/__openerp__.py | 1 + addons/delivery/test/delivery_test.yml | 155 ++++++ addons/marketing_campaign/__openerp__.py | 2 + .../marketing_campaign_workflow.xml | 117 +++++ addons/mrp/__openerp__.py | 6 +- addons/mrp/mrp_view.xml | 25 +- addons/mrp/mrp_workflow.xml | 37 +- .../mrp/report/mrp_production_order_view.xml | 6 +- addons/mrp/report/order.rml | 95 +++- addons/mrp/test/mrp_phantom_bom.yml | 16 +- addons/mrp/test/mrp_procurement.yml | 336 +++++++++++++ addons/mrp/test/mrp_production_order.yml | 12 +- .../mrp_procurement/mrp_procurement_view.xml | 21 +- .../mrp_procurement_workflow.xml | 60 ++- addons/multi_company/i18n/fr.po | 22 +- addons/point_of_sale/__openerp__.py | 1 + addons/point_of_sale/pos.py | 29 +- addons/point_of_sale/pos_demo.xml | 1 + addons/point_of_sale/pos_view.xml | 35 +- addons/point_of_sale/posrule_data.xml | 4 +- addons/point_of_sale/test/pos_test.yml | 476 ++++++++++++++++++ addons/point_of_sale/wizard/pos_get_sale.py | 2 +- addons/point_of_sale/wizard/pos_payment.py | 76 +-- addons/point_of_sale/wizard/pos_return.py | 18 +- addons/product/product_data.xml | 3 +- addons/product/product_view.xml | 21 +- addons/project/project_view.xml | 8 +- addons/project_mrp/__openerp__.py | 4 +- addons/project_mrp/project_mrp_workflow.xml | 4 +- addons/purchase/__openerp__.py | 5 + addons/purchase/purchase.py | 2 +- addons/purchase/purchase_view.xml | 6 +- addons/purchase/test/purchase_from_manual.yml | 148 ++++++ addons/purchase/test/purchase_from_order.yml | 154 ++++++ .../purchase/test/purchase_from_picking.yml | 174 +++++++ addons/purchase/wizard/purchase_installer.py | 2 +- .../wizard/purchase_line_invoice_view.xml | 4 +- addons/purchase_requisition/__openerp__.py | 4 +- .../purchase_requisition.py | 12 +- .../purchase_requisition_view.xml | 63 ++- .../test/purchase_requisition.yml | 183 +++++++ .../test/purchase_requisition_exclusive.yml | 112 +++++ .../wizard/purchase_requisition_partner.py | 4 +- .../purchase_requisition_partner_view.xml | 1 + addons/sale/__openerp__.py | 7 + addons/sale/sale_view.xml | 38 +- addons/sale/test/advance_invoice.yml | 301 +++++++++++ addons/sale/test/prepaid_sale_order.yml | 379 ++++++++++++++ addons/sale/test/sale_procurement.yml | 91 ++++ .../sale/test/shipping_manual_sale_order.yml | 384 ++++++++++++++ addons/sale/wizard/__init__.py | 3 +- addons/sale/wizard/make_invoice.py | 96 ---- addons/sale/wizard/sale_line_invoice.py | 7 - addons/sale/wizard/sale_line_invoice.xml | 2 - addons/sale/wizard/sale_make_invoice.py | 74 +++ addons/sale/wizard/sale_make_invoice.xml | 29 ++ .../sale/wizard/sale_make_invoice_advance.py | 1 - addons/sale_crm/sale_crm_view.xml | 4 +- addons/sale_journal/picking_journal_view.xml | 28 +- .../picking_journal_view_report.xml | 32 +- addons/sale_journal/sale_journal_view.xml | 40 +- addons/stock/__openerp__.py | 2 +- addons/stock/i18n/fr.po | 10 +- addons/stock/product_view.xml | 4 +- addons/stock/report/report_stock_move.py | 41 +- .../stock/report/report_stock_move_view.xml | 42 +- addons/stock/report/report_stock_view.xml | 16 +- addons/stock/stock.py | 69 ++- addons/stock/stock_view.xml | 262 +++++----- addons/stock/test/stock_test.yml | 347 +++++++++++++ addons/stock/wizard/__init__.py | 4 +- .../stock_change_standard_price_view.xml | 1 + addons/stock/wizard/stock_partial_move.py | 7 +- addons/stock/wizard/stock_replacement.py | 68 +++ .../stock/wizard/stock_replacement_view.xml | 41 ++ addons/stock/wizard/stock_ups.py | 91 ++++ addons/stock/wizard/stock_ups_view.xml | 56 +++ addons/stock/wizard/wizard_replacement.py | 60 --- addons/stock/wizard/wizard_ups.py | 85 ---- addons/stock_location/__openerp__.py | 3 + addons/stock_location/test/stock_location.yml | 273 ++++++++++ addons/stock_planning/stock_planning.py | 13 +- addons/stock_planning/stock_planning_view.xml | 22 +- 98 files changed, 5528 insertions(+), 1317 deletions(-) create mode 100644 addons/auction/wizard/auction_aie_send.py create mode 100644 addons/auction/wizard/auction_aie_send_result.py create mode 100644 addons/auction/wizard/auction_aie_send_result_view.xml create mode 100644 addons/auction/wizard/auction_aie_send_view.xml create mode 100644 addons/auction/wizard/auction_lots_numerotate.py create mode 100644 addons/auction/wizard/auction_lots_numerotate_view.xml delete mode 100644 addons/auction/wizard/wizard_aie_send.py delete mode 100644 addons/auction/wizard/wizard_aie_send_result.py delete mode 100644 addons/auction/wizard/wizard_lots_numerotate.py create mode 100644 addons/delivery/test/delivery_test.yml create mode 100644 addons/marketing_campaign/marketing_campaign_workflow.xml create mode 100644 addons/mrp/test/mrp_procurement.yml create mode 100644 addons/point_of_sale/test/pos_test.yml create mode 100644 addons/purchase/test/purchase_from_manual.yml create mode 100644 addons/purchase/test/purchase_from_order.yml create mode 100644 addons/purchase/test/purchase_from_picking.yml create mode 100644 addons/purchase_requisition/test/purchase_requisition.yml create mode 100644 addons/purchase_requisition/test/purchase_requisition_exclusive.yml create mode 100644 addons/sale/test/advance_invoice.yml create mode 100644 addons/sale/test/prepaid_sale_order.yml create mode 100644 addons/sale/test/sale_procurement.yml create mode 100644 addons/sale/test/shipping_manual_sale_order.yml delete mode 100644 addons/sale/wizard/make_invoice.py create mode 100644 addons/sale/wizard/sale_make_invoice.py create mode 100644 addons/sale/wizard/sale_make_invoice.xml create mode 100644 addons/stock/test/stock_test.yml create mode 100644 addons/stock/wizard/stock_replacement.py create mode 100644 addons/stock/wizard/stock_replacement_view.xml create mode 100644 addons/stock/wizard/stock_ups.py create mode 100644 addons/stock/wizard/stock_ups_view.xml delete mode 100644 addons/stock/wizard/wizard_replacement.py delete mode 100644 addons/stock/wizard/wizard_ups.py create mode 100644 addons/stock_location/test/stock_location.yml diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py index ce6341cc9b2..003a33b5e1d 100644 --- a/addons/account/account_analytic_line.py +++ b/addons/account/account_analytic_line.py @@ -42,7 +42,7 @@ class account_analytic_line(osv.osv): } _defaults = { 'date': lambda *a: time.strftime('%Y-%m-%d'), - 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', c), + 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', context=c), } _order = 'date' diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index c23bd35b6a7..9fd609c7ed3 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -630,7 +630,7 @@ class account_bank_statement_line(osv.osv): 'statement_id': fields.many2one('account.bank.statement', 'Statement', select=True, required=True, ondelete='cascade'), 'reconcile_id': fields.many2one('account.bank.statement.reconcile', - 'Reconcile', states={'confirm':[('readonly',True)]}), + 'Reconcile'), 'move_ids': fields.many2many('account.move', 'account_bank_statement_line_move_rel', 'move_id','statement_id', 'Moves'), diff --git a/addons/account/i18n/th.po b/addons/account/i18n/th.po index 320fdc82290..7389cdda788 100644 --- a/addons/account/i18n/th.po +++ b/addons/account/i18n/th.po @@ -8,13 +8,13 @@ msgstr "" "Project-Id-Version: openobject-addons\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-03-15 03:12+0000\n" +"PO-Revision-Date: 2010-05-20 07:09+0000\n" "Last-Translator: Songpon Phusing \n" "Language-Team: Thai \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-04-17 04:08+0000\n" +"X-Launchpad-Export-Date: 2010-05-21 03:38+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account @@ -51,7 +51,7 @@ msgstr "" #. module: account #: model:account.account.type,name:account.account_type_asset msgid "Asset" -msgstr "" +msgstr "สินทรัพย์" #. module: account #: constraint:ir.actions.act_window:0 @@ -106,7 +106,7 @@ msgstr "" #: model:ir.actions.wizard,name:account.wizard_vat_declaration #: model:ir.ui.menu,name:account.menu_wizard_vat_declaration msgid "Print Taxes Report" -msgstr "" +msgstr "พิมพ์รายงานภาษี" #. module: account #: field:account.account,parent_id:0 @@ -2133,7 +2133,8 @@ msgid "Analytic Entry" msgstr "" #. module: account -#: view:res.company:0 field:res.company,overdue_msg:0 +#: view:res.company:0 +#: field:res.company,overdue_msg:0 msgid "Overdue Payments Message" msgstr "" diff --git a/addons/auction/__openerp__.py b/addons/auction/__openerp__.py index 8918a6394aa..cd27c60fdb7 100644 --- a/addons/auction/__openerp__.py +++ b/addons/auction/__openerp__.py @@ -50,8 +50,10 @@ 'wizard/auction_payer_sel_view.xml', 'wizard/auction_lots_sms_send_view.xml', 'wizard/auction_catalog_flagey_view.xml', +# 'wizard/auction_aie_send_view.xml', # 'wizard/auction_aie_send_result_view.xml', 'wizard/auction_lots_buyer_map_view.xml', +# 'wizard/auction_lots_numerotate_view.xml', 'auction_view.xml', 'auction_report.xml', diff --git a/addons/auction/wizard/__init__.py b/addons/auction/wizard/__init__.py index 957ab02b053..41ada315889 100644 --- a/addons/auction/wizard/__init__.py +++ b/addons/auction/wizard/__init__.py @@ -31,8 +31,10 @@ import auction_lots_sms_send import auction_catalog_flagey_report #import auction_lots_cancel #import auction_transfer_unsold_object +#import auction_aie_send #import auction_aie_send_result import auction_lots_buyer_map +#import auction_lots_numerotate # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/auction/wizard/auction_aie_send.py b/addons/auction/wizard/auction_aie_send.py new file mode 100644 index 00000000000..51368349a98 --- /dev/null +++ b/addons/auction/wizard/auction_aie_send.py @@ -0,0 +1,223 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +# +# Does not properly work concurrently !!! +# +import base64 +import mimetypes +import httplib +import threading +from tools.translate import _ +from osv import fields,osv + +class auction_lots_send_aie(osv.osv_memory): + _name = 'auction.lots.send.aie' + _descritption = 'Send to website' + + def _date_get(self, cr, uid, context={}): + selection = context and context.get('selection') + if selection: + return [('','')] + selection + return [('','')] + + _columns = { + 'uname': fields.char('Login', size=64), + 'password': fields.char('Password', size=64), + 'objects': fields.integer('# of objects', readonly=True), + 'lang': fields.selection([('fr','fr'),('ned','ned'),('eng','eng'),('de','de')],'Language'), + 'numerotation': fields.selection([('prov','Provisoire'),('definite','Definitive (ordre catalogue)')],'Numerotation'), + 'dates': fields.selection(_date_get,'Auction Date'), + 'img_send': fields.boolean('Send Image also ?'), + } + + def default_get(self, cr, uid, fields, context): + """ + To get default values for the object. + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param fields: List of fields for which we want default values + @param context: A standard dictionary + @return: A dictionary which of fields with values. + """ + res = super(auction_lots_send_aie, self).default_get(cr, uid, fields, context=context) + if 'uname' in fields and context.get('uname',False): + res['uname'] = context.get('uname') + if 'password' in fields and context.get('password',False): + res['password'] = context.get('password') + return res + + def _catalog_send(uname, passwd, lang, did, catalog): + def post_multipart(host, selector, fields, files): + def encode_multipart_formdata(fields, files): + BOUNDARY = '----------ThIs_Is_tHe_bouNdaRY_$' + CRLF = '\r\n' + L = [] + for (key, value) in fields: + L.append('--' + BOUNDARY) + L.append('Content-Disposition: form-data; name="%s"' % key) + L.append('') + L.append(value) + for (key,value) in files: + L.append('--' + BOUNDARY) + L.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (key, key+'.pickle')) + L.append('Content-Type: application/octet-stream') + L.append('') + L.append(value) + L.append('--' + BOUNDARY + '--') + L.append('') + body = CRLF.join(L) + content_type = 'multipart/form-data; boundary=%s' % BOUNDARY + return content_type, body + content_type, body = encode_multipart_formdata(fields, files) + import httplib + + headers = {"Content-type": content_type, "Accept": "*/*"} + conn = httplib.HTTPConnection(host) + conn.request("POST", '/bin/catalog.cgi', body, headers = headers) + response = conn.getresponse() + val = response.status + conn.close() + return val + return post_multipart('auction-in-europe.com', "/bin/catalog.cgi", (('uname',uname),('password',passwd),('did',did),('lang',lang)),(('file',catalog),)) + + def _photo_bin_send(uname, passwd, ref, did, photo_name, photo_data): + def get_content_type(filename): + return mimetypes.guess_type(filename)[0] or 'application/octet-stream' + + def post_multipart(host, selector, fields, files): + def encode_multipart_formdata(fields, files): + BOUNDARY = '----------ThIs_Is_tHe_bouNdaRY_$' + CRLF = '\r\n' + L = [] + for (key, value) in fields: + L.append('--' + BOUNDARY) + L.append('Content-Disposition: form-data; name="%s"' % key) + L.append('') + L.append(value) + for (key, filename, data) in files: + L.append('--' + BOUNDARY) + L.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (key, filename)) + L.append('Content-Type: %s' % get_content_type(filename)) + L.append('') + L.append(data) + L.append('--' + BOUNDARY + '--') + L.append('') + body = CRLF.join(L) + content_type = 'multipart/form-data; boundary=%s' % BOUNDARY + return content_type, body + content_type, body = encode_multipart_formdata(fields, files) + + headers = {"Content-type": content_type, "Accept": "*/*"} + conn = httplib.HTTPConnection(host) + conn.request("POST", '/bin/photo.cgi', body, headers = headers) + response = conn.getresponse() + val = response.status + conn.close() + return val + return post_multipart('auction-in-europe.com', "/bin/photo.cgi", (('uname',uname),('ref',ref),('passwd',passwd),('did',did)),(('file',photo_name,photo_data),)) + + + def _photos_send(cr, uid, uname, passwd, did, ids): + service = netsvc.LocalService("object_proxy") + for (ref,id) in ids: + + # ids_attach = service.execute(db_name,uid, 'ir.attachment', 'search', [('res_model','=','auction.lots'), ('res_id', '=',id)]) + datas = service.execute(cr.db_name,uid, 'auction.lots', 'read',[id], ['name','image']) + if len(datas): + bin = base64.decodestring(datas[0]['image']) + fname = datas[0]['name'] + _photo_bin_send(uname, passwd, ref, did, fname, bin) + + def get_dates(self, cr, uid, ids, context={}): + import httplib + data_obj = self.pool.get('ir.model.data') + conn = httplib.HTTPConnection('www.auction-in-europe.com') + datas = self.read(cr, uid, ids[0],['uname','password']) + conn.request("GET", "/aie_upload/dates_get.php?uname=%s&passwd=%s" % (datas['uname'], datas['password'])) + response = conn.getresponse() + if response.status == 200: + def _date_decode(x): + return (x.split(' - ')[0], (' - '.join(x.split(' - ')[1:]).decode('latin1','replace').encode('utf-8','replace'))) + context['selection'] = map(_date_decode, response.read().split('\n')) + self._date_get(cr, uid, context=context) + else: + raise osv.except_osv(_('Error'), _("Connection to WWW.Auction-in-Europe.com failed !")) + id1 = data_obj._get_id(cr, uid, 'auction', 'view_auction_lots_send') + res_id = data_obj.browse(cr, uid, id1, context=context).res_id + context.update(datas) + return { + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'auction.lots.send.aie', + 'views': [(res_id,'form')], + 'type': 'ir.actions.act_window', + 'target':'new', + 'context': context + } + + def _send(self, cr, uid, ids, context={}): + import pickle, thread, sql_db + cr.execute('select name,aie_categ from auction_lot_category') + vals = dict(cr.fetchall()) + cr.close() + + service = netsvc.LocalService("object_proxy") + lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', context['active_ids'], ['obj_num','lot_num','obj_desc','bord_vnd_id','lot_est1','lot_est2','artist_id','lot_type','aie_categ']) + lots_ids = [] + datas = self.read(cr, uid, ids[0],['uname','login','lang','numerotation','dates']) + for l in lots: + if datas['numerotation']=='prov': + l['ref']='%s%03d' % (l['bord_vnd_id'][1],l['lot_num']) + l['ref2']='%s%03d' % (l['bord_vnd_id'][1],l['lot_num']) + else: + l['ref']='%04d' % (l['obj_num'],) + l['ref2']='%s%03d' % (l['bord_vnd_id'][1],l['lot_num']) + if l['artist_id']: + l['artist_id'] = l['artist_id'][1] + else: + l['artist_id'] = '' + for n in ('obj_desc','artist_id','lot_type'): + try: + l[n]=l[n].decode('utf-8','replace').encode('latin1','replace') + except: + l[n]='' + del l['lot_num'] + del l['obj_num'] + del l['bord_vnd_id'] + l['aie_categ'] = vals.get(l['lot_type'], False) + lots_ids.append((l['ref'], l['id'])) + args = pickle.dumps(lots) + thread.start_new_thread(_catalog_send, (datas['uname'],datas['password'],datas['lang'],datas['dates'], args)) + if(datas['form']['img_send']==True): + thread.start_new_thread(_photos_send, (cr.dbname, uid, datas['uname'], datas['password'],datas['dates'], lots_ids)) + return {} + + def send_pdf(self, cr, uid, ids, context): + threaded_calculation = threading.Thread(target=self._send, args=(cr, uid, ids, context)) + threaded_calculation.start() + return {} + +auction_lots_send_aie() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/auction/wizard/auction_aie_send_result.py b/addons/auction/wizard/auction_aie_send_result.py new file mode 100644 index 00000000000..404881b2d6b --- /dev/null +++ b/addons/auction/wizard/auction_aie_send_result.py @@ -0,0 +1,139 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +# +# Does not properly work concurrently !!! +# + +import netsvc +from tools.translate import _ +from osv import fields, osv + +class auction_lots_pay(osv.osv_memory): + _name = 'auction.lots.send.aie.results' + _description = 'Send results to Auction-in-europe.com' + + + def _date_get(self, cr, uid, context={}): + selection = context and context.get('selection') + if selection: + return [('','')] + selection + return [('','')] + + _columns = { + 'uname': fields.char('Login', size=64), + 'password': fields.char('Password', size=64), + 'objects': fields.integer('# of objects'), + 'dates': fields.selection(_date_get,'Auction Date'), + } + + def default_get(self, cr, uid, fields, context): + """ + To get default values for the object. + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param fields: List of fields for which we want default values + @param context: A standard dictionary + @return: A dictionary which of fields with values. + """ + res = super(auction_lots_pay, self).default_get(cr, uid, fields, context=context) + if 'uname' in fields and context.get('uname',False): + res['uname'] = context.get('uname') + if 'password' in fields and context.get('password',False): + res['password'] = context.get('password') + return res + + def _catalog_send(self, uname, passwd, did, catalog): + def post_multipart(host, selector, fields, files): + def encode_multipart_formdata(fields, files): + BOUNDARY = '----------ThIs_Is_tHe_bouNdaRY_$' + CRLF = '\r\n' + L = [] + for (key, value) in fields: + L.append('--' + BOUNDARY) + L.append('Content-Disposition: form-data; name="%s"' % key) + L.append('') + L.append(value) + for (key,value) in files: + L.append('--' + BOUNDARY) + L.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (key, key+'.pickle')) + L.append('Content-Type: application/octet-stream') + L.append('') + L.append(value) + L.append('--' + BOUNDARY + '--') + L.append('') + body = CRLF.join(L) + content_type = 'multipart/form-data; boundary=%s' % BOUNDARY + return content_type, body + content_type, body = encode_multipart_formdata(fields, files) + import httplib + + headers = {"Content-type": content_type, "Accept": "*/*"} + conn = httplib.HTTPConnection(host) + conn.request("POST", '/bin/catalog_result.cgi', body, headers = headers) + response = conn.getresponse() + val = response.status + conn.close() + return val + return post_multipart('auction-in-europe.com', "/bin/catalog_result.cgi", (('uname',uname),('password',passwd),('did',did)),(('file',catalog),)) + + def get_dates(self, cr, uid, ids, context): + import httplib + conn = httplib.HTTPConnection('www.auction-in-europe.com') + data_obj = self.pool.get('ir.model.data') + datas = self.read(cr, uid, ids[0],['uname','password']) + conn.request("GET", "/aie_upload/dates_get_result.php?uname=%s&passwd=%s" % (datas['uname'], datas['password'])) + response = conn.getresponse() + if response.status == 200: + def _date_decode(x): + return (x.split(' - ')[0], (' - '.join(x.split(' - ')[1:]).decode('latin1').encode('utf-8'))) + context['selection'] = map(_date_decode, response.read().split('\n')) + self._date_get(cr, uid, context=context) + else: + raise osv.except_osv(_('Error'), + _("Connection to WWW.Auction-in-Europe.com failed !")) + id1 = data_obj._get_id(cr, uid, 'auction', 'view_auction_lots_send_result_send') + res_id = data_obj.browse(cr, uid, id1, context=context).res_id + context.update(datas) + return { + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'auction.lots.send.aie.results', + 'views': [(res_id,'form')], + 'type': 'ir.actions.act_window', + 'target':'new', + 'context': context + } + + def send(self, cr, uid, ids, context): + import pickle + service = netsvc.LocalService("object_proxy") + datas = self.read(cr, uid, ids[0],['uname','password','dates']) + lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', context['active_ids'], ['obj_num','obj_price']) + args = pickle.dumps(lots) + self._catalog_send(datas['uname'], datas['password'], datas['dates'], args) + return {} + +auction_lots_pay() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/auction/wizard/auction_aie_send_result_view.xml b/addons/auction/wizard/auction_aie_send_result_view.xml new file mode 100644 index 00000000000..7056e88b20e --- /dev/null +++ b/addons/auction/wizard/auction_aie_send_result_view.xml @@ -0,0 +1,58 @@ + + + + + + + + Auction lots send result - Login + auction.lots.send.aie.results + form + +
+ + + + +