From 3f0936e6d33c806b14defce95a81c87e8fc31d99 Mon Sep 17 00:00:00 2001 From: Jay Vora Date: Mon, 6 Oct 2008 14:33:54 +0530 Subject: [PATCH 1/8] Modified the Account budget reports acc. to new layout:Crossovered budget and Master Budget bzr revid: jvo@tinyerp.com-20081006090354-hvgdx9lsjyiy0bnv --- .../account_budget/report/budget_report.rml | 4 +- .../report/crossovered_budget_report.rml | 211 ++++++++++-------- 2 files changed, 123 insertions(+), 92 deletions(-) diff --git a/addons/account_budget/report/budget_report.rml b/addons/account_budget/report/budget_report.rml index 175cd17b1d6..f996587b919 100644 --- a/addons/account_budget/report/budget_report.rml +++ b/addons/account_budget/report/budget_report.rml @@ -204,10 +204,10 @@ - [[ o.code ]] + [[ o.code ]] - [[ o.name ]] + [[ o.name ]] diff --git a/addons/account_budget/report/crossovered_budget_report.rml b/addons/account_budget/report/crossovered_budget_report.rml index dfbc9416cd7..45dc7397594 100644 --- a/addons/account_budget/report/crossovered_budget_report.rml +++ b/addons/account_budget/report/crossovered_budget_report.rml @@ -10,167 +10,198 @@ - - - - - - - - - - - - - + + + + + - - - - - - + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - [[ repeatIn(objects,'o') ]] - + [[ repeatIn(objects,'o') ]] + - - [[ company.name ]] - + [[ company.name ]] - + - - Currency: [[ company.currency_id.name ]] + Currency: [[ company.currency_id.name ]] + + + Printed at: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S')]] + + + + + + Analysis from [[ data['form']['date_from'] ]] to [[ data['form']['date_to'] ]] - Printed at: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S')]] + Budget : [[ o.name ]] - - - - Analysis from [[ data['form']['date_from'] ]] to [[ data['form']['date_to'] ]] - - - Budget : [[ o.name ]] - - - - + - + + + + - Description + Description - Theoretical Amount + Theoretical Amount - Planned Amount + Planned Amount - Practical Amount + Practical Amount - % + Perc(%) + + +
- [[ repeatIn(funct(o,data['form']),'a') ]] - - - - - [['.....'*(a['status']-1) ]][[ setTag('font','font',{'color':'white'}) ]][[ a['status']==1 and ( setTag('font','font',{'name':'Times-bold'})) ]][[ a['name'] ]] - - - - [[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ '%.2f' % a['theo'] ]] - - - [[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ '%.2f' % a['pln'] ]] - - - [[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ '%.2f' % a['prac'] ]] - - - [[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ '%.2f' % a['perc'] ]]% - - - + [[ repeatIn(funct(o,data['form']),'a') ]] + + + + [['.....' *(a['status']-1) ]] [[ setTag('font','font',{'color':'white'}) ]][[ a['status']==1 and (setTag('font','font',{'name':'Helvetica-bold'})) ]][[ a['name'] ]] + + + [[ a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'})) ]][[ '%.2f' % a['theo'] ]] + + + [[ a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'})) ]][[ '%.2f' % a['pln'] ]] + + + [[ a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'})) ]][[ '%.2f' % a['prac'] ]] + + + [[ a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'})) ]][[ '%.2f' % a['perc'] ]]% + + +
- - - - + + + + - Total: + [[ repeatIn(funct_total(data['form']),'b') ]] Total : - [[ repeatIn(funct_total(data['form']),'b') ]] [[ '%.2f' % b ['tot_theo'] ]] + [[ '%.2f' % b['tot_theo'] ]] - [[ '%.2f' % b['tot_pln'] ]] + [[ '%.2f' % b['tot_pln'] ]] - [[ '%.2f' % b['tot_prac'] ]] + [[ '%.2f' % b['tot_prac'] ]] - [[ '%.2f' % b['tot_perc'] ]]% + [[ '%.2f' % b['tot_perc'] ]]% - +
- - + \ No newline at end of file From 38f3d006b2a6e8b395daa41ac9c6b986b6cee9a4 Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Mon, 6 Oct 2008 15:16:37 +0530 Subject: [PATCH 2/8] *complted Analytic Balance reports. *add partner_balance with wizard... bzr revid: patelamit2003@gmail.com-20081006094637-8rpw9qndk6o4uue0 --- .../project/report/analytic_balance.py | 3 +- .../project/report/analytic_balance.rml | 336 ++++++------ addons/account/report/account_balance.py | 10 +- addons/account/report/account_balance.rml | 27 +- addons/account/report/partner_balance.py | 509 ++++++++++++++---- addons/account/report/partner_balance.rml | 343 +++++------- .../wizard/wizard_partner_balance_report.py | 93 +++- 7 files changed, 773 insertions(+), 548 deletions(-) diff --git a/addons/account/project/report/analytic_balance.py b/addons/account/project/report/analytic_balance.py index b16a6040237..34f8632e301 100644 --- a/addons/account/project/report/analytic_balance.py +++ b/addons/account/project/report/analytic_balance.py @@ -31,8 +31,9 @@ import pooler import time from report import report_sxw +import rml_parse -class account_analytic_balance(report_sxw.rml_parse): +class account_analytic_balance(rml_parse.rml_parse): def __init__(self, cr, uid, name, context): super(account_analytic_balance, self).__init__(cr, uid, name, context) self.localcontext.update( { diff --git a/addons/account/project/report/analytic_balance.rml b/addons/account/project/report/analytic_balance.rml index 6191906b446..77d52c2526c 100644 --- a/addons/account/project/report/analytic_balance.rml +++ b/addons/account/project/report/analytic_balance.rml @@ -3,6 +3,37 @@ @@ -10,65 +41,30 @@ - - + - - - - - - - - - - - + + - + - + + - + - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - @@ -76,152 +72,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - Analytic Balance - - - - - - - - - - [[ company.name ]] - - - Period from [[ data['form']['date1'] ]] - to [[ data['form']['date2'] ]] - - - Currency: [[ company.currency_id.name ]] - - - - - - - Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]] - - - - - - - Code - - - Account Name - - - Debit - - - Credit - - - Balance - - - Quantity - - - - - -
- [[ repeatIn(objects,'o') ]] - + - [[ o.code ]] [[ o.complete_name ]] + Code + + + Account Name + + + Debit + + + Credit + + + Balance + + + Quantity + + + + + + Total + + + + [[ sum_debit(objects,data['form']['date1'],data['form']['date2']) or 0.0 ]] + + + [[ sum_credit(objects,data['form']['date1'],data['form']['date2']) or 0.0 ]] + + + [[ sum_balance(objects,data['form']['date1'],data['form']['date2']) or 0.0 ]] + + + [[ sum_quantity(objects,data['form']['date1'],data['form']['date2']) or 0.0 ]] + + + + + + [[ repeatIn(objects,'o') ]] + + + + [[ o.code ]] + + + [[ o.complete_name ]] + + + [[ move_sum_debit(o.id,data['form']['date1'],data['form']['date2']) or 0.0 ]] + + + [[ move_sum_credit(o.id,data['form']['date1'],data['form']['date2']) or 0.0 ]] + + + [[ move_sum_balance(o.id,data['form']['date1'],data['form']['date2']) or 0.0 ]] + + + [[ move_sum_quantity(o.id,data['form']['date1'],data['form']['date2']) or 0.0 ]] + + + + + [[ repeatIn(lines_g(o.id,data['form']['date1'],data['form']['date2']),'move_g') ]] + [[ move_g['code'] ]] + + + [[ move_g['name'] ]] + + + [[ move_g['debit'] ]] + + + [[ move_g['credit'] ]] + + + [[ move_g['balance'] ]] + + + [[ (move_g['quantity'] or 0.0) ]] + + + + + + - - - - [[ repeatIn(lines_g(o.id,data['form']['date1'],data['form']['date2']),'move_g') ]] - [[ move_g['code'] ]] - - - [[ move_g['name'] ]] - - - [[ '%.2f' % move_g['debit'] ]] - - - [[ '%.2f' % move_g['credit'] ]] - - - [[ '%.2f' % move_g['balance'] ]] - - - [[ '%.2f' % (move_g['quantity'] or 0.0) ]] - - - - - - - Total ([[ o.code ]]) - - - [[ '%.2f' % (move_sum_debit(o.id,data['form']['date1'],data['form']['date2']) or 0.0) ]] - - - [[ '%.2f' % (move_sum_credit(o.id,data['form']['date1'],data['form']['date2']) or 0.0 )]] - - - [[ '%.2f' % (move_sum_balance(o.id,data['form']['date1'],data['form']['date2']) or 0.0) ]] - - - [[ '%.2f' % move_sum_quantity(o.id,data['form']['date1'],data['form']['date2']) or 0.0]] - - - - +
- - - - - - - Total - - - [[ '%.2f' % (sum_debit(objects,data['form']['date1'],data['form']['date2']) or 0.0) ]] - - - [[ '%.2f' % (sum_credit(objects,data['form']['date1'],data['form']['date2']) or 0.0) ]] - - - [[ '%.2f' % (sum_balance(objects,data['form']['date1'],data['form']['date2']) or 0.0)]] - - - [[ '%.2f' % sum_quantity(objects,data['form']['date1'],data['form']['date2']) or 0.0 ]] - - - - - - - - -
- - + \ No newline at end of file diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py index 5ff60c44a18..1ecb0869876 100644 --- a/addons/account/report/account_balance.py +++ b/addons/account/report/account_balance.py @@ -71,7 +71,10 @@ class account_balance(report_sxw.rml_parse): self.cr.execute("select name from account_period where id in (%s)" % (period_ids)) res=self.cr.fetchall() for r in res: - result+=r[0]+", " + if (r == res[res.__len__()-1]): + result+=r[0]+". " + else: + result+=r[0]+", " return str(result and result[:-1]) or '' def lines(self, form, ids={}, done=None, level=1): @@ -118,6 +121,7 @@ class account_balance(report_sxw.rml_parse): 'credit': account.credit, 'balance': account.balance, 'leef': not bool(account.child_id), + 'bal_type':'', } self.sum_debit += account.debit self.sum_credit += account.credit @@ -177,6 +181,10 @@ class account_balance(report_sxw.rml_parse): r['credit']='' r['balance']='' r['leef']='' + if sum > 0.0: + r['bal_type']=" Dr." + else: + r['bal_type']=" Cr." return res or '' def date_range(self,start,end): diff --git a/addons/account/report/account_balance.rml b/addons/account/report/account_balance.rml index 462a7bd1744..0b614106551 100644 --- a/addons/account/report/account_balance.rml +++ b/addons/account/report/account_balance.rml @@ -61,15 +61,14 @@ - - + - - + + - + @@ -94,7 +93,7 @@ fontSize="8.0" /> [[ setTag('para','para',{'style':('Level'+str(a['level']))}) ]][[ (a['level']<6 and removeParentNode('font') or '... '*(a['level']-4)) ]][[ setTag('blockTable','blockTable',{'style':'TrLevel'+str(a['level'])}) ]][[ a['name'] ]] - [[ formatLang(a['debit']) and '%.2f'%a['debit'] or '']] + [[ (a['level']<4) and setTag('para','para',{'style':'P3'}) ]][[ (a['leef'] and removeParentNode('para')) or formatLang(a['debit']) and '%.2f'%a['debit'] or '0.00' ]] + [[ ((not a['leef']) and removeParentNode('para')) or formatLang(a['debit']) and '%.2f'%a['debit'] or '0.00' ]] - [[ formatLang(a['credit']) and '%.2f'%a['credit'] or '']] + [[ (a['level']<4) and setTag('para','para',{'style':'P3'}) ]][[ (a['leef'] and removeParentNode('para')) or formatLang(a['credit']) and '%.2f'%a['credit'] or '0.00' ]] + [[ ((not a['leef']) and removeParentNode('para')) or formatLang(a['credit']) and '%.2f'%a['credit'] or '0.00' ]] - [[ (a['level']<4) and setTag('para','para',{'style':'P3a'}) ]][[ (a['leef'] and removeParentNode('para')) or formatLang(a['balance']) and '%.2f'%a['balance'] or '' ]] - [[ ((not a['leef']) and removeParentNode('para')) or formatLang(a['balance']) and formatLang(a['balance']) or '' ]] + [[ (a['level']<4) and setTag('para','para',{'style':'P3a'}) ]][[ (a['leef'] and removeParentNode('para')) or formatLang(a['balance']) and '%.2f'%a['balance'] or '0.00' ]] + [[ ((not a['leef']) and removeParentNode('para')) or formatLang(a['balance']) and formatLang(a['balance']) or '0.00' ]] @@ -166,13 +167,13 @@ [[ '... '*(a['level']-3) ]][[ a['lname'] ]] - [[ formatLang(a['debit1']) and '%.2f'%a['debit1'] or '']] + [[ formatLang(a['debit1']) and '%.2f'%a['debit1'] or '0.00']] - [[ formatLang(a['credit1']) and '%.2f'%a['credit1'] or '']] + [[ formatLang(a['credit1']) and '%.2f'%a['credit1'] or '0.00']] - [[ formatLang(a['balance1']) and '%.2f'%a['balance1'] or '']] + [[ formatLang(a['balance1']) and '%.2f'%a['balance1'] or '0.00' ]] diff --git a/addons/account/report/partner_balance.py b/addons/account/report/partner_balance.py index 912e8396ef2..e7313354aea 100644 --- a/addons/account/report/partner_balance.py +++ b/addons/account/report/partner_balance.py @@ -1,9 +1,6 @@ -# -*- encoding: utf-8 -*- ############################################################################## # -# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved. -# -# $Id$ +# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved. # # WARNING: This program as such is intended to be used by professional # programmers who take the whole responsability of assessing all potential @@ -30,11 +27,15 @@ import pooler import time +import re +import datetime from report import report_sxw class partner_balance(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(partner_balance, self).__init__(cr, uid, name, context) + self.date_lst = [] + self.date_lst_string = '' self.localcontext.update( { 'time': time, 'lines': self.lines, @@ -47,44 +48,138 @@ class partner_balance(report_sxw.rml_parse): 'solde_credit': self._solde_balance_credit, 'get_company': self._get_company, 'get_currency': self._get_currency, + 'comma_me' : self.comma_me, }) - + ## Compute account list one time + # + # Date Management + # + def date_range(self,start,end): + start = datetime.date.fromtimestamp(time.mktime(time.strptime(start,"%Y-%m-%d"))) + end = datetime.date.fromtimestamp(time.mktime(time.strptime(end,"%Y-%m-%d"))) + full_str_date = [] + # + r = (end+datetime.timedelta(days=1)-start).days + # + date_array = [start+datetime.timedelta(days=i) for i in range(r)] + for date in date_array: + full_str_date.append(str(date)) + return full_str_date + + # + def transform_period_into_date_array(self,data): + ## Get All Period Date + # + # If we have no period we will take all perdio in the FiscalYear. + if not data['form']['periods'][0][2] : + periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) + else: + periods_id = data['form']['periods'][0][2] + date_array = [] + for period_id in periods_id: + period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id) + date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop) + + self.date_lst = date_array + self.date_lst.sort() + + + def transform_date_into_date_array(self,data): + return_array = self.date_range(data['form']['date1'],data['form']['date2']) + self.date_lst = return_array + self.date_lst.sort() + + + + def comma_me(self,amount): + if type(amount) is float : + amount = str('%.2f'%amount) + else : + amount = str(amount) + if (amount == '0'): + return ' ' + orig = amount + new = re.sub("^(-?\d+)(\d{3})", "\g<1>'\g<2>", amount) + if orig == new: + return new + else: + return self.comma_me(new) + def preprocess(self, objects, data, ids): + # Transformation des date + # + # + if data['form'].has_key('fiscalyear'): + self.transform_period_into_date_array(data) + else: + self.transform_date_into_date_array(data) + ## + self.date_lst_string = '\'' + '\',\''.join(map(str,self.date_lst)) + '\'' + ## Compute Code account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') - line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line', - context={'fiscalyear': data['form']['fiscalyear']}) - self.cr.execute('SELECT DISTINCT line.partner_id ' \ - 'FROM account_move_line AS line, account_account AS account ' \ - 'WHERE line.partner_id IS NOT NULL ' \ - 'AND line.date >= %s ' \ - 'AND line.date <= %s ' \ - 'AND ' + line_query + ' ' \ - 'AND line.account_id = account.id ' \ - 'AND account.company_id = %d ' \ - 'AND account.active', - (data['form']['date1'], data['form']['date2'], - data['form']['company_id'])) - new_ids = [id for (id,) in self.cr.fetchall()] + # + if (data['form']['result_selection'] == 'customer' ): + self.ACCOUNT_TYPE = "('receivable')" + elif (data['form']['result_selection'] == 'supplier'): + self.ACCOUNT_TYPE = "('payable')" + else: + self.ACCOUNT_TYPE = "('payable','receivable')" + # self.cr.execute('SELECT a.id ' \ 'FROM account_account a ' \ 'LEFT JOIN account_account_type t ' \ 'ON (a.type = t.code) ' \ 'WHERE t.partner_account = TRUE ' \ 'AND a.company_id = %d ' \ + 'AND a.type IN ' + self.ACCOUNT_TYPE + " " \ 'AND a.active', (data['form']['company_id'],)) self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()]) - self.partner_ids = ','.join(map(str, new_ids)) - objects = self.pool.get('res.partner').browse(self.cr, self.uid, new_ids) - super(partner_balance, self).preprocess(objects, data, new_ids) + + super(partner_balance, self).preprocess(objects, data, ids) + + def lines(self,data): - def lines(self): - if not self.partner_ids: - return [] account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') - line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='l', - context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']}) + full_account = [] + result_tmp = 0.0 + + # + # + # + if data['form']['soldeinit'] : + self.cr.execute( + "SELECT p.ref, p.name,l.account_id,ac.name as account_name,ac.code as code , sum(debit) as debit, sum(credit) as credit, " \ + "CASE WHEN sum(debit) > sum(credit) " \ + "THEN sum(debit) - sum(credit) " \ + "ELSE 0 " \ + "END AS sdebit, " \ + "CASE WHEN sum(debit) < sum(credit) " \ + "THEN sum(credit) - sum(debit) " \ + "ELSE 0 " \ + "END AS scredit, " \ + "(SELECT sum(debit-credit) " \ + "FROM account_move_line l " \ + "WHERE partner_id = p.id " \ + "AND date < %s " \ + "AND blocked = TRUE AND l.reconcile_id IS NULL " \ + ") AS enlitige " \ + "FROM account_move_line l LEFT JOIN res_partner p ON (l.partner_id=p.id) " \ + "JOIN account_account ac ON (l.account_id = ac.id)" \ + "WHERE " \ +# " account_id IN (" + self.account_ids + ") " \ + "l.date < %s AND l.reconcile_id IS NULL " \ + "GROUP BY p.id, p.ref, p.name,l.account_id,ac.name,ac.code " \ + "ORDER BY l.account_id,p.name", + (self.date_lst[0],self.date_lst[0])) + res = self.cr.dictfetchall() + + for r in res: + full_account.append(r) + # + # + # self.cr.execute( - "SELECT p.ref, p.name, sum(debit) as debit, sum(credit) as credit, " \ + "SELECT p.ref,l.account_id,ac.name as account_name,ac.code as code ,p.name, sum(debit) as debit, sum(credit) as credit, " \ "CASE WHEN sum(debit) > sum(credit) " \ "THEN sum(debit) - sum(credit) " \ "ELSE 0 " \ @@ -96,129 +191,315 @@ class partner_balance(report_sxw.rml_parse): "(SELECT sum(debit-credit) " \ "FROM account_move_line l " \ "WHERE partner_id = p.id " \ - "AND date >= %s " \ - "AND date <= %s " \ + "AND l.date IN (" + self.date_lst_string + ") " \ "AND blocked = TRUE " \ - "AND " + line_query + " " \ ") AS enlitige " \ "FROM account_move_line l LEFT JOIN res_partner p ON (l.partner_id=p.id) " \ - "WHERE partner_id IN (" + self.partner_ids + ") " \ - "AND account_id IN (" + self.account_ids + ") " \ - "AND l.date >= %s " \ - "AND l.date <= %s " \ - "AND " + line_query + " " \ - "GROUP BY p.id, p.ref, p.name " \ - "ORDER BY p.ref, p.name", - (self.datas['form']['date1'], self.datas['form']['date2'], - self.datas['form']['date1'], self.datas['form']['date2'])) + "JOIN account_account ac ON (l.account_id = ac.id)" \ + "WHERE " \ +# " account_id IN (" + self.account_ids + ") " \ + " l.date IN (" + self.date_lst_string + ") " \ + "GROUP BY p.id, p.ref, p.name,l.account_id,ac.name,ac.code " \ + "ORDER BY l.account_id,p.name") res = self.cr.dictfetchall() - return res + print"=====res=====",res + for r in res: + full_account.append(r) + + ## We will now compute Total + return self._add_subtotal(full_account) - def _sum_debit(self): + def _add_subtotal(self,cleanarray): + i=0 + completearray = [] + tot_debit = 0.0 + tot_credit = 0.0 + tot_scredit = 0.0 + tot_sdebit = 0.0 + tot_enlitige = 0.0 + for r in cleanarray: + # For the first element we always add the line + # type = 1 is the line is the first of the account + # type = 2 is an other line of the account + if i==0: + # We add the first as the header + # + ## + new_header = {} + new_header['ref'] = '' + new_header['name'] = r['account_name'] + new_header['code'] = r['code'] + new_header['debit'] = 0 + new_header['credit'] = 0 + new_header['scredit'] = 0 + new_header['sdebit'] = 0 + new_header['enlitige'] = 0 + new_header['balance'] = 0 + new_header['type'] = 3 + ## + completearray.append(new_header) + # + r['type'] = 1 + r['balance'] = float(r['sdebit']) - float(r['scredit']) + completearray.append(r) + # + tot_debit = r['debit'] + tot_credit = r['credit'] + tot_scredit = r['scredit'] + tot_sdebit = r['sdebit'] + tot_enlitige = (r['enlitige'] or 0.0) + # + else: + if cleanarray[i]['account_id'] <> cleanarray[i-1]['account_id']: + ## + new_tot = {} + new_tot['ref'] = 'Total' + new_tot['name'] = cleanarray[i-1]['account_name'] + new_tot['code'] = cleanarray[i-1]['code'] + + new_tot['debit'] = tot_debit + new_tot['credit'] = tot_credit + new_tot['scredit'] = tot_scredit + new_tot['sdebit'] = tot_sdebit + new_tot['enlitige'] = tot_enlitige + new_tot['balance'] = float(tot_sdebit) - float(tot_scredit) + new_tot['type'] = 3 + ## + completearray.append(new_tot) + + # we reset the counter + tot_debit = r['debit'] + tot_credit = r['credit'] + tot_scredit = r['scredit'] + tot_sdebit = r['sdebit'] + tot_enlitige = (r['enlitige'] or 0.0) + # + ## + new_header = {} + new_header['ref'] = '' + new_header['name'] = r['account_name'] + new_header['code'] = r['code'] + new_header['debit'] = 0 + new_header['credit'] = 0 + new_header['scredit'] = 0 + new_header['sdebit'] = 0 + new_header['enlitige'] = 0 + new_header['balance'] = 0 + new_header['type'] = 3 + ## + ## + completearray.append(new_header) + ## + # + r['type'] = 1 + # + r['balance'] = float(r['sdebit']) - float(r['scredit']) + # + completearray.append(r) + if cleanarray[i]['account_id'] == cleanarray[i-1]['account_id']: + # we reset the counter + tot_debit = tot_debit + r['debit'] + tot_credit = tot_credit + r['credit'] + tot_scredit = tot_scredit + r['scredit'] + tot_sdebit = tot_sdebit + r['sdebit'] + tot_enlitige = tot_enlitige + (r['enlitige'] or 0.0) + # + r['type'] = 2 + # + r['balance'] = float(r['sdebit']) - float(r['scredit']) + # + completearray.append(r) + i = i + 1 + return completearray + + + def _sum_debit(self,data): if not self.ids: return 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') - line_query = account_move_line_obj._query_get(self.cr, self.uid, - obj='account_move_line', - context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']}) + result_tmp = 0.0 + # + # + if data['form']['soldeinit'] : + self.cr.execute( + 'SELECT sum(debit) ' \ + 'FROM account_move_line AS l ' \ + 'WHERE ' \ +# ' account_id IN (' + self.account_ids + ') ' \ + ' l.reconcile_id IS NULL ' \ + 'AND date < %s ', + (self.date_lst[0],)) + result_tmp = float(self.cr.fetchone()[0] or 0.0) + # + # self.cr.execute( 'SELECT sum(debit) ' \ - 'FROM account_move_line ' \ - 'WHERE partner_id IN (' + self.partner_ids + ') ' \ - 'AND account_id IN (' + self.account_ids + ') ' \ - 'AND date >=%s ' \ - 'AND date <= %s ' \ - 'AND ' + line_query, - (self.datas['form']['date1'], self.datas['form']['date2'])) - return self.cr.fetchone()[0] or 0.0 + 'FROM account_move_line AS l ' \ + 'WHERE ' \ +# ' account_id IN (' + self.account_ids + ') ' \ + ' l.date IN (' + self.date_lst_string + ') ' ) + result_tmp = result_tmp + float(self.cr.fetchone()[0] or 0.0) + + return result_tmp - def _sum_credit(self): + def _sum_credit(self,data): if not self.ids: return 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') - line_query = account_move_line_obj._query_get(self.cr, self.uid, - obj='account_move_line', - context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']}) + + result_tmp = 0.0 + # + # + if data['form']['soldeinit'] : + self.cr.execute( + 'SELECT sum(credit) ' \ + 'FROM account_move_line AS l ' \ + 'WHERE ' \ +# ' account_id IN (' + self.account_ids + ') ' \ + ' l.reconcile_id IS NULL ' \ + 'AND date < %s ' , + (self.date_lst[0],)) + result_tmp = float(self.cr.fetchone()[0] or 0.0) + # + # self.cr.execute( 'SELECT sum(credit) ' \ - 'FROM account_move_line ' \ - 'WHERE partner_id IN (' + self.partner_ids + ') ' \ - 'AND account_id IN (' + self.account_ids + ') ' \ - 'AND date >= %s ' \ - 'AND date <= %s ' \ - 'AND ' + line_query, - (self.datas['form']['date1'], self.datas['form']['date2'])) - return self.cr.fetchone()[0] or 0.0 + 'FROM account_move_line AS l ' \ + 'WHERE ' \ +# ' account_id IN (' + self.account_ids + ') ' \ + ' l.date IN (' + self.date_lst_string + ') ' ) + + result_tmp = result_tmp + float(self.cr.fetchone()[0] or 0.0) + + return result_tmp - def _sum_litige(self): + def _sum_litige(self,data): if not self.ids: return 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') - line_query = account_move_line_obj._query_get(self.cr, self.uid, - obj='account_move_line', - context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']}) + result_tmp = 0.0 + + # + # + if data['form']['soldeinit'] : + self.cr.execute( + 'SELECT sum(debit-credit) ' \ + 'FROM account_move_line AS l ' \ + 'WHERE ' \ +# ' account_id IN (' + self.account_ids + ') ' \ + ' l.reconcile_id IS NULL ' \ + 'AND date < %s ' \ + 'AND blocked=TRUE ' , + (self.date_lst[0],)) + result_tmp = float(self.cr.fetchone()[0] or 0.0) + # + # self.cr.execute( 'SELECT sum(debit-credit) ' \ - 'FROM account_move_line ' \ - 'WHERE partner_id IN (' + self.partner_ids + ') ' \ - 'AND account_id IN (' + self.account_ids + ') ' \ - 'AND date >= %s ' \ - 'AND date <= %s ' \ - 'AND blocked=TRUE ' \ - 'AND ' + line_query, - (self.datas['form']['date1'], self.datas['form']['date2'])) - return self.cr.fetchone()[0] or 0.0 + 'FROM account_move_line AS l ' \ + 'WHERE ' \ +# ' account_id IN (' + self.account_ids + ') ' \ + ' l.date IN (' + self.date_lst_string + ') ' \ + 'AND blocked=TRUE ' ) + result_tmp = result_tmp + float(self.cr.fetchone()[0] or 0.0) + + return result_tmp - def _sum_sdebit(self): + def _sum_sdebit(self,data): if not self.ids: return 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') - line_query = account_move_line_obj._query_get(self.cr, self.uid, - obj='account_move_line', - context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']}) + result_tmp = 0.0 + + # + # + if data['form']['soldeinit'] : + self.cr.execute( + 'SELECT CASE WHEN sum(debit) > sum(credit) ' \ + 'THEN sum(debit) - sum(credit) ' \ + 'ELSE 0 ' \ + 'END ' \ + 'FROM account_move_line AS l ' \ + 'WHERE ' \ +# ' account_id IN (' + self.account_ids + ') ' \ + ' date < %s ' \ + 'AND reconcile_id IS NULL ' \ + 'GROUP BY partner_id', + (self.date_lst[0],)) + + if self.cr.fetchone() != None: + result_tmp = float(self.cr.fetchone()[0]) + else: + result_tmp = 0.0 + # + # self.cr.execute( 'SELECT CASE WHEN sum(debit) > sum(credit) ' \ - 'THEN sum(debit - credit) ' \ + 'THEN sum(debit) - sum(credit) ' \ 'ELSE 0 ' \ 'END ' \ - 'FROM account_move_line ' \ - 'WHERE partner_id IN (' + self.partner_ids + ') ' \ - 'AND account_id IN (' + self.account_ids + ') ' \ - 'AND date >= %s ' \ - 'AND date <= %s ' \ - 'AND ' + line_query + ' ' \ - 'GROUP BY partner_id', - (self.datas['form']['date1'], self.datas['form']['date2'])) - return self.cr.fetchone()[0] or 0.0 + 'FROM account_move_line AS l ' \ + 'WHERE ' \ +# ' account_id IN (' + self.account_ids + ') ' \ + 'l.date IN (' + self.date_lst_string + ') ' \ + 'GROUP BY partner_id') + + if self.cr.fetchone() != None: + result_tmp = result_tmp + float(self.cr.fetchone()[0] or 0.0) + else: + result_tmp = 0.0 + return result_tmp - def _sum_scredit(self): + def _sum_scredit(self,data): if not self.ids: return 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') - line_query = account_move_line_obj._query_get(self.cr, self.uid, - obj='account_move_line', - context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']}) + result_tmp = 0.0 + # + # + if data['form']['soldeinit'] : + self.cr.execute( + 'SELECT CASE WHEN sum(debit) < sum(credit) ' \ + 'THEN sum(credit) - sum(debit) ' \ + 'ELSE 0 ' \ + 'END ' \ + 'FROM account_move_line AS l ' \ + 'WHERE ' \ +# ' account_id IN (' + self.account_ids + ') ' \ + ' date <= %s ' \ + 'AND l.reconcile_id IS NULL ' \ + 'GROUP BY partner_id', + (self.date_lst[0],)) + if self.cr.fetchone() != None: + result_tmp = float(self.cr.fetchone()[0]) + else: + result_tmp = 0.0 + # + # self.cr.execute( 'SELECT CASE WHEN sum(debit) < sum(credit) ' \ - 'THEN sum(credit - debit) ' \ + 'THEN sum(credit) - sum(debit) ' \ 'ELSE 0 ' \ 'END ' \ - 'FROM account_move_line ' \ - 'WHERE partner_id IN (' + self.partner_ids + ') ' \ - 'AND account_id IN (' + self.account_ids + ') ' \ - 'AND date >= %s ' \ - 'AND date <= %s ' \ - 'AND ' + line_query + ' ' \ - 'GROUP BY partner_id', - (self.datas['form']['date1'], self.datas['form']['date2'])) - return self.cr.fetchone()[0] or 0.0 - - def _solde_balance_debit(self): - debit, credit = self._sum_debit(), self._sum_credit() + 'FROM account_move_line AS l ' \ + 'WHERE ' \ +# ' account_id IN (' + self.account_ids + ') ' \ + 'l.date IN (' + self.date_lst_string + ') ' \ + 'GROUP BY partner_id') + + if self.cr.fetchone() != None: + result_tmp = result_tmp + float(self.cr.fetchone()[0] or 0.0) + else: + result_tmp = 0.0 + + return result_tmp + + def _solde_balance_debit(self,data): + debit, credit = self._sum_debit(data), self._sum_credit(data) return debit > credit and debit - credit - def _solde_balance_credit(self): - debit, credit = self._sum_debit(), self._sum_credit() + def _solde_balance_credit(self,data): + debit, credit = self._sum_debit(data), self._sum_credit(data) return credit > debit and credit - debit def _get_company(self, form): @@ -228,9 +509,5 @@ class partner_balance(report_sxw.rml_parse): return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name report_sxw.report_sxw('report.account.partner.balance', 'res.partner', - 'addons/account/report/partner_balance.rml',parser=partner_balance, + 'account/report/partner_balance.rml',parser=partner_balance, header=False) - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/account/report/partner_balance.rml b/addons/account/report/partner_balance.rml index c0d9ea67a2c..5e99323bb09 100644 --- a/addons/account/report/partner_balance.rml +++ b/addons/account/report/partner_balance.rml @@ -1,8 +1,37 @@ - + @@ -13,55 +42,24 @@ - - - - - - + + + + + + - - - - - - - - - - - - - - - - + - + + + - - - - - - - - - - - - - - - - - - - + @@ -70,197 +68,63 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - Third party balance - - - From [[ formatLang(data['form']['date1'], date=True) ]] - to [[ formatLang(data['form']['date2'], date=True) ]] - - - - - [[ get_company(data['form']) ]] - - - - - - - - Currency: [[ get_currency(data['form']) ]] - - - - - - - Printing date: [[ formatLang(time.strftime('%Y-%m-%d'), date=True) ]] at [[ time.strftime('%H:%M:%S') ]] - - - - - - - Account number - - - Account name - - - Transactions - - - Balances - - - In dispute - - - - - - - - - - - - Debit - - - Credit - - - Debit - - - Credit - - - - - - - - - - - - - - - [[ repeatIn(lines(), 'a') ]][[ a['ref'] ]] - - - [[ a['name'] ]] - - - [[ formatLang(a['debit']) ]] - - - [[ formatLang(a['credit']) ]] - - - [[ formatLang(a['sdebit']) ]] - - - [[ formatLang(a['scredit']) ]] - - - [[ formatLang((a['enlitige'] or 0.0)) ]] - - - - - - - + + Grand total - [[ formatLang(sum_debit()) ]] + [[ comma_me(sum_debit(data)) ]] - [[ formatLang(sum_credit()) ]] + [[ comma_me(sum_credit(data)) ]] - [[ formatLang(sum_sdebit()) ]] + [[ comma_me(sum_sdebit(data)) ]] - [[ formatLang(sum_scredit()) ]] + [[ comma_me(sum_scredit(data)) ]] - [[ formatLang(sum_litige()) ]] + [[ comma_me(sum_litige(data)) ]] @@ -278,10 +142,10 @@ - [[ formatLang(solde_debit()) ]] + [[ comma_me(solde_debit(data)) ]] - [[ formatLang(solde_credit()) ]] + [[ comma_me(solde_credit(data)) ]] @@ -290,10 +154,55 @@ + + + + Code + + + Partner name + + + Débit + + + Crédit + + + Balance + + + In dispute + + + + + [[ repeatIn(lines(data), 'a') ]][[ a['type']==3 and ( setTag('para','para',{'fontName':'Helvetica-Bold'})) ]] [[ a['ref'] ]] + + + [[ a['type']==3 and ( setTag('para','para',{'fontName':'Helvetica-Bold'})) ]] [[ a['type']==3 and a['code'] ]] [[ a['name'] ]] + + + [[ a['type']==3 and ( setTag('para','para',{'fontName':'Helvetica-Bold'})) ]] [[ comma_me(a['debit']) ]] + + + [[ a['type']==3 and ( setTag('para','para',{'fontName':'Helvetica-Bold'})) ]] [[ comma_me(a['credit']) ]] + + + [[ a['type']==3 and ( setTag('para','para',{'fontName':'Helvetica-Bold'})) ]] [[ comma_me(a['balance']) ]] + + + [[ a['type']==3 and ( setTag('para','para',{'fontName':'Helvetica-Bold'})) ]] [[ comma_me(a['enlitige']) ]] + + + + + + + - diff --git a/addons/account/wizard/wizard_partner_balance_report.py b/addons/account/wizard/wizard_partner_balance_report.py index d5ce386dae7..08af6074215 100644 --- a/addons/account/wizard/wizard_partner_balance_report.py +++ b/addons/account/wizard/wizard_partner_balance_report.py @@ -1,9 +1,6 @@ -# -*- encoding: utf-8 -*- ############################################################################## # -# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved. -# -# $Id$ +# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved. # # WARNING: This program as such is intended to be used by professional # programmers who take the whole responsability of assessing all potential @@ -32,28 +29,51 @@ import time import wizard import pooler +report_type = ''' +
+
''' + + dates_form = '''
- -
+ + + Date: Mon, 6 Oct 2008 16:17:44 +0530 Subject: [PATCH 4/8] Bugfix on Account_analytic_analysis for month summary bzr revid: jvo@tinyerp.com-20081006104744-mqgj7yn6moftjfen --- addons/account_analytic_analysis/account_analytic_analysis.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account_analytic_analysis/account_analytic_analysis.py b/addons/account_analytic_analysis/account_analytic_analysis.py index 4a2a9988c00..212cdbbe8d4 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis.py +++ b/addons/account_analytic_analysis/account_analytic_analysis.py @@ -1,5 +1,5 @@ # -*- encoding: utf-8 -*- -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved. @@ -643,7 +643,7 @@ class account_analytic_account_summary_month(osv.osv): '(TO_NUMBER(TO_CHAR(d.month, \'YYYYMM\'), \'999999\') + (d.account_id * 1000000))::integer AS id, ' \ 'd.account_id AS account_id, ' \ 'TO_CHAR(d.month, \'Mon YYYY\') AS month, ' \ - 'TO_CHAR(d.month, \'YYYYMM\') AS month_id, ' \ + 'TO_NUMBER(TO_CHAR(d.month, \'YYYYMM\'), \'999999\') AS month_id, ' \ 'COALESCE(SUM(l.unit_amount), 0.0) AS unit_amount ' \ 'FROM ' \ '(SELECT ' \ From dfb03b524518061738e20cda572a043c7e4d8fe2 Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Mon, 6 Oct 2008 16:31:27 +0530 Subject: [PATCH 5/8] small changes in account/project/report/analytic_balance.py bzr revid: patelamit2003@gmail.com-20081006110127-adltybjhi7dtprpu --- addons/account/project/report/analytic_balance.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/project/report/analytic_balance.py b/addons/account/project/report/analytic_balance.py index 34f8632e301..62b7c9f0a4b 100644 --- a/addons/account/project/report/analytic_balance.py +++ b/addons/account/project/report/analytic_balance.py @@ -31,9 +31,9 @@ import pooler import time from report import report_sxw -import rml_parse -class account_analytic_balance(rml_parse.rml_parse): + +class account_analytic_balance(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(account_analytic_balance, self).__init__(cr, uid, name, context) self.localcontext.update( { From d3984a4be9c465db921cf16a62a48e6d2e6c59b1 Mon Sep 17 00:00:00 2001 From: Jay Vora Date: Mon, 6 Oct 2008 17:31:54 +0530 Subject: [PATCH 6/8] Account_budget : Modified report of analytic account with budgets bzr revid: jvo@tinyerp.com-20081006120154-lspgqk0qf3j9y2on --- .../report/analytic_account_budget_report.rml | 185 +++++++++++------- .../report/crossovered_budget_report.rml | 1 + 2 files changed, 111 insertions(+), 75 deletions(-) diff --git a/addons/account_budget/report/analytic_account_budget_report.rml b/addons/account_budget/report/analytic_account_budget_report.rml index b7fa076ab35..8f15f8a8ecd 100644 --- a/addons/account_budget/report/analytic_account_budget_report.rml +++ b/addons/account_budget/report/analytic_account_budget_report.rml @@ -10,73 +10,106 @@ - - - - - - - - - - - - - + + + + + + - - - - - - + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - [[ repeatIn(objects,'o') ]] - + [[ repeatIn(objects,'o') ]] + - [[ company.name ]] + [[ company.name ]] - + Currency: [[ company.currency_id.name ]] @@ -85,21 +118,24 @@ Printed at: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S')]] - - - Analysis from [[ data['form']['date_from'] ]] to [[ data['form']['date_to'] ]] + + Analysis from [[ data['form']['date_from'] ]] to [[ data['form']['date_to'] ]] + - Analytic Account : [[ o.name ]] + Analytic Account : [[ o.name ]] - + - + + + + Description @@ -114,59 +150,58 @@ Practical Amount - % + Perc(%) + + +
- [[ repeatIn(funct(o,data['form']),'a') ]] - - - - - [['.....'*(a['status']-1) ]][[ setTag('font','font',{'color':'white'}) ]][[ a['status']==1 and ( setTag('font','font',{'name':'Times-bold'})) ]][[ a['name'] ]] - - - - [[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ '%.2f' % a['theo'] ]] - - - [[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ '%.2f' % a['pln'] ]] - - - [[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ '%.2f' % a['prac'] ]] - - - [[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ '%.2f' % a['perc'] ]]% - - - + [[ repeatIn(funct(o,data['form']),'a') ]] + + + + [['.....' *(a['status']-1) ]] [[ setTag('font','font',{'color':'white'}) ]][[ a['status']==1 and (setTag('font','font',{'name':'Helvetica-bold'})) ]][[ a['name'] ]] + + + [[ a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'})) ]][[ '%.2f' % a['theo'] ]] + + + [[ a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'})) ]][[ '%.2f' % a['pln'] ]] + + + [[ a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'})) ]][[ '%.2f' % a['prac'] ]] + + + [[ a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'})) ]][[ '%.2f' % a['perc'] ]]% + + +
- - - - + + + + - Total: + [[ repeatIn(funct_total(data['form']),'b') ]] Total : - - [[ repeatIn(funct_total(data['form']),'b') ]] [[ '%.2f' % b['tot_theo'] ]] - + [[ '%.2f' % b['tot_theo'] ]] - [[ '%.2f' % b['tot_pln'] ]] + [[ '%.2f' % b['tot_pln'] ]] - [[ '%.2f' % b['tot_prac'] ]] + [[ '%.2f' % b['tot_prac'] ]] - [[ '%.2f' % b['tot_perc'] ]]% + [[ '%.2f' % b['tot_perc'] ]]% - +
diff --git a/addons/account_budget/report/crossovered_budget_report.rml b/addons/account_budget/report/crossovered_budget_report.rml index 45dc7397594..fa997efe8fa 100644 --- a/addons/account_budget/report/crossovered_budget_report.rml +++ b/addons/account_budget/report/crossovered_budget_report.rml @@ -17,6 +17,7 @@ + From 97a5771d3f14e7d75d65071eb915cb58b12fb5c6 Mon Sep 17 00:00:00 2001 From: qdp Date: Mon, 6 Oct 2008 16:39:28 +0200 Subject: [PATCH 7/8] *improved name_get of res_partner_contact *typo corrected *added name_get for res_partner_job bzr revid: qdp@tinyerp.com-20081006143928-ahe20kt1gxluw80s --- addons/base_contact/base_contact.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/addons/base_contact/base_contact.py b/addons/base_contact/base_contact.py index 0b7ff4ef151..7a94e88fdd7 100644 --- a/addons/base_contact/base_contact.py +++ b/addons/base_contact/base_contact.py @@ -61,8 +61,9 @@ class res_partner_contact(osv.osv): if not len(ids): return [] res = [] - for r in self.read(cr, user, ids, ['name','first_name']): - addr = str(r['name'] or '') + for r in self.read(cr, user, ids, ['name','first_name','title']): + addr = r['title'] and str(r['title'])+" " or '' + addr +=str(r['name'] or '') if r['name'] and r['first_name']: addr += ' ' addr += str(r['first_name'] or '') @@ -88,7 +89,7 @@ class res_partner_address(osv.osv): _name = 'res.partner.address' _inherit='res.partner.address' - _description ='Partner Contact' + _description ='Partner Address' _columns = { 'job_ids':fields.one2many('res.partner.job', 'address_id', 'Contacts'), } @@ -96,10 +97,18 @@ res_partner_address() class res_partner_job(osv.osv): - def _get_partner_name(self, cr, uid, ids, *a): + def _get_partner_id(self, cr, uid, ids, *a): res={} for id in self.browse(cr, uid, ids): - res[id.id] = id.address_id.partner_id.id + res[id.id] = id.address_id.partner_id and id.address_id.partner_id.id or False + return res + + def name_get(self, cr, uid, ids, context={}): + if not len(ids): + return [] + res = [] + for r in self.browse(cr, uid, ids): + res.append((r.id, self.pool.get('res.partner.contact').name_get(cr, uid, [r.contact_id.id])[0][1] +", "+ r.function_id.name)) return res def search(self, cr, user, args, offset=0, limit=None, order=None, @@ -115,7 +124,7 @@ class res_partner_job(osv.osv): _description ='Contact Function' _order = 'sequence_contact' _columns = { - 'name': fields.function(_get_partner_name, method=True, type='many2one', relation='res.partner', string='Partner'), + 'name': fields.function(_get_partner_id, method=True, type='many2one', relation='res.partner', string='Partner'), 'address_id':fields.many2one('res.partner.address','Address', required=True), 'contact_id':fields.many2one('res.partner.contact','Contact', required=True), 'function_id': fields.many2one('res.partner.function','Function', required=True), From 79100b55ec1723edb832b3a8d41c1a87973786b9 Mon Sep 17 00:00:00 2001 From: qdp Date: Mon, 6 Oct 2008 17:30:37 +0200 Subject: [PATCH 8/8] *modified remind_user function in order to take the address from the section (reply_to field) in place that the address mail on the res_partner_address from the user responsible bzr revid: qdp@tinyerp.com-20081006153037-kf2e9tt5tzxejrsy --- addons/crm/crm.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index ce79cd20ebd..3cd86c36d25 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -564,11 +564,9 @@ class crm_case(osv.osv): def remind_user(self, cr, uid, ids, context={}, attach=False, destination=True): for case in self.browse(cr, uid, ids): - if case.user_id and case.user_id.address_id \ - and case.user_id.address_id.email \ - and case.email_from: + if case.section_id.reply_to and case.email_from: src = case.email_from - dest = case.user_id.address_id.email + dest = case.section_id.reply_to body = case.email_last or case.description if not destination: src,dest = dest,src