openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #01675
lp:~vauxoo/account-financial-report/7.0-afr_GB_partner-dev-hbto into lp:account-financial-report
hbto [Vauxoo] http://www.vauxoo.com has proposed merging lp:~vauxoo/account-financial-report/7.0-afr_GB_partner-dev-hbto into lp:account-financial-report.
Requested reviews:
Account Report Core Editors (account-report-core-editor)
For more details, see:
https://code.launchpad.net/~vauxoo/account-financial-report/7.0-afr_GB_partner-dev-hbto/+merge/196764
Allows to breakdown the partner details of accounts of type
(other, liquidity, receivable & payable)
When asking for a report of Four Columns and type Balance Sheet
Regards.
--
https://code.launchpad.net/~vauxoo/account-financial-report/7.0-afr_GB_partner-dev-hbto/+merge/196764
Your team Account Report Core Editors is requested to review the proposed merge of lp:~vauxoo/account-financial-report/7.0-afr_GB_partner-dev-hbto into lp:account-financial-report.
=== modified file 'account_financial_report/model/account_financial_report.py'
--- account_financial_report/model/account_financial_report.py 2013-07-26 17:03:11 +0000
+++ account_financial_report/model/account_financial_report.py 2013-11-26 18:12:27 +0000
@@ -49,7 +49,9 @@
'analytic_ledger': fields.boolean('Analytic Ledger', help="Allows to Generate an Analytic Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"),
'journal_ledger': fields.boolean('journal Ledger', help="Allows to Generate an journal Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"),
-
+ 'partner_balance': fields.boolean('Partner Balance', help="""Allows to
+ Generate a Partner Balance for accounts with moves. Available when
+ Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"""),
'tot_check': fields.boolean('Summarize?', help='Checking will add a new line at the end of the Report which will Summarize Columns in Report'),
'lab_str': fields.char('Description', help='Description for the Summary', size=128),
'target_move': fields.selection([('posted', 'All Posted Entries'),
=== added file 'account_financial_report/report/balance_full_4_cols_partner_balance.rml'
--- account_financial_report/report/balance_full_4_cols_partner_balance.rml 1970-01-01 00:00:00 +0000
+++ account_financial_report/report/balance_full_4_cols_partner_balance.rml 2013-11-26 18:12:27 +0000
@@ -0,0 +1,273 @@
+<?xml version="1.0"?>
+<document filename="test.pdf">
+ <template pageSize="(27.94cm,21.59cm)" title="Test" author="Martin Simon" allowSplitting="20" showBoundary="0">
+ <pageTemplate id="first">
+ <frame id="first" x1="1.0cm" y1="1.0cm" width="26.0cm" height="16.65cm"/>
+ <pageGraphics>
+ <setFont name="Helvetica-Oblique" size="6"/>
+
+ <image x="1.0cm" y="17.65cm" width="5.0cm">[[company.logo and company.logo or removeParentNode('image')]]</image>
+<!--
+ <drawString x="1.0cm" y="24.5cm">[[company.logo and removeParentNode('para') or company.name]]</drawString>
+-->
+
+ <place x="-3.5cm" y="16.15cm" width="19cm" height="5.0cm">
+ <blockTable colWidths="9.6cm,9.4cm" style="TITLE">
+ <tr>
+ <td><para style="TOP_TITLE"></para></td>
+ <td><para style="TITLE_CENTER_NAME">
+ <font>[[ (company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE')]]</font>
+ <font>[[ get_vat_by_country(data['form']) ]]</font>
+ </para></td>
+ </tr>
+ <tr>
+ <td><para style="TOP_TITLE"></para></td>
+ <td><para style="TITLE_CENTER">[[ get_informe_text(data['form']) ]]</para></td>
+ </tr>
+ <tr>
+ <td><para style="TOP_TITLE"></para></td>
+ <td><para style="TITLE_CENTER">(Expressed in [[data['form'] and (' %s'%( exchange_name(data['form']))) or '']])</para></td>
+ </tr>
+ <tr>
+ <td><para style="TOP_TITLE"></para></td>
+ <td><para style="TITLE_CENTER">[[data['form'] and get_month(data['form']) or '']]</para></td>
+ </tr>
+ </blockTable>
+ </place>
+ <drawRightString x="270mm" y="5mm">Printing Date: [[ formatLang(time.strftime('%Y-%m-%d %H:%M:%S'),date_time=True) ]] [[ get_informe_text(data['form']) ]] / Pág.: <pageNumber/>-<pageCount/></drawRightString>
+ </pageGraphics>
+
+ </pageTemplate>
+ </template>
+ <stylesheet>
+ <blockTableStyle id="BODY_LINE">
+ <blockValign value="TOP"/>
+ <blockAlignment value="RIGHT"/>
+ <blockTopPadding length="1.0"/>
+ <blockBottomPadding length="1.0"/>
+ <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,0" stop="-1,-1" thickness='0.25'/>
+ </blockTableStyle>
+ <blockTableStyle id="TITLE">
+ <blockValign value="TOP"/>
+ </blockTableStyle>
+ <blockTableStyle id="BODY">
+ <blockValign value="TOP"/>
+ <blockAlignment value="RIGHT"/>
+ <blockTopPadding length="1.0"/>
+ <blockBottomPadding length="1.0"/>
+ <lineStyle kind="LINEBELOW" colorName="darkgrey" start="0,0" stop="-1,-1" thickness='0.25'/>
+ </blockTableStyle>
+ <blockTableStyle id="BODY_STRIKE">
+ <blockValign value="TOP"/>
+ <blockAlignment value="RIGHT"/>
+ <blockTopPadding length="1.0"/>
+ <blockBottomPadding length="1.0"/>
+ <lineStyle kind="LINEBELOW" colorName="#FFFFFF" start="0,1" stop="-1,-1" thickness='0.5'/>
+ </blockTableStyle>
+ <blockTableStyle id="TOP_TABLE">
+ <blockAlignment value="LEFT"/>
+ <blockValign value="TOP"/>
+ <lineStyle kind="LINEBELOW" colorName="#FFFFFF" start="0,-1" stop="0,-1" thickness='0.25'/>
+ </blockTableStyle>
+
+ <initialize>
+ <paraStyle name="all" alignment="justify"/>
+ </initialize>
+
+ <paraStyle
+ name="TITLE_LEFT_ALIGN_NEW"
+ fontName="Courier"
+ fontSize="7.0"
+ leading="10"
+ alignment="RIGHT"
+ spaceBefore="0.0"
+ spaceAfter="0.0"/>
+ <paraStyle name="TITLES_NEW"
+ fontName="Courier"
+ fontSize="7.0"
+ leading="10"
+ alignment="LEFT"
+ spaceBefore="0.0"
+ spaceAfter="0.0"/>
+ <paraStyle
+ name="TITLE_LEFT_ALIGN"
+ fontName="Helvetica-Bold"
+ fontSize="7.0"
+ leading="10"
+ alignment="RIGHT"
+ spaceBefore="0.0"
+ spaceAfter="0.0"/>
+ <paraStyle name="TOP_TITLE" fontName="Helvetica-Bold" fontSize="7" leftIndent="0.0" alignment="LEFT"/>
+ <paraStyle
+ name="TITLES"
+ fontName="Helvetica-Bold"
+ fontSize="7.0"
+ leading="10"
+ alignment="LEFT"
+ spaceBefore="0.0"
+ spaceAfter="0.0"/>
+ <paraStyle name="TITLE_CENTER" fontName="Helvetica-Bold" fontSize="7" leading="10" leftIndent="0.0" alignment="CENTER"/>
+ <paraStyle name="TITLE_CENTER_NAME" fontName="Helvetica-Bold" fontSize="12" leading="13" leftIndent="0.0" alignment="CENTER"/>
+ <paraStyle
+ name="TITLE"
+ alignment="CENTER"
+ fontName="Helvetica"
+ fontSize="18.0"
+ leading="20"
+ spaceBefore="-3.0"
+ textColor="black"/>
+ </stylesheet>
+ <images/>
+ <story>
+ <para>[[setLang(user.lang)]]</para>
+
+ <blockTable colWidths="2.5cm,13.5cm,2.5cm,2.5cm,2.5cm,2.5cm" style="BODY" repeatRows="0">
+ <tr noRowsplits="0">
+ <td>
+ <para style="TITLE_LEFT_ALIGN">
+ <font>CODE</font>
+ </para>
+ </td>
+ <td>
+ <para style="TITLES">ACCOUNT</para>
+ </td>
+ <td>
+ <para style="TITLE_LEFT_ALIGN">INITIAL</para>
+ </td>
+ <td>
+ <para style="TITLE_LEFT_ALIGN">DEBIT</para>
+ </td>
+ <td>
+ <para style="TITLE_LEFT_ALIGN">CREDIT</para>
+ </td>
+ <td>
+ <para style="TITLE_LEFT_ALIGN">BALANCE</para>
+ </td>
+ </tr>
+ </blockTable>
+
+ <blockTable colWidths="2.25cm,13.75cm,2.5cm,2.5cm,2.5cm,2.5cm" style="BODY_LINE" repeatRows="1">
+<!--
+ [[ (a['type'] <> 'view') or removeParentNode('blockTable') ]]
+-->
+ <tr noRowsplits="1">
+ <td>
+ <para style="TITLES_NEW">
+ <font></font>
+ </para>
+ </td>
+ <td>
+ <para style="TITLES_NEW">
+ <font>PARTNER</font>
+ </para>
+ </td>
+ <td>
+ <para style="TITLES_NEW"></para>
+ </td>
+ <td>
+ <para style="TITLE_LEFT_ALIGN"></para>
+ </td>
+ <td>
+ <para style="TITLE_LEFT_ALIGN"></para>
+ </td>
+ <td>
+ <para style="TITLE_LEFT_ALIGN"></para>
+ </td>
+ </tr>
+ </blockTable>
+
+
+
+
+
+ <section>
+ <para>[[ repeatIn([x for x in lines(data['form']) if x['type'] != 'view'], 'a') ]]</para>
+ <blockTable colWidths="2.5cm,13.5cm,2.5cm,2.5cm,2.5cm,2.5cm" style="BODY" repeatRows="0">
+ <tr>
+ <td>
+ <para style="TITLE_LEFT_ALIGN">
+ <font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]]</font>
+ <i>[[a['label']==True and a['code'] or '' ]]</i>
+ </para>
+ </td>
+ <td>
+ <para style="TITLES">
+ <font>[[ ((a['total'] and not a['label']) and setTag('para','para',{'alignment':"RIGHT"}) or (a['type']<>'view' and setTag('para','para',{'fontName':"Courier-Bold"}))) or removeParentNode('font') ]]</font>
+ <font>[[ a['type']=='view' and a['name'].upper() or a['name'].title() ]]</font>
+ </para>
+ </td>
+ <td>
+ <para style="TITLE_LEFT_ALIGN">
+ <font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]]</font>
+ <font>[[ (a['total']==True) and formatLang(a['balanceinit'] and a['balanceinit'] * a.get('change_sign',1.0) or 0.0, digits=2, grouping=True) or '']]</font>
+ </para>
+ </td>
+ <td>
+ <para style="TITLE_LEFT_ALIGN">
+ <font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]]</font>
+ <font>[[ (a['total']==True) and formatLang(a['debit'], digits=2, grouping=True) or '']]</font>
+ </para>
+ </td>
+ <td>
+ <para style="TITLE_LEFT_ALIGN">
+ <font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]]</font>
+ <font>[[ (a['total']==True) and formatLang(a['credit'], digits=2, grouping=True) or '']]</font>
+ </para>
+ </td>
+ <td>
+ <para style="TITLE_LEFT_ALIGN">
+ <font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]]</font>
+ <font>[[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign',1.0) or 0.0, digits=2, grouping=True) or '']]</font>
+ </para>
+ </td>
+ </tr>
+ </blockTable>
+
+ <section>
+ <para>[[ repeatIn(a['partner'], 'm') ]]</para>
+ <blockTable colWidths="2.25cm,13.75cm,2.5cm,2.5cm,2.5cm,2.5cm" style="BODY_LINE" repeatRows="1">
+<!--
+ [[ (a['type'] <> 'view') or removeParentNode('blockTable') ]]
+-->
+ <tr>
+ <td>
+ <para style="TITLES_NEW">
+ </para>
+ </td>
+ <td>
+ <para style="TITLES_NEW">
+ <font>[[ m['partner_name'] ]]</font>
+ </para>
+ </td>
+ <td>
+ <para style="TITLE_LEFT_ALIGN">
+ <font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
+ <font>[[ (a['total']==True) and formatLang(m['balanceinit'] and m['balanceinit'] * m.get('change_sign',1.0) or 0.0, digits=2, grouping=True) or '']]</font>
+ </para>
+ </td>
+ <td>
+ <para style="TITLE_LEFT_ALIGN">
+ <font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
+ <font>[[ (a['total']==True) and formatLang(m['debit'], digits=2, grouping=True) or '']]</font>
+ </para>
+ </td>
+ <td>
+ <para style="TITLE_LEFT_ALIGN">
+ <font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
+ <font>[[ (a['total']==True) and formatLang(m['credit'], digits=2, grouping=True) or '']]</font>
+ </para>
+ </td>
+ <td>
+ <para style="TITLE_LEFT_ALIGN">
+ <font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
+ <font>[[ (a['total']==True) and formatLang(m['balance'] and m['balance'] * a.get('change_sign',1.0) or 0.0, digits=2, grouping=True) or '']]</font>
+ </para>
+ </td>
+ </tr>
+ </blockTable>
+ </section>
+ <spacer length="2.5mm"/>
+ </section>
+
+ </story>
+</document>
=== modified file 'account_financial_report/report/parser.py'
--- account_financial_report/report/parser.py 2013-07-31 13:01:43 +0000
+++ account_financial_report/report/parser.py 2013-11-26 18:12:27 +0000
@@ -35,7 +35,6 @@
from tools import config
from tools.translate import _
from osv import osv
-import pdb
from openerp.tools.safe_eval import safe_eval as eval
@@ -190,6 +189,103 @@
else:
return [brw.id for brw in rc_obj.browse(self.cr, self.uid, company_id).debit_account_ids]
+ def _get_partner_balance(self, account, init_period, ctx=None):
+ rp_obj = self.pool.get('res.partner')
+ res = []
+ ctx = ctx or {}
+ if account['type'] in ('other', 'liquidity', 'receivable', 'payable'):
+ sql_query = """
+ SELECT
+ CASE
+ WHEN aml.partner_id IS NOT NULL
+ THEN (SELECT name FROM res_partner WHERE aml.partner_id = id)
+ ELSE 'UNKNOWN'
+ END AS partner_name,
+ CASE
+ WHEN aml.partner_id IS NOT NULL
+ THEN aml.partner_id
+ ELSE 0
+ END AS p_idx,
+ %s,
+ %s,
+ %s,
+ %s
+ FROM account_move_line AS aml
+ INNER JOIN account_account aa ON aa.id = aml.account_id
+ INNER JOIN account_move am ON am.id = aml.move_id
+ %s
+ GROUP BY p_idx, partner_name
+ """
+
+ WHERE_POSTED = ''
+ if ctx.get('state','posted')=='posted':
+ WHERE_POSTED = "AND am.state = 'posted'"
+
+ cur_periods = ', '.join([str(i) for i in ctx['periods']])
+ init_periods = ', '.join([str(i) for i in init_period])
+
+ WHERE = """
+ WHERE aml.period_id IN (%s)
+ AND aa.id = %s
+ AND aml.state <> 'draft'
+ """ % (init_periods, account['id'])
+ query_init = sql_query%('SUM(aml.debit) AS init_dr',
+ 'SUM(aml.credit) AS init_cr',
+ '0.0 AS bal_dr',
+ '0.0 AS bal_cr',
+ WHERE+WHERE_POSTED)
+
+ WHERE = """
+ WHERE aml.period_id IN (%s)
+ AND aa.id = %s
+ AND aml.state <> 'draft'
+ """ % (cur_periods, account['id'])
+
+ query_bal = sql_query%('0.0 AS init_dr',
+ '0.0 AS init_cr',
+ 'SUM(aml.debit) AS bal_dr',
+ 'SUM(aml.credit) AS bal_cr',
+ WHERE+WHERE_POSTED)
+
+ query = '''
+ SELECT
+ partner_name,
+ p_idx,
+ SUM(init_dr)-SUM(init_cr) AS balanceinit,
+ SUM(bal_dr) AS debit,
+ SUM(bal_cr) AS credit,
+ SUM(init_dr) - SUM(init_cr) + SUM(bal_dr) - SUM(bal_cr) AS balance
+ FROM (
+ SELECT
+ *
+ FROM (%s) vinit
+ UNION ALL (%s)
+ ) v
+ GROUP BY p_idx, partner_name
+ ORDER BY partner_name
+ '''%(query_init,query_bal)
+
+ self.cr.execute(query)
+ res_dict = self.cr.dictfetchall()
+ unknown = False
+ for det in res_dict:
+ i,d,c,b = det['balanceinit'], det['debit'], det['credit'], det['balance'],
+ if not any([i,d,c,b]):
+ continue
+ data = {
+ 'partner_name': det['partner_name'],
+ 'balanceinit': i,
+ 'debit': d,
+ 'credit': c,
+ 'balance': b,
+ }
+ if not det['p_idx']:
+ unknown = data
+ continue
+ res.append(data)
+ unknown and res.append(unknown)
+ return res
+
def _get_analytic_ledger(self, account, ctx={}):
res = []
@@ -828,6 +924,8 @@
res['mayor'] = self._get_analytic_ledger(res, ctx=ctx_end)
elif to_include and form['journal_ledger'] and form['columns'] == 'four' and form['inf_type'] == 'BS' and res['type'] in ('other', 'liquidity', 'receivable', 'payable'):
res['journal'] = self._get_journal_ledger(res, ctx=ctx_end)
+ elif to_include and form['partner_balance'] and form['columns'] == 'four' and form['inf_type'] == 'BS' and res['type'] in ('other', 'liquidity', 'receivable', 'payable'):
+ res['partner'] = self._get_partner_balance(res, ctx_i['periods'], ctx=ctx_end)
else:
res['mayor'] = []
@@ -938,6 +1036,12 @@
parser=account_balance,
header=False)
+report_sxw.report_sxw('report.afr.partner.balance',
+ 'wizard.report',
+ 'account_financial_report/report/balance_full_4_cols_partner_balance.rml',
+ parser=account_balance,
+ header=False)
+
report_sxw.report_sxw('report.afr.journal.ledger',
'wizard.report',
'account_financial_report/report/balance_full_4_cols_journal_ledger.rml',
=== modified file 'account_financial_report/view/report.xml'
--- account_financial_report/view/report.xml 2013-07-26 16:57:50 +0000
+++ account_financial_report/view/report.xml 2013-11-26 18:12:27 +0000
@@ -48,6 +48,17 @@
<report
auto="False"
+ id="partner_balance_report"
+ menu="True"
+ model="wizard.report"
+ name="afr.partner.balance"
+ rml="account_financial_report/report/balance_full_4_cols_partner_balance.rml"
+ string="Partner Balance"
+ header="False"
+ />
+
+ <report
+ auto="False"
id="journal_ledger_report"
menu="True"
model="wizard.report"
=== modified file 'account_financial_report/view/wizard.xml'
--- account_financial_report/view/wizard.xml 2013-07-28 00:18:28 +0000
+++ account_financial_report/view/wizard.xml 2013-11-26 18:12:27 +0000
@@ -44,6 +44,9 @@
<field name="journal_ledger"
attrs="{'readonly':['|',('columns','!=','four'),('inf_type','!=','BS')],}"
/>
+ <field name="partner_balance"
+ attrs="{'readonly':['|',('columns','!=','four'),('inf_type','!=','BS')],}"
+ />
</group>
</group>
<group>
=== modified file 'account_financial_report/wizard/wizard.py'
--- account_financial_report/wizard/wizard.py 2013-07-26 17:03:11 +0000
+++ account_financial_report/wizard/wizard.py 2013-11-26 18:12:27 +0000
@@ -51,7 +51,9 @@
'analytic_ledger': fields.boolean('Analytic Ledger', help="Allows to Generate an Analytic Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"),
'journal_ledger': fields.boolean('Journal Ledger', help="Allows to Generate an Journal Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"),
-
+ 'partner_balance': fields.boolean('Partner Balance', help="""Allows to
+ Generate a Partner Balance for accounts with moves. Available when
+ Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"""),
'tot_check': fields.boolean('Summarize?', help='Checking will add a new line at the end of the Report which will Summarize Columns in Report'),
'lab_str': fields.char('Description', help='Description for the Summary', size=128),
@@ -276,6 +278,8 @@
name = 'afr.analytic.ledger'
elif data['form']['journal_ledger'] and data['form']['inf_type'] == 'BS':
name = 'afr.journal.ledger'
+ elif data['form']['partner_balance'] and data['form']['inf_type'] == 'BS':
+ name = 'afr.partner.balance'
else:
name = 'afr.4cols'
if data['form']['columns'] == 'five':
Follow ups