[DEL] remove account_financial_report_webkit from the 9.0 branch
superseded by account_financial_report_qwebpull/230/head
parent
13d43100ee
commit
eb650d671e
|
@ -1,23 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Nicolas Bessi. Copyright Camptocamp SA
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from . import account
|
||||
from . import wizard
|
||||
from . import report
|
||||
from . import account_move_line
|
|
@ -1,207 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Authors: Nicolas Bessi, Guewen Baconnier
|
||||
# Copyright Camptocamp SA 2011
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
{
|
||||
'name': 'Financial Reports - Webkit',
|
||||
'description': """
|
||||
Financial Reports - Webkit
|
||||
==========================
|
||||
|
||||
This module adds or replaces the following standard OpenERP financial reports:
|
||||
- General ledger
|
||||
- Trial Balance (simple or comparative view)
|
||||
- Partner ledger
|
||||
- Partner balance
|
||||
- Open invoices report
|
||||
- Aged Partner Balance
|
||||
|
||||
Main improvements per report:
|
||||
-----------------------------
|
||||
|
||||
The General ledger: details of all entries posted in your books sorted by
|
||||
account.
|
||||
|
||||
* Filter by account is available in the wizard (no need to go to the
|
||||
Chart of Accounts to do this anymore) or by View account (the report
|
||||
will display all regular children accounts) i.e. you can select all
|
||||
P&L accounts.
|
||||
* The report only prints accounts with moves OR with a non
|
||||
null balance. No more endless report with empty accounts (field:
|
||||
display account is hidden)
|
||||
* initial balance computation on the fly if no open entry posted
|
||||
* Thanks to a new checkbox in the account form, you will have the
|
||||
possibility to centralize any account you like. This means you do
|
||||
not want to see all entries posted under the account ‘VAT on sales’;
|
||||
you will only see aggregated amounts by periods.
|
||||
* Counterpart account is displayed for each transaction (3 accounts max.)
|
||||
to ease searching.
|
||||
* Better ergonomy on the wizard: important information is displayed in
|
||||
the top part, filters are in the middle, and options are in the
|
||||
bottom or on a separate tab. There is more specific filtering on
|
||||
separate tabs. No more unique wizard layout for all financial
|
||||
reports (we have removed the journal tab for the GL report)
|
||||
* improved report style
|
||||
|
||||
The partner ledger: details of entries relative to payable &
|
||||
receivable accounts posted in your books sorted by account and
|
||||
partner.
|
||||
|
||||
* Filter by partner now available
|
||||
* Now you can see Accounts then Partner with subtotals for each
|
||||
account allowing you to check you data with trial balance and
|
||||
partner balance for instance. Accounts are ordered in the same way as
|
||||
in the Chart of account
|
||||
* Period have been added (date only is not filled in since date can be
|
||||
outside period)
|
||||
* Reconciliation code added
|
||||
* Subtotal by account
|
||||
* Alphabetical sorting (same as in partner balance)
|
||||
|
||||
Open invoice report : other version of the partner ledger showing
|
||||
unreconciled / partially reconciled entries.
|
||||
|
||||
* Possibility to print unreconciled transactions only at any date in
|
||||
the past (thanks to the new field: `last_rec_date` which computes
|
||||
the last move line reconciliation date). No more pain to get open
|
||||
invoices at the last closing date.
|
||||
* no initial balance computed because the report shows open invoices
|
||||
from previous years.
|
||||
|
||||
The Trial balance: list of accounts with balances
|
||||
|
||||
* You can either see the columns: initial balance, debit, credit,
|
||||
end balance or compare balances over 4 periods of your choice
|
||||
* You can select the "opening" filter to get the opening trial balance
|
||||
only
|
||||
* If you create an extra virtual chart (using consolidated account) of
|
||||
accounts for your P&L and your balance sheet, you can print your
|
||||
statutory accounts (with comparison over years for instance)
|
||||
* If you compare 2 periods, you will get the differences in values and
|
||||
in percent
|
||||
|
||||
The Partner balance: list of account with balances
|
||||
|
||||
* Subtotal by account and partner
|
||||
* Alphabetical sorting (same as in partner balance)
|
||||
|
||||
|
||||
Aged Partner Balance: Summary of aged open amount per partner
|
||||
|
||||
This report is an accounting tool helping in various tasks.
|
||||
You can credit control or partner balance provisions computation for instance.
|
||||
|
||||
The aged balance report allows you to print balances per partner
|
||||
like the trial balance but add an extra information :
|
||||
|
||||
* It will split balances into due amounts
|
||||
(due date not reached à the end date of the report) and overdue amounts
|
||||
Overdue data are also split by period.
|
||||
* For each partner following columns will be displayed:
|
||||
|
||||
* Total balance (all figures must match with same date partner balance
|
||||
report).
|
||||
This column equals the sum of all following columns)
|
||||
|
||||
* Due
|
||||
* Overdue <= 30 days
|
||||
* Overdue <= 60 days
|
||||
* Overdue <= 90 days
|
||||
* Overdue <= 120 days
|
||||
* Older
|
||||
|
||||
Hypothesis / Contraints of aged partner balance
|
||||
|
||||
* Overdues columns will be by default be based on 30 days range fix number of
|
||||
days. This can be changed by changes the RANGES constraint
|
||||
* All data will be displayed in company currency
|
||||
* When partial payments, the payment must appear in the same colums than the
|
||||
invoice (Except if multiple payment terms)
|
||||
* Data granularity: partner (will not display figures at invoices level)
|
||||
* The report aggregate data per account with sub-totals
|
||||
* Initial balance must be calculated the same way that
|
||||
the partner balance / Ignoring the opening entry
|
||||
in special period (idem open invoice report)
|
||||
* Only accounts with internal type payable or receivable are considered
|
||||
(idem open invoice report)
|
||||
* If maturity date is null then use move line date
|
||||
|
||||
|
||||
Limitations:
|
||||
------------
|
||||
|
||||
In order to run properly this module makes sure you have installed the
|
||||
library `wkhtmltopdf` for the pdf rendering (the library path must be
|
||||
set in a System Parameter `webkit_path`).
|
||||
|
||||
Initial balances in these reports are based either on opening entry
|
||||
posted in the opening period or computed on the fly. So make sure
|
||||
that your past accounting opening entries are in an opening period.
|
||||
Initials balances are not computed when using the Date filter (since a
|
||||
date can be outside its logical period and the initial balance could
|
||||
be different when computed by data or by initial balance for the
|
||||
period). The opening period is assumed to be the Jan. 1st of the year
|
||||
with an opening flag and the first period of the year must start also
|
||||
on Jan 1st.
|
||||
|
||||
Totals for amounts in currencies are effective if the partner belongs to
|
||||
an account with a secondary currency.
|
||||
|
||||
HTML headers and footers are deactivated for these reports because of
|
||||
an issue in wkhtmltopdf
|
||||
(http://code.google.com/p/wkhtmltopdf/issues/detail?id=656) Instead,
|
||||
the header and footer are created as text with arguments passed to
|
||||
wkhtmltopdf. The texts are defined inside the report classes.
|
||||
""",
|
||||
'version': '8.0.1.1.0',
|
||||
'author': "Camptocamp,Odoo Community Association (OCA)",
|
||||
'license': 'AGPL-3',
|
||||
'category': 'Finance',
|
||||
'website': 'http://www.camptocamp.com',
|
||||
'images': [
|
||||
'images/ledger.png', ],
|
||||
'depends': ['account',
|
||||
'report_webkit'],
|
||||
'demo': [],
|
||||
'data': ['account_view.xml',
|
||||
'data/financial_webkit_header.xml',
|
||||
'report/report.xml',
|
||||
'wizard/wizard.xml',
|
||||
'wizard/balance_common_view.xml',
|
||||
'wizard/general_ledger_wizard_view.xml',
|
||||
'wizard/partners_ledger_wizard_view.xml',
|
||||
'wizard/trial_balance_wizard_view.xml',
|
||||
'wizard/partner_balance_wizard_view.xml',
|
||||
'wizard/open_invoices_wizard_view.xml',
|
||||
'wizard/aged_partner_balance_wizard.xml',
|
||||
'wizard/print_journal_view.xml',
|
||||
'report_menus.xml',
|
||||
],
|
||||
# tests order matter
|
||||
'test': ['tests/general_ledger.yml',
|
||||
'tests/partner_ledger.yml',
|
||||
'tests/trial_balance.yml',
|
||||
'tests/partner_balance.yml',
|
||||
'tests/open_invoices.yml',
|
||||
'tests/aged_trial_balance.yml'],
|
||||
# 'tests/account_move_line.yml'
|
||||
'active': False,
|
||||
'installable': False,
|
||||
'application': True,
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)
|
||||
#
|
||||
# Author: Guewen Baconnier (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.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import fields, orm
|
||||
|
||||
|
||||
class AccountAccount(orm.Model):
|
||||
_inherit = 'account.account'
|
||||
|
||||
_columns = {
|
||||
'centralized': fields.boolean(
|
||||
'Centralized',
|
||||
help="If flagged, no details will be displayed in "
|
||||
"the General Ledger report (the webkit one only), "
|
||||
"only centralized amounts per period."),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'centralized': False,
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Nicolas Bessi.
|
||||
# Copyright Camptocamp SA 2011
|
||||
#
|
||||
# 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 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import fields, orm
|
||||
|
||||
|
||||
class AccountMoveLine(orm.Model):
|
||||
|
||||
"""Overriding Account move line in order to add last_rec_date.
|
||||
Last rec date is the date of the last reconciliation (full or partial)
|
||||
account move line"""
|
||||
_inherit = 'account.move.line'
|
||||
|
||||
def _get_move_line_from_line_rec(self, cr, uid, ids, context=None):
|
||||
moves = []
|
||||
for reconcile in self.pool['account.move.reconcile'].browse(
|
||||
cr, uid, ids, context=context):
|
||||
for move_line in reconcile.line_partial_ids:
|
||||
moves.append(move_line.id)
|
||||
for move_line in reconcile.line_id:
|
||||
moves.append(move_line.id)
|
||||
return list(set(moves))
|
||||
|
||||
def _get_last_rec_date(self, cursor, uid, ids, name, args, context=None):
|
||||
if not isinstance(ids, list):
|
||||
ids = [ids]
|
||||
res = {}
|
||||
for line in self.browse(cursor, uid, ids, context):
|
||||
res[line.id] = {'last_rec_date': False}
|
||||
rec = line.reconcile_id or line.reconcile_partial_id or False
|
||||
if rec:
|
||||
# we use cursor in order to gain some perfs.
|
||||
# also, important point: LIMIT 1 is not used due to
|
||||
# performance issues when in conjonction with "OR"
|
||||
# (one backwards index scan instead of 2 scans and a sort)
|
||||
cursor.execute('SELECT date from account_move_line'
|
||||
' WHERE reconcile_id = %s'
|
||||
' OR reconcile_partial_id = %s'
|
||||
' ORDER BY date DESC',
|
||||
(rec.id, rec.id))
|
||||
res_set = cursor.fetchone()
|
||||
if res_set:
|
||||
res[line.id] = {'last_rec_date': res_set[0]}
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'last_rec_date': fields.function(
|
||||
_get_last_rec_date,
|
||||
method=True,
|
||||
string='Last reconciliation date',
|
||||
store={'account.move.line': (lambda self, cr, uid, ids, c={}: ids,
|
||||
['date'], 20),
|
||||
'account.move.reconcile': (_get_move_line_from_line_rec,
|
||||
None, 20)},
|
||||
type='date',
|
||||
multi='all',
|
||||
help="the date of the last reconciliation (full or partial) \
|
||||
account move line"),
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_account_form_webkit" model="ir.ui.view">
|
||||
<field name="name">account.account.form.webkit</field>
|
||||
<field name="model">account.account</field>
|
||||
<field name="inherit_id" ref="account.view_account_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<field name="active" position="after">
|
||||
<field name="centralized" groups="account.group_account_manager"/>
|
||||
</field>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,409 +0,0 @@
|
|||
<?xml version="1.0" ?>
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
<record id="financial_landscape_header" model="ir.header_webkit">
|
||||
<field name="footer_html"><![CDATA[
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
|
||||
<script>
|
||||
function subst() {
|
||||
var vars={};
|
||||
var x=document.location.search.substring(1).split('&');
|
||||
for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
|
||||
var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
|
||||
for(var i in x) {
|
||||
var y = document.getElementsByClassName(x[i]);
|
||||
for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<% import datetime %>
|
||||
<body style="border:0; margin: 0;" onload="subst()">
|
||||
<table style="border-top: 1px solid black; width: 1080px">
|
||||
<tr style="border-collapse:collapse;">
|
||||
<td style="text-align:left;font-size:10;width:350px;">${formatLang( str(datetime.datetime.today()), date_time=True)}</td>
|
||||
<td style="text-align:center;font-size:10;width:350px;">${user.name}</td>
|
||||
<td style="text-align:right;font-size:10;width:350px;">Page <span class="page"/></td>
|
||||
<td style="text-align:left;font-size:10;width:30px"> of <span class="topage"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>]]></field>
|
||||
<field name="orientation">Landscape</field>
|
||||
<field name="format">A4</field>
|
||||
<field name="html"><![CDATA[
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
|
||||
<script>
|
||||
function subst() {
|
||||
var vars={};
|
||||
var x=document.location.search.substring(1).split('&');
|
||||
for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
|
||||
var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
|
||||
for(var i in x) {
|
||||
var y = document.getElementsByClassName(x[i]);
|
||||
for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style type="text/css">
|
||||
${css}
|
||||
</style>
|
||||
</head>
|
||||
<body style="border:0; margin: 0;" onload="subst()">
|
||||
<table class="header" style="border-bottom: 0px solid black; width: 100%">
|
||||
<tr>
|
||||
<td style="text-align:left; font-size:11px; font-weight: bold;"><span style="text-transform:uppercase; font-size:12px;">${report_name}</span> - ${company.partner_id.name | entity} - ${company.currency_id.name | entity}</td>
|
||||
</tr>
|
||||
</table> ${_debug or ''|n} </body>
|
||||
</html>]]>
|
||||
</field>
|
||||
<field eval="0.0" name="margin_top"/>
|
||||
<field name="css"><![CDATA[
|
||||
|
||||
body, table, td, span, div {
|
||||
font-family: Helvetica, Arial;
|
||||
}
|
||||
|
||||
.act_as_table {
|
||||
display: table;
|
||||
}
|
||||
.act_as_row {
|
||||
display: table-row;
|
||||
}
|
||||
.act_as_cell {
|
||||
display: table-cell;
|
||||
}
|
||||
.act_as_thead {
|
||||
display: table-header-group;
|
||||
}
|
||||
.act_as_tbody {
|
||||
display: table-row-group;
|
||||
}
|
||||
.act_as_tfoot {
|
||||
display: table-footer-group;
|
||||
}
|
||||
.act_as_caption {
|
||||
display: table-caption;
|
||||
}
|
||||
act_as_colgroup {
|
||||
display: table-column-group;
|
||||
}
|
||||
|
||||
.list_table, .data_table {
|
||||
width: 1080px;
|
||||
table-layout: fixed
|
||||
}
|
||||
|
||||
.bg, .act_as_row.labels {
|
||||
background-color:#F0F0F0;
|
||||
}
|
||||
|
||||
.list_table, .data_table, .list_table .act_as_row {
|
||||
border-left:0px;
|
||||
border-right:0px;
|
||||
text-align:left;
|
||||
font-size:9px;
|
||||
padding-right:3px;
|
||||
padding-left:3px;
|
||||
padding-top:2px;
|
||||
padding-bottom:2px;
|
||||
border-collapse:collapse;
|
||||
}
|
||||
|
||||
.list_table .act_as_row.labels, .list_table .act_as_row.initial_balance, .list_table .act_as_row.lines {
|
||||
border-color:gray;
|
||||
border-bottom:1px solid lightGrey;
|
||||
}
|
||||
|
||||
.data_table .act_as_cell {
|
||||
border: 1px solid lightGrey;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.data_table .act_as_cell, .list_table .act_as_cell {
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.data_table .act_as_row.labels {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.initial_balance .act_as_cell {
|
||||
font-style:italic;
|
||||
}
|
||||
|
||||
.account_title {
|
||||
font-size:10px;
|
||||
font-weight:bold;
|
||||
page-break-after: avoid;
|
||||
}
|
||||
|
||||
.act_as_cell.amount {
|
||||
word-wrap:normal;
|
||||
text-align:right;
|
||||
}
|
||||
|
||||
.list_table .act_as_cell{
|
||||
padding-left: 5px;
|
||||
/* border-right:1px solid lightGrey; uncomment to active column lines */
|
||||
}
|
||||
.list_table .act_as_cell.first_column {
|
||||
padding-left: 0px;
|
||||
/* border-left:1px solid lightGrey; uncomment to active column lines */
|
||||
}
|
||||
|
||||
.sep_left {
|
||||
border-left: 1px solid lightGrey;
|
||||
}
|
||||
|
||||
.overflow_ellipsis {
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.open_invoice_previous_line {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.clearance_line {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
]]>
|
||||
</field>
|
||||
<field name="name">Financial Landscape Header</field>
|
||||
</record>
|
||||
|
||||
<record id="financial_portrait_header" model="ir.header_webkit">
|
||||
<field name="footer_html"><![CDATA[
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
|
||||
<script>
|
||||
function subst() {
|
||||
var vars={};
|
||||
var x=document.location.search.substring(1).split('&');
|
||||
for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
|
||||
var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
|
||||
for(var i in x) {
|
||||
var y = document.getElementsByClassName(x[i]);
|
||||
for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<% import datetime %>
|
||||
<body style="border:0; margin: 0;" onload="subst()">
|
||||
<table style="border-top: 1px solid black; width: 1080px">
|
||||
<tr style="border-collapse:collapse;">
|
||||
<td style="text-align:left;font-size:10;width:350px;">${formatLang( str(datetime.datetime.today()), date_time=True)}</td>
|
||||
<td style="text-align:center;font-size:10;width:350px;">${user.name}</td>
|
||||
<td style="text-align:right;font-size:10;width:350px;">Page <span class="page"/></td>
|
||||
<td style="text-align:left;font-size:10;width:30px"> of <span class="topage"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>]]></field>
|
||||
<field name="orientation">Portrait</field>
|
||||
<field name="format">A4</field>
|
||||
<field name="html"><![CDATA[
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
|
||||
<script>
|
||||
function subst() {
|
||||
var vars={};
|
||||
var x=document.location.search.substring(1).split('&');
|
||||
for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
|
||||
var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
|
||||
for(var i in x) {
|
||||
var y = document.getElementsByClassName(x[i]);
|
||||
for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style type="text/css">
|
||||
${css}
|
||||
</style>
|
||||
</head>
|
||||
<body style="border:0; margin: 0;" onload="subst()">
|
||||
<table class="header" style="border-bottom: 0px solid black; width: 100%">
|
||||
<tr>
|
||||
<td style="text-align:left; font-size:11px; font-weight: bold;"><span style="text-transform:uppercase; font-size:12px;">${report_name}</span> - ${company.partner_id.name | entity} - ${company.currency_id.name | entity}</td>
|
||||
</tr>
|
||||
</table> ${_debug or ''|n} </body>
|
||||
</html>]]>
|
||||
</field>
|
||||
<field eval="17.0" name="margin_top"/>
|
||||
<field eval="15.0" name="margin_bottom"/>
|
||||
<field name="css"><![CDATA[
|
||||
|
||||
body, table, td, span, div {
|
||||
font-family: Helvetica, Arial;
|
||||
}
|
||||
|
||||
.act_as_table {
|
||||
display: table;
|
||||
}
|
||||
.act_as_row {
|
||||
display: table-row;
|
||||
}
|
||||
.act_as_cell {
|
||||
display: table-cell;
|
||||
}
|
||||
.act_as_thead {
|
||||
display: table-header-group;
|
||||
}
|
||||
.act_as_tbody {
|
||||
display: table-row-group;
|
||||
}
|
||||
.act_as_tfoot {
|
||||
display: table-footer-group;
|
||||
}
|
||||
.act_as_caption {
|
||||
display: table-caption;
|
||||
}
|
||||
act_as_colgroup {
|
||||
display: table-column-group;
|
||||
}
|
||||
|
||||
.list_table, .data_table {
|
||||
width: 690px;
|
||||
table-layout: fixed
|
||||
}
|
||||
|
||||
.bg, .act_as_row.labels {
|
||||
background-color:#F0F0F0;
|
||||
}
|
||||
|
||||
.list_table, .data_table, .list_table .act_as_row {
|
||||
border-left:0px;
|
||||
border-right:0px;
|
||||
text-align:left;
|
||||
font-size:9px;
|
||||
padding-right:3px;
|
||||
padding-left:3px;
|
||||
padding-top:2px;
|
||||
padding-bottom:2px;
|
||||
border-collapse:collapse;
|
||||
}
|
||||
|
||||
.list_table .act_as_row.labels, .list_table .act_as_row.initial_balance, .list_table .act_as_row.lines {
|
||||
border-color:gray;
|
||||
border-bottom:1px solid lightGrey;
|
||||
}
|
||||
|
||||
.data_table .act_as_cell {
|
||||
border: 1px solid lightGrey;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.data_table .act_as_cell, .list_table .act_as_cell {
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.data_table .act_as_row.labels {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.initial_balance .act_as_cell {
|
||||
font-style:italic;
|
||||
}
|
||||
|
||||
.account_title {
|
||||
font-size:10px;
|
||||
font-weight:bold;
|
||||
page-break-after: avoid;
|
||||
}
|
||||
|
||||
.act_as_cell.amount {
|
||||
word-wrap:normal;
|
||||
text-align:right;
|
||||
}
|
||||
|
||||
.list_table .act_as_cell{
|
||||
padding-left: 5px;
|
||||
/* border-right:1px solid lightGrey; uncomment to active column lines */
|
||||
}
|
||||
.list_table .act_as_cell.first_column {
|
||||
padding-left: 0px;
|
||||
/* border-left:1px solid lightGrey; uncomment to active column lines */
|
||||
}
|
||||
|
||||
.sep_left {
|
||||
border-left: 1px solid lightGrey;
|
||||
}
|
||||
|
||||
.account_level_1 {
|
||||
text-transform: uppercase;
|
||||
/*font-weight: bold;*/
|
||||
font-size: 15px;
|
||||
background-color:#F0F0F0;
|
||||
}
|
||||
|
||||
/*
|
||||
.account_level_1 .act_as_cell {
|
||||
height: 30px;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
*/
|
||||
|
||||
.account_level_2 {
|
||||
/*text-transform: uppercase;
|
||||
font-weight: bold;*/
|
||||
font-size: 12px;
|
||||
background-color:#F0F0F0;
|
||||
}
|
||||
|
||||
/*
|
||||
.account_level_2 .act_as_cell {
|
||||
height: 20px;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
.account_level_3 {
|
||||
text-transform: uppercase;
|
||||
font-weight: bold;
|
||||
font-size: 11px;
|
||||
background-color:#FAFAFA;
|
||||
}
|
||||
|
||||
.account_level_4 {
|
||||
font-weight: bold;
|
||||
font-size: 11px;
|
||||
}
|
||||
*/
|
||||
|
||||
.account_level_5 {
|
||||
|
||||
}
|
||||
|
||||
.regular_account_type {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.view_account_type {
|
||||
font-weight: bold;
|
||||
|
||||
.account_level_consol {
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.overflow_ellipsis {
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
]]>
|
||||
</field>
|
||||
<field name="name">Financial Portrait Header</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 54 KiB |
|
@ -1,41 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Nicolas Bessi.
|
||||
# Copyright Camptocamp SA 2011
|
||||
#
|
||||
# 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 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
if not version:
|
||||
# only run at first install
|
||||
cr.execute("UPDATE account_move_line as acm "
|
||||
" SET last_rec_date ="
|
||||
" (SELECT date from account_move_line"
|
||||
" WHERE reconcile_id = acm.reconcile_id"
|
||||
" AND reconcile_id IS NOT NULL"
|
||||
" ORDER BY date DESC LIMIT 1)"
|
||||
" WHERE last_rec_date is null;")
|
||||
|
||||
cr.execute("UPDATE account_move_line as acm "
|
||||
" SET last_rec_date ="
|
||||
" (SELECT date from account_move_line"
|
||||
" WHERE reconcile_partial_id"
|
||||
" = acm.reconcile_partial_id"
|
||||
" AND reconcile_partial_id IS NOT NULL"
|
||||
" ORDER BY date DESC LIMIT 1)"
|
||||
" WHERE last_rec_date is null;")
|
|
@ -1,12 +0,0 @@
|
|||
from . import common_reports
|
||||
from . import common_partner_reports
|
||||
from . import common_balance_reports
|
||||
from . import common_partner_balance_reports
|
||||
from . import general_ledger
|
||||
from . import partners_ledger
|
||||
from . import webkit_parser_header_fix
|
||||
from . import trial_balance
|
||||
from . import partner_balance
|
||||
from . import open_invoices
|
||||
from . import print_journal
|
||||
from . import aged_partner_balance
|
|
@ -1,429 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Nicolas Bessi
|
||||
# Copyright 2014 Camptocamp SA
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from __future__ import division
|
||||
from datetime import datetime
|
||||
|
||||
from openerp import pooler
|
||||
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||
from openerp.tools.translate import _
|
||||
from .open_invoices import PartnersOpenInvoicesWebkit
|
||||
from .webkit_parser_header_fix import HeaderFooterTextWebKitParser
|
||||
|
||||
|
||||
def make_ranges(top, offset):
|
||||
"""Return sorted days ranges
|
||||
|
||||
:param top: maximum overdue day
|
||||
:param offset: offset for ranges
|
||||
|
||||
:returns: list of sorted ranges tuples in days
|
||||
eg. [(-100000, 0), (0, offset),
|
||||
(offset, n*offset), ... (top, 100000)]
|
||||
"""
|
||||
ranges = [(n, min(n + offset, top)) for n in xrange(0, top, offset)]
|
||||
ranges.insert(0, (-100000000000, 0))
|
||||
ranges.append((top, 100000000000))
|
||||
return ranges
|
||||
|
||||
# list of overdue ranges
|
||||
RANGES = make_ranges(120, 30)
|
||||
|
||||
|
||||
def make_ranges_titles():
|
||||
"""Generates title to be used by mako"""
|
||||
titles = [_('Due')]
|
||||
titles += [_(u'Overdue ≤ %s d.') % x[1] for x in RANGES[1:-1]]
|
||||
titles.append(_('Older'))
|
||||
return titles
|
||||
|
||||
# list of overdue ranges title
|
||||
RANGES_TITLES = make_ranges_titles()
|
||||
# list of payable journal types
|
||||
REC_PAY_TYPE = ('purchase', 'sale')
|
||||
# list of refund payable type
|
||||
REFUND_TYPE = ('purchase_refund', 'sale_refund')
|
||||
INV_TYPE = REC_PAY_TYPE + REFUND_TYPE
|
||||
|
||||
|
||||
class AccountAgedTrialBalanceWebkit(PartnersOpenInvoicesWebkit):
|
||||
|
||||
"""Compute Aged Partner Balance based on result of Open Invoices"""
|
||||
|
||||
def __init__(self, cursor, uid, name, context=None):
|
||||
"""Constructor,
|
||||
refer to :class:`openerp.report.report_sxw.rml_parse`"""
|
||||
super(AccountAgedTrialBalanceWebkit, self).__init__(cursor, uid, name,
|
||||
context=context)
|
||||
self.pool = pooler.get_pool(self.cr.dbname)
|
||||
self.cursor = self.cr
|
||||
company = self.pool.get('res.users').browse(self.cr, uid, uid,
|
||||
context=context).company_id
|
||||
|
||||
header_report_name = ' - '.join((_('Aged Partner Balance'),
|
||||
company.currency_id.name))
|
||||
|
||||
footer_date_time = self.formatLang(str(datetime.today()),
|
||||
date_time=True)
|
||||
|
||||
self.localcontext.update({
|
||||
'cr': cursor,
|
||||
'uid': uid,
|
||||
'company': company,
|
||||
'ranges': self._get_ranges(),
|
||||
'ranges_titles': self._get_ranges_titles(),
|
||||
'report_name': _('Aged Partner Balance'),
|
||||
'additional_args': [
|
||||
('--header-font-name', 'Helvetica'),
|
||||
('--footer-font-name', 'Helvetica'),
|
||||
('--header-font-size', '10'),
|
||||
('--footer-font-size', '6'),
|
||||
('--header-left', header_report_name),
|
||||
('--header-spacing', '2'),
|
||||
('--footer-left', footer_date_time),
|
||||
('--footer-right',
|
||||
' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
|
||||
('--footer-line',),
|
||||
],
|
||||
})
|
||||
|
||||
def _get_ranges(self):
|
||||
""":returns: :cons:`RANGES`"""
|
||||
return RANGES
|
||||
|
||||
def _get_ranges_titles(self):
|
||||
""":returns: :cons: `RANGES_TITLES`"""
|
||||
return RANGES_TITLES
|
||||
|
||||
def set_context(self, objects, data, ids, report_type=None):
|
||||
"""Populate aged_lines, aged_balance, aged_percents attributes
|
||||
|
||||
on each account browse record that will be used by mako template
|
||||
The browse record are store in :attr:`objects`
|
||||
|
||||
The computation are based on the ledger_lines attribute set on account
|
||||
contained by :attr:`objects`
|
||||
|
||||
:attr:`objects` values were previously set by parent class
|
||||
:class: `.open_invoices.PartnersOpenInvoicesWebkit`
|
||||
|
||||
:returns: parent :class:`.open_invoices.PartnersOpenInvoicesWebkit`
|
||||
call to set_context
|
||||
|
||||
"""
|
||||
|
||||
res = super(AccountAgedTrialBalanceWebkit, self).set_context(
|
||||
objects,
|
||||
data,
|
||||
ids,
|
||||
report_type=report_type
|
||||
)
|
||||
|
||||
agged_lines_accounts = {}
|
||||
agged_totals_accounts = {}
|
||||
agged_percents_accounts = {}
|
||||
|
||||
for acc in self.objects:
|
||||
agged_lines_accounts[acc.id] = {}
|
||||
agged_totals_accounts[acc.id] = {}
|
||||
agged_percents_accounts[acc.id] = {}
|
||||
|
||||
for part_id, partner_lines in\
|
||||
self.localcontext['ledger_lines'][acc.id].items():
|
||||
|
||||
aged_lines = self.compute_aged_lines(part_id,
|
||||
partner_lines,
|
||||
data)
|
||||
if aged_lines:
|
||||
agged_lines_accounts[acc.id][part_id] = aged_lines
|
||||
agged_totals_accounts[acc.id] = totals = self.compute_totals(
|
||||
agged_lines_accounts[acc.id].values())
|
||||
agged_percents_accounts[acc.id] = self.compute_percents(totals)
|
||||
|
||||
self.localcontext.update({
|
||||
'agged_lines_accounts': agged_lines_accounts,
|
||||
'agged_totals_accounts': agged_totals_accounts,
|
||||
'agged_percents_accounts': agged_percents_accounts,
|
||||
})
|
||||
|
||||
# Free some memory
|
||||
del(self.localcontext['ledger_lines'])
|
||||
return res
|
||||
|
||||
def compute_aged_lines(self, partner_id, ledger_lines, data):
|
||||
"""Add property aged_lines to accounts browse records
|
||||
|
||||
contained in :attr:`objects` for a given partner
|
||||
|
||||
:param: partner_id: current partner
|
||||
:param ledger_lines: generated by parent
|
||||
:class:`.open_invoices.PartnersOpenInvoicesWebkit`
|
||||
|
||||
:returns: dict of computed aged lines
|
||||
eg {'balance': 1000.0,
|
||||
'aged_lines': {(90, 120): 0.0, ...}
|
||||
|
||||
"""
|
||||
lines_to_age = self.filter_lines(partner_id, ledger_lines)
|
||||
res = {}
|
||||
end_date = self._get_end_date(data)
|
||||
aged_lines = dict.fromkeys(RANGES, 0.0)
|
||||
reconcile_lookup = self.get_reconcile_count_lookup(lines_to_age)
|
||||
res['aged_lines'] = aged_lines
|
||||
for line in lines_to_age:
|
||||
compute_method = self.get_compute_method(reconcile_lookup,
|
||||
partner_id,
|
||||
line)
|
||||
delay = compute_method(line, end_date, ledger_lines)
|
||||
classification = self.classify_line(partner_id, delay)
|
||||
aged_lines[classification] += line['debit'] - line['credit']
|
||||
self.compute_balance(res, aged_lines)
|
||||
return res
|
||||
|
||||
def _get_end_date(self, data):
|
||||
"""Retrieve end date to be used to compute delay.
|
||||
|
||||
:param data: data dict send to report contains form dict
|
||||
|
||||
:returns: end date to be used to compute overdue delay
|
||||
|
||||
"""
|
||||
end_date = None
|
||||
date_to = data['form']['date_to']
|
||||
period_to_id = data['form']['period_to']
|
||||
fiscal_to_id = data['form']['fiscalyear_id']
|
||||
if date_to:
|
||||
end_date = date_to
|
||||
elif period_to_id:
|
||||
period_to = self.pool['account.period'].browse(self.cr,
|
||||
self.uid,
|
||||
period_to_id)
|
||||
end_date = period_to.date_stop
|
||||
elif fiscal_to_id:
|
||||
fiscal_to = self.pool['account.fiscalyear'].browse(self.cr,
|
||||
self.uid,
|
||||
fiscal_to_id)
|
||||
end_date = fiscal_to.date_stop
|
||||
else:
|
||||
raise ValueError('End date and end period not available')
|
||||
return end_date
|
||||
|
||||
def _compute_delay_from_key(self, key, line, end_date):
|
||||
"""Compute overdue delay delta in days for line using attribute in key
|
||||
|
||||
delta = end_date - date of key
|
||||
|
||||
:param line: current ledger line
|
||||
:param key: date key to be used to compute delta
|
||||
:param end_date: end_date computed for wizard data
|
||||
|
||||
:returns: delta in days
|
||||
"""
|
||||
from_date = datetime.strptime(line[key], DEFAULT_SERVER_DATE_FORMAT)
|
||||
end_date = datetime.strptime(end_date, DEFAULT_SERVER_DATE_FORMAT)
|
||||
delta = end_date - from_date
|
||||
return delta.days
|
||||
|
||||
def compute_delay_from_maturity(self, line, end_date, ledger_lines):
|
||||
"""Compute overdue delay delta in days for line using attribute in key
|
||||
|
||||
delta = end_date - maturity date
|
||||
|
||||
:param line: current ledger line
|
||||
:param end_date: end_date computed for wizard data
|
||||
:param ledger_lines: generated by parent
|
||||
:class:`.open_invoices.PartnersOpenInvoicesWebkit`
|
||||
|
||||
:returns: delta in days
|
||||
"""
|
||||
return self._compute_delay_from_key('date_maturity',
|
||||
line,
|
||||
end_date)
|
||||
|
||||
def compute_delay_from_date(self, line, end_date, ledger_lines):
|
||||
"""Compute overdue delay delta in days for line using attribute in key
|
||||
|
||||
delta = end_date - date
|
||||
|
||||
:param line: current ledger line
|
||||
:param end_date: end_date computed for wizard data
|
||||
:param ledger_lines: generated by parent
|
||||
:class:`.open_invoices.PartnersOpenInvoicesWebkit`
|
||||
|
||||
:returns: delta in days
|
||||
"""
|
||||
return self._compute_delay_from_key('ldate',
|
||||
line,
|
||||
end_date)
|
||||
|
||||
def compute_delay_from_partial_rec(self, line, end_date, ledger_lines):
|
||||
"""Compute overdue delay delta in days for the case where move line
|
||||
|
||||
is related to a partial reconcile with more than one reconcile line
|
||||
|
||||
:param line: current ledger line
|
||||
:param end_date: end_date computed for wizard data
|
||||
:param ledger_lines: generated by parent
|
||||
:class:`.open_invoices.PartnersOpenInvoicesWebkit`
|
||||
|
||||
:returns: delta in days
|
||||
"""
|
||||
sale_lines = [
|
||||
x for x in ledger_lines if x['jtype'] in REC_PAY_TYPE and
|
||||
line['rec_id'] == x['rec_id']
|
||||
]
|
||||
refund_lines = [
|
||||
x for x in ledger_lines if x['jtype'] in REFUND_TYPE and
|
||||
line['rec_id'] == x['rec_id']
|
||||
]
|
||||
if len(sale_lines) == 1:
|
||||
reference_line = sale_lines[0]
|
||||
elif len(refund_lines) == 1:
|
||||
reference_line = refund_lines[0]
|
||||
else:
|
||||
reference_line = line
|
||||
key = 'date_maturity' if reference_line.get(
|
||||
'date_maturity') else 'ldate'
|
||||
return self._compute_delay_from_key(key,
|
||||
reference_line,
|
||||
end_date)
|
||||
|
||||
def get_compute_method(self, reconcile_lookup, partner_id, line):
|
||||
"""Get the function that should compute the delay for a given line
|
||||
|
||||
:param reconcile_lookup: dict of reconcile group by id and count
|
||||
{rec_id: count of line related to reconcile}
|
||||
:param partner_id: current partner_id
|
||||
:param line: current ledger line generated by parent
|
||||
:class:`.open_invoices.PartnersOpenInvoicesWebkit`
|
||||
|
||||
:returns: function bounded to :class:`.AccountAgedTrialBalanceWebkit`
|
||||
|
||||
"""
|
||||
if reconcile_lookup.get(line['rec_id'], 0.0) > 1:
|
||||
return self.compute_delay_from_partial_rec
|
||||
elif line['jtype'] in INV_TYPE and line.get('date_maturity'):
|
||||
return self.compute_delay_from_maturity
|
||||
else:
|
||||
return self.compute_delay_from_date
|
||||
|
||||
def line_is_valid(self, partner_id, line):
|
||||
"""Predicate hook that allows to filter line to be treated
|
||||
|
||||
:param partner_id: current partner_id
|
||||
:param line: current ledger line generated by parent
|
||||
:class:`.open_invoices.PartnersOpenInvoicesWebkit`
|
||||
|
||||
:returns: boolean True if line is allowed
|
||||
"""
|
||||
return True
|
||||
|
||||
def filter_lines(self, partner_id, lines):
|
||||
"""Filter ledger lines that have to be treated
|
||||
|
||||
:param partner_id: current partner_id
|
||||
:param lines: ledger_lines related to current partner
|
||||
and generated by parent
|
||||
:class:`.open_invoices.PartnersOpenInvoicesWebkit`
|
||||
|
||||
:returns: list of allowed lines
|
||||
|
||||
"""
|
||||
return [x for x in lines if self.line_is_valid(partner_id, x)]
|
||||
|
||||
def classify_line(self, partner_id, overdue_days):
|
||||
"""Return the overdue range for a given delay
|
||||
|
||||
We loop from smaller range to higher
|
||||
This should be the most effective solution as generaly
|
||||
customer tend to have one or two month of delay
|
||||
|
||||
:param overdue_days: delay in days
|
||||
:param partner_id: current partner_id
|
||||
|
||||
:returns: the correct range in :const:`RANGES`
|
||||
|
||||
"""
|
||||
for drange in RANGES:
|
||||
if overdue_days <= drange[1]:
|
||||
return drange
|
||||
return drange
|
||||
|
||||
def compute_balance(self, res, aged_lines):
|
||||
"""Compute the total balance of aged line
|
||||
for given account"""
|
||||
res['balance'] = sum(aged_lines.values())
|
||||
|
||||
def compute_totals(self, aged_lines):
|
||||
"""Compute the totals for an account
|
||||
|
||||
:param aged_lines: dict of aged line taken from the
|
||||
property added to account record
|
||||
|
||||
:returns: dict of total {'balance':1000.00, (30, 60): 3000,...}
|
||||
|
||||
"""
|
||||
totals = {}
|
||||
totals['balance'] = sum(x.get('balance', 0.0) for
|
||||
x in aged_lines)
|
||||
aged_ranges = [x.get('aged_lines', {}) for x in aged_lines]
|
||||
for drange in RANGES:
|
||||
totals[drange] = sum(x.get(drange, 0.0) for x in aged_ranges)
|
||||
return totals
|
||||
|
||||
def compute_percents(self, totals):
|
||||
percents = {}
|
||||
base = totals['balance'] or 1.0
|
||||
for drange in RANGES:
|
||||
percents[drange] = (totals[drange] / base) * 100.0
|
||||
return percents
|
||||
|
||||
def get_reconcile_count_lookup(self, lines):
|
||||
"""Compute an lookup dict
|
||||
|
||||
It contains has partial reconcile id as key and the count of lines
|
||||
related to the reconcile id
|
||||
|
||||
:param: a list of ledger lines generated by parent
|
||||
:class:`.open_invoices.PartnersOpenInvoicesWebkit`
|
||||
|
||||
:retuns: lookup dict {ṛec_id: count}
|
||||
|
||||
"""
|
||||
# possible bang if l_ids is really long.
|
||||
# We have the same weakness in common_report ...
|
||||
# but it seems not really possible for a partner
|
||||
# So I'll keep that option.
|
||||
l_ids = tuple(x['id'] for x in lines)
|
||||
sql = ("SELECT reconcile_partial_id, COUNT(*) FROM account_move_line"
|
||||
" WHERE reconcile_partial_id IS NOT NULL"
|
||||
" AND id in %s"
|
||||
" GROUP BY reconcile_partial_id")
|
||||
self.cr.execute(sql, (l_ids,))
|
||||
res = self.cr.fetchall()
|
||||
return dict((x[0], x[1]) for x in res)
|
||||
|
||||
HeaderFooterTextWebKitParser(
|
||||
'report.account.account_aged_trial_balance_webkit',
|
||||
'account.account',
|
||||
'addons/account_financial_report_webkit/report/templates/\
|
||||
aged_trial_webkit.mako',
|
||||
parser=AccountAgedTrialBalanceWebkit,
|
||||
)
|
|
@ -1,355 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Guewen Baconnier
|
||||
# Copyright Camptocamp SA 2011
|
||||
# SQL inspired from OpenERP original code
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from operator import add
|
||||
|
||||
from .common_reports import CommonReportHeaderWebkit
|
||||
|
||||
|
||||
class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit):
|
||||
|
||||
"""Define common helper for balance (trial balance, P&L, BS oriented
|
||||
financial report"""
|
||||
|
||||
def _get_numbers_display(self, data):
|
||||
return self._get_form_param('numbers_display', data)
|
||||
|
||||
@staticmethod
|
||||
def find_key_by_value_in_list(dic, value):
|
||||
return [key for key, val in dic.iteritems() if value in val][0]
|
||||
|
||||
def _get_account_details(self, account_ids, target_move, fiscalyear,
|
||||
main_filter, start, stop, initial_balance_mode,
|
||||
context=None):
|
||||
"""
|
||||
Get details of accounts to display on the report
|
||||
@param account_ids: ids of accounts to get details
|
||||
@param target_move: selection filter for moves (all or posted)
|
||||
@param fiscalyear: browse of the fiscalyear
|
||||
@param main_filter: selection filter period / date or none
|
||||
@param start: start date or start period browse instance
|
||||
@param stop: stop date or stop period browse instance
|
||||
@param initial_balance_mode: False: no calculation,
|
||||
'opening_balance': from the opening period,
|
||||
'initial_balance': computed from previous year / periods
|
||||
@return: dict of list containing accounts details, keys are
|
||||
the account ids
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
account_obj = self.pool.get('account.account')
|
||||
period_obj = self.pool.get('account.period')
|
||||
use_period_ids = main_filter in (
|
||||
'filter_no', 'filter_period', 'filter_opening')
|
||||
|
||||
if use_period_ids:
|
||||
if main_filter == 'filter_opening':
|
||||
period_ids = [start.id]
|
||||
else:
|
||||
period_ids = period_obj.build_ctx_periods(
|
||||
self.cursor, self.uid, start.id, stop.id)
|
||||
# never include the opening in the debit / credit amounts
|
||||
period_ids = self.exclude_opening_periods(period_ids)
|
||||
|
||||
init_balance = False
|
||||
if initial_balance_mode == 'opening_balance':
|
||||
init_balance = self._read_opening_balance(account_ids, start)
|
||||
elif initial_balance_mode:
|
||||
init_balance = self._compute_initial_balances(
|
||||
account_ids, start, fiscalyear)
|
||||
|
||||
ctx = context.copy()
|
||||
ctx.update({'state': target_move,
|
||||
'all_fiscalyear': True})
|
||||
|
||||
if use_period_ids:
|
||||
ctx.update({'periods': period_ids})
|
||||
elif main_filter == 'filter_date':
|
||||
ctx.update({'date_from': start,
|
||||
'date_to': stop})
|
||||
|
||||
accounts = account_obj.read(
|
||||
self.cursor,
|
||||
self.uid,
|
||||
account_ids,
|
||||
['type', 'code', 'name', 'debit', 'credit',
|
||||
'balance', 'parent_id', 'level', 'child_id'],
|
||||
context=ctx)
|
||||
|
||||
accounts_by_id = {}
|
||||
for account in accounts:
|
||||
if init_balance:
|
||||
# sum for top level views accounts
|
||||
child_ids = account_obj._get_children_and_consol(
|
||||
self.cursor, self.uid, account['id'], ctx)
|
||||
if child_ids:
|
||||
child_init_balances = [
|
||||
init_bal['init_balance']
|
||||
for acnt_id, init_bal in init_balance.iteritems()
|
||||
if acnt_id in child_ids]
|
||||
top_init_balance = reduce(add, child_init_balances)
|
||||
account['init_balance'] = top_init_balance
|
||||
else:
|
||||
account.update(init_balance[account['id']])
|
||||
account['balance'] = account['init_balance'] + \
|
||||
account['debit'] - account['credit']
|
||||
accounts_by_id[account['id']] = account
|
||||
return accounts_by_id
|
||||
|
||||
def _get_comparison_details(self, data, account_ids, target_move,
|
||||
comparison_filter, index):
|
||||
"""
|
||||
|
||||
@param data: data of the wizard form
|
||||
@param account_ids: ids of the accounts to get details
|
||||
@param comparison_filter: selected filter on the form for
|
||||
the comparison (filter_no, filter_year, filter_period,
|
||||
filter_date)
|
||||
@param index: index of the fields to get
|
||||
(ie. comp1_fiscalyear_id where 1 is the index)
|
||||
@return: dict of account details (key = account id)
|
||||
"""
|
||||
fiscalyear = self._get_info(
|
||||
data, "comp%s_fiscalyear_id" % (index,), 'account.fiscalyear')
|
||||
start_period = self._get_info(
|
||||
data, "comp%s_period_from" % (index,), 'account.period')
|
||||
stop_period = self._get_info(
|
||||
data, "comp%s_period_to" % (index,), 'account.period')
|
||||
start_date = self._get_form_param("comp%s_date_from" % (index,), data)
|
||||
stop_date = self._get_form_param("comp%s_date_to" % (index,), data)
|
||||
init_balance = self.is_initial_balance_enabled(comparison_filter)
|
||||
|
||||
accounts_by_ids = {}
|
||||
comp_params = {}
|
||||
details_filter = comparison_filter
|
||||
if comparison_filter != 'filter_no':
|
||||
start_period, stop_period, start, stop = \
|
||||
self._get_start_stop_for_filter(
|
||||
comparison_filter, fiscalyear, start_date, stop_date,
|
||||
start_period, stop_period)
|
||||
if comparison_filter == 'filter_year':
|
||||
details_filter = 'filter_no'
|
||||
|
||||
initial_balance_mode = init_balance \
|
||||
and self._get_initial_balance_mode(start) or False
|
||||
accounts_by_ids = self._get_account_details(
|
||||
account_ids, target_move, fiscalyear, details_filter,
|
||||
start, stop, initial_balance_mode)
|
||||
comp_params = {
|
||||
'comparison_filter': comparison_filter,
|
||||
'fiscalyear': fiscalyear,
|
||||
'start': start,
|
||||
'stop': stop,
|
||||
'initial_balance': init_balance,
|
||||
'initial_balance_mode': initial_balance_mode,
|
||||
}
|
||||
|
||||
return accounts_by_ids, comp_params
|
||||
|
||||
def _get_diff(self, balance, previous_balance):
|
||||
"""
|
||||
@param balance: current balance
|
||||
@param previous_balance: last balance
|
||||
@return: dict of form {'diff': difference,
|
||||
'percent_diff': diff in percentage}
|
||||
"""
|
||||
diff = balance - previous_balance
|
||||
|
||||
obj_precision = self.pool.get('decimal.precision')
|
||||
precision = obj_precision.precision_get(
|
||||
self.cursor, self.uid, 'Account')
|
||||
# round previous balance with account precision to avoid big numbers
|
||||
# if previous balance is 0.0000001 or a any very small number
|
||||
if round(previous_balance, precision) == 0:
|
||||
percent_diff = False
|
||||
else:
|
||||
percent_diff = round(diff / previous_balance * 100, precision)
|
||||
|
||||
return {'diff': diff, 'percent_diff': percent_diff}
|
||||
|
||||
def _comp_filters(self, data, comparison_number):
|
||||
"""
|
||||
@param data: data of the report
|
||||
@param comparison_number: number of comparisons
|
||||
@return: list of comparison filters, nb of comparisons used and
|
||||
comparison mode (no_comparison, single, multiple)
|
||||
"""
|
||||
comp_filters = []
|
||||
for index in range(comparison_number):
|
||||
comp_filters.append(
|
||||
self._get_form_param("comp%s_filter" % (index,), data,
|
||||
default='filter_no'))
|
||||
|
||||
nb_comparisons = len(
|
||||
[comp_filter for comp_filter in comp_filters
|
||||
if comp_filter != 'filter_no'])
|
||||
if not nb_comparisons:
|
||||
comparison_mode = 'no_comparison'
|
||||
elif nb_comparisons > 1:
|
||||
comparison_mode = 'multiple'
|
||||
else:
|
||||
comparison_mode = 'single'
|
||||
return comp_filters, nb_comparisons, comparison_mode
|
||||
|
||||
def _get_start_stop_for_filter(self, main_filter, fiscalyear, start_date,
|
||||
stop_date, start_period, stop_period):
|
||||
if main_filter in ('filter_no', 'filter_year'):
|
||||
start_period = self.get_first_fiscalyear_period(fiscalyear)
|
||||
stop_period = self.get_last_fiscalyear_period(fiscalyear)
|
||||
elif main_filter == 'filter_opening':
|
||||
opening_period = self._get_st_fiscalyear_period(
|
||||
fiscalyear, special=True)
|
||||
start_period = stop_period = opening_period
|
||||
if main_filter == 'filter_date':
|
||||
start = start_date
|
||||
stop = stop_date
|
||||
else:
|
||||
start = start_period
|
||||
stop = stop_period
|
||||
|
||||
return start_period, stop_period, start, stop
|
||||
|
||||
def compute_balance_data(self, data, filter_report_type=None):
|
||||
new_ids = data['form']['account_ids'] or data[
|
||||
'form']['chart_account_id']
|
||||
max_comparison = self._get_form_param(
|
||||
'max_comparison', data, default=0)
|
||||
main_filter = self._get_form_param('filter', data, default='filter_no')
|
||||
|
||||
comp_filters, nb_comparisons, comparison_mode = self._comp_filters(
|
||||
data, max_comparison)
|
||||
|
||||
fiscalyear = self.get_fiscalyear_br(data)
|
||||
|
||||
start_period = self.get_start_period_br(data)
|
||||
stop_period = self.get_end_period_br(data)
|
||||
|
||||
target_move = self._get_form_param('target_move', data, default='all')
|
||||
start_date = self._get_form_param('date_from', data)
|
||||
stop_date = self._get_form_param('date_to', data)
|
||||
chart_account = self._get_chart_account_id_br(data)
|
||||
|
||||
start_period, stop_period, start, stop = \
|
||||
self._get_start_stop_for_filter(main_filter, fiscalyear,
|
||||
start_date, stop_date,
|
||||
start_period, stop_period)
|
||||
|
||||
init_balance = self.is_initial_balance_enabled(main_filter)
|
||||
initial_balance_mode = init_balance and self._get_initial_balance_mode(
|
||||
start) or False
|
||||
|
||||
# Retrieving accounts
|
||||
account_ids = self.get_all_accounts(
|
||||
new_ids, only_type=filter_report_type)
|
||||
|
||||
# get details for each accounts, total of debit / credit / balance
|
||||
accounts_by_ids = self._get_account_details(
|
||||
account_ids, target_move, fiscalyear, main_filter, start, stop,
|
||||
initial_balance_mode)
|
||||
|
||||
comparison_params = []
|
||||
comp_accounts_by_ids = []
|
||||
for index in range(max_comparison):
|
||||
if comp_filters[index] != 'filter_no':
|
||||
comparison_result, comp_params = self._get_comparison_details(
|
||||
data, account_ids, target_move, comp_filters[index], index)
|
||||
comparison_params.append(comp_params)
|
||||
comp_accounts_by_ids.append(comparison_result)
|
||||
|
||||
objects = self.pool.get('account.account').browse(self.cursor,
|
||||
self.uid,
|
||||
account_ids)
|
||||
|
||||
to_display_accounts = dict.fromkeys(account_ids, True)
|
||||
init_balance_accounts = dict.fromkeys(account_ids, False)
|
||||
comparisons_accounts = dict.fromkeys(account_ids, [])
|
||||
debit_accounts = dict.fromkeys(account_ids, False)
|
||||
credit_accounts = dict.fromkeys(account_ids, False)
|
||||
balance_accounts = dict.fromkeys(account_ids, False)
|
||||
|
||||
for account in objects:
|
||||
if not account.parent_id: # hide top level account
|
||||
continue
|
||||
if account.type == 'consolidation':
|
||||
to_display_accounts.update(
|
||||
dict([(a.id, False) for a in account.child_consol_ids]))
|
||||
elif account.type == 'view':
|
||||
to_display_accounts.update(
|
||||
dict([(a.id, True) for a in account.child_id]))
|
||||
debit_accounts[account.id] = \
|
||||
accounts_by_ids[account.id]['debit']
|
||||
credit_accounts[account.id] = \
|
||||
accounts_by_ids[account.id]['credit']
|
||||
balance_accounts[account.id] = \
|
||||
accounts_by_ids[account.id]['balance']
|
||||
init_balance_accounts[account.id] = \
|
||||
accounts_by_ids[account.id].get('init_balance', 0.0)
|
||||
|
||||
# if any amount is != 0 in comparisons, we have to display the
|
||||
# whole account
|
||||
display_account = False
|
||||
comp_accounts = []
|
||||
for comp_account_by_id in comp_accounts_by_ids:
|
||||
values = comp_account_by_id.get(account.id)
|
||||
values.update(
|
||||
self._get_diff(account.balance, values['balance']))
|
||||
display_account = any((values.get('credit', 0.0),
|
||||
values.get('debit', 0.0),
|
||||
values.get('balance', 0.0),
|
||||
values.get('init_balance', 0.0)))
|
||||
comp_accounts.append(values)
|
||||
comparisons_accounts[account.id] = comp_accounts
|
||||
# we have to display the account if a comparison as an amount or
|
||||
# if we have an amount in the main column
|
||||
# we set it as a property to let the data in the report if someone
|
||||
# want to use it in a custom report
|
||||
display_account = display_account\
|
||||
or any((debit_accounts[account.id],
|
||||
credit_accounts[account.id],
|
||||
balance_accounts[account.id],
|
||||
init_balance_accounts[account.id]))
|
||||
to_display_accounts.update(
|
||||
{account.id: display_account and
|
||||
to_display_accounts[account.id]})
|
||||
|
||||
context_report_values = {
|
||||
'fiscalyear': fiscalyear,
|
||||
'start_date': start_date,
|
||||
'stop_date': stop_date,
|
||||
'start_period': start_period,
|
||||
'stop_period': stop_period,
|
||||
'chart_account': chart_account,
|
||||
'comparison_mode': comparison_mode,
|
||||
'nb_comparison': nb_comparisons,
|
||||
'initial_balance': init_balance,
|
||||
'initial_balance_mode': initial_balance_mode,
|
||||
'comp_params': comparison_params,
|
||||
'to_display_accounts': to_display_accounts,
|
||||
'init_balance_accounts': init_balance_accounts,
|
||||
'comparisons_accounts': comparisons_accounts,
|
||||
'debit_accounts': debit_accounts,
|
||||
'credit_accounts': credit_accounts,
|
||||
'balance_accounts': balance_accounts,
|
||||
}
|
||||
|
||||
return objects, new_ids, context_report_values
|
|
@ -1,359 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Guewen Baconnier
|
||||
# Copyright Camptocamp SA 2011
|
||||
# SQL inspired from OpenERP original code
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from collections import defaultdict
|
||||
from operator import add
|
||||
|
||||
from .common_balance_reports import CommonBalanceReportHeaderWebkit
|
||||
from .common_partner_reports import CommonPartnersReportHeaderWebkit
|
||||
|
||||
|
||||
class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit,
|
||||
CommonPartnersReportHeaderWebkit):
|
||||
|
||||
"""Define common helper for balance (trial balance, P&L,
|
||||
BS oriented financial report"""
|
||||
|
||||
def _get_account_partners_details(self, account_by_ids, main_filter,
|
||||
target_move, start, stop,
|
||||
initial_balance_mode,
|
||||
partner_filter_ids=False):
|
||||
res = {}
|
||||
filter_from = False
|
||||
if main_filter in ('filter_period', 'filter_no', 'filter_opening'):
|
||||
filter_from = 'period'
|
||||
elif main_filter == 'filter_date':
|
||||
filter_from = 'date'
|
||||
|
||||
partners_init_balances_by_ids = {}
|
||||
for account_id, account_details in account_by_ids.iteritems():
|
||||
partners_init_balances_by_ids.update(
|
||||
self._get_partners_initial_balances(
|
||||
account_id, start, initial_balance_mode,
|
||||
partner_filter_ids=partner_filter_ids,
|
||||
# we'll never exclude reconciled entries in the legal
|
||||
# reports
|
||||
exclude_reconcile=False))
|
||||
opening_mode = 'exclude_opening'
|
||||
if main_filter == 'filter_opening':
|
||||
opening_mode = 'include_opening'
|
||||
# get credit and debit for partner
|
||||
details = self._get_partners_totals_account(
|
||||
filter_from,
|
||||
account_id,
|
||||
start,
|
||||
stop,
|
||||
target_move,
|
||||
partner_filter_ids=partner_filter_ids,
|
||||
mode=opening_mode)
|
||||
|
||||
# merge initial balances in partner details
|
||||
if partners_init_balances_by_ids.get(account_id):
|
||||
for partner_id, initial_balances in \
|
||||
partners_init_balances_by_ids[account_id].iteritems():
|
||||
if initial_balances.get('init_balance'):
|
||||
details[partner_id].update(
|
||||
{'init_balance': initial_balances['init_balance']})
|
||||
|
||||
# compute balance for the partner
|
||||
for partner_id, partner_details in details.iteritems():
|
||||
details[partner_id]['balance'] = details[partner_id].\
|
||||
get('init_balance', 0.0) + \
|
||||
details[partner_id].get('debit', 0.0) - \
|
||||
details[partner_id].get('credit', 0.0)
|
||||
res[account_id] = details
|
||||
|
||||
return res
|
||||
|
||||
def _get_partners_initial_balances(self, account_ids, start_period,
|
||||
initial_balance_mode,
|
||||
partner_filter_ids=None,
|
||||
exclude_reconcile=False):
|
||||
# we get the initial balance from the opening period (opening_balance)
|
||||
# when the opening period is included in the start period and
|
||||
# when there is at least one entry in the opening period. Otherwise we
|
||||
# compute it from previous periods
|
||||
if initial_balance_mode == 'opening_balance':
|
||||
opening_period_selected = self.get_included_opening_period(
|
||||
start_period)
|
||||
res = self._compute_partners_initial_balances(
|
||||
account_ids, start_period, partner_filter_ids,
|
||||
force_period_ids=opening_period_selected,
|
||||
exclude_reconcile=exclude_reconcile)
|
||||
elif initial_balance_mode == 'initial_balance':
|
||||
res = self._compute_partners_initial_balances(
|
||||
account_ids, start_period, partner_filter_ids,
|
||||
exclude_reconcile=exclude_reconcile)
|
||||
else:
|
||||
res = {}
|
||||
return res
|
||||
|
||||
def _get_partners_totals_account(self, filter_from, account_id, start,
|
||||
stop, target_move,
|
||||
partner_filter_ids=None,
|
||||
mode='exclude_opening'):
|
||||
final_res = defaultdict(dict)
|
||||
|
||||
sql_select = """
|
||||
SELECT account_move_line.partner_id,
|
||||
sum(account_move_line.debit) AS debit,
|
||||
sum(account_move_line.credit) AS credit
|
||||
FROM account_move_line"""
|
||||
sql_joins = ''
|
||||
sql_where = "WHERE account_move_line.account_id = %(account_id)s \
|
||||
AND account_move_line.state = 'valid' "
|
||||
method = getattr(self, '_get_query_params_from_' + filter_from + 's')
|
||||
sql_conditions, search_params = method(start, stop, mode=mode)
|
||||
sql_where += sql_conditions
|
||||
|
||||
if partner_filter_ids:
|
||||
sql_where += " AND account_move_line.partner_id \
|
||||
in %(partner_ids)s"
|
||||
search_params.update({'partner_ids': tuple(partner_filter_ids)})
|
||||
|
||||
if target_move == 'posted':
|
||||
sql_joins += "INNER JOIN account_move \
|
||||
ON account_move_line.move_id = account_move.id"
|
||||
sql_where += " AND account_move.state = %(target_move)s"
|
||||
search_params.update({'target_move': target_move})
|
||||
|
||||
sql_groupby = "GROUP BY account_move_line.partner_id"
|
||||
|
||||
search_params.update({'account_id': account_id})
|
||||
query = ' '.join((sql_select, sql_joins, sql_where, sql_groupby))
|
||||
|
||||
self.cursor.execute(query, search_params)
|
||||
res = self.cursor.dictfetchall()
|
||||
if res:
|
||||
for row in res:
|
||||
final_res[row['partner_id']] = row
|
||||
return final_res
|
||||
|
||||
def _get_filter_type(self, result_selection):
|
||||
filter_type = ('payable', 'receivable')
|
||||
if result_selection == 'customer':
|
||||
filter_type = ('receivable',)
|
||||
if result_selection == 'supplier':
|
||||
filter_type = ('payable',)
|
||||
return filter_type
|
||||
|
||||
def _get_partners_comparison_details(self, data, account_ids, target_move,
|
||||
comparison_filter, index,
|
||||
partner_filter_ids=False):
|
||||
"""
|
||||
|
||||
@param data: data of the wizard form
|
||||
@param account_ids: ids of the accounts to get details
|
||||
@param comparison_filter: selected filter on the form for
|
||||
the comparison (filter_no, filter_year, filter_period, filter_date)
|
||||
@param index: index of the fields to get (ie. comp1_fiscalyear_id
|
||||
where 1 is the index)
|
||||
@param partner_filter_ids: list of ids of partners to select
|
||||
@return: dict of account details (key = account id)
|
||||
"""
|
||||
fiscalyear = self._get_info(
|
||||
data, "comp%s_fiscalyear_id" % (index,), 'account.fiscalyear')
|
||||
start_period = self._get_info(
|
||||
data, "comp%s_period_from" % (index,), 'account.period')
|
||||
stop_period = self._get_info(
|
||||
data, "comp%s_period_to" % (index,), 'account.period')
|
||||
start_date = self._get_form_param("comp%s_date_from" % (index,), data)
|
||||
stop_date = self._get_form_param("comp%s_date_to" % (index,), data)
|
||||
init_balance = self.is_initial_balance_enabled(comparison_filter)
|
||||
|
||||
comp_params = {}
|
||||
accounts_details_by_ids = defaultdict(dict)
|
||||
if comparison_filter != 'filter_no':
|
||||
start_period, stop_period, start, stop = \
|
||||
self._get_start_stop_for_filter(
|
||||
comparison_filter, fiscalyear, start_date, stop_date,
|
||||
start_period, stop_period)
|
||||
details_filter = comparison_filter
|
||||
if comparison_filter == 'filter_year':
|
||||
details_filter = 'filter_no'
|
||||
|
||||
initial_balance_mode = init_balance \
|
||||
and self._get_initial_balance_mode(start) or False
|
||||
|
||||
accounts_by_ids = self._get_account_details(
|
||||
account_ids, target_move, fiscalyear, details_filter, start,
|
||||
stop, initial_balance_mode)
|
||||
|
||||
partner_details_by_ids = self._get_account_partners_details(
|
||||
accounts_by_ids, details_filter,
|
||||
target_move, start, stop, initial_balance_mode,
|
||||
partner_filter_ids=partner_filter_ids)
|
||||
|
||||
for account_id in account_ids:
|
||||
accounts_details_by_ids[account_id][
|
||||
'account'] = accounts_by_ids[account_id]
|
||||
accounts_details_by_ids[account_id][
|
||||
'partners_amounts'] = partner_details_by_ids[account_id]
|
||||
|
||||
comp_params = {
|
||||
'comparison_filter': comparison_filter,
|
||||
'fiscalyear': fiscalyear,
|
||||
'start': start,
|
||||
'stop': stop,
|
||||
'initial_balance_mode': initial_balance_mode,
|
||||
}
|
||||
|
||||
return accounts_details_by_ids, comp_params
|
||||
|
||||
def compute_partner_balance_data(self, data, filter_report_type=None):
|
||||
new_ids = data['form']['account_ids'] or data[
|
||||
'form']['chart_account_id']
|
||||
max_comparison = self._get_form_param(
|
||||
'max_comparison', data, default=0)
|
||||
main_filter = self._get_form_param('filter', data, default='filter_no')
|
||||
|
||||
comp_filters, nb_comparisons, comparison_mode = self._comp_filters(
|
||||
data, max_comparison)
|
||||
|
||||
fiscalyear = self.get_fiscalyear_br(data)
|
||||
|
||||
start_period = self.get_start_period_br(data)
|
||||
stop_period = self.get_end_period_br(data)
|
||||
target_move = self._get_form_param('target_move', data, default='all')
|
||||
start_date = self._get_form_param('date_from', data)
|
||||
stop_date = self._get_form_param('date_to', data)
|
||||
chart_account = self._get_chart_account_id_br(data)
|
||||
result_selection = self._get_form_param('result_selection', data)
|
||||
partner_ids = self._get_form_param('partner_ids', data)
|
||||
|
||||
filter_type = self._get_filter_type(result_selection)
|
||||
|
||||
start_period, stop_period, start, stop = \
|
||||
self._get_start_stop_for_filter(
|
||||
main_filter, fiscalyear, start_date, stop_date, start_period,
|
||||
stop_period)
|
||||
|
||||
initial_balance = self.is_initial_balance_enabled(main_filter)
|
||||
initial_balance_mode = initial_balance \
|
||||
and self._get_initial_balance_mode(start) or False
|
||||
|
||||
# Retrieving accounts
|
||||
account_ids = self.get_all_accounts(
|
||||
new_ids, only_type=filter_type,
|
||||
filter_report_type=filter_report_type)
|
||||
|
||||
# get details for each accounts, total of debit / credit / balance
|
||||
accounts_by_ids = self._get_account_details(
|
||||
account_ids, target_move, fiscalyear, main_filter, start, stop,
|
||||
initial_balance_mode)
|
||||
|
||||
partner_details_by_ids = self._get_account_partners_details(
|
||||
accounts_by_ids, main_filter, target_move, start, stop,
|
||||
initial_balance_mode, partner_filter_ids=partner_ids)
|
||||
|
||||
comparison_params = []
|
||||
comp_accounts_by_ids = []
|
||||
for index in range(max_comparison):
|
||||
if comp_filters[index] != 'filter_no':
|
||||
comparison_result, comp_params = self.\
|
||||
_get_partners_comparison_details(
|
||||
data, account_ids,
|
||||
target_move,
|
||||
comp_filters[index],
|
||||
index,
|
||||
partner_filter_ids=partner_ids)
|
||||
comparison_params.append(comp_params)
|
||||
comp_accounts_by_ids.append(comparison_result)
|
||||
objects = self.pool.get('account.account').browse(self.cursor,
|
||||
self.uid,
|
||||
account_ids)
|
||||
|
||||
init_balance_accounts = {}
|
||||
comparisons_accounts = {}
|
||||
partners_order_accounts = {}
|
||||
partners_amounts_accounts = {}
|
||||
debit_accounts = {}
|
||||
credit_accounts = {}
|
||||
balance_accounts = {}
|
||||
|
||||
for account in objects:
|
||||
if not account.parent_id: # hide top level account
|
||||
continue
|
||||
debit_accounts[account.id] = accounts_by_ids[account.id]['debit']
|
||||
credit_accounts[account.id] = accounts_by_ids[account.id]['credit']
|
||||
balance_accounts[account.id] = \
|
||||
accounts_by_ids[account.id]['balance']
|
||||
init_balance_accounts[account.id] = accounts_by_ids[
|
||||
account.id].get('init_balance', 0.0)
|
||||
partners_amounts_accounts[account.id] =\
|
||||
partner_details_by_ids[account.id]
|
||||
comp_accounts = []
|
||||
for comp_account_by_id in comp_accounts_by_ids:
|
||||
values = comp_account_by_id.get(account.id)
|
||||
|
||||
values['account'].update(
|
||||
self._get_diff(account.balance,
|
||||
values['account'].get('balance', 0.0)))
|
||||
comp_accounts.append(values)
|
||||
|
||||
for partner_id, partner_values in \
|
||||
values['partners_amounts'].copy().iteritems():
|
||||
partners_amounts_account =\
|
||||
partners_amounts_accounts[account.id]
|
||||
base_partner_balance =\
|
||||
partners_amounts_account[partner_id]['balance']\
|
||||
if partners_amounts_accounts.get(account.id)\
|
||||
and partners_amounts_accounts.get(account.id)\
|
||||
.get(partner_id) else 0.0
|
||||
partner_values.update(self._get_diff(
|
||||
base_partner_balance,
|
||||
partner_values.get('balance', 0.0)))
|
||||
values['partners_amounts'][
|
||||
partner_id].update(partner_values)
|
||||
|
||||
comparisons_accounts[account.id] = comp_accounts
|
||||
|
||||
all_partner_ids = reduce(add, [comp['partners_amounts'].keys()
|
||||
for comp in comp_accounts],
|
||||
partners_amounts_accounts[account.id]
|
||||
.keys())
|
||||
|
||||
partners_order_accounts[account.id] = \
|
||||
self._order_partners(all_partner_ids)
|
||||
|
||||
context_report_values = {
|
||||
'fiscalyear': fiscalyear,
|
||||
'start_date': start_date,
|
||||
'stop_date': stop_date,
|
||||
'start_period': start_period,
|
||||
'stop_period': stop_period,
|
||||
'chart_account': chart_account,
|
||||
'comparison_mode': comparison_mode,
|
||||
'nb_comparison': nb_comparisons,
|
||||
'comp_params': comparison_params,
|
||||
'initial_balance_mode': initial_balance_mode,
|
||||
'compute_diff': self._get_diff,
|
||||
'init_balance_accounts': init_balance_accounts,
|
||||
'comparisons_accounts': comparisons_accounts,
|
||||
'partners_order_accounts': partners_order_accounts,
|
||||
'partners_amounts_accounts': partners_amounts_accounts,
|
||||
'debit_accounts': debit_accounts,
|
||||
'credit_accounts': credit_accounts,
|
||||
'balance_accounts': balance_accounts,
|
||||
}
|
||||
|
||||
return objects, new_ids, context_report_values
|
|
@ -1,378 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Nicolas Bessi, Guewen Baconnier
|
||||
# Copyright Camptocamp SA 2011
|
||||
# SQL inspired from OpenERP original code
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
# TODO refactor helper in order to act more like mixin
|
||||
# By using properties we will have a more simple signature in fuctions
|
||||
|
||||
from collections import defaultdict
|
||||
from datetime import datetime
|
||||
|
||||
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||
from .common_reports import CommonReportHeaderWebkit
|
||||
|
||||
|
||||
class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
|
||||
|
||||
"""Define common helper for partner oriented financial report"""
|
||||
|
||||
######################################
|
||||
# Account move line retrieval helper #
|
||||
######################################
|
||||
|
||||
def get_partners_move_lines_ids(self, account_id, main_filter, start, stop,
|
||||
target_move,
|
||||
exclude_reconcile=False,
|
||||
partner_filter=False):
|
||||
filter_from = False
|
||||
if main_filter in ('filter_period', 'filter_no'):
|
||||
filter_from = 'period'
|
||||
elif main_filter == 'filter_date':
|
||||
filter_from = 'date'
|
||||
if filter_from:
|
||||
return self._get_partners_move_line_ids(
|
||||
filter_from, account_id, start, stop, target_move,
|
||||
exclude_reconcile=exclude_reconcile,
|
||||
partner_filter=partner_filter)
|
||||
|
||||
def _get_first_special_period(self):
|
||||
"""
|
||||
Returns the browse record of the period with the `special` flag, which
|
||||
is the special period of the first fiscal year used in the accounting.
|
||||
|
||||
i.e. it searches the first fiscal year with at least one journal entry,
|
||||
and it returns the id of the first period for which `special` is True
|
||||
in this fiscal year.
|
||||
|
||||
It is used for example in the partners reports, where we have to
|
||||
include the first, and only the first opening period.
|
||||
|
||||
:return: browse record of the first special period.
|
||||
"""
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
first_entry_id = move_line_obj.search(
|
||||
self.cr, self.uid, [], order='date ASC', limit=1)
|
||||
# it means there is no entry at all, that's unlikely to happen, but
|
||||
# it may so
|
||||
if not first_entry_id:
|
||||
return
|
||||
first_entry = move_line_obj.browse(
|
||||
self.cr, self.uid, first_entry_id[0])
|
||||
fiscalyear = first_entry.period_id.fiscalyear_id
|
||||
special_periods = [
|
||||
period for period in fiscalyear.period_ids if period.special]
|
||||
# so, we have no opening period on the first year, nothing to return
|
||||
if not special_periods:
|
||||
return
|
||||
return min(special_periods,
|
||||
key=lambda p: datetime.strptime(p.date_start,
|
||||
DEFAULT_SERVER_DATE_FORMAT))
|
||||
|
||||
def _get_period_range_from_start_period(self, start_period,
|
||||
include_opening=False,
|
||||
fiscalyear=False,
|
||||
stop_at_previous_opening=False):
|
||||
"""We retrieve all periods before start period"""
|
||||
periods = super(CommonPartnersReportHeaderWebkit, self).\
|
||||
_get_period_range_from_start_period(
|
||||
start_period,
|
||||
include_opening=include_opening,
|
||||
fiscalyear=fiscalyear,
|
||||
stop_at_previous_opening=stop_at_previous_opening)
|
||||
first_special = self._get_first_special_period()
|
||||
if first_special and first_special.id not in periods:
|
||||
periods.append(first_special.id)
|
||||
return periods
|
||||
|
||||
def _get_query_params_from_periods(self, period_start, period_stop,
|
||||
mode='exclude_opening'):
|
||||
"""
|
||||
Build the part of the sql "where clause" which filters on the selected
|
||||
periods.
|
||||
|
||||
:param browse_record period_start: first period of the report to print
|
||||
:param browse_record period_stop: last period of the report to print
|
||||
:param str mode: deprecated
|
||||
"""
|
||||
# we do not want opening period so we exclude opening
|
||||
periods = self.pool.get('account.period').build_ctx_periods(
|
||||
self.cr, self.uid, period_start.id, period_stop.id)
|
||||
if not periods:
|
||||
return []
|
||||
|
||||
if mode != 'include_opening':
|
||||
periods = self.exclude_opening_periods(periods)
|
||||
|
||||
search_params = {'period_ids': tuple(periods),
|
||||
'date_stop': period_stop.date_stop}
|
||||
|
||||
sql_conditions = ""
|
||||
if periods:
|
||||
sql_conditions = " AND account_move_line.period_id in \
|
||||
%(period_ids)s"
|
||||
|
||||
return sql_conditions, search_params
|
||||
|
||||
def _get_query_params_from_dates(self, date_start, date_stop, **args):
|
||||
"""
|
||||
Build the part of the sql where clause based on the dates to print.
|
||||
|
||||
:param str date_start: start date of the report to print
|
||||
:param str date_stop: end date of the report to print
|
||||
"""
|
||||
|
||||
periods = self._get_opening_periods()
|
||||
if not periods:
|
||||
periods = (-1,)
|
||||
|
||||
search_params = {'period_ids': tuple(periods),
|
||||
'date_start': date_start,
|
||||
'date_stop': date_stop}
|
||||
|
||||
sql_conditions = " AND account_move_line.period_id not \
|
||||
in %(period_ids)s \
|
||||
AND account_move_line.date between \
|
||||
date(%(date_start)s) and date((%(date_stop)s))"
|
||||
|
||||
return sql_conditions, search_params
|
||||
|
||||
def _get_partners_move_line_ids(self, filter_from, account_id, start, stop,
|
||||
target_move,
|
||||
opening_mode='exclude_opening',
|
||||
exclude_reconcile=False,
|
||||
partner_filter=None):
|
||||
"""
|
||||
|
||||
:param str filter_from: "periods" or "dates"
|
||||
:param int account_id: id of the account where to search move lines
|
||||
:param str or browse_record start: start date or start period
|
||||
:param str or browse_record stop: stop date or stop period
|
||||
:param str target_move: 'posted' or 'all'
|
||||
:param opening_mode: deprecated
|
||||
:param boolean exclude_reconcile: wether the reconciled entries are
|
||||
filtred or not
|
||||
:param list partner_filter: list of partner ids, will filter on their
|
||||
move lines
|
||||
"""
|
||||
|
||||
final_res = defaultdict(list)
|
||||
|
||||
sql_select = "SELECT account_move_line.id, \
|
||||
account_move_line.partner_id FROM account_move_line"
|
||||
sql_joins = ''
|
||||
sql_where = " WHERE account_move_line.account_id = %(account_ids)s " \
|
||||
" AND account_move_line.state = 'valid' "
|
||||
|
||||
method = getattr(self, '_get_query_params_from_' + filter_from + 's')
|
||||
sql_conditions, search_params = method(start, stop)
|
||||
|
||||
sql_where += sql_conditions
|
||||
|
||||
if exclude_reconcile:
|
||||
sql_where += (" AND ((account_move_line.reconcile_id IS NULL)"
|
||||
" OR (account_move_line.reconcile_id IS NOT NULL \
|
||||
AND account_move_line.last_rec_date > \
|
||||
date(%(date_stop)s)))")
|
||||
|
||||
if partner_filter:
|
||||
sql_where += " AND account_move_line.partner_id \
|
||||
in %(partner_ids)s"
|
||||
|
||||
if target_move == 'posted':
|
||||
sql_joins += "INNER JOIN account_move \
|
||||
ON account_move_line.move_id = account_move.id"
|
||||
sql_where += " AND account_move.state = %(target_move)s"
|
||||
search_params.update({'target_move': target_move})
|
||||
|
||||
search_params.update({
|
||||
'account_ids': account_id,
|
||||
'partner_ids': tuple(partner_filter),
|
||||
})
|
||||
|
||||
sql = ' '.join((sql_select, sql_joins, sql_where))
|
||||
self.cursor.execute(sql, search_params)
|
||||
res = self.cursor.dictfetchall()
|
||||
if res:
|
||||
for row in res:
|
||||
final_res[row['partner_id']].append(row['id'])
|
||||
return final_res
|
||||
|
||||
def _get_clearance_move_line_ids(self, move_line_ids, date_stop,
|
||||
date_until):
|
||||
if not move_line_ids:
|
||||
return []
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
# we do not use orm in order to gain perfo
|
||||
# In this case I have to test the effective gain over an itteration
|
||||
# Actually ORM does not allows distinct behavior
|
||||
sql = "Select distinct reconcile_id from account_move_line \
|
||||
where id in %s"
|
||||
self.cursor.execute(sql, (tuple(move_line_ids),))
|
||||
rec_ids = self.cursor.fetchall()
|
||||
if rec_ids:
|
||||
rec_ids = [x[0] for x in rec_ids]
|
||||
l_ids = move_line_obj.search(self.cursor,
|
||||
self.uid,
|
||||
[('reconcile_id', 'in', rec_ids),
|
||||
('date', '>=', date_stop),
|
||||
('date', '<=', date_until)])
|
||||
return l_ids
|
||||
else:
|
||||
return []
|
||||
|
||||
##############################################
|
||||
# Initial Partner Balance helper #
|
||||
##############################################
|
||||
|
||||
def _tree_move_line_ids(self, move_lines_data, key=None):
|
||||
"""
|
||||
move_lines_data must be a list of dict which contains at least keys :
|
||||
- account_id
|
||||
- partner_id
|
||||
- other keys with values of the line
|
||||
- if param key is defined, only this key will be inserted in the tree
|
||||
returns a tree like
|
||||
res[account_id.1][partner_id.1][move_line.1,
|
||||
move_line.2]
|
||||
[partner_id.2][move_line.3]
|
||||
res[account_id.2][partner_id.1][move_line.4]
|
||||
"""
|
||||
res = defaultdict(dict)
|
||||
for row in move_lines_data[:]:
|
||||
account_id = row.pop('account_id')
|
||||
partner_id = row.pop('partner_id')
|
||||
if key:
|
||||
res[account_id].setdefault(partner_id, []).append(row[key])
|
||||
else:
|
||||
res[account_id][partner_id] = row
|
||||
return res
|
||||
|
||||
def _partners_initial_balance_line_ids(self, account_ids, start_period,
|
||||
partner_filter,
|
||||
exclude_reconcile=False,
|
||||
force_period_ids=False,
|
||||
date_stop=None):
|
||||
# take ALL previous periods
|
||||
period_ids = force_period_ids \
|
||||
if force_period_ids \
|
||||
else self._get_period_range_from_start_period(
|
||||
start_period, fiscalyear=False, include_opening=False)
|
||||
|
||||
if not period_ids:
|
||||
period_ids = [-1]
|
||||
search_param = {
|
||||
'date_start': start_period.date_start,
|
||||
'period_ids': tuple(period_ids),
|
||||
'account_ids': tuple(account_ids),
|
||||
}
|
||||
sql = ("SELECT ml.id, ml.account_id, ml.partner_id "
|
||||
"FROM account_move_line ml "
|
||||
"INNER JOIN account_account a "
|
||||
"ON a.id = ml.account_id "
|
||||
"WHERE ml.period_id in %(period_ids)s "
|
||||
"AND ml.account_id in %(account_ids)s ")
|
||||
if exclude_reconcile:
|
||||
if not date_stop:
|
||||
raise Exception(
|
||||
"Missing \"date_stop\" to compute the open invoices.")
|
||||
search_param.update({'date_stop': date_stop})
|
||||
sql += ("AND ((ml.reconcile_id IS NULL) "
|
||||
"OR (ml.reconcile_id IS NOT NULL \
|
||||
AND ml.last_rec_date > date(%(date_stop)s))) ")
|
||||
if partner_filter:
|
||||
sql += "AND ml.partner_id in %(partner_ids)s "
|
||||
search_param.update({'partner_ids': tuple(partner_filter)})
|
||||
|
||||
self.cursor.execute(sql, search_param)
|
||||
return self.cursor.dictfetchall()
|
||||
|
||||
def _compute_partners_initial_balances(self, account_ids, start_period,
|
||||
partner_filter=None,
|
||||
exclude_reconcile=False,
|
||||
force_period_ids=False):
|
||||
"""We compute initial balance.
|
||||
If form is filtered by date all initial balance are equal to 0
|
||||
This function will sum pear and apple in currency amount if account
|
||||
as no secondary currency"""
|
||||
if isinstance(account_ids, (int, long)):
|
||||
account_ids = [account_ids]
|
||||
move_line_ids = self._partners_initial_balance_line_ids(
|
||||
account_ids, start_period, partner_filter,
|
||||
exclude_reconcile=exclude_reconcile,
|
||||
force_period_ids=force_period_ids)
|
||||
if not move_line_ids:
|
||||
move_line_ids = [{'id': -1}]
|
||||
sql = ("SELECT ml.account_id, ml.partner_id,"
|
||||
" sum(ml.debit) as debit, sum(ml.credit) as credit,"
|
||||
" sum(ml.debit-ml.credit) as init_balance,"
|
||||
" CASE WHEN a.currency_id ISNULL THEN 0.0\
|
||||
ELSE sum(ml.amount_currency) \
|
||||
END as init_balance_currency, "
|
||||
" c.name as currency_name "
|
||||
"FROM account_move_line ml "
|
||||
"INNER JOIN account_account a "
|
||||
"ON a.id = ml.account_id "
|
||||
"LEFT JOIN res_currency c "
|
||||
"ON c.id = a.currency_id "
|
||||
"WHERE ml.id in %(move_line_ids)s "
|
||||
"GROUP BY ml.account_id, ml.partner_id, a.currency_id, c.name")
|
||||
search_param = {
|
||||
'move_line_ids': tuple([move_line['id'] for move_line in
|
||||
move_line_ids])}
|
||||
self.cursor.execute(sql, search_param)
|
||||
res = self.cursor.dictfetchall()
|
||||
return self._tree_move_line_ids(res)
|
||||
|
||||
############################################################
|
||||
# Partner specific helper #
|
||||
############################################################
|
||||
|
||||
def _order_partners(self, *args):
|
||||
"""We get the partner linked to all current accounts that are used.
|
||||
We also use ensure that partner are ordered by name
|
||||
args must be list"""
|
||||
res = []
|
||||
partner_ids = []
|
||||
for arg in args:
|
||||
if arg:
|
||||
partner_ids += arg
|
||||
if not partner_ids:
|
||||
return []
|
||||
|
||||
existing_partner_ids = [
|
||||
partner_id for partner_id in partner_ids if partner_id]
|
||||
if existing_partner_ids:
|
||||
# We may use orm here as the performance optimization is not that
|
||||
# big
|
||||
sql = ("SELECT name|| ' ' ||CASE WHEN ref IS NOT NULL \
|
||||
THEN '('||ref||')' \
|
||||
ELSE '' END, id, ref, name"
|
||||
" FROM res_partner \
|
||||
WHERE id IN %s ORDER BY LOWER(name), ref")
|
||||
self.cursor.execute(sql, (tuple(set(existing_partner_ids)),))
|
||||
res = self.cursor.fetchall()
|
||||
|
||||
# move lines without partners, set None for empty partner
|
||||
if not all(partner_ids):
|
||||
res.append((None, None, None, None))
|
||||
|
||||
if not res:
|
||||
return []
|
||||
return res
|
|
@ -1,600 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Nicolas Bessi, Guewen Baconnier
|
||||
# Copyright Camptocamp SA 2011
|
||||
# SQL inspired from OpenERP original code
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
# TODO refactor helper in order to act more like mixin
|
||||
# By using properties we will have a more simple signature in fuctions
|
||||
|
||||
import logging
|
||||
|
||||
from openerp.osv import osv
|
||||
from openerp.tools.translate import _
|
||||
from openerp.addons.account.report.common_report_header \
|
||||
import common_report_header
|
||||
|
||||
_logger = logging.getLogger('financial.reports.webkit')
|
||||
|
||||
MAX_MONSTER_SLICE = 50000
|
||||
|
||||
|
||||
class CommonReportHeaderWebkit(common_report_header):
|
||||
|
||||
"""Define common helper for financial report"""
|
||||
|
||||
######################################################################
|
||||
# From getter helper #
|
||||
######################################################################
|
||||
|
||||
def get_start_period_br(self, data):
|
||||
return self._get_info(data, 'period_from', 'account.period')
|
||||
|
||||
def get_end_period_br(self, data):
|
||||
return self._get_info(data, 'period_to', 'account.period')
|
||||
|
||||
def get_fiscalyear_br(self, data):
|
||||
return self._get_info(data, 'fiscalyear_id', 'account.fiscalyear')
|
||||
|
||||
def _get_chart_account_id_br(self, data):
|
||||
return self._get_info(data, 'chart_account_id', 'account.account')
|
||||
|
||||
def _get_accounts_br(self, data):
|
||||
return self._get_info(data, 'account_ids', 'account.account')
|
||||
|
||||
def _get_info(self, data, field, model):
|
||||
info = data.get('form', {}).get(field)
|
||||
if info:
|
||||
return self.pool.get(model).browse(self.cursor, self.uid, info)
|
||||
return False
|
||||
|
||||
def _get_journals_br(self, data):
|
||||
return self._get_info(data, 'journal_ids', 'account.journal')
|
||||
|
||||
def _get_display_account(self, data):
|
||||
val = self._get_form_param('display_account', data)
|
||||
if val == 'bal_all':
|
||||
return _('All accounts')
|
||||
elif val == 'bal_mix':
|
||||
return _('With transactions or non zero balance')
|
||||
else:
|
||||
return val
|
||||
|
||||
def _get_display_partner_account(self, data):
|
||||
val = self._get_form_param('result_selection', data)
|
||||
if val == 'customer':
|
||||
return _('Receivable Accounts')
|
||||
elif val == 'supplier':
|
||||
return _('Payable Accounts')
|
||||
elif val == 'customer_supplier':
|
||||
return _('Receivable and Payable Accounts')
|
||||
else:
|
||||
return val
|
||||
|
||||
def _get_display_target_move(self, data):
|
||||
val = self._get_form_param('target_move', data)
|
||||
if val == 'posted':
|
||||
return _('All Posted Entries')
|
||||
elif val == 'all':
|
||||
return _('All Entries')
|
||||
else:
|
||||
return val
|
||||
|
||||
def _get_display_account_raw(self, data):
|
||||
return self._get_form_param('display_account', data)
|
||||
|
||||
def _get_filter(self, data):
|
||||
return self._get_form_param('filter', data)
|
||||
|
||||
def _get_target_move(self, data):
|
||||
return self._get_form_param('target_move', data)
|
||||
|
||||
def _get_initial_balance(self, data):
|
||||
return self._get_form_param('initial_balance', data)
|
||||
|
||||
def _get_amount_currency(self, data):
|
||||
return self._get_form_param('amount_currency', data)
|
||||
|
||||
def _get_date_from(self, data):
|
||||
return self._get_form_param('date_from', data)
|
||||
|
||||
def _get_date_to(self, data):
|
||||
return self._get_form_param('date_to', data)
|
||||
|
||||
def _get_form_param(self, param, data, default=False):
|
||||
return data.get('form', {}).get(param, default)
|
||||
|
||||
#############################################
|
||||
# Account and account line filter helper #
|
||||
#############################################
|
||||
|
||||
def sort_accounts_with_structure(self, root_account_ids, account_ids,
|
||||
context=None):
|
||||
"""Sort accounts by code respecting their structure"""
|
||||
|
||||
def recursive_sort_by_code(accounts, parent):
|
||||
sorted_accounts = []
|
||||
# add all accounts with same parent
|
||||
level_accounts = [
|
||||
account for account in accounts
|
||||
if account['parent_id'] and
|
||||
account['parent_id'][0] == parent['id']]
|
||||
# add consolidation children of parent, as they are logically on
|
||||
# the same level
|
||||
if parent.get('child_consol_ids'):
|
||||
level_accounts.extend([account for account in accounts
|
||||
if account['id']
|
||||
in parent['child_consol_ids']])
|
||||
# stop recursion if no children found
|
||||
if not level_accounts:
|
||||
return []
|
||||
|
||||
level_accounts = sorted(level_accounts, key=lambda a: a['code'])
|
||||
|
||||
for level_account in level_accounts:
|
||||
sorted_accounts.append(level_account['id'])
|
||||
sorted_accounts.extend(
|
||||
recursive_sort_by_code(accounts, parent=level_account))
|
||||
return sorted_accounts
|
||||
|
||||
if not account_ids:
|
||||
return []
|
||||
|
||||
accounts_data = self.pool.get('account.account').read(
|
||||
self.cr, self.uid, account_ids,
|
||||
['id', 'parent_id', 'level', 'code', 'child_consol_ids'],
|
||||
context=context)
|
||||
|
||||
sorted_accounts = []
|
||||
|
||||
root_accounts_data = [account_data for account_data in accounts_data
|
||||
if account_data['id'] in root_account_ids]
|
||||
for root_account_data in root_accounts_data:
|
||||
sorted_accounts.append(root_account_data['id'])
|
||||
sorted_accounts.extend(
|
||||
recursive_sort_by_code(accounts_data, root_account_data))
|
||||
|
||||
# fallback to unsorted accounts when sort failed
|
||||
# sort fails when the levels are miscalculated by account.account
|
||||
# check lp:783670
|
||||
if len(sorted_accounts) != len(account_ids):
|
||||
_logger.warn('Webkit financial reports: Sort of accounts failed.')
|
||||
sorted_accounts = account_ids
|
||||
|
||||
return sorted_accounts
|
||||
|
||||
def get_all_accounts(self, account_ids, exclude_type=None, only_type=None,
|
||||
filter_report_type=None, context=None):
|
||||
"""Get all account passed in params with their childrens
|
||||
|
||||
@param exclude_type: list of types to exclude (view, receivable,
|
||||
payable, consolidation, other)
|
||||
@param only_type: list of types to filter on (view, receivable,
|
||||
payable, consolidation, other)
|
||||
@param filter_report_type: list of report type to filter on
|
||||
"""
|
||||
context = context or {}
|
||||
accounts = []
|
||||
if not isinstance(account_ids, list):
|
||||
account_ids = [account_ids]
|
||||
acc_obj = self.pool.get('account.account')
|
||||
for account_id in account_ids:
|
||||
accounts.append(account_id)
|
||||
accounts += acc_obj._get_children_and_consol(
|
||||
self.cursor, self.uid, account_id, context=context)
|
||||
res_ids = list(set(accounts))
|
||||
res_ids = self.sort_accounts_with_structure(
|
||||
account_ids, res_ids, context=context)
|
||||
|
||||
if exclude_type or only_type or filter_report_type:
|
||||
sql_filters = {'ids': tuple(res_ids)}
|
||||
sql_select = "SELECT a.id FROM account_account a"
|
||||
sql_join = ""
|
||||
sql_where = "WHERE a.id IN %(ids)s"
|
||||
if exclude_type:
|
||||
sql_where += " AND a.type not in %(exclude_type)s"
|
||||
sql_filters.update({'exclude_type': tuple(exclude_type)})
|
||||
if only_type:
|
||||
sql_where += " AND a.type IN %(only_type)s"
|
||||
sql_filters.update({'only_type': tuple(only_type)})
|
||||
if filter_report_type:
|
||||
sql_join += "INNER JOIN account_account_type t" \
|
||||
" ON t.id = a.user_type"
|
||||
sql_join += " AND t.report_type IN %(report_type)s"
|
||||
sql_filters.update({'report_type': tuple(filter_report_type)})
|
||||
|
||||
sql = ' '.join((sql_select, sql_join, sql_where))
|
||||
self.cursor.execute(sql, sql_filters)
|
||||
fetch_only_ids = self.cursor.fetchall()
|
||||
if not fetch_only_ids:
|
||||
return []
|
||||
only_ids = [only_id[0] for only_id in fetch_only_ids]
|
||||
# keep sorting but filter ids
|
||||
res_ids = [res_id for res_id in res_ids if res_id in only_ids]
|
||||
return res_ids
|
||||
|
||||
##########################################
|
||||
# Periods and fiscal years helper #
|
||||
##########################################
|
||||
|
||||
def _get_opening_periods(self):
|
||||
"""Return the list of all journal that can be use to create opening
|
||||
entries.
|
||||
We actually filter on this instead of opening period as older version
|
||||
of OpenERP did not have this notion"""
|
||||
return self.pool.get('account.period').search(self.cursor, self.uid,
|
||||
[('special', '=', True)])
|
||||
|
||||
def exclude_opening_periods(self, period_ids):
|
||||
period_obj = self.pool.get('account.period')
|
||||
return period_obj.search(self.cr, self.uid, [['special', '=', False],
|
||||
['id', 'in', period_ids]])
|
||||
|
||||
def get_included_opening_period(self, period):
|
||||
"""Return the opening included in normal period we use the assumption
|
||||
that there is only one opening period per fiscal year"""
|
||||
period_obj = self.pool.get('account.period')
|
||||
return period_obj.search(self.cursor, self.uid,
|
||||
[('special', '=', True),
|
||||
('date_start', '>=', period.date_start),
|
||||
('date_stop', '<=', period.date_stop),
|
||||
('company_id', '=', period.company_id.id)],
|
||||
limit=1)
|
||||
|
||||
def periods_contains_move_lines(self, period_ids):
|
||||
if not period_ids:
|
||||
return False
|
||||
mv_line_obj = self.pool.get('account.move.line')
|
||||
if isinstance(period_ids, (int, long)):
|
||||
period_ids = [period_ids]
|
||||
return mv_line_obj.search(self.cursor, self.uid,
|
||||
[('period_id', 'in', period_ids)], limit=1) \
|
||||
and True or False
|
||||
|
||||
def _get_period_range_from_periods(self, start_period, stop_period,
|
||||
mode=None):
|
||||
"""
|
||||
Deprecated. We have to use now the build_ctx_periods of period_obj
|
||||
otherwise we'll have inconsistencies, because build_ctx_periods does
|
||||
never filter on the the special
|
||||
"""
|
||||
period_obj = self.pool.get('account.period')
|
||||
search_period = [('date_start', '>=', start_period.date_start),
|
||||
('date_stop', '<=', stop_period.date_stop)]
|
||||
|
||||
if mode == 'exclude_opening':
|
||||
search_period += [('special', '=', False)]
|
||||
res = period_obj.search(self.cursor, self.uid, search_period)
|
||||
return res
|
||||
|
||||
def _get_period_range_from_start_period(self, start_period,
|
||||
include_opening=False,
|
||||
fiscalyear=False,
|
||||
stop_at_previous_opening=False):
|
||||
"""We retrieve all periods before start period"""
|
||||
opening_period_id = False
|
||||
past_limit = []
|
||||
period_obj = self.pool.get('account.period')
|
||||
mv_line_obj = self.pool.get('account.move.line')
|
||||
# We look for previous opening period
|
||||
if stop_at_previous_opening:
|
||||
opening_search = [('special', '=', True),
|
||||
('date_stop', '<', start_period.date_start)]
|
||||
if fiscalyear:
|
||||
opening_search.append(('fiscalyear_id', '=', fiscalyear.id))
|
||||
|
||||
opening_periods = period_obj.search(self.cursor, self.uid,
|
||||
opening_search,
|
||||
order='date_stop desc')
|
||||
for opening_period in opening_periods:
|
||||
validation_res = mv_line_obj.search(self.cursor,
|
||||
self.uid,
|
||||
[('period_id', '=',
|
||||
opening_period)],
|
||||
limit=1)
|
||||
if validation_res:
|
||||
opening_period_id = opening_period
|
||||
break
|
||||
if opening_period_id:
|
||||
# we also look for overlapping periods
|
||||
opening_period_br = period_obj.browse(
|
||||
self.cursor, self.uid, opening_period_id)
|
||||
past_limit = [
|
||||
('date_start', '>=', opening_period_br.date_stop)]
|
||||
|
||||
periods_search = [('date_stop', '<=', start_period.date_stop)]
|
||||
periods_search += past_limit
|
||||
|
||||
if not include_opening:
|
||||
periods_search += [('special', '=', False)]
|
||||
|
||||
if fiscalyear:
|
||||
periods_search.append(('fiscalyear_id', '=', fiscalyear.id))
|
||||
periods = period_obj.search(self.cursor, self.uid, periods_search)
|
||||
if include_opening and opening_period_id:
|
||||
periods.append(opening_period_id)
|
||||
periods = list(set(periods))
|
||||
if start_period.id in periods:
|
||||
periods.remove(start_period.id)
|
||||
return periods
|
||||
|
||||
def get_first_fiscalyear_period(self, fiscalyear):
|
||||
return self._get_st_fiscalyear_period(fiscalyear)
|
||||
|
||||
def get_last_fiscalyear_period(self, fiscalyear):
|
||||
return self._get_st_fiscalyear_period(fiscalyear, order='DESC')
|
||||
|
||||
def _get_st_fiscalyear_period(self, fiscalyear, special=False,
|
||||
order='ASC'):
|
||||
period_obj = self.pool.get('account.period')
|
||||
p_id = period_obj.search(self.cursor,
|
||||
self.uid,
|
||||
[('special', '=', special),
|
||||
('fiscalyear_id', '=', fiscalyear.id)],
|
||||
limit=1,
|
||||
order='date_start %s' % (order,))
|
||||
if not p_id:
|
||||
raise osv.except_osv(_('No period found'), '')
|
||||
return period_obj.browse(self.cursor, self.uid, p_id[0])
|
||||
|
||||
###############################
|
||||
# Initial Balance helper #
|
||||
###############################
|
||||
|
||||
def _compute_init_balance(self, account_id=None, period_ids=None,
|
||||
mode='computed', default_values=False):
|
||||
if not isinstance(period_ids, list):
|
||||
period_ids = [period_ids]
|
||||
res = {}
|
||||
|
||||
if not default_values:
|
||||
if not account_id or not period_ids:
|
||||
raise Exception('Missing account or period_ids')
|
||||
try:
|
||||
self.cursor.execute("SELECT sum(debit) AS debit, "
|
||||
" sum(credit) AS credit, "
|
||||
" sum(debit)-sum(credit) AS balance, "
|
||||
" sum(amount_currency) AS curr_balance"
|
||||
" FROM account_move_line"
|
||||
" WHERE period_id in %s"
|
||||
" AND account_id = %s",
|
||||
(tuple(period_ids), account_id))
|
||||
res = self.cursor.dictfetchone()
|
||||
|
||||
except Exception:
|
||||
self.cursor.rollback()
|
||||
raise
|
||||
|
||||
return {'debit': res.get('debit') or 0.0,
|
||||
'credit': res.get('credit') or 0.0,
|
||||
'init_balance': res.get('balance') or 0.0,
|
||||
'init_balance_currency': res.get('curr_balance') or 0.0,
|
||||
'state': mode}
|
||||
|
||||
def _read_opening_balance(self, account_ids, start_period):
|
||||
""" Read opening balances from the opening balance
|
||||
"""
|
||||
opening_period_selected = self.get_included_opening_period(
|
||||
start_period)
|
||||
if not opening_period_selected:
|
||||
raise osv.except_osv(
|
||||
_('Error'),
|
||||
_('No opening period found to compute the opening balances.\n'
|
||||
'You have to configure a period on the first of January'
|
||||
' with the special flag.'))
|
||||
|
||||
res = {}
|
||||
for account_id in account_ids:
|
||||
res[account_id] = self._compute_init_balance(
|
||||
account_id, opening_period_selected, mode='read')
|
||||
return res
|
||||
|
||||
def _compute_initial_balances(self, account_ids, start_period, fiscalyear):
|
||||
"""We compute initial balance.
|
||||
If form is filtered by date all initial balance are equal to 0
|
||||
This function will sum pear and apple in currency amount if account as
|
||||
no secondary currency"""
|
||||
# if opening period is included in start period we do not need to
|
||||
# compute init balance we just read it from opening entries
|
||||
res = {}
|
||||
# PNL and Balance accounts are not computed the same way look for
|
||||
# attached doc We include opening period in pnl account in order to see
|
||||
# if opening entries were created by error on this account
|
||||
pnl_periods_ids = self._get_period_range_from_start_period(
|
||||
start_period, fiscalyear=fiscalyear, include_opening=True)
|
||||
bs_period_ids = self._get_period_range_from_start_period(
|
||||
start_period, include_opening=True, stop_at_previous_opening=True)
|
||||
opening_period_selected = self.get_included_opening_period(
|
||||
start_period)
|
||||
|
||||
for acc in self.pool.get('account.account').browse(self.cursor,
|
||||
self.uid,
|
||||
account_ids):
|
||||
res[acc.id] = self._compute_init_balance(default_values=True)
|
||||
if acc.user_type.close_method == 'none':
|
||||
# we compute the initial balance for close_method == none only
|
||||
# when we print a GL during the year, when the opening period
|
||||
# is not included in the period selection!
|
||||
if pnl_periods_ids and not opening_period_selected:
|
||||
res[acc.id] = self._compute_init_balance(
|
||||
acc.id, pnl_periods_ids)
|
||||
else:
|
||||
res[acc.id] = self._compute_init_balance(acc.id, bs_period_ids)
|
||||
return res
|
||||
|
||||
################################################
|
||||
# Account move retrieval helper #
|
||||
################################################
|
||||
def _get_move_ids_from_periods(self, account_id, period_start, period_stop,
|
||||
target_move):
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
period_obj = self.pool.get('account.period')
|
||||
periods = period_obj.build_ctx_periods(
|
||||
self.cursor, self.uid, period_start.id, period_stop.id)
|
||||
if not periods:
|
||||
return []
|
||||
search = [
|
||||
('period_id', 'in', periods), ('account_id', '=', account_id)]
|
||||
if target_move == 'posted':
|
||||
search += [('move_id.state', '=', 'posted')]
|
||||
return move_line_obj.search(self.cursor, self.uid, search)
|
||||
|
||||
def _get_move_ids_from_dates(self, account_id, date_start, date_stop,
|
||||
target_move, mode='include_opening'):
|
||||
# TODO imporve perfomance by setting opening period as a property
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
search_period = [('date', '>=', date_start),
|
||||
('date', '<=', date_stop),
|
||||
('account_id', '=', account_id)]
|
||||
|
||||
# actually not used because OpenERP itself always include the opening
|
||||
# when we get the periods from january to december
|
||||
if mode == 'exclude_opening':
|
||||
opening = self._get_opening_periods()
|
||||
if opening:
|
||||
search_period += ['period_id', 'not in', opening]
|
||||
|
||||
if target_move == 'posted':
|
||||
search_period += [('move_id.state', '=', 'posted')]
|
||||
|
||||
return move_line_obj.search(self.cursor, self.uid, search_period)
|
||||
|
||||
def get_move_lines_ids(self, account_id, main_filter, start, stop,
|
||||
target_move, mode='include_opening'):
|
||||
"""Get account move lines base on form data"""
|
||||
if mode not in ('include_opening', 'exclude_opening'):
|
||||
raise osv.except_osv(
|
||||
_('Invalid query mode'),
|
||||
_('Must be in include_opening, exclude_opening'))
|
||||
|
||||
if main_filter in ('filter_period', 'filter_no'):
|
||||
return self._get_move_ids_from_periods(account_id, start, stop,
|
||||
target_move)
|
||||
|
||||
elif main_filter == 'filter_date':
|
||||
return self._get_move_ids_from_dates(account_id, start, stop,
|
||||
target_move)
|
||||
else:
|
||||
raise osv.except_osv(
|
||||
_('No valid filter'), _('Please set a valid time filter'))
|
||||
|
||||
def _get_move_line_datas(self, move_line_ids,
|
||||
order='per.special DESC, l.date ASC, \
|
||||
per.date_start ASC, m.name ASC'):
|
||||
# Possible bang if move_line_ids is too long
|
||||
# We can not slice here as we have to do the sort.
|
||||
# If slice has to be done it means that we have to reorder in python
|
||||
# after all is finished. That quite crapy...
|
||||
# We have a defective desing here (mea culpa) that should be fixed
|
||||
#
|
||||
# TODO improve that by making a better domain or if not possible
|
||||
# by using python sort
|
||||
if not move_line_ids:
|
||||
return []
|
||||
if not isinstance(move_line_ids, list):
|
||||
move_line_ids = [move_line_ids]
|
||||
monster = """
|
||||
SELECT l.id AS id,
|
||||
l.date AS ldate,
|
||||
j.code AS jcode ,
|
||||
j.type AS jtype,
|
||||
l.currency_id,
|
||||
l.account_id,
|
||||
l.amount_currency,
|
||||
l.ref AS lref,
|
||||
l.name AS lname,
|
||||
COALESCE(l.debit, 0.0) - COALESCE(l.credit, 0.0) AS balance,
|
||||
l.debit,
|
||||
l.credit,
|
||||
l.period_id AS lperiod_id,
|
||||
per.code as period_code,
|
||||
per.special AS peropen,
|
||||
l.partner_id AS lpartner_id,
|
||||
p.name AS partner_name,
|
||||
m.name AS move_name,
|
||||
COALESCE(partialrec.name, fullrec.name, '') AS rec_name,
|
||||
COALESCE(partialrec.id, fullrec.id, NULL) AS rec_id,
|
||||
m.id AS move_id,
|
||||
c.name AS currency_code,
|
||||
i.id AS invoice_id,
|
||||
i.type AS invoice_type,
|
||||
i.number AS invoice_number,
|
||||
l.date_maturity
|
||||
FROM account_move_line l
|
||||
JOIN account_move m on (l.move_id=m.id)
|
||||
LEFT JOIN res_currency c on (l.currency_id=c.id)
|
||||
LEFT JOIN account_move_reconcile partialrec
|
||||
on (l.reconcile_partial_id = partialrec.id)
|
||||
LEFT JOIN account_move_reconcile fullrec on (l.reconcile_id = fullrec.id)
|
||||
LEFT JOIN res_partner p on (l.partner_id=p.id)
|
||||
LEFT JOIN account_invoice i on (m.id =i.move_id)
|
||||
LEFT JOIN account_period per on (per.id=l.period_id)
|
||||
JOIN account_journal j on (l.journal_id=j.id)
|
||||
WHERE l.id in %s"""
|
||||
monster += (" ORDER BY %s" % (order,))
|
||||
try:
|
||||
self.cursor.execute(monster, (tuple(move_line_ids),))
|
||||
res = self.cursor.dictfetchall()
|
||||
except Exception:
|
||||
self.cursor.rollback()
|
||||
raise
|
||||
return res or []
|
||||
|
||||
def _get_moves_counterparts(self, move_ids, account_id, limit=3):
|
||||
if not move_ids:
|
||||
return {}
|
||||
if not isinstance(move_ids, list):
|
||||
move_ids = [move_ids]
|
||||
sql = """
|
||||
SELECT account_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 =account_move_line.move_id
|
||||
AND m2.account_id<>%s limit %s) , ', ')
|
||||
|
||||
FROM account_move
|
||||
JOIN account_move_line
|
||||
on (account_move_line.move_id = account_move.id)
|
||||
JOIN account_account
|
||||
on (account_move_line.account_id = account_account.id)
|
||||
WHERE move_id in %s"""
|
||||
|
||||
try:
|
||||
self.cursor.execute(sql, (account_id, limit, tuple(move_ids)))
|
||||
res = self.cursor.fetchall()
|
||||
except Exception:
|
||||
self.cursor.rollback()
|
||||
raise
|
||||
return res and dict(res) or {}
|
||||
|
||||
def is_initial_balance_enabled(self, main_filter):
|
||||
if main_filter not in ('filter_no', 'filter_year', 'filter_period'):
|
||||
return False
|
||||
return True
|
||||
|
||||
def _get_initial_balance_mode(self, start_period):
|
||||
opening_period_selected = self.get_included_opening_period(
|
||||
start_period)
|
||||
opening_move_lines = self.periods_contains_move_lines(
|
||||
opening_period_selected)
|
||||
if opening_move_lines:
|
||||
return 'opening_balance'
|
||||
else:
|
||||
return 'initial_balance'
|
|
@ -1,243 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Nicolas Bessi, Guewen Baconnier
|
||||
# Copyright Camptocamp SA 2011
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from operator import itemgetter
|
||||
from itertools import groupby
|
||||
from datetime import datetime
|
||||
|
||||
from openerp.report import report_sxw
|
||||
from openerp import pooler
|
||||
from openerp.tools.translate import _
|
||||
from .common_reports import CommonReportHeaderWebkit
|
||||
from .webkit_parser_header_fix import HeaderFooterTextWebKitParser
|
||||
|
||||
|
||||
class GeneralLedgerWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
|
||||
|
||||
def __init__(self, cursor, uid, name, context):
|
||||
super(GeneralLedgerWebkit, self).__init__(
|
||||
cursor, uid, name, context=context)
|
||||
self.pool = pooler.get_pool(self.cr.dbname)
|
||||
self.cursor = self.cr
|
||||
|
||||
company = self.pool.get('res.users').browse(
|
||||
self.cr, uid, uid, context=context).company_id
|
||||
header_report_name = ' - '.join(
|
||||
(_('GENERAL LEDGER'), company.name, company.currency_id.name))
|
||||
|
||||
footer_date_time = self.formatLang(
|
||||
str(datetime.today()), date_time=True)
|
||||
|
||||
self.localcontext.update({
|
||||
'cr': cursor,
|
||||
'uid': uid,
|
||||
'report_name': _('General Ledger'),
|
||||
'display_account': self._get_display_account,
|
||||
'display_account_raw': self._get_display_account_raw,
|
||||
'filter_form': self._get_filter,
|
||||
'target_move': self._get_target_move,
|
||||
'initial_balance': self._get_initial_balance,
|
||||
'amount_currency': self._get_amount_currency,
|
||||
'display_target_move': self._get_display_target_move,
|
||||
'accounts': self._get_accounts_br,
|
||||
'additional_args': [
|
||||
('--header-font-name', 'Helvetica'),
|
||||
('--footer-font-name', 'Helvetica'),
|
||||
('--header-font-size', '10'),
|
||||
('--footer-font-size', '6'),
|
||||
('--header-left', header_report_name),
|
||||
('--header-spacing', '2'),
|
||||
('--footer-left', footer_date_time),
|
||||
('--footer-right',
|
||||
' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
|
||||
('--footer-line',),
|
||||
],
|
||||
})
|
||||
|
||||
def set_context(self, objects, data, ids, report_type=None):
|
||||
"""Populate a ledger_lines attribute on each browse record that will be
|
||||
used by mako template"""
|
||||
new_ids = data['form']['account_ids'] or data[
|
||||
'form']['chart_account_id']
|
||||
|
||||
# Account initial balance memoizer
|
||||
init_balance_memoizer = {}
|
||||
|
||||
# Reading form
|
||||
main_filter = self._get_form_param('filter', data, default='filter_no')
|
||||
target_move = self._get_form_param('target_move', data, default='all')
|
||||
start_date = self._get_form_param('date_from', data)
|
||||
stop_date = self._get_form_param('date_to', data)
|
||||
do_centralize = self._get_form_param('centralize', data)
|
||||
start_period = self.get_start_period_br(data)
|
||||
stop_period = self.get_end_period_br(data)
|
||||
fiscalyear = self.get_fiscalyear_br(data)
|
||||
chart_account = self._get_chart_account_id_br(data)
|
||||
|
||||
if main_filter == 'filter_no':
|
||||
start_period = self.get_first_fiscalyear_period(fiscalyear)
|
||||
stop_period = self.get_last_fiscalyear_period(fiscalyear)
|
||||
|
||||
# computation of ledger lines
|
||||
if main_filter == 'filter_date':
|
||||
start = start_date
|
||||
stop = stop_date
|
||||
else:
|
||||
start = start_period
|
||||
stop = stop_period
|
||||
|
||||
initial_balance = self.is_initial_balance_enabled(main_filter)
|
||||
initial_balance_mode = initial_balance \
|
||||
and self._get_initial_balance_mode(start) or False
|
||||
|
||||
# Retrieving accounts
|
||||
accounts = self.get_all_accounts(new_ids, exclude_type=['view'])
|
||||
if initial_balance_mode == 'initial_balance':
|
||||
init_balance_memoizer = self._compute_initial_balances(
|
||||
accounts, start, fiscalyear)
|
||||
elif initial_balance_mode == 'opening_balance':
|
||||
init_balance_memoizer = self._read_opening_balance(accounts, start)
|
||||
|
||||
ledger_lines_memoizer = self._compute_account_ledger_lines(
|
||||
accounts, init_balance_memoizer, main_filter, target_move, start,
|
||||
stop)
|
||||
objects = self.pool.get('account.account').browse(self.cursor,
|
||||
self.uid,
|
||||
accounts)
|
||||
|
||||
init_balance = {}
|
||||
ledger_lines = {}
|
||||
for account in objects:
|
||||
if do_centralize and account.centralized \
|
||||
and ledger_lines_memoizer.get(account.id):
|
||||
ledger_lines[account.id] = self._centralize_lines(
|
||||
main_filter, ledger_lines_memoizer.get(account.id, []))
|
||||
else:
|
||||
ledger_lines[account.id] = ledger_lines_memoizer.get(
|
||||
account.id, [])
|
||||
init_balance[account.id] = init_balance_memoizer.get(account.id,
|
||||
{})
|
||||
|
||||
self.localcontext.update({
|
||||
'fiscalyear': fiscalyear,
|
||||
'start_date': start_date,
|
||||
'stop_date': stop_date,
|
||||
'start_period': start_period,
|
||||
'stop_period': stop_period,
|
||||
'chart_account': chart_account,
|
||||
'initial_balance_mode': initial_balance_mode,
|
||||
'init_balance': init_balance,
|
||||
'ledger_lines': ledger_lines,
|
||||
})
|
||||
|
||||
return super(GeneralLedgerWebkit, self).set_context(
|
||||
objects, data, new_ids, report_type=report_type)
|
||||
|
||||
def _centralize_lines(self, filter, ledger_lines, context=None):
|
||||
""" Group by period in filter mode 'period' or on one line in filter
|
||||
mode 'date' ledger_lines parameter is a list of dict built
|
||||
by _get_ledger_lines"""
|
||||
def group_lines(lines):
|
||||
if not lines:
|
||||
return {}
|
||||
sums = reduce(lambda line, memo:
|
||||
dict((key, value + memo[key]) for key, value
|
||||
in line.iteritems() if key in
|
||||
('balance', 'debit', 'credit')), lines)
|
||||
|
||||
res_lines = {
|
||||
'balance': sums['balance'],
|
||||
'debit': sums['debit'],
|
||||
'credit': sums['credit'],
|
||||
'lname': _('Centralized Entries'),
|
||||
'account_id': lines[0]['account_id'],
|
||||
}
|
||||
return res_lines
|
||||
|
||||
centralized_lines = []
|
||||
if filter == 'filter_date':
|
||||
# by date we centralize all entries in only one line
|
||||
centralized_lines.append(group_lines(ledger_lines))
|
||||
|
||||
else: # by period
|
||||
# by period we centralize all entries in one line per period
|
||||
period_obj = self.pool.get('account.period')
|
||||
# we need to sort the lines per period in order to use groupby
|
||||
# unique ids of each used period id in lines
|
||||
period_ids = list(
|
||||
set([line['lperiod_id'] for line in ledger_lines]))
|
||||
# search on account.period in order to sort them by date_start
|
||||
sorted_period_ids = period_obj.search(
|
||||
self.cr, self.uid, [('id', 'in', period_ids)],
|
||||
order='special desc, date_start', context=context)
|
||||
sorted_ledger_lines = sorted(
|
||||
ledger_lines, key=lambda x: sorted_period_ids.
|
||||
index(x['lperiod_id']))
|
||||
|
||||
for period_id, lines_per_period_iterator in groupby(
|
||||
sorted_ledger_lines, itemgetter('lperiod_id')):
|
||||
lines_per_period = list(lines_per_period_iterator)
|
||||
if not lines_per_period:
|
||||
continue
|
||||
group_per_period = group_lines(lines_per_period)
|
||||
group_per_period.update({
|
||||
'lperiod_id': period_id,
|
||||
# period code is anyway the same on each line per period
|
||||
'period_code': lines_per_period[0]['period_code'],
|
||||
})
|
||||
centralized_lines.append(group_per_period)
|
||||
|
||||
return centralized_lines
|
||||
|
||||
def _compute_account_ledger_lines(self, accounts_ids,
|
||||
init_balance_memoizer, main_filter,
|
||||
target_move, start, stop):
|
||||
res = {}
|
||||
for acc_id in accounts_ids:
|
||||
move_line_ids = self.get_move_lines_ids(
|
||||
acc_id, main_filter, start, stop, target_move)
|
||||
if not move_line_ids:
|
||||
res[acc_id] = []
|
||||
continue
|
||||
|
||||
lines = self._get_ledger_lines(move_line_ids, acc_id)
|
||||
res[acc_id] = lines
|
||||
return res
|
||||
|
||||
def _get_ledger_lines(self, move_line_ids, account_id):
|
||||
if not move_line_ids:
|
||||
return []
|
||||
res = self._get_move_line_datas(move_line_ids)
|
||||
# computing counter part is really heavy in term of ressouces
|
||||
# consuption looking for a king of SQL to help me improve it
|
||||
move_ids = [x.get('move_id') for x in res]
|
||||
counter_parts = self._get_moves_counterparts(move_ids, account_id)
|
||||
for line in res:
|
||||
line['counterparts'] = counter_parts.get(line.get('move_id'), '')
|
||||
return res
|
||||
|
||||
|
||||
HeaderFooterTextWebKitParser(
|
||||
'report.account.account_report_general_ledger_webkit',
|
||||
'account.account',
|
||||
'addons/account_financial_report_webkit/report/templates/\
|
||||
account_report_general_ledger.mako',
|
||||
parser=GeneralLedgerWebkit)
|
|
@ -1,268 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Nicolas Bessi, Guewen Baconnier
|
||||
# Copyright Camptocamp SA 2011
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from collections import defaultdict
|
||||
from datetime import datetime
|
||||
from itertools import groupby
|
||||
from operator import itemgetter
|
||||
from mako.template import Template
|
||||
|
||||
|
||||
from openerp import pooler
|
||||
from openerp.osv import osv
|
||||
from openerp.report import report_sxw
|
||||
from openerp.tools.translate import _
|
||||
from openerp.addons.report_webkit import report_helper
|
||||
from .common_partner_reports import CommonPartnersReportHeaderWebkit
|
||||
from .webkit_parser_header_fix import HeaderFooterTextWebKitParser
|
||||
from openerp.modules.module import get_module_resource
|
||||
|
||||
|
||||
def get_mako_template(obj, *args):
|
||||
template_path = get_module_resource(*args)
|
||||
return Template(filename=template_path, input_encoding='utf-8')
|
||||
|
||||
report_helper.WebKitHelper.get_mako_template = get_mako_template
|
||||
|
||||
|
||||
class PartnersOpenInvoicesWebkit(report_sxw.rml_parse,
|
||||
CommonPartnersReportHeaderWebkit):
|
||||
|
||||
def __init__(self, cursor, uid, name, context):
|
||||
super(PartnersOpenInvoicesWebkit, self).__init__(
|
||||
cursor, uid, name, context=context)
|
||||
self.pool = pooler.get_pool(self.cr.dbname)
|
||||
self.cursor = self.cr
|
||||
|
||||
company = self.pool.get('res.users').browse(
|
||||
self.cr, uid, uid, context=context).company_id
|
||||
header_report_name = ' - '.join((_('OPEN INVOICES REPORT'),
|
||||
company.name,
|
||||
company.currency_id.name))
|
||||
|
||||
footer_date_time = self.formatLang(
|
||||
str(datetime.today()), date_time=True)
|
||||
|
||||
self.localcontext.update({
|
||||
'cr': cursor,
|
||||
'uid': uid,
|
||||
'report_name': _('Open Invoices Report'),
|
||||
'display_account_raw': self._get_display_account_raw,
|
||||
'filter_form': self._get_filter,
|
||||
'target_move': self._get_target_move,
|
||||
'amount_currency': self._get_amount_currency,
|
||||
'display_partner_account': self._get_display_partner_account,
|
||||
'display_target_move': self._get_display_target_move,
|
||||
'additional_args': [
|
||||
('--header-font-name', 'Helvetica'),
|
||||
('--footer-font-name', 'Helvetica'),
|
||||
('--header-font-size', '10'),
|
||||
('--footer-font-size', '6'),
|
||||
('--header-left', header_report_name),
|
||||
('--header-spacing', '2'),
|
||||
('--footer-left', footer_date_time),
|
||||
('--footer-right',
|
||||
' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
|
||||
('--footer-line',),
|
||||
],
|
||||
})
|
||||
|
||||
def _group_lines_by_currency(self, account_br):
|
||||
account_br.grouped_ledger_lines = {}
|
||||
if not account_br.ledger_lines:
|
||||
return
|
||||
for part_id, plane_lines in account_br.ledger_lines.items():
|
||||
account_br.grouped_ledger_lines[part_id] = []
|
||||
plane_lines.sort(key=itemgetter('currency_code'))
|
||||
for curr, lines in groupby(plane_lines,
|
||||
key=itemgetter('currency_code')):
|
||||
tmp = [x for x in lines]
|
||||
account_br.grouped_ledger_lines[part_id].append(
|
||||
(curr, tmp)) # I want to reiter many times
|
||||
|
||||
def set_context(self, objects, data, ids, report_type=None):
|
||||
"""Populate a ledger_lines attribute on each browse record that will
|
||||
be used by mako template"""
|
||||
new_ids = data['form']['chart_account_id']
|
||||
# Account initial balance memoizer
|
||||
init_balance_memoizer = {}
|
||||
# Reading form
|
||||
main_filter = self._get_form_param('filter', data, default='filter_no')
|
||||
target_move = self._get_form_param('target_move', data, default='all')
|
||||
start_date = self._get_form_param('date_from', data)
|
||||
stop_date = self._get_form_param('date_to', data)
|
||||
start_period = self.get_start_period_br(data)
|
||||
stop_period = self.get_end_period_br(data)
|
||||
fiscalyear = self.get_fiscalyear_br(data)
|
||||
partner_ids = self._get_form_param('partner_ids', data)
|
||||
result_selection = self._get_form_param('result_selection', data)
|
||||
date_until = self._get_form_param('until_date', data)
|
||||
chart_account = self._get_chart_account_id_br(data)
|
||||
group_by_currency = self._get_form_param('group_by_currency', data)
|
||||
|
||||
if main_filter == 'filter_no' and fiscalyear:
|
||||
start_period = self.get_first_fiscalyear_period(fiscalyear)
|
||||
stop_period = self.get_last_fiscalyear_period(fiscalyear)
|
||||
|
||||
# Retrieving accounts
|
||||
filter_type = ('payable', 'receivable')
|
||||
if result_selection == 'customer':
|
||||
filter_type = ('receivable',)
|
||||
if result_selection == 'supplier':
|
||||
filter_type = ('payable',)
|
||||
|
||||
account_ids = self.get_all_accounts(
|
||||
new_ids, exclude_type=['view'], only_type=filter_type)
|
||||
|
||||
if not account_ids:
|
||||
raise osv.except_osv(_('Error'), _('No accounts to print.'))
|
||||
|
||||
# computation of ledeger lines
|
||||
if main_filter == 'filter_date':
|
||||
start = start_date
|
||||
stop = stop_date
|
||||
else:
|
||||
start = start_period
|
||||
stop = stop_period
|
||||
ledger_lines_memoizer = self._compute_open_transactions_lines(
|
||||
account_ids, main_filter, target_move, start, stop, date_until,
|
||||
partner_filter=partner_ids)
|
||||
objects = self.pool.get('account.account').browse(self.cursor,
|
||||
self.uid,
|
||||
account_ids)
|
||||
|
||||
ledger_lines = {}
|
||||
init_balance = {}
|
||||
partners_order = {}
|
||||
for account in objects:
|
||||
ledger_lines[account.id] = ledger_lines_memoizer.get(account.id,
|
||||
{})
|
||||
init_balance[account.id] = init_balance_memoizer.get(account.id,
|
||||
{})
|
||||
# we have to compute partner order based on inital balance
|
||||
# and ledger line as we may have partner with init bal
|
||||
# that are not in ledger line and vice versa
|
||||
ledg_lines_pids = ledger_lines_memoizer.get(account.id, {}).keys()
|
||||
non_null_init_balances = dict([
|
||||
(ib, amounts) for ib, amounts
|
||||
in init_balance[account.id].iteritems()
|
||||
if amounts['init_balance'] or
|
||||
amounts['init_balance_currency']])
|
||||
init_bal_lines_pids = non_null_init_balances.keys()
|
||||
|
||||
partners_order[account.id] = self._order_partners(
|
||||
ledg_lines_pids, init_bal_lines_pids)
|
||||
ledger_lines[account.id] = ledger_lines_memoizer.get(account.id,
|
||||
{})
|
||||
if group_by_currency:
|
||||
self._group_lines_by_currency(account)
|
||||
|
||||
self.localcontext.update({
|
||||
'fiscalyear': fiscalyear,
|
||||
'start_date': start_date,
|
||||
'stop_date': stop_date,
|
||||
'start_period': start_period,
|
||||
'stop_period': stop_period,
|
||||
'date_until': date_until,
|
||||
'partner_ids': partner_ids,
|
||||
'chart_account': chart_account,
|
||||
'ledger_lines': ledger_lines,
|
||||
'init_balance': init_balance,
|
||||
'partners_order': partners_order
|
||||
})
|
||||
|
||||
return super(PartnersOpenInvoicesWebkit, self).set_context(
|
||||
objects, data, new_ids, report_type=report_type)
|
||||
|
||||
def _compute_open_transactions_lines(self, accounts_ids, main_filter,
|
||||
target_move, start, stop,
|
||||
date_until=False,
|
||||
partner_filter=False):
|
||||
res = defaultdict(dict)
|
||||
|
||||
# we check if until date and date stop have the same value
|
||||
if main_filter in ('filter_period', 'filter_no'):
|
||||
date_stop = stop.date_stop
|
||||
date_until_match = (date_stop == date_until)
|
||||
|
||||
elif main_filter == 'filter_date':
|
||||
date_stop = stop
|
||||
date_until_match = (stop == date_until)
|
||||
|
||||
else:
|
||||
raise osv.except_osv(_('Unsuported filter'),
|
||||
_('Filter has to be in filter date, period, \
|
||||
or none'))
|
||||
|
||||
initial_move_lines_per_account = {}
|
||||
if main_filter in ('filter_period', 'filter_no'):
|
||||
initial_move_lines_per_account = self._tree_move_line_ids(
|
||||
self._partners_initial_balance_line_ids(accounts_ids,
|
||||
start,
|
||||
partner_filter,
|
||||
exclude_reconcile=True,
|
||||
force_period_ids=False,
|
||||
date_stop=date_stop),
|
||||
key='id')
|
||||
|
||||
for account_id in accounts_ids:
|
||||
initial_move_lines_ids_per_partner = \
|
||||
initial_move_lines_per_account.get(account_id, {})
|
||||
|
||||
# We get the move line ids of the account
|
||||
move_line_ids_per_partner = self.get_partners_move_lines_ids(
|
||||
account_id, main_filter, start, stop, target_move,
|
||||
exclude_reconcile=True, partner_filter=partner_filter)
|
||||
|
||||
if not initial_move_lines_ids_per_partner \
|
||||
and not move_line_ids_per_partner:
|
||||
continue
|
||||
for partner_id in list(
|
||||
set(initial_move_lines_ids_per_partner.keys() +
|
||||
move_line_ids_per_partner.keys())):
|
||||
partner_line_ids = (
|
||||
move_line_ids_per_partner.get(partner_id, []) +
|
||||
initial_move_lines_ids_per_partner.get(partner_id, []))
|
||||
|
||||
clearance_line_ids = []
|
||||
if date_until and not date_until_match and partner_line_ids:
|
||||
clearance_line_ids = self._get_clearance_move_line_ids(
|
||||
partner_line_ids, date_stop, date_until)
|
||||
partner_line_ids += clearance_line_ids
|
||||
|
||||
lines = self._get_move_line_datas(list(set(partner_line_ids)))
|
||||
for line in lines:
|
||||
if line['id'] in initial_move_lines_ids_per_partner.\
|
||||
get(partner_id, []):
|
||||
line['is_from_previous_periods'] = True
|
||||
if line['id'] in clearance_line_ids:
|
||||
line['is_clearance_line'] = True
|
||||
|
||||
res[account_id][partner_id] = lines
|
||||
return res
|
||||
|
||||
|
||||
HeaderFooterTextWebKitParser(
|
||||
'report.account.account_report_open_invoices_webkit',
|
||||
'account.account',
|
||||
'addons/account_financial_report_webkit/report/templates/\
|
||||
account_report_open_invoices.mako',
|
||||
parser=PartnersOpenInvoicesWebkit)
|
|
@ -1,101 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Guewen Baconnier
|
||||
# Copyright Camptocamp SA 2011
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from openerp import pooler
|
||||
from openerp.report import report_sxw
|
||||
from openerp.tools.translate import _
|
||||
from .common_partner_balance_reports \
|
||||
import CommonPartnerBalanceReportHeaderWebkit
|
||||
from .webkit_parser_header_fix import HeaderFooterTextWebKitParser
|
||||
|
||||
|
||||
class PartnerBalanceWebkit(report_sxw.rml_parse,
|
||||
CommonPartnerBalanceReportHeaderWebkit):
|
||||
|
||||
def __init__(self, cursor, uid, name, context):
|
||||
super(PartnerBalanceWebkit, self).__init__(
|
||||
cursor, uid, name, context=context)
|
||||
self.pool = pooler.get_pool(self.cr.dbname)
|
||||
self.cursor = self.cr
|
||||
|
||||
company = self.pool.get('res.users').browse(
|
||||
self.cr, uid, uid, context=context).company_id
|
||||
header_report_name = ' - '.join((_('PARTNER BALANCE'),
|
||||
company.name,
|
||||
company.currency_id.name))
|
||||
|
||||
footer_date_time = self.formatLang(
|
||||
str(datetime.today()), date_time=True)
|
||||
|
||||
self.localcontext.update({
|
||||
'cr': cursor,
|
||||
'uid': uid,
|
||||
'report_name': _('Partner Balance'),
|
||||
'display_account': self._get_display_account,
|
||||
'display_account_raw': self._get_display_account_raw,
|
||||
'filter_form': self._get_filter,
|
||||
'target_move': self._get_target_move,
|
||||
'display_target_move': self._get_display_target_move,
|
||||
'display_partner_account': self._get_display_partner_account,
|
||||
'accounts': self._get_accounts_br,
|
||||
'additional_args': [
|
||||
('--header-font-name', 'Helvetica'),
|
||||
('--footer-font-name', 'Helvetica'),
|
||||
('--header-font-size', '10'),
|
||||
('--footer-font-size', '6'),
|
||||
('--header-left', header_report_name),
|
||||
('--header-spacing', '2'),
|
||||
('--footer-left', footer_date_time),
|
||||
('--footer-right',
|
||||
' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
|
||||
('--footer-line',),
|
||||
],
|
||||
})
|
||||
|
||||
def _get_initial_balance_mode(self, start_period):
|
||||
""" Force computing of initial balance for the partner balance,
|
||||
because we cannot use the entries generated by
|
||||
OpenERP in the opening period.
|
||||
|
||||
OpenERP allows to reconcile move lines between different partners,
|
||||
so the generated entries in the opening period are unreliable.
|
||||
"""
|
||||
return 'initial_balance'
|
||||
|
||||
def set_context(self, objects, data, ids, report_type=None):
|
||||
"""Populate a ledger_lines attribute on each browse record that will
|
||||
be used by mako template"""
|
||||
objects, new_ids, context_report_values = self.\
|
||||
compute_partner_balance_data(data)
|
||||
|
||||
self.localcontext.update(context_report_values)
|
||||
return super(PartnerBalanceWebkit, self).set_context(
|
||||
objects, data, new_ids, report_type=report_type)
|
||||
|
||||
HeaderFooterTextWebKitParser(
|
||||
'report.account.account_report_partner_balance_webkit',
|
||||
'account.account',
|
||||
'addons/account_financial_report_webkit/report/templates/\
|
||||
account_report_partner_balance.mako',
|
||||
parser=PartnerBalanceWebkit)
|
|
@ -1,218 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Nicolas Bessi, Guewen Baconnier
|
||||
# Copyright Camptocamp SA 2011
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from collections import defaultdict
|
||||
from datetime import datetime
|
||||
|
||||
from openerp import pooler
|
||||
from openerp.osv import osv
|
||||
from openerp.report import report_sxw
|
||||
from openerp.tools.translate import _
|
||||
from .common_partner_reports import CommonPartnersReportHeaderWebkit
|
||||
from .webkit_parser_header_fix import HeaderFooterTextWebKitParser
|
||||
|
||||
|
||||
class PartnersLedgerWebkit(report_sxw.rml_parse,
|
||||
CommonPartnersReportHeaderWebkit):
|
||||
|
||||
def __init__(self, cursor, uid, name, context):
|
||||
super(PartnersLedgerWebkit, self).__init__(
|
||||
cursor, uid, name, context=context)
|
||||
self.pool = pooler.get_pool(self.cr.dbname)
|
||||
self.cursor = self.cr
|
||||
|
||||
company = self.pool.get('res.users').browse(
|
||||
self.cr, uid, uid, context=context).company_id
|
||||
header_report_name = ' - '.join((_('PARTNER LEDGER'),
|
||||
company.name,
|
||||
company.currency_id.name))
|
||||
|
||||
footer_date_time = self.formatLang(
|
||||
str(datetime.today()), date_time=True)
|
||||
|
||||
self.localcontext.update({
|
||||
'cr': cursor,
|
||||
'uid': uid,
|
||||
'report_name': _('Partner Ledger'),
|
||||
'display_account_raw': self._get_display_account_raw,
|
||||
'filter_form': self._get_filter,
|
||||
'target_move': self._get_target_move,
|
||||
'initial_balance': self._get_initial_balance,
|
||||
'amount_currency': self._get_amount_currency,
|
||||
'display_partner_account': self._get_display_partner_account,
|
||||
'display_target_move': self._get_display_target_move,
|
||||
'additional_args': [
|
||||
('--header-font-name', 'Helvetica'),
|
||||
('--footer-font-name', 'Helvetica'),
|
||||
('--header-font-size', '10'),
|
||||
('--footer-font-size', '6'),
|
||||
('--header-left', header_report_name),
|
||||
('--header-spacing', '2'),
|
||||
('--footer-left', footer_date_time),
|
||||
('--footer-right',
|
||||
' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
|
||||
('--footer-line',),
|
||||
],
|
||||
})
|
||||
|
||||
def _get_initial_balance_mode(self, start_period):
|
||||
""" Force computing of initial balance for the partner ledger,
|
||||
because we cannot use the entries generated by
|
||||
OpenERP in the opening period.
|
||||
|
||||
OpenERP allows to reconcile move lines between different partners,
|
||||
so the generated entries in the opening period are unreliable.
|
||||
"""
|
||||
return 'initial_balance'
|
||||
|
||||
def set_context(self, objects, data, ids, report_type=None):
|
||||
"""Populate a ledger_lines attribute on each browse record that will
|
||||
be used by mako template"""
|
||||
new_ids = data['form']['chart_account_id']
|
||||
|
||||
# account partner memoizer
|
||||
# Reading form
|
||||
main_filter = self._get_form_param('filter', data, default='filter_no')
|
||||
target_move = self._get_form_param('target_move', data, default='all')
|
||||
start_date = self._get_form_param('date_from', data)
|
||||
stop_date = self._get_form_param('date_to', data)
|
||||
start_period = self.get_start_period_br(data)
|
||||
stop_period = self.get_end_period_br(data)
|
||||
fiscalyear = self.get_fiscalyear_br(data)
|
||||
partner_ids = self._get_form_param('partner_ids', data)
|
||||
result_selection = self._get_form_param('result_selection', data)
|
||||
chart_account = self._get_chart_account_id_br(data)
|
||||
|
||||
if main_filter == 'filter_no' and fiscalyear:
|
||||
start_period = self.get_first_fiscalyear_period(fiscalyear)
|
||||
stop_period = self.get_last_fiscalyear_period(fiscalyear)
|
||||
|
||||
# Retrieving accounts
|
||||
filter_type = ('payable', 'receivable')
|
||||
if result_selection == 'customer':
|
||||
filter_type = ('receivable',)
|
||||
if result_selection == 'supplier':
|
||||
filter_type = ('payable',)
|
||||
|
||||
accounts = self.get_all_accounts(new_ids, exclude_type=['view'],
|
||||
only_type=filter_type)
|
||||
|
||||
if not accounts:
|
||||
raise osv.except_osv(_('Error'), _('No accounts to print.'))
|
||||
|
||||
if main_filter == 'filter_date':
|
||||
start = start_date
|
||||
stop = stop_date
|
||||
else:
|
||||
start = start_period
|
||||
stop = stop_period
|
||||
|
||||
# when the opening period is included in the selected range of periods
|
||||
# and the opening period contains move lines, we must not compute the
|
||||
# initial balance from previous periods but only display the move lines
|
||||
# of the opening period we identify them as:
|
||||
# - 'initial_balance' means compute the sums of move lines from
|
||||
# previous periods
|
||||
# - 'opening_balance' means display the move lines of the opening
|
||||
# period
|
||||
init_balance = main_filter in ('filter_no', 'filter_period')
|
||||
initial_balance_mode = init_balance and self._get_initial_balance_mode(
|
||||
start) or False
|
||||
|
||||
initial_balance_lines = {}
|
||||
if initial_balance_mode == 'initial_balance':
|
||||
initial_balance_lines = self._compute_partners_initial_balances(
|
||||
accounts, start_period, partner_filter=partner_ids,
|
||||
exclude_reconcile=False)
|
||||
|
||||
ledger_lines = self._compute_partner_ledger_lines(
|
||||
accounts, main_filter, target_move, start, stop,
|
||||
partner_filter=partner_ids)
|
||||
objects = self.pool.get('account.account').browse(self.cursor,
|
||||
self.uid,
|
||||
accounts)
|
||||
|
||||
init_balance = {}
|
||||
ledger_lines_dict = {}
|
||||
partners_order = {}
|
||||
for account in objects:
|
||||
ledger_lines_dict[account.id] = ledger_lines.get(account.id, {})
|
||||
init_balance[account.id] = initial_balance_lines.get(account.id,
|
||||
{})
|
||||
# we have to compute partner order based on inital balance
|
||||
# and ledger line as we may have partner with init bal
|
||||
# that are not in ledger line and vice versa
|
||||
ledg_lines_pids = ledger_lines.get(account.id, {}).keys()
|
||||
if initial_balance_mode:
|
||||
non_null_init_balances = dict(
|
||||
[(ib, amounts) for ib, amounts
|
||||
in init_balance[account.id].iteritems()
|
||||
if amounts['init_balance'] or
|
||||
amounts['init_balance_currency']])
|
||||
init_bal_lines_pids = non_null_init_balances.keys()
|
||||
else:
|
||||
init_balance[account.id] = {}
|
||||
init_bal_lines_pids = []
|
||||
|
||||
partners_order[account.id] = self._order_partners(
|
||||
ledg_lines_pids, init_bal_lines_pids)
|
||||
|
||||
self.localcontext.update({
|
||||
'fiscalyear': fiscalyear,
|
||||
'start_date': start_date,
|
||||
'stop_date': stop_date,
|
||||
'start_period': start_period,
|
||||
'stop_period': stop_period,
|
||||
'partner_ids': partner_ids,
|
||||
'chart_account': chart_account,
|
||||
'initial_balance_mode': initial_balance_mode,
|
||||
'init_balance': init_balance,
|
||||
'ledger_lines': ledger_lines_dict,
|
||||
'partners_order': partners_order
|
||||
})
|
||||
|
||||
return super(PartnersLedgerWebkit, self).set_context(
|
||||
objects, data, new_ids, report_type=report_type)
|
||||
|
||||
def _compute_partner_ledger_lines(self, accounts_ids, main_filter,
|
||||
target_move, start, stop,
|
||||
partner_filter=False):
|
||||
res = defaultdict(dict)
|
||||
|
||||
for acc_id in accounts_ids:
|
||||
move_line_ids = self.get_partners_move_lines_ids(
|
||||
acc_id, main_filter, start, stop, target_move,
|
||||
exclude_reconcile=False, partner_filter=partner_filter)
|
||||
if not move_line_ids:
|
||||
continue
|
||||
for partner_id in move_line_ids:
|
||||
partner_line_ids = move_line_ids.get(partner_id, [])
|
||||
lines = self._get_move_line_datas(list(set(partner_line_ids)))
|
||||
res[acc_id][partner_id] = lines
|
||||
return res
|
||||
|
||||
|
||||
HeaderFooterTextWebKitParser(
|
||||
'report.account.account_report_partners_ledger_webkit',
|
||||
'account.account',
|
||||
'addons/account_financial_report_webkit/report/templates/\
|
||||
account_report_partners_ledger.mako',
|
||||
parser=PartnersLedgerWebkit)
|
|
@ -1,168 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# account_financial_report_webkit module for OpenERP, Webkit based
|
||||
# extended report financial report
|
||||
# Copyright (C) 2012 SYLEAM Info Services (<http://www.syleam.fr/>)
|
||||
# Sebastien LANGE <sebastien.lange@syleam.fr>
|
||||
#
|
||||
# This file is a part of account_financial_report_webkit
|
||||
#
|
||||
# account_financial_report_webkit 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.
|
||||
#
|
||||
# account_financial_report_webkit 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.report import report_sxw
|
||||
from openerp.tools.translate import _
|
||||
from openerp import pooler
|
||||
from datetime import datetime
|
||||
|
||||
from .common_reports import CommonReportHeaderWebkit
|
||||
from .webkit_parser_header_fix import HeaderFooterTextWebKitParser
|
||||
|
||||
|
||||
class PrintJournalWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
|
||||
|
||||
def __init__(self, cursor, uid, name, context):
|
||||
super(PrintJournalWebkit, self).__init__(cursor, uid, name,
|
||||
context=context)
|
||||
self.pool = pooler.get_pool(self.cr.dbname)
|
||||
self.cursor = self.cr
|
||||
|
||||
company_obj = self.pool.get('res.company')
|
||||
|
||||
company_id = company_obj._company_default_get(self.cr, uid,
|
||||
'res.users',
|
||||
context=context)
|
||||
company = company_obj.browse(self.cr, uid, company_id, context=context)
|
||||
header_report_name = ' - '.join((_('JOURNALS'), company.name,
|
||||
company.currency_id.name))
|
||||
|
||||
footer_date_time = self.formatLang(str(datetime.today()),
|
||||
date_time=True)
|
||||
|
||||
self.localcontext.update({
|
||||
'cr': cursor,
|
||||
'uid': uid,
|
||||
'report_name': _('Journals'),
|
||||
'display_account_raw': self._get_display_account_raw,
|
||||
'filter_form': self._get_filter,
|
||||
'target_move': self._get_target_move,
|
||||
'initial_balance': self._get_initial_balance,
|
||||
'amount_currency': self._get_amount_currency,
|
||||
'display_partner_account': self._get_display_partner_account,
|
||||
'display_target_move': self._get_display_target_move,
|
||||
'journals': self._get_journals_br,
|
||||
'additional_args': [
|
||||
('--header-font-name', 'Helvetica'),
|
||||
('--footer-font-name', 'Helvetica'),
|
||||
('--header-font-size', '10'),
|
||||
('--footer-font-size', '6'),
|
||||
('--header-left', header_report_name),
|
||||
('--header-spacing', '2'),
|
||||
('--footer-left', footer_date_time),
|
||||
('--footer-right', ' '.join((_('Page'), '[page]', _('of'),
|
||||
'[topage]'))),
|
||||
('--footer-line',),
|
||||
],
|
||||
})
|
||||
|
||||
def set_context(self, objects, data, ids, report_type=None):
|
||||
"""Populate a ledger_lines attribute on each browse record that will
|
||||
be used by mako template"""
|
||||
|
||||
# Reading form
|
||||
main_filter = self._get_form_param('filter', data, default='filter_no')
|
||||
target_move = self._get_form_param('target_move', data, default='all')
|
||||
start_date = self._get_form_param('date_from', data)
|
||||
stop_date = self._get_form_param('date_to', data)
|
||||
start_period = self.get_start_period_br(data)
|
||||
stop_period = self.get_end_period_br(data)
|
||||
fiscalyear = self.get_fiscalyear_br(data)
|
||||
journal_ids = self._get_form_param('journal_ids', data)
|
||||
chart_account = self._get_chart_account_id_br(data)
|
||||
account_period_obj = self.pool.get('account.period')
|
||||
|
||||
domain = [('journal_id', 'in', journal_ids)]
|
||||
if main_filter == 'filter_no':
|
||||
domain += [
|
||||
('date', '>=',
|
||||
self.get_first_fiscalyear_period(fiscalyear).date_start),
|
||||
('date', '<=',
|
||||
self.get_last_fiscalyear_period(fiscalyear).date_stop),
|
||||
]
|
||||
# computation of move lines
|
||||
elif main_filter == 'filter_date':
|
||||
domain += [
|
||||
('date', '>=', start_date),
|
||||
('date', '<=', stop_date),
|
||||
]
|
||||
elif main_filter == 'filter_period':
|
||||
period_ids = account_period_obj.build_ctx_periods(self.cursor,
|
||||
self.uid,
|
||||
start_period.id,
|
||||
stop_period.id)
|
||||
domain = [
|
||||
('period_id', 'in', period_ids),
|
||||
]
|
||||
if target_move == 'posted':
|
||||
domain += [('state', '=', 'posted')]
|
||||
account_journal_period_obj = self.pool.get('account.journal.period')
|
||||
new_ids = account_journal_period_obj.search(self.cursor, self.uid, [
|
||||
('journal_id', 'in', journal_ids),
|
||||
('period_id', 'in', period_ids),
|
||||
])
|
||||
objects = account_journal_period_obj.browse(self.cursor, self.uid,
|
||||
new_ids)
|
||||
# Sort by journal and period
|
||||
objects.sorted(key=lambda a: (a.journal_id.code,
|
||||
a.period_id.date_start))
|
||||
move_obj = self.pool.get('account.move')
|
||||
moves = {}
|
||||
for journal_period in objects:
|
||||
domain_arg = [
|
||||
('journal_id', '=', journal_period.journal_id.id),
|
||||
('period_id', '=', journal_period.period_id.id),
|
||||
]
|
||||
if target_move == 'posted':
|
||||
domain_arg += [('state', '=', 'posted')]
|
||||
move_ids = move_obj.search(self.cursor, self.uid, domain_arg,
|
||||
order="name")
|
||||
moves[journal_period.id] = move_obj.browse(self.cursor, self.uid,
|
||||
move_ids)
|
||||
# Sort account move line by account accountant
|
||||
for move in moves[journal_period.id]:
|
||||
move.line_id.sorted(key=lambda a: (a.date, a.account_id.code))
|
||||
|
||||
self.localcontext.update({
|
||||
'fiscalyear': fiscalyear,
|
||||
'start_date': start_date,
|
||||
'stop_date': stop_date,
|
||||
'start_period': start_period,
|
||||
'stop_period': stop_period,
|
||||
'chart_account': chart_account,
|
||||
'moves': moves,
|
||||
})
|
||||
|
||||
return super(PrintJournalWebkit, self).set_context(
|
||||
objects, data, new_ids, report_type=report_type)
|
||||
|
||||
HeaderFooterTextWebKitParser(
|
||||
'report.account.account_report_print_journal_webkit',
|
||||
'account.journal.period',
|
||||
'addons/account_financial_report_webkit/report/templates/\
|
||||
account_report_print_journal.mako',
|
||||
parser=PrintJournalWebkit)
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -1,158 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- we do not use report tag has we can not set header ref -->
|
||||
<record id="account_report_general_ledger_webkit" model="ir.actions.report.xml">
|
||||
<field name="report_type">webkit</field>
|
||||
<field name="report_name">account.account_report_general_ledger_webkit</field>
|
||||
<field eval="[(6,0,[])]" name="groups_id"/>
|
||||
<field eval="0" name="multi"/>
|
||||
<field eval="0" name="auto"/>
|
||||
<field eval="1" name="header"/>
|
||||
<field name="model">account.account</field>
|
||||
<field name="type">ir.actions.report.xml</field>
|
||||
<field name="name">General Ledger Webkit</field>
|
||||
<field name="report_rml">account_financial_report_webkit/report/templates/account_report_general_ledger.mako</field>
|
||||
<field name="report_file">account_financial_report_webkit/report/templates/account_report_general_ledger.mako</field>
|
||||
</record>
|
||||
|
||||
<record id="property_account_report_general_ledger_webkit" model="ir.property">
|
||||
<field name="name">account_report_general_ledger_webkit</field>
|
||||
<field name="fields_id" ref="report_webkit.field_ir_act_report_xml_webkit_header"/>
|
||||
<field eval="'ir.header_webkit,'+str(ref('account_financial_report_webkit.financial_landscape_header'))" model="ir.header_webkit" name="value"/>
|
||||
<field eval="'ir.actions.report.xml,'+str(ref('account_financial_report_webkit.account_report_general_ledger_webkit'))" model="ir.actions.report.xml" name="res_id"/>
|
||||
</record>
|
||||
|
||||
<!-- we do not use report tag has we can not set header ref -->
|
||||
<record id="account_report_partners_ledger_webkit" model="ir.actions.report.xml">
|
||||
<field name="report_type">webkit</field>
|
||||
<field name="report_name">account.account_report_partners_ledger_webkit</field>
|
||||
<field eval="[(6,0,[])]" name="groups_id"/>
|
||||
<field eval="0" name="multi"/>
|
||||
<field eval="0" name="auto"/>
|
||||
<field eval="1" name="header"/>
|
||||
<field name="model">account.account</field>
|
||||
<field name="type">ir.actions.report.xml</field>
|
||||
<field name="name">Partner Ledger Webkit</field>
|
||||
<field name="report_rml">account_financial_report_webkit/report/templates/account_report_partners_ledger.mako</field>
|
||||
<field name="report_file">account_financial_report_webkit/report/templates/account_report_partners_ledger.mako</field>
|
||||
</record>
|
||||
|
||||
<record id="property_account_report_partners_ledger_webkit" model="ir.property">
|
||||
<field name="name">account_report_partners_ledger_webkit</field>
|
||||
<field name="fields_id" ref="report_webkit.field_ir_act_report_xml_webkit_header"/>
|
||||
<field eval="'ir.header_webkit,'+str(ref('account_financial_report_webkit.financial_landscape_header'))" model="ir.header_webkit" name="value"/>
|
||||
<field eval="'ir.actions.report.xml,'+str(ref('account_financial_report_webkit.account_report_partners_ledger_webkit'))" model="ir.actions.report.xml" name="res_id"/>
|
||||
</record>
|
||||
|
||||
<record id="account_report_trial_balance_webkit" model="ir.actions.report.xml">
|
||||
<field name="report_type">webkit</field>
|
||||
<field name="report_name">account.account_report_trial_balance_webkit</field>
|
||||
<field eval="[(6,0,[])]" name="groups_id"/>
|
||||
<field eval="0" name="multi"/>
|
||||
<field eval="0" name="auto"/>
|
||||
<field eval="1" name="header"/>
|
||||
<field name="model">account.account</field>
|
||||
<field name="type">ir.actions.report.xml</field>
|
||||
<field name="name">Trial Balance Webkit</field>
|
||||
<field name="report_rml">account_financial_report_webkit/report/templates/account_report_trial_balance.mako</field>
|
||||
<field name="report_file">account_financial_report_webkit/report/templates/account_report_trial_balance.mako</field>
|
||||
</record>
|
||||
|
||||
<record id="property_account_report_trial_balance_webkit" model="ir.property">
|
||||
<field name="name">account_report_trial_balance_webkit</field>
|
||||
<field name="fields_id" ref="report_webkit.field_ir_act_report_xml_webkit_header"/>
|
||||
<field eval="'ir.header_webkit,'+str(ref('account_financial_report_webkit.financial_portrait_header'))" model="ir.header_webkit" name="value"/>
|
||||
<field eval="'ir.actions.report.xml,'+str(ref('account_financial_report_webkit.account_report_trial_balance_webkit'))" model="ir.actions.report.xml" name="res_id"/>
|
||||
</record>
|
||||
|
||||
<record id="account_report_partner_balance_webkit" model="ir.actions.report.xml">
|
||||
<field name="report_type">webkit</field>
|
||||
<field name="report_name">account.account_report_partner_balance_webkit</field>
|
||||
<field eval="[(6,0,[])]" name="groups_id"/>
|
||||
<field eval="0" name="multi"/>
|
||||
<field eval="0" name="auto"/>
|
||||
<field eval="1" name="header"/>
|
||||
<field name="model">account.account</field>
|
||||
<field name="type">ir.actions.report.xml</field>
|
||||
<field name="name">Partner Balance Webkit</field>
|
||||
<field name="report_rml">account_financial_report_webkit/report/templates/account_report_partner_balance.mako</field>
|
||||
<field name="report_file">account_financial_report_webkit/report/templates/account_report_partner_balance.mako</field>
|
||||
</record>
|
||||
|
||||
<record id="property_account_report_partner_balance_webkit" model="ir.property">
|
||||
<field name="name">account_report_partner_balance_webkit</field>
|
||||
<field name="fields_id" ref="report_webkit.field_ir_act_report_xml_webkit_header"/>
|
||||
<field eval="'ir.header_webkit,'+str(ref('account_financial_report_webkit.financial_portrait_header'))" model="ir.header_webkit" name="value"/>
|
||||
<field eval="'ir.actions.report.xml,'+str(ref('account_financial_report_webkit.account_report_partner_balance_webkit'))" model="ir.actions.report.xml" name="res_id"/>
|
||||
</record>
|
||||
|
||||
<record id="account_report_open_invoices_webkit" model="ir.actions.report.xml">
|
||||
<field name="report_type">webkit</field>
|
||||
<field name="report_name">account.account_report_open_invoices_webkit</field>
|
||||
<field eval="[(6,0,[])]" name="groups_id"/>
|
||||
<field eval="0" name="multi"/>
|
||||
<field eval="0" name="auto"/>
|
||||
<field eval="1" name="header"/>
|
||||
<field name="model">account.account</field>
|
||||
<field name="type">ir.actions.report.xml</field>
|
||||
<field name="name">Open Invoices Report</field>
|
||||
<field name="report_rml">account_financial_report_webkit/report/templates/account_report_open_invoices.mako</field>
|
||||
<field name="report_file">account_financial_report_webkit/report/templates/account_report_open_invoices.mako</field>
|
||||
</record>
|
||||
|
||||
<record id="property_account_report_open_invoices_webkit" model="ir.property">
|
||||
<field name="name">account_report_open_invoices_webkit</field>
|
||||
<field name="fields_id" ref="report_webkit.field_ir_act_report_xml_webkit_header"/>
|
||||
<field eval="'ir.header_webkit,'+str(ref('account_financial_report_webkit.financial_landscape_header'))" model="ir.header_webkit" name="value"/>
|
||||
<field eval="'ir.actions.report.xml,'+str(ref('account_financial_report_webkit.account_report_open_invoices_webkit'))" model="ir.actions.report.xml" name="res_id"/>
|
||||
</record>
|
||||
|
||||
<record id="account_report_aged_trial_blanance_webkit" model="ir.actions.report.xml">
|
||||
<field name="report_type">webkit</field>
|
||||
<field name="report_name">account.account_aged_trial_balance_webkit</field>
|
||||
<field eval="[(6,0,[])]" name="groups_id"/>
|
||||
<field eval="0" name="multi"/>
|
||||
<field eval="0" name="auto"/>
|
||||
<field eval="1" name="header"/>
|
||||
<field name="model">account.account</field>
|
||||
<field name="type">ir.actions.report.xml</field>
|
||||
<field name="name">Aged Partner Balance</field>
|
||||
<field name="report_rml">account_financial_report_webkit/report/templates/aged_trial_webkit.mako</field>
|
||||
<field name="report_file">account_financial_report_webkit/report/templates/aged_trial_webkit.mako</field>
|
||||
</record>
|
||||
|
||||
<record id="property_account_report_aged_trial_balance_webkit" model="ir.property">
|
||||
<field name="name">account_aged_trial_balance_webkit</field>
|
||||
<field name="fields_id" ref="report_webkit.field_ir_act_report_xml_webkit_header"/>
|
||||
<field eval="'ir.header_webkit,'+str(ref('account_financial_report_webkit.financial_landscape_header'))"
|
||||
model="ir.header_webkit"
|
||||
name="value"/>
|
||||
<field eval="'ir.actions.report.xml,'+str(ref('account_financial_report_webkit.account_report_aged_trial_blanance_webkit'))"
|
||||
model="ir.actions.report.xml"
|
||||
name="res_id"/>
|
||||
</record>
|
||||
|
||||
<record id="account_report_print_journal_webkit" model="ir.actions.report.xml">
|
||||
<field name="report_type">webkit</field>
|
||||
<field name="report_name">account.account_report_print_journal_webkit</field>
|
||||
<field eval="[(6,0,[])]" name="groups_id"/>
|
||||
<field eval="0" name="multi"/>
|
||||
<field eval="0" name="auto"/>
|
||||
<field eval="1" name="header"/>
|
||||
<field name="model">account.move</field>
|
||||
<field name="type">ir.actions.report.xml</field>
|
||||
<field name="name">Journals</field>
|
||||
<field name="report_rml">account_financial_report_webkit/report/templates/account_report_print_journal.mako</field>
|
||||
<field name="report_file">account_financial_report_webkit/report/templates/account_report_print_journal.mako</field>
|
||||
</record>
|
||||
|
||||
<record id="property_account_report_print_journal_webkit" model="ir.property">
|
||||
<field name="name">account_report_print_journal_webkit</field>
|
||||
<field name="fields_id" ref="report_webkit.field_ir_act_report_xml_webkit_header"/>
|
||||
<field eval="'ir.header_webkit,'+str(ref('account_financial_report_webkit.financial_landscape_header'))" model="ir.header_webkit" name="value"/>
|
||||
<field eval="'ir.actions.report.xml,'+str(ref('account_financial_report_webkit.account_report_print_journal_webkit'))" model="ir.actions.report.xml" name="res_id"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,243 +0,0 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<style type="text/css">
|
||||
.overflow_ellipsis {
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
${css}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<%!
|
||||
def amount(text):
|
||||
return text.replace('-', '‑') # replace by a non-breaking hyphen (it will not word-wrap between hyphen and numbers)
|
||||
%>
|
||||
|
||||
<%setLang(user.lang)%>
|
||||
|
||||
<%
|
||||
initial_balance_text = {'initial_balance': _('Computed'), 'opening_balance': _('Opening Entries'), False: _('No')}
|
||||
%>
|
||||
|
||||
%if amount_currency(data):
|
||||
<div class="act_as_table data_table" style="width: 1205px;">
|
||||
%else:
|
||||
<div class="act_as_table data_table" style="width: 1100px;">
|
||||
%endif
|
||||
<div class="act_as_row labels">
|
||||
<div class="act_as_cell">${_('Chart of Account')}</div>
|
||||
<div class="act_as_cell">${_('Fiscal Year')}</div>
|
||||
<div class="act_as_cell">
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${_('Dates Filter')}
|
||||
%else:
|
||||
${_('Periods Filter')}
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${_('Accounts Filter')}</div>
|
||||
<div class="act_as_cell">${_('Target Moves')}</div>
|
||||
<div class="act_as_cell">${_('Initial Balance')}</div>
|
||||
</div>
|
||||
<div class="act_as_row">
|
||||
<div class="act_as_cell">${ chart_account.name }</div>
|
||||
<div class="act_as_cell">${ fiscalyear.name if fiscalyear else '-' }</div>
|
||||
<div class="act_as_cell">
|
||||
${_('From:')}
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${formatLang(start_date, date=True) if start_date else u'' }
|
||||
%else:
|
||||
${start_period.name if start_period else u''}
|
||||
%endif
|
||||
${_('To:')}
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${ formatLang(stop_date, date=True) if stop_date else u'' }
|
||||
%else:
|
||||
${stop_period.name if stop_period else u'' }
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">
|
||||
%if accounts(data):
|
||||
${', '.join([account.code for account in accounts(data)])}
|
||||
%else:
|
||||
${_('All')}
|
||||
%endif
|
||||
|
||||
</div>
|
||||
<div class="act_as_cell">${ display_target_move(data) }</div>
|
||||
<div class="act_as_cell">${ initial_balance_text[initial_balance_mode] }</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- we use div with css instead of table for tabular data because div do not cut rows at half at page breaks -->
|
||||
%for account in objects:
|
||||
<%
|
||||
display_initial_balance = init_balance[account.id] and (init_balance[account.id].get('debit') != 0.0 or init_balance[account.id].get('credit', 0.0) != 0.0)
|
||||
display_ledger_lines = ledger_lines[account.id]
|
||||
%>
|
||||
%if display_account_raw(data) == 'all' or (display_ledger_lines or display_initial_balance):
|
||||
<%
|
||||
cumul_debit = 0.0
|
||||
cumul_credit = 0.0
|
||||
cumul_balance = 0.0
|
||||
cumul_balance_curr = 0.0
|
||||
%>
|
||||
<div class="act_as_table list_table" style="margin-top: 10px;">
|
||||
|
||||
<div class="act_as_caption account_title">
|
||||
${account.code} - ${account.name}
|
||||
</div>
|
||||
<div class="act_as_thead">
|
||||
<div class="act_as_row labels">
|
||||
## date
|
||||
<div class="act_as_cell first_column" style="width: 50px;">${_('Date')}</div>
|
||||
## period
|
||||
<div class="act_as_cell" style="width: 50px;">${_('Period')}</div>
|
||||
## move
|
||||
<div class="act_as_cell" style="width: 100px;">${_('Entry')}</div>
|
||||
## journal
|
||||
<div class="act_as_cell" style="width: 70px;">${_('Journal')}</div>
|
||||
## account code
|
||||
<div class="act_as_cell" style="width: 65px;">${_('Account')}</div>
|
||||
## partner
|
||||
<div class="act_as_cell" style="width: 140px;">${_('Partner')}</div>
|
||||
## move reference
|
||||
<div class="act_as_cell" style="width: 140px;">${_('Reference')}</div>
|
||||
## label
|
||||
<div class="act_as_cell" style="width: 160px;">${_('Label')}</div>
|
||||
## counterpart
|
||||
<div class="act_as_cell" style="width: 100px;">${_('Counter part')}</div>
|
||||
## debit
|
||||
<div class="act_as_cell amount" style="width: 75px;">${_('Debit')}</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount" style="width: 75px;">${_('Credit')}</div>
|
||||
## balance cumulated
|
||||
<div class="act_as_cell amount" style="width: 75px;">${_('Cumul. Bal.')}</div>
|
||||
%if amount_currency(data):
|
||||
## currency balance
|
||||
<div class="act_as_cell amount sep_left" style="width: 75px;">${_('Curr. Balance')}</div>
|
||||
## curency code
|
||||
<div class="act_as_cell amount" style="width: 30px; text-align: right;">${_('Curr.')}</div>
|
||||
%endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="act_as_tbody">
|
||||
%if display_initial_balance:
|
||||
<%
|
||||
cumul_debit = init_balance[account.id].get('debit') or 0.0
|
||||
cumul_credit = init_balance[account.id].get('credit') or 0.0
|
||||
cumul_balance = init_balance[account.id].get('init_balance') or 0.0
|
||||
cumul_balance_curr = init_balance[account.id].get('init_balance_currency') or 0.0
|
||||
%>
|
||||
<div class="act_as_row initial_balance">
|
||||
## date
|
||||
<div class="act_as_cell first_column"></div>
|
||||
## period
|
||||
<div class="act_as_cell"></div>
|
||||
## move
|
||||
<div class="act_as_cell"></div>
|
||||
## journal
|
||||
<div class="act_as_cell"></div>
|
||||
## account code
|
||||
<div class="act_as_cell"></div>
|
||||
## partner
|
||||
<div class="act_as_cell"></div>
|
||||
## move reference
|
||||
<div class="act_as_cell"></div>
|
||||
## label
|
||||
<div class="act_as_cell">${_('Initial Balance')}</div>
|
||||
## counterpart
|
||||
<div class="act_as_cell"></div>
|
||||
## debit
|
||||
<div class="act_as_cell amount">${formatLang(init_balance[account.id].get('debit')) | amount}</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount">${formatLang(init_balance[account.id].get('credit')) | amount}</div>
|
||||
## balance cumulated
|
||||
<div class="act_as_cell amount" style="padding-right: 1px;">${formatLang(cumul_balance) | amount }</div>
|
||||
%if amount_currency(data):
|
||||
## currency balance
|
||||
<div class="act_as_cell amount sep_left">${formatLang(cumul_balance_curr) | amount }</div>
|
||||
## curency code
|
||||
<div class="act_as_cell amount"></div>
|
||||
%endif
|
||||
|
||||
</div>
|
||||
%endif
|
||||
%for line in ledger_lines[account.id]:
|
||||
<%
|
||||
cumul_debit += line.get('debit') or 0.0
|
||||
cumul_credit += line.get('credit') or 0.0
|
||||
cumul_balance_curr += line.get('amount_currency') or 0.0
|
||||
cumul_balance += line.get('balance') or 0.0
|
||||
label_elements = [line.get('lname') or '']
|
||||
if line.get('invoice_number'):
|
||||
label_elements.append("(%s)" % (line['invoice_number'],))
|
||||
label = ' '.join(label_elements)
|
||||
%>
|
||||
|
||||
<div class="act_as_row lines">
|
||||
## date
|
||||
<div class="act_as_cell first_column">${formatLang(line.get('ldate') or '', date=True)}</div>
|
||||
## period
|
||||
<div class="act_as_cell">${line.get('period_code') or ''}</div>
|
||||
## move
|
||||
<div class="act_as_cell">${line.get('move_name') or ''}</div>
|
||||
## journal
|
||||
<div class="act_as_cell">${line.get('jcode') or ''}</div>
|
||||
## account code
|
||||
<div class="act_as_cell">${account.code}</div>
|
||||
## partner
|
||||
<div class="act_as_cell overflow_ellipsis">${line.get('partner_name') or ''}</div>
|
||||
## move reference
|
||||
<div class="act_as_cell">${line.get('lref') or ''}</div>
|
||||
## label
|
||||
<div class="act_as_cell">${label}</div>
|
||||
## counterpart
|
||||
<div class="act_as_cell">${line.get('counterparts') or ''}</div>
|
||||
## debit
|
||||
<div class="act_as_cell amount">${ formatLang(line.get('debit', 0.0)) | amount }</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount">${ formatLang(line.get('credit', 0.0)) | amount }</div>
|
||||
## balance cumulated
|
||||
<div class="act_as_cell amount" style="padding-right: 1px;">${ formatLang(cumul_balance) | amount }</div>
|
||||
%if amount_currency(data):
|
||||
## currency balance
|
||||
<div class="act_as_cell amount sep_left">${formatLang(line.get('amount_currency') or 0.0) | amount }</div>
|
||||
## curency code
|
||||
<div class="act_as_cell amount" style="text-align: right;">${line.get('currency_code') or ''}</div>
|
||||
%endif
|
||||
</div>
|
||||
%endfor
|
||||
</div>
|
||||
<div class="act_as_table list_table">
|
||||
<div class="act_as_row labels" style="font-weight: bold;">
|
||||
## date
|
||||
<div class="act_as_cell first_column" style="width: 615px;">${account.code} - ${account.name}</div>
|
||||
<div class="act_as_cell" style="width: 260px;">${_("Cumulated Balance on Account")}</div>
|
||||
## debit
|
||||
<div class="act_as_cell amount" style="width: 75px;">${ formatLang(cumul_debit) | amount }</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount" style="width: 75px;">${ formatLang(cumul_credit) | amount }</div>
|
||||
## balance cumulated
|
||||
<div class="act_as_cell amount" style="width: 75px; padding-right: 1px;">${ formatLang(cumul_balance) | amount }</div>
|
||||
%if amount_currency(data):
|
||||
%if account.currency_id:
|
||||
## currency balance
|
||||
<div class="act_as_cell amount sep_left" style="width: 75px;">${formatLang(cumul_balance_curr) | amount }</div>
|
||||
%else:
|
||||
<div class="act_as_cell amount sep_left" style="width: 75px;">-</div>
|
||||
%endif
|
||||
## curency code
|
||||
<div class="act_as_cell amount" style="width: 30px; text-align: right;"></div>
|
||||
%endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
%endif
|
||||
%endfor
|
||||
</body>
|
||||
</html>
|
|
@ -1,85 +0,0 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<!DOCTYPE html SYSTEM
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<style type="text/css">
|
||||
.overflow_ellipsis {
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.open_invoice_previous_line {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.clearance_line {
|
||||
font-style: italic;
|
||||
}
|
||||
${css}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<% template1 = helper.get_mako_template('account_financial_report_webkit','report', 'templates', 'open_invoices_inclusion.mako.html') %>
|
||||
<% context.lookup.put_template('open_invoices_inclusion.mako.html', template1) %>
|
||||
<% template2 = helper.get_mako_template('account_financial_report_webkit','report', 'templates', 'grouped_by_curr_open_invoices_inclusion.mako.html') %>
|
||||
<% context.lookup.put_template('grouped_by_curr_open_invoices_inclusion.mako.html', template2) %>
|
||||
<%setLang(user.lang)%>
|
||||
|
||||
<div class="act_as_table data_table">
|
||||
<div class="act_as_row labels">
|
||||
<div class="act_as_cell">${_('Chart of Account')}</div>
|
||||
<div class="act_as_cell">${_('Fiscal Year')}</div>
|
||||
<div class="act_as_cell">
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${_('Dates Filter')}
|
||||
%else:
|
||||
${_('Periods Filter')}
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${_('Clearance Date')}</div>
|
||||
<div class="act_as_cell">${_('Accounts Filter')}</div>
|
||||
<div class="act_as_cell">${_('Target Moves')}</div>
|
||||
|
||||
</div>
|
||||
<div class="act_as_row">
|
||||
<div class="act_as_cell">${ chart_account.name }</div>
|
||||
<div class="act_as_cell">${ fiscalyear.name if fiscalyear else '-' }</div>
|
||||
<div class="act_as_cell">
|
||||
${_('From:')}
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${formatLang(start_date, date=True) if start_date else u'' }
|
||||
%else:
|
||||
${start_period.name if start_period else u''}
|
||||
%endif
|
||||
${_('To:')}
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${ formatLang(stop_date, date=True) if stop_date else u'' }
|
||||
%else:
|
||||
${stop_period.name if stop_period else u'' }
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${ formatLang(date_until, date=True) }</div>
|
||||
<div class="act_as_cell">
|
||||
%if partner_ids:
|
||||
${_('Custom Filter')}
|
||||
%else:
|
||||
${ display_partner_account(data) }
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${ display_target_move(data) }</div>
|
||||
</div>
|
||||
</div>
|
||||
%for acc in objects:
|
||||
%if 'grouped_ledger_lines' in acc:
|
||||
<% fl = formatLang %>
|
||||
<%include file="grouped_by_curr_open_invoices_inclusion.mako.html" args="account=acc,formatLang=fl"/>
|
||||
%else:
|
||||
<% fl = formatLang %>
|
||||
<%include file="open_invoices_inclusion.mako.html" args="account=acc,formatLang=fl"/>
|
||||
%endif
|
||||
%endfor
|
||||
</body>
|
||||
</html>
|
|
@ -1,291 +0,0 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<style type="text/css">
|
||||
${css}
|
||||
|
||||
.list_table .act_as_row {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
font-size:10px;
|
||||
}
|
||||
|
||||
.account_line {
|
||||
font-weight: bold;
|
||||
font-size: 15px;
|
||||
background-color:#F0F0F0;
|
||||
}
|
||||
|
||||
.account_line .act_as_cell {
|
||||
height: 30px;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<%!
|
||||
def amount(text):
|
||||
return text.replace('-', '‑') # replace by a non-breaking hyphen (it will not word-wrap between hyphen and numbers)
|
||||
|
||||
def display_line(all_comparison_lines):
|
||||
return any([line.get('balance') for line in all_comparison_lines])
|
||||
%>
|
||||
|
||||
<%setLang(user.lang)%>
|
||||
|
||||
<%
|
||||
initial_balance_text = {'initial_balance': _('Computed'), 'opening_balance': _('Opening Entries'), False: _('No')}
|
||||
%>
|
||||
|
||||
<div class="act_as_table data_table">
|
||||
<div class="act_as_row labels">
|
||||
<div class="act_as_cell">${_('Chart of Account')}</div>
|
||||
<div class="act_as_cell">${_('Fiscal Year')}</div>
|
||||
<div class="act_as_cell">
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${_('Dates Filter')}
|
||||
%else:
|
||||
${_('Periods Filter')}
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${_('Accounts Filter')}</div>
|
||||
<div class="act_as_cell">${_('Partners Filter')}</div>
|
||||
<div class="act_as_cell">${_('Target Moves')}</div>
|
||||
<div class="act_as_cell">${_('Initial Balance')}</div>
|
||||
</div>
|
||||
<div class="act_as_row">
|
||||
<div class="act_as_cell">${ chart_account.name }</div>
|
||||
<div class="act_as_cell">${ fiscalyear.name if fiscalyear else '-' }</div>
|
||||
<div class="act_as_cell">
|
||||
${_('From:')}
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${formatLang(start_date, date=True) if start_date else u'' }
|
||||
%else:
|
||||
${start_period.name if start_period else u''}
|
||||
%endif
|
||||
${_('To:')}
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${ formatLang(stop_date, date=True) if stop_date else u'' }
|
||||
%else:
|
||||
${stop_period.name if stop_period else u'' }
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">
|
||||
%if accounts(data):
|
||||
${', '.join([account.code for account in accounts(data)])}
|
||||
%else:
|
||||
${_('All')}
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${display_partner_account(data)}</div>
|
||||
<div class="act_as_cell">${ display_target_move(data) }</div>
|
||||
<div class="act_as_cell">${ initial_balance_text[initial_balance_mode] }</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
%for index, params in enumerate(comp_params):
|
||||
<div class="act_as_table data_table">
|
||||
<div class="act_as_row">
|
||||
<div class="act_as_cell">${_('Comparison %s') % (index + 1,)} (${"C%s" % (index + 1,)})</div>
|
||||
<div class="act_as_cell">
|
||||
%if params['comparison_filter'] == 'filter_date':
|
||||
${_('Dates Filter:')} ${formatLang(params['start'], date=True) } - ${formatLang(params['stop'], date=True) }
|
||||
%elif params['comparison_filter'] == 'filter_period':
|
||||
${_('Periods Filter:')} ${params['start'].name} - ${params['stop'].name}
|
||||
%else:
|
||||
${_('Fiscal Year :')} ${params['fiscalyear'].name}
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${ _('Initial Balance:')} ${ initial_balance_text[params['initial_balance_mode']] }</div>
|
||||
</div>
|
||||
</div>
|
||||
%endfor
|
||||
|
||||
%for current_account in objects:
|
||||
<%
|
||||
partners_order = partners_order_accounts[current_account.id]
|
||||
|
||||
# do not display accounts without partners
|
||||
if not partners_order:
|
||||
continue
|
||||
|
||||
comparisons = comparisons_accounts[current_account.id]
|
||||
|
||||
# in multiple columns mode, we do not want to print accounts without any rows
|
||||
if comparison_mode in ('single', 'multiple'):
|
||||
all_comparison_lines = [comp['partners_amounts'][partner_id[1]]
|
||||
for partner_id in partners_order
|
||||
for comp in comparisons]
|
||||
if not display_line(all_comparison_lines):
|
||||
continue
|
||||
|
||||
current_partner_amounts = partners_amounts_accounts[current_account.id]
|
||||
|
||||
total_initial_balance = 0.0
|
||||
total_debit = 0.0
|
||||
total_credit = 0.0
|
||||
total_balance = 0.0
|
||||
if comparison_mode in ('single', 'multiple'):
|
||||
comparison_total = {}
|
||||
for i, comp in enumerate(comparisons):
|
||||
comparison_total[i] = {'balance': 0.0}
|
||||
%>
|
||||
|
||||
<div class="account_title bg" style="margin-top: 20px; font-size: 12px; width: 690px;">${current_account.code} - ${current_account.name}</div>
|
||||
|
||||
<div class="act_as_table list_table">
|
||||
|
||||
<div class="act_as_thead">
|
||||
<div class="act_as_row labels">
|
||||
## account name
|
||||
<div class="act_as_cell" style="width: 80px;">${_('Account / Partner Name')}</div>
|
||||
## code
|
||||
<div class="act_as_cell first_column" style="width: 20px;">${_('Code / Ref')}</div>
|
||||
%if comparison_mode == 'no_comparison':
|
||||
%if initial_balance_mode:
|
||||
## initial balance
|
||||
<div class="act_as_cell amount" style="width: 30px;">${_('Initial Balance')}</div>
|
||||
%endif
|
||||
## debit
|
||||
<div class="act_as_cell amount" style="width: 30px;">${_('Debit')}</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount" style="width: 30px;">${_('Credit')}</div>
|
||||
%endif
|
||||
## balance
|
||||
<div class="act_as_cell amount" style="width: 30px;">
|
||||
%if comparison_mode == 'no_comparison' or not fiscalyear:
|
||||
${_('Balance')}
|
||||
%else:
|
||||
${_('Balance %s') % (fiscalyear.name,)}
|
||||
%endif
|
||||
</div>
|
||||
%if comparison_mode in ('single', 'multiple'):
|
||||
%for index in range(nb_comparison):
|
||||
<div class="act_as_cell amount" style="width: 30px;">
|
||||
%if comp_params[index]['comparison_filter'] == 'filter_year' and comp_params[index].get('fiscalyear', False):
|
||||
${_('Balance %s') % (comp_params[index]['fiscalyear'].name,)}
|
||||
%else:
|
||||
${_('Balance C%s') % (index + 1,)}
|
||||
%endif
|
||||
</div>
|
||||
%if comparison_mode == 'single': ## no diff in multiple comparisons because it shows too data
|
||||
<div class="act_as_cell amount" style="width: 30px;">${_('Difference')}</div>
|
||||
<div class="act_as_cell amount" style="width: 30px;">${_('% Difference')}</div>
|
||||
%endif
|
||||
%endfor
|
||||
%endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="act_as_tbody">
|
||||
|
||||
%for (partner_code_name, partner_id, partner_ref, partner_name) in partners_order:
|
||||
<%
|
||||
partner = current_partner_amounts.get(partner_id, {})
|
||||
|
||||
# in single mode, we have to display all the partners
|
||||
# even if their balance is 0.0 because the initial balance
|
||||
# should match with the previous year closings
|
||||
|
||||
# in multiple columns mode, we do not want to print partners
|
||||
# which have a balance at 0.0 in each comparison column
|
||||
if comparison_mode in ('single', 'multiple'):
|
||||
all_comparison_lines = [comp['partners_amounts'][partner_id]
|
||||
for comp in comparisons
|
||||
if comp['partners_amounts'].get(partner_id)]
|
||||
if not display_line(all_comparison_lines):
|
||||
continue
|
||||
|
||||
total_initial_balance += partner.get('init_balance', 0.0)
|
||||
total_debit += partner.get('debit', 0.0)
|
||||
total_credit += partner.get('credit', 0.0)
|
||||
total_balance += partner.get('balance', 0.0)
|
||||
%>
|
||||
<div class="act_as_row lines">
|
||||
<div class="act_as_cell">${partner_name if partner_name else _('Unallocated') }</div>
|
||||
<div class="act_as_cell first_column">${partner_ref if partner_ref else ''}</div>
|
||||
%if comparison_mode == 'no_comparison':
|
||||
%if initial_balance_mode:
|
||||
<div class="act_as_cell amount">${formatLang(partner.get('init_balance', 0.0)) | amount}</div>
|
||||
%endif
|
||||
<div class="act_as_cell amount">${formatLang(partner.get('debit', 0.0)) | amount}</div>
|
||||
<div class="act_as_cell amount">${formatLang(partner.get('credit', 0.0)) | amount}</div>
|
||||
%endif
|
||||
<div class="act_as_cell amount">${formatLang(partner['balance'] if partner else 0.0) | amount}</div>
|
||||
|
||||
%if comparison_mode in ('single', 'multiple'):
|
||||
%for i, comp in enumerate(comparisons):
|
||||
<%
|
||||
comp_partners = comp['partners_amounts']
|
||||
balance = diff = percent_diff = 0
|
||||
if comp_partners.get(partner_id):
|
||||
balance = comp_partners[partner_id]['balance']
|
||||
diff = comp_partners[partner_id]['diff']
|
||||
percent_diff = comp_partners[partner_id]['percent_diff']
|
||||
comparison_total[i]['balance'] += balance
|
||||
%>
|
||||
<div class="act_as_cell amount">${formatLang(balance) | amount}</div>
|
||||
%if comparison_mode == 'single': ## no diff in multiple comparisons because it shows too data
|
||||
<div class="act_as_cell amount">${formatLang(diff) | amount}</div>
|
||||
<div class="act_as_cell amount">
|
||||
%if percent_diff is False:
|
||||
${ '-' }
|
||||
%else:
|
||||
${int(round(percent_diff)) | amount} %
|
||||
%endif
|
||||
</div>
|
||||
%endif
|
||||
%endfor
|
||||
%endif
|
||||
</div>
|
||||
%endfor
|
||||
|
||||
</div>
|
||||
<div class="act_as_tfoot" style="margin-top:5px;">
|
||||
<div class="act_as_row labels" style="font-weight: bold; font-size: 11x;">
|
||||
## account name
|
||||
<div class="act_as_cell">${current_account.name}</div>
|
||||
## code
|
||||
<div class="act_as_cell first_column">${current_account.code}</div>
|
||||
%if comparison_mode == 'no_comparison':
|
||||
%if initial_balance_mode:
|
||||
## opening balance
|
||||
<div class="act_as_cell amount">${formatLang(total_initial_balance) | amount}</div>
|
||||
%endif
|
||||
## debit
|
||||
<div class="act_as_cell amount">${formatLang(total_debit) | amount}</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount">${formatLang(total_credit and total_credit * -1 or 0.0) | amount}</div>
|
||||
%endif
|
||||
## balance
|
||||
<div class="act_as_cell amount">${formatLang(total_balance) | amount}</div>
|
||||
|
||||
%if comparison_mode in ('single', 'multiple'):
|
||||
%for i, comp in enumerate(comparisons):
|
||||
<%
|
||||
comp_account = comp['account']
|
||||
diffs = compute_diff(total_balance, comparison_total[i]['balance'])
|
||||
%>
|
||||
<div class="act_as_cell amount">${formatLang(comparison_total[i]['balance']) | amount}</div>
|
||||
%if comparison_mode == 'single': ## no diff in multiple comparisons because it shows too data
|
||||
<div class="act_as_cell amount">${formatLang(diffs['diff']) | amount}</div>
|
||||
<div class="act_as_cell amount">
|
||||
%if diffs['percent_diff'] is False:
|
||||
${ '-' }
|
||||
%else:
|
||||
${int(round(diffs['percent_diff'])) | amount} %
|
||||
%endif
|
||||
</div>
|
||||
%endif
|
||||
%endfor
|
||||
%endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
%endfor
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,290 +0,0 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<style type="text/css">
|
||||
.overflow_ellipsis {
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
${css}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<%!
|
||||
def amount(text):
|
||||
return text.replace('-', '‑') # replace by a non-breaking hyphen (it will not word-wrap between hyphen and numbers)
|
||||
%>
|
||||
|
||||
<%setLang(user.lang)%>
|
||||
|
||||
<%
|
||||
initial_balance_text = {'initial_balance': _('Computed'), 'opening_balance': _('Opening Entries'), False: _('No')}
|
||||
%>
|
||||
|
||||
<div class="act_as_table data_table">
|
||||
<div class="act_as_row labels">
|
||||
<div class="act_as_cell">${_('Chart of Account')}</div>
|
||||
<div class="act_as_cell">${_('Fiscal Year')}</div>
|
||||
<div class="act_as_cell">
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${_('Dates Filter')}
|
||||
%else:
|
||||
${_('Periods Filter')}
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${_('Accounts Filter')}</div>
|
||||
<div class="act_as_cell">${_('Target Moves')}</div>
|
||||
<div class="act_as_cell">${_('Initial Balance')}</div>
|
||||
</div>
|
||||
<div class="act_as_row">
|
||||
<div class="act_as_cell">${ chart_account.name }</div>
|
||||
<div class="act_as_cell">${ fiscalyear.name if fiscalyear else '-' }</div>
|
||||
<div class="act_as_cell">
|
||||
${_('From:')}
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${formatLang(start_date, date=True) if start_date else u'' }
|
||||
%else:
|
||||
${start_period.name if start_period else u''}
|
||||
%endif
|
||||
${_('To:')}
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${ formatLang(stop_date, date=True) if stop_date else u'' }
|
||||
%else:
|
||||
${stop_period.name if stop_period else u'' }
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">
|
||||
%if partner_ids:
|
||||
${_('Custom Filter')}
|
||||
%else:
|
||||
${ display_partner_account(data) }
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${ display_target_move(data) }</div>
|
||||
<div class="act_as_cell">${ initial_balance_text[initial_balance_mode] }</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
%for account in objects:
|
||||
%if ledger_lines[account.id] or init_balance[account.id]:
|
||||
<%
|
||||
if not partners_order[account.id]:
|
||||
continue
|
||||
account_total_debit = 0.0
|
||||
account_total_credit = 0.0
|
||||
account_balance_cumul = 0.0
|
||||
account_balance_cumul_curr = 0.0
|
||||
%>
|
||||
|
||||
<div class="account_title bg" style="width: 1080px; margin-top: 20px; font-size: 12px;">${account.code} - ${account.name}</div>
|
||||
|
||||
%for partner_name, p_id, p_ref, p_name in partners_order[account.id]:
|
||||
<%
|
||||
total_debit = 0.0
|
||||
total_credit = 0.0
|
||||
cumul_balance = 0.0
|
||||
cumul_balance_curr = 0.0
|
||||
|
||||
part_cumul_balance = 0.0
|
||||
part_cumul_balance_curr = 0.0
|
||||
%>
|
||||
<div class="act_as_table list_table" style="margin-top: 5px;">
|
||||
<div class="act_as_caption account_title">
|
||||
${partner_name or _('No Partner')}
|
||||
</div>
|
||||
<div class="act_as_thead">
|
||||
<div class="act_as_row labels">
|
||||
## date
|
||||
<div class="act_as_cell first_column" style="width: 50px;">${_('Date')}</div>
|
||||
## period
|
||||
<div class="act_as_cell" style="width: 70px;">${_('Period')}</div>
|
||||
## move
|
||||
<div class="act_as_cell" style="width: 100px;">${_('Entry')}</div>
|
||||
## journal
|
||||
<div class="act_as_cell" style="width: 70px;">${_('Journal')}</div>
|
||||
## partner
|
||||
<div class="act_as_cell" style="width: 100px;">${_('Partner')}</div>
|
||||
## move reference
|
||||
<div class="act_as_cell" style="width: 60px;">${_('Reference')}</div>
|
||||
## label
|
||||
<div class="act_as_cell" style="width: 280px;">${_('Label')}</div>
|
||||
## reconcile
|
||||
<div class="act_as_cell" style="width: 80px;">${_('Rec.')}</div>
|
||||
## debit
|
||||
<div class="act_as_cell amount" style="width: 80px;">${_('Debit')}</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount" style="width: 80px;">${_('Credit')}</div>
|
||||
## balance cumulated
|
||||
<div class="act_as_cell amount" style="width: 80px;">${_('Cumul. Bal.')}</div>
|
||||
%if amount_currency(data):
|
||||
## currency balance
|
||||
<div class="act_as_cell amount sep_left" style="width: 80px;">${_('Curr. Balance')}</div>
|
||||
## curency code
|
||||
<div class="act_as_cell amount" style="width: 30px; text-align: right;">${_('Curr.')}</div>
|
||||
%endif
|
||||
</div>
|
||||
</div>
|
||||
<div class="act_as_tbody">
|
||||
<%
|
||||
total_debit = init_balance[account.id].get(p_id, {}).get('debit') or 0.0
|
||||
total_credit =init_balance[account.id].get(p_id, {}).get('credit') or 0.0
|
||||
%>
|
||||
%if initial_balance_mode and (total_debit or total_credit):
|
||||
<%
|
||||
part_cumul_balance = init_balance[account.id].get(p_id, {}).get('init_balance') or 0.0
|
||||
part_cumul_balance_curr = init_balance[account.id].get(p_id, {}).get('init_balance_currency') or 0.0
|
||||
balance_forward_currency = init_balance[account.id].get(p_id, {}).get('currency_name') or ''
|
||||
|
||||
cumul_balance += part_cumul_balance
|
||||
cumul_balance_curr += part_cumul_balance_curr
|
||||
%>
|
||||
<div class="act_as_row initial_balance">
|
||||
## date
|
||||
<div class="act_as_cell first_column"></div>
|
||||
## period
|
||||
<div class="act_as_cell"></div>
|
||||
## move
|
||||
<div class="act_as_cell"></div>
|
||||
## journal
|
||||
<div class="act_as_cell"></div>
|
||||
## partner
|
||||
<div class="act_as_cell"></div>
|
||||
## move reference
|
||||
<div class="act_as_cell"></div>
|
||||
## label
|
||||
<div class="act_as_cell" >${_('Initial Balance')}</div>
|
||||
## reconcile
|
||||
<div class="act_as_cell"></div>
|
||||
## debit
|
||||
<div class="act_as_cell amount">${formatLang(total_debit) | amount }</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount">${formatLang(total_credit) | amount }</div>
|
||||
## balance cumulated
|
||||
<div class="act_as_cell amount" style="padding-right: 1px;">${formatLang(part_cumul_balance) | amount }</div>
|
||||
%if amount_currency(data):
|
||||
## currency balance
|
||||
<div class="act_as_cell sep_left amount">${formatLang(part_cumul_balance_curr) | amount }</div>
|
||||
## curency code
|
||||
<div class="act_as_cell">${balance_forward_currency}</div>
|
||||
%endif
|
||||
|
||||
</div>
|
||||
%endif
|
||||
|
||||
%for line in ledger_lines[account.id].get(p_id, []):
|
||||
<%
|
||||
total_debit += line.get('debit') or 0.0
|
||||
total_credit += line.get('credit') or 0.0
|
||||
|
||||
label_elements = [line.get('lname') or '']
|
||||
if line.get('invoice_number'):
|
||||
label_elements.append("(%s)" % (line['invoice_number'],))
|
||||
label = ' '.join(label_elements)
|
||||
%>
|
||||
<div class="act_as_row lines">
|
||||
## date
|
||||
<div class="act_as_cell first_column">${formatLang(line.get('ldate') or '', date=True)}</div>
|
||||
## period
|
||||
<div class="act_as_cell">${line.get('period_code') or ''}</div>
|
||||
## move
|
||||
<div class="act_as_cell">${line.get('move_name') or ''}</div>
|
||||
## journal
|
||||
<div class="act_as_cell">${line.get('jcode') or ''}</div>
|
||||
## partner
|
||||
<div class="act_as_cell overflow_ellipsis">${line.get('partner_name') or ''}</div>
|
||||
## move reference
|
||||
<div class="act_as_cell">${line.get('lref') or ''}</div>
|
||||
## label
|
||||
<div class="act_as_cell">${label}</div>
|
||||
## reconcile
|
||||
<div class="act_as_cell">${line.get('rec_name') or ''}</div>
|
||||
## debit
|
||||
<div class="act_as_cell amount">${formatLang(line.get('debit') or 0.0) | amount }</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount">${formatLang(line.get('credit') or 0.0) | amount }</div>
|
||||
## balance cumulated
|
||||
<% cumul_balance += line.get('balance') or 0.0 %>
|
||||
<div class="act_as_cell amount" style="padding-right: 1px;">${formatLang(cumul_balance) | amount }</div>
|
||||
%if amount_currency(data):
|
||||
## currency balance
|
||||
<div class="act_as_cell sep_left amount">${formatLang(line.get('amount_currency') or 0.0) | amount }</div>
|
||||
## curency code
|
||||
<div class="act_as_cell" style="text-align: right; ">${line.get('currency_code') or ''}</div>
|
||||
%endif
|
||||
</div>
|
||||
%endfor
|
||||
<div class="act_as_row lines labels">
|
||||
## date
|
||||
<div class="act_as_cell first_column"></div>
|
||||
## period
|
||||
<div class="act_as_cell"></div>
|
||||
## move
|
||||
<div class="act_as_cell"></div>
|
||||
## journal
|
||||
<div class="act_as_cell"></div>
|
||||
## partner
|
||||
<div class="act_as_cell"></div>
|
||||
## move reference
|
||||
<div class="act_as_cell"></div>
|
||||
## label
|
||||
<div class="act_as_cell">${_('Cumulated Balance on Partner')}</div>
|
||||
## reconcile
|
||||
<div class="act_as_cell"></div>
|
||||
## debit
|
||||
<div class="act_as_cell amount">${formatLang(total_debit) | amount }</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount">${formatLang(total_credit) | amount }</div>
|
||||
## balance cumulated
|
||||
<div class="act_as_cell amount" style="padding-right: 1px;">${formatLang(cumul_balance) | amount }</div>
|
||||
%if amount_currency(data):
|
||||
## currency balance
|
||||
%if account.currency_id:
|
||||
<div class="act_as_cell amount sep_left">${formatLang(cumul_balance_curr) | amount }</div>
|
||||
%else:
|
||||
<div class="act_as_cell sep_left amount">${ u'-' }</div>
|
||||
%endif
|
||||
## currency code
|
||||
<div class="act_as_cell" style="text-align: right; padding-right: 1px;">${ account.currency_id.name if account.currency_id else u'' }</div>
|
||||
%endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%
|
||||
account_total_debit += total_debit
|
||||
account_total_credit += total_credit
|
||||
account_balance_cumul += cumul_balance
|
||||
account_balance_cumul_curr += cumul_balance_curr
|
||||
%>
|
||||
%endfor
|
||||
|
||||
<div class="act_as_table list_table" style="margin-top:5px;">
|
||||
<div class="act_as_row labels" style="font-weight: bold; font-size: 12px;">
|
||||
<div class="act_as_cell first_column" style="width: 450px;">${account.code} - ${account.name}</div>
|
||||
## label
|
||||
<div class="act_as_cell" style="width: 360px;">${_("Cumulated Balance on Account")}</div>
|
||||
## debit
|
||||
<div class="act_as_cell amount" style="width: 80px;">${ formatLang(account_total_debit) | amount }</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount" style="width: 80px;">${ formatLang(account_total_credit) | amount }</div>
|
||||
## balance cumulated
|
||||
<div class="act_as_cell amount" style="width: 80px; padding-right: 1px;">${ formatLang(account_balance_cumul) | amount }</div>
|
||||
%if amount_currency(data):
|
||||
## currency balance
|
||||
%if account.currency_id:
|
||||
<div class="act_as_cell amount sep_left" style="width: 80px;">${ formatLang(account_balance_cumul_curr) | amount }</div>
|
||||
%else:
|
||||
<div class="act_as_cell amount sep_left" style="width: 80px;">${ u'-' }</div>
|
||||
%endif
|
||||
## curency code
|
||||
<div class="act_as_cell amount" style="width: 30px; text-align: right; padding-right: 1px;">${ account.currency_id.name if account.currency_id else u'' }</div>
|
||||
%endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
%endif
|
||||
%endfor
|
||||
</body>
|
||||
</html>
|
|
@ -1,170 +0,0 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<style type="text/css">
|
||||
.overflow_ellipsis {
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
${css}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<%!
|
||||
def amount(text):
|
||||
return text.replace('-', '‑') # replace by a non-breaking hyphen (it will not word-wrap between hyphen and numbers)
|
||||
%>
|
||||
|
||||
<%setLang(user.lang)%>
|
||||
|
||||
<div class="act_as_table data_table">
|
||||
<div class="act_as_row labels">
|
||||
<div class="act_as_cell">${_('Chart of Account')}</div>
|
||||
<div class="act_as_cell">${_('Fiscal Year')}</div>
|
||||
<div class="act_as_cell">
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${_('Dates Filter')}
|
||||
%else:
|
||||
${_('Periods Filter')}
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${_('Journal Filter')}</div>
|
||||
<div class="act_as_cell">${_('Target Moves')}</div>
|
||||
</div>
|
||||
<div class="act_as_row">
|
||||
<div class="act_as_cell">${ chart_account.name }</div>
|
||||
<div class="act_as_cell">${ fiscalyear.name if fiscalyear else '-' }</div>
|
||||
<div class="act_as_cell">
|
||||
${_('From:')}
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${formatLang(start_date, date=True) if start_date else u'' }
|
||||
%else:
|
||||
${start_period.name if start_period else u''}
|
||||
%endif
|
||||
${_('To:')}
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${ formatLang(stop_date, date=True) if stop_date else u'' }
|
||||
%else:
|
||||
${stop_period.name if stop_period else u'' }
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">
|
||||
%if journals(data):
|
||||
${', '.join([journal.name for journal in journals(data)])}
|
||||
%else:
|
||||
${_('All')}
|
||||
%endif
|
||||
|
||||
</div>
|
||||
<div class="act_as_cell">${ display_target_move(data) }</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
%for journal_period in objects:
|
||||
<%
|
||||
account_total_debit = 0.0
|
||||
account_total_credit = 0.0
|
||||
account_total_currency = 0.0
|
||||
%>
|
||||
|
||||
<div class="account_title bg" style="width: 1080px; margin-top: 20px; font-size: 12px;">${journal_period.journal_id.name} - ${journal_period.period_id.name}</div>
|
||||
|
||||
<!-- we use div with css instead of table for tabular data because div do not cut rows at half at page breaks -->
|
||||
<div class="act_as_table list_table" style="margin-top: 5px;">
|
||||
<div class="act_as_thead">
|
||||
<div class="act_as_row labels">
|
||||
## date
|
||||
<div class="act_as_cell first_column">${_('Date')}</div>
|
||||
## move
|
||||
<div class="act_as_cell">${_('Entry')}</div>
|
||||
## account code
|
||||
<div class="act_as_cell">${_('Account')}</div>
|
||||
## date
|
||||
<div class="act_as_cell">${_('Due Date')}</div>
|
||||
## partner
|
||||
<div class="act_as_cell" style="width: 280px;">${_('Partner')}</div>
|
||||
## label
|
||||
<div class="act_as_cell" style="width: 310px;">${_('Label')}</div>
|
||||
## debit
|
||||
<div class="act_as_cell amount">${_('Debit')}</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount">${_('Credit')}</div>
|
||||
%if amount_currency(data):
|
||||
## currency balance
|
||||
<div class="act_as_cell amount sep_left">${_('Curr. Balance')}</div>
|
||||
## curency code
|
||||
<div class="act_as_cell amount" style="text-align: right;">${_('Curr.')}</div>
|
||||
%endif
|
||||
</div>
|
||||
</div>
|
||||
%for move in moves[journal_period.id]:
|
||||
<%
|
||||
new_move = True
|
||||
%>
|
||||
|
||||
%for line in move.line_id:
|
||||
<div class="act_as_tbody">
|
||||
<%
|
||||
account_total_debit += line.debit or 0.0
|
||||
account_total_credit += line.credit or 0.0
|
||||
%>
|
||||
<div class="act_as_row lines">
|
||||
## date
|
||||
<div class="act_as_cell first_column">${formatLang(move.date, date=True) if new_move else ''}</div>
|
||||
## move
|
||||
<div class="act_as_cell">${move.name if new_move else ''}</div>
|
||||
## account code
|
||||
<div class="act_as_cell">${line.account_id.code}</div>
|
||||
## date
|
||||
<div class="act_as_cell">${formatLang(line.date_maturity or '', date=True)}</div>
|
||||
## partner
|
||||
<div class="act_as_cell overflow_ellipsis" style="width: 280px;">${line.partner_id.name if new_move else ''}</div>
|
||||
## label
|
||||
<div class="act_as_cell overflow_ellipsis" style="width: 310px;">${line.name}</div>
|
||||
## debit
|
||||
<div class="act_as_cell amount">${formatLang(line.debit) if line.debit else ''}</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount">${formatLang(line.credit) if line.credit else ''}</div>
|
||||
%if amount_currency(data):
|
||||
## currency balance
|
||||
<div class="act_as_cell amount sep_left">${formatLang(line.amount_currency) if line.amount_currency else ''}</div>
|
||||
## curency code
|
||||
<div class="act_as_cell amount" style="text-align: right;">${line.currency_id.symbol or ''}</div>
|
||||
%endif
|
||||
</div>
|
||||
<%
|
||||
new_move = False
|
||||
%>
|
||||
</div>
|
||||
%endfor
|
||||
%endfor
|
||||
<div class="act_as_row lines labels">
|
||||
## date
|
||||
<div class="act_as_cell first_column"></div>
|
||||
## move
|
||||
<div class="act_as_cell"></div>
|
||||
## account code
|
||||
<div class="act_as_cell"></div>
|
||||
## date
|
||||
<div class="act_as_cell"></div>
|
||||
## partner
|
||||
<div class="act_as_cell" style="width: 280px;"></div>
|
||||
## label
|
||||
<div class="act_as_cell" style="width: 310px;"></div>
|
||||
## debit
|
||||
<div class="act_as_cell amount">${formatLang(account_total_debit) | amount }</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount">${formatLang(account_total_credit) | amount }</div>
|
||||
%if amount_currency(data):
|
||||
## currency balance
|
||||
<div class="act_as_cell amount sep_left"></div>
|
||||
## currency code
|
||||
<div class="act_as_cell" style="text-align: right; right;"></div>
|
||||
%endif
|
||||
</div>
|
||||
</div>
|
||||
%endfor
|
||||
</body>
|
||||
</html>
|
|
@ -1,211 +0,0 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<style type="text/css">
|
||||
${css}
|
||||
|
||||
.list_table .act_as_row {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
font-size:10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<%!
|
||||
|
||||
def amount(text):
|
||||
return text.replace('-', '‑') # replace by a non-breaking hyphen (it will not word-wrap between hyphen and numbers)
|
||||
%>
|
||||
|
||||
<%def name="format_amount(amount, display_option=None)">
|
||||
<%
|
||||
output = amount
|
||||
if display_option == 'normal':
|
||||
output = amount
|
||||
elif display_option == 'round':
|
||||
output = u"%.0f" % round(amount)
|
||||
elif display_option == 'kilo':
|
||||
if amount:
|
||||
output = u"%.2fK" % (amount / 1000,)
|
||||
%>
|
||||
${output}
|
||||
</%def>
|
||||
|
||||
<%setLang(user.lang)%>
|
||||
|
||||
<div class="act_as_table data_table">
|
||||
<div class="act_as_row labels">
|
||||
<div class="act_as_cell">${_('Chart of Account')}</div>
|
||||
<div class="act_as_cell">${_('Fiscal Year')}</div>
|
||||
<div class="act_as_cell">
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${_('Dates')}
|
||||
%else:
|
||||
${_('Periods')}
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${_('Displayed Accounts')}</div>
|
||||
<div class="act_as_cell">${_('Target Moves')}</div>
|
||||
<div class="act_as_cell">${_('Initial Balance')}</div>
|
||||
</div>
|
||||
<div class="act_as_row">
|
||||
<div class="act_as_cell">${ chart_account.name }</div>
|
||||
<div class="act_as_cell">${ fiscalyear.name if fiscalyear else '-' }</div>
|
||||
<div class="act_as_cell">
|
||||
${_('From:')}
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${formatLang(start_date, date=True) if start_date else u'' }
|
||||
%else:
|
||||
${start_period.name if start_period else u''}
|
||||
%endif
|
||||
${_('To:')}
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${ formatLang(stop_date, date=True) if stop_date else u'' }
|
||||
%else:
|
||||
${stop_period.name if stop_period else u'' }
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">
|
||||
%if accounts(data):
|
||||
${', '.join([account.code for account in accounts(data)])}
|
||||
%else:
|
||||
${_('All')}
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${ display_target_move(data) }</div>
|
||||
<div class="act_as_cell">${ _('Yes') if initial_balance else _('No') }</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
%for index, params in enumerate(comp_params):
|
||||
<div class="act_as_table data_table">
|
||||
<div class="act_as_row">
|
||||
<div class="act_as_cell">${_('Comparison %s') % (index + 1,)} (${"C%s" % (index + 1,)})</div>
|
||||
<div class="act_as_cell">
|
||||
%if params['comparison_filter'] == 'filter_date':
|
||||
${_('Dates : ')} ${formatLang(params['start'], date=True) } - ${formatLang(params['stop'], date=True) }
|
||||
%elif params['comparison_filter'] == 'filter_period':
|
||||
${_('Periods : ')} ${params['start'].name} - ${params['stop'].name}
|
||||
%else:
|
||||
${_('Fiscal Year : ')} ${params['fiscalyear'].name}
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${_('Initial Balance:')} ${ _('Yes') if params['initial_balance'] else _('No') }</div>
|
||||
</div>
|
||||
</div>
|
||||
%endfor
|
||||
|
||||
<div class="act_as_table list_table" style="margin-top: 20px;">
|
||||
|
||||
<div class="act_as_thead">
|
||||
<div class="act_as_row labels">
|
||||
## account name
|
||||
<div class="act_as_cell" style="width: 80px;">${_('Account')}</div>
|
||||
%if comparison_mode == 'no_comparison':
|
||||
%if initial_balance:
|
||||
## initial balance
|
||||
<div class="act_as_cell amount" style="width: 30px;">${_('Initial Balance')}</div>
|
||||
%endif
|
||||
## debit
|
||||
<div class="act_as_cell amount" style="width: 30px;">${_('Debit')}</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount" style="width: 30px;">${_('Credit')}</div>
|
||||
%endif
|
||||
## balance
|
||||
<div class="act_as_cell amount" style="width: 30px;">
|
||||
%if comparison_mode == 'no_comparison' or not fiscalyear:
|
||||
${_('Balance')}
|
||||
%else:
|
||||
${_('Balance %s') % (fiscalyear.name,)}
|
||||
%endif
|
||||
</div>
|
||||
%if comparison_mode in ('single', 'multiple'):
|
||||
%for index in range(nb_comparison):
|
||||
<div class="act_as_cell amount" style="width: 30px;">
|
||||
%if comp_params[index]['comparison_filter'] == 'filter_year' and comp_params[index].get('fiscalyear', False):
|
||||
${_('Balance %s') % (comp_params[index]['fiscalyear'].name,)}
|
||||
%else:
|
||||
${_('Balance C%s') % (index + 1,)}
|
||||
%endif
|
||||
</div>
|
||||
%if comparison_mode == 'single': ## no diff in multiple comparisons because it shows too data
|
||||
<div class="act_as_cell amount" style="width: 30px;">${_('Difference')}</div>
|
||||
<div class="act_as_cell amount" style="width: 30px;">${_('% Difference')}</div>
|
||||
%endif
|
||||
%endfor
|
||||
%endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="act_as_tbody">
|
||||
%for account_at in objects:
|
||||
<%
|
||||
current_account = account_at['current']
|
||||
level = current_account['level']
|
||||
%>
|
||||
%if level_print(data, level): ## how to manage levels?
|
||||
<%
|
||||
styles = []
|
||||
if level_bold(data, level):
|
||||
styles.append('font-weight: bold;')
|
||||
else:
|
||||
styles.append('font-weight: normal;')
|
||||
|
||||
if level_italic(data, level):
|
||||
styles.append('font-style: italic;')
|
||||
else:
|
||||
styles.append('font-style: normal;')
|
||||
|
||||
if level_underline(data, level):
|
||||
styles.append('text-decoration: underline;')
|
||||
else:
|
||||
styles.append('text-decoration: none;')
|
||||
|
||||
if level_uppercase(data, level):
|
||||
styles.append('text-transform: uppercase;')
|
||||
else:
|
||||
styles.append('font-decoration: none;')
|
||||
|
||||
styles.append("font-size: %spx;" % (level_size(data, level),))
|
||||
|
||||
%>
|
||||
<div class="act_as_row lines ${"account_level_%s" % (current_account['level'])}" styles="${' '.join(styles)}">
|
||||
## account name
|
||||
<div class="act_as_cell" style="padding-left: ${current_account.get('level', 0) * 5}px; ${' '.join(styles)}">${current_account['name']}</div>
|
||||
%if comparison_mode == 'no_comparison':
|
||||
%if initial_balance:
|
||||
## opening balance
|
||||
<div class="act_as_cell amount" style="${' '.join(styles)}">${format_amount(current_account['init_balance'], numbers_display(data)) | amount}</div>
|
||||
%endif
|
||||
## debit
|
||||
<div class="act_as_cell amount" style="${' '.join(styles)}">${format_amount(current_account['debit'], numbers_display(data)) | amount}</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount" style="${' '.join(styles)}">${format_amount(current_account['credit'] * -1, numbers_display(data)) if current_account['credit'] else 0.0 | amount}</div>
|
||||
%endif
|
||||
## balance
|
||||
<div class="act_as_cell amount" style="${' '.join(styles)}">${format_amount(current_account['balance'], numbers_display(data)) | amount}</div>
|
||||
|
||||
%if comparison_mode in ('single', 'multiple'):
|
||||
%for comp_account in account_at['comparisons']:
|
||||
<div class="act_as_cell amount" style="${' '.join(styles)}">${format_amount(comp_account['balance'], numbers_display(data)) | amount}</div>
|
||||
%if comparison_mode == 'single': ## no diff in multiple comparisons because it shows too data
|
||||
<div class="act_as_cell amount" style="${' '.join(styles)}">${format_amount(comp_account['diff'], numbers_display(data)) | amount}</div>
|
||||
<div class="act_as_cell amount" style="${' '.join(styles)}">
|
||||
%if comp_account['percent_diff'] is False:
|
||||
${ '-' }
|
||||
%else:
|
||||
${comp_account['percent_diff'] | amount} %
|
||||
%endif
|
||||
</div>
|
||||
%endif
|
||||
%endfor
|
||||
%endif
|
||||
</div>
|
||||
%endif
|
||||
%endfor
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,218 +0,0 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<style type="text/css">
|
||||
.account_level_1 {
|
||||
text-transform: uppercase;
|
||||
font-size: 15px;
|
||||
background-color:#F0F0F0;
|
||||
}
|
||||
|
||||
.account_level_2 {
|
||||
font-size: 12px;
|
||||
background-color:#F0F0F0;
|
||||
}
|
||||
|
||||
.regular_account_type {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.view_account_type {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.account_level_consol {
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
${css}
|
||||
|
||||
.list_table .act_as_row {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
font-size:10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<%!
|
||||
def amount(text):
|
||||
return text.replace('-', '‑') # replace by a non-breaking hyphen (it will not word-wrap between hyphen and numbers)
|
||||
%>
|
||||
|
||||
<%setLang(user.lang)%>
|
||||
|
||||
<%
|
||||
initial_balance_text = {'initial_balance': _('Computed'), 'opening_balance': _('Opening Entries'), False: _('No')}
|
||||
%>
|
||||
|
||||
<div class="act_as_table data_table">
|
||||
<div class="act_as_row labels">
|
||||
<div class="act_as_cell">${_('Chart of Account')}</div>
|
||||
<div class="act_as_cell">${_('Fiscal Year')}</div>
|
||||
<div class="act_as_cell">
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${_('Dates Filter')}
|
||||
%else:
|
||||
${_('Periods Filter')}
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${_('Accounts Filter')}</div>
|
||||
<div class="act_as_cell">${_('Target Moves')}</div>
|
||||
<div class="act_as_cell">${_('Initial Balance')}</div>
|
||||
</div>
|
||||
<div class="act_as_row">
|
||||
<div class="act_as_cell">${ chart_account.name }</div>
|
||||
<div class="act_as_cell">${ fiscalyear.name if fiscalyear else '-' }</div>
|
||||
<div class="act_as_cell">
|
||||
${_('From:')}
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${formatLang(start_date, date=True) if start_date else u'' }
|
||||
%else:
|
||||
${start_period.name if start_period else u''}
|
||||
%endif
|
||||
${_('To:')}
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${ formatLang(stop_date, date=True) if stop_date else u'' }
|
||||
%else:
|
||||
${stop_period.name if stop_period else u'' }
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">
|
||||
%if accounts(data):
|
||||
${', '.join([account.code for account in accounts(data)])}
|
||||
%else:
|
||||
${_('All')}
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${ display_target_move(data) }</div>
|
||||
<div class="act_as_cell">${ initial_balance_text[initial_balance_mode] }</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
%for index, params in enumerate(comp_params):
|
||||
<div class="act_as_table data_table">
|
||||
<div class="act_as_row">
|
||||
<div class="act_as_cell">${_('Comparison %s') % (index + 1,)} (${"C%s" % (index + 1,)})</div>
|
||||
<div class="act_as_cell">
|
||||
%if params['comparison_filter'] == 'filter_date':
|
||||
${_('Dates Filter:')} ${formatLang(params['start'], date=True) } - ${formatLang(params['stop'], date=True) }
|
||||
%elif params['comparison_filter'] == 'filter_period':
|
||||
${_('Periods Filter:')} ${params['start'].name} - ${params['stop'].name}
|
||||
%else:
|
||||
${_('Fiscal Year :')} ${params['fiscalyear'].name}
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${_('Initial Balance:')} ${ initial_balance_text[params['initial_balance_mode']] }</div>
|
||||
</div>
|
||||
</div>
|
||||
%endfor
|
||||
|
||||
<div class="act_as_table list_table" style="margin-top: 20px;">
|
||||
|
||||
<div class="act_as_thead">
|
||||
<div class="act_as_row labels">
|
||||
## code
|
||||
<div class="act_as_cell first_column" style="width: 20px;">${_('Code')}</div>
|
||||
## account name
|
||||
<div class="act_as_cell" style="width: 80px;">${_('Account')}</div>
|
||||
%if comparison_mode == 'no_comparison':
|
||||
%if initial_balance_mode:
|
||||
## initial balance
|
||||
<div class="act_as_cell amount" style="width: 30px;">${_('Initial Balance')}</div>
|
||||
%endif
|
||||
## debit
|
||||
<div class="act_as_cell amount" style="width: 30px;">${_('Debit')}</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount" style="width: 30px;">${_('Credit')}</div>
|
||||
%endif
|
||||
## balance
|
||||
<div class="act_as_cell amount" style="width: 30px;">
|
||||
%if comparison_mode == 'no_comparison' or not fiscalyear:
|
||||
${_('Balance')}
|
||||
%else:
|
||||
${_('Balance %s') % (fiscalyear.name,)}
|
||||
%endif
|
||||
</div>
|
||||
%if comparison_mode in ('single', 'multiple'):
|
||||
%for index in range(nb_comparison):
|
||||
<div class="act_as_cell amount" style="width: 30px;">
|
||||
%if comp_params[index]['comparison_filter'] == 'filter_year' and comp_params[index].get('fiscalyear', False):
|
||||
${_('Balance %s') % (comp_params[index]['fiscalyear'].name,)}
|
||||
%else:
|
||||
${_('Balance C%s') % (index + 1,)}
|
||||
%endif
|
||||
</div>
|
||||
%if comparison_mode == 'single': ## no diff in multiple comparisons because it shows too data
|
||||
<div class="act_as_cell amount" style="width: 30px;">${_('Difference')}</div>
|
||||
<div class="act_as_cell amount" style="width: 30px;">${_('% Difference')}</div>
|
||||
%endif
|
||||
%endfor
|
||||
%endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="act_as_tbody">
|
||||
<%
|
||||
last_child_consol_ids = []
|
||||
last_level = False
|
||||
%>
|
||||
%for current_account in objects:
|
||||
<%
|
||||
if not to_display_accounts[current_account.id]:
|
||||
continue
|
||||
|
||||
comparisons = comparisons_accounts[current_account.id]
|
||||
|
||||
if current_account.id in last_child_consol_ids:
|
||||
# current account is a consolidation child of the last account: use the level of last account
|
||||
level = last_level
|
||||
level_class = "account_level_consol"
|
||||
else:
|
||||
# current account is a not a consolidation child: use its own level
|
||||
level = current_account.level or 0
|
||||
level_class = "account_level_%s" % (level,)
|
||||
last_child_consol_ids = [child_consol_id.id for child_consol_id in current_account.child_consol_ids]
|
||||
last_level = current_account.level
|
||||
%>
|
||||
<div class="act_as_row lines ${level_class} ${"%s_account_type" % (current_account.type,)}">
|
||||
## code
|
||||
<div class="act_as_cell first_column">${current_account.code}</div>
|
||||
## account name
|
||||
<div class="act_as_cell" style="padding-left: ${level * 5}px;">${current_account.name}</div>
|
||||
%if comparison_mode == 'no_comparison':
|
||||
%if initial_balance_mode:
|
||||
## opening balance
|
||||
<div class="act_as_cell amount">${formatLang(init_balance_accounts[current_account.id]) | amount}</div>
|
||||
%endif
|
||||
## debit
|
||||
<div class="act_as_cell amount">${formatLang(debit_accounts[current_account.id]) | amount}</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount">${formatLang(credit_accounts[current_account.id]) | amount}</div>
|
||||
%endif
|
||||
## balance
|
||||
<div class="act_as_cell amount">${formatLang(balance_accounts[current_account.id]) | amount}</div>
|
||||
|
||||
%if comparison_mode in ('single', 'multiple'):
|
||||
%for comp_account in comparisons:
|
||||
<div class="act_as_cell amount">${formatLang(comp_account['balance']) | amount}</div>
|
||||
%if comparison_mode == 'single': ## no diff in multiple comparisons because it shows too data
|
||||
<div class="act_as_cell amount">${formatLang(comp_account['diff']) | amount}</div>
|
||||
<div class="act_as_cell amount">
|
||||
%if comp_account['percent_diff'] is False:
|
||||
${ '-' }
|
||||
%else:
|
||||
${int(round(comp_account['percent_diff'])) | amount} %
|
||||
%endif
|
||||
</div>
|
||||
%endif
|
||||
%endfor
|
||||
%endif
|
||||
</div>
|
||||
%endfor
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,155 +0,0 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<!DOCTYPE html SYSTEM
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<style type="text/css">
|
||||
.overflow_ellipsis {
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.open_invoice_previous_line {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.percent_line {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.amount {
|
||||
text-align:right;
|
||||
}
|
||||
|
||||
.classif_title {
|
||||
text-align:right;
|
||||
}
|
||||
|
||||
.classif{
|
||||
width: ${700/len(ranges)}px;
|
||||
}
|
||||
.total{
|
||||
font-weight:bold;
|
||||
}
|
||||
${css}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<%!
|
||||
def amount(text):
|
||||
# replace by a non-breaking hyphen (it will not word-wrap between hyphen and numbers)
|
||||
return text.replace('-', '‑')
|
||||
%>
|
||||
<body>
|
||||
<%setLang(user.lang)%>
|
||||
|
||||
<div class="act_as_table data_table">
|
||||
<div class="act_as_row labels">
|
||||
<div class="act_as_cell">${_('Chart of Account')}</div>
|
||||
<div class="act_as_cell">${_('Fiscal Year')}</div>
|
||||
<div class="act_as_cell">
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${_('Dates Filter')}
|
||||
%else:
|
||||
${_('Periods Filter')}
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${_('Clearance Date')}</div>
|
||||
<div class="act_as_cell">${_('Accounts Filter')}</div>
|
||||
<div class="act_as_cell">${_('Target Moves')}</div>
|
||||
|
||||
</div>
|
||||
<div class="act_as_row">
|
||||
<div class="act_as_cell">${ chart_account.name }</div>
|
||||
<div class="act_as_cell">${ fiscalyear.name if fiscalyear else '-' }</div>
|
||||
<div class="act_as_cell">
|
||||
${_('From:')}
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${formatLang(start_date, date=True) if start_date else u'' }
|
||||
%else:
|
||||
${start_period.name if start_period else u''}
|
||||
%endif
|
||||
${_('To:')}
|
||||
%if filter_form(data) == 'filter_date':
|
||||
${ formatLang(stop_date, date=True) if stop_date else u'' }
|
||||
%else:
|
||||
${stop_period.name if stop_period else u'' }
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${ formatLang(date_until, date=True) }</div>
|
||||
<div class="act_as_cell">
|
||||
%if partner_ids:
|
||||
${_('Custom Filter')}
|
||||
%else:
|
||||
${ display_partner_account(data) }
|
||||
%endif
|
||||
</div>
|
||||
<div class="act_as_cell">${ display_target_move(data) }</div>
|
||||
</div>
|
||||
</div>
|
||||
%for acc in objects:
|
||||
%if agged_lines_accounts[acc.id]:
|
||||
<div class="account_title bg" style="width: 1080px; margin-top: 20px; font-size: 12px;">${acc.code} - ${acc.name}</div>
|
||||
|
||||
|
||||
|
||||
<div class="act_as_table list_table" style="margin-top: 5px;">
|
||||
<div class="act_as_thead">
|
||||
<div class="act_as_row labels">
|
||||
## partner
|
||||
<div class="act_as_cell first_column" style="width: 60px;">${_('Partner')}</div>
|
||||
## code
|
||||
<div class="act_as_cell" style="width: 70px;">${_('code')}</div>
|
||||
## balance
|
||||
<div class="act_as_cell classif_title" style="width: 70px;">${_('balance')}</div>
|
||||
## Classifications
|
||||
%for title in ranges_titles:
|
||||
<div class="act_as_cell classif classif_title">${title}</div>
|
||||
%endfor
|
||||
</div>
|
||||
</div>
|
||||
<div class="act_as_tbody">
|
||||
%for partner_name, p_id, p_ref, p_name in partners_order[acc.id]:
|
||||
%if agged_lines_accounts[acc.id].get(p_id):
|
||||
<div class="act_as_row lines">
|
||||
<%line = agged_lines_accounts[acc.id][p_id]%>
|
||||
<%percents = agged_percents_accounts[acc.id]%>
|
||||
<%totals = agged_totals_accounts[acc.id]%>
|
||||
<div class="act_as_cell first_column">${partner_name}</div>
|
||||
<div class="act_as_cell">${p_ref or ''}</div>
|
||||
|
||||
<div class="act_as_cell amount">${formatLang(line.get('balance') or 0.0) | amount}</div>
|
||||
%for classif in ranges:
|
||||
<div class="act_as_cell classif amount">
|
||||
${formatLang(line['aged_lines'][classif] or 0.0) | amount}
|
||||
</div>
|
||||
%endfor
|
||||
</div>
|
||||
%endif
|
||||
%endfor
|
||||
<div class="act_as_row labels">
|
||||
<div class="act_as_cell total">${_('Total')}</div>
|
||||
<div class="act_as_cell"></div>
|
||||
<div class="act_as_cell amount classif total">${formatLang(totals['balance']) | amount}</div>
|
||||
%for classif in ranges:
|
||||
<div class="act_as_cell amount classif total">${formatLang(totals[classif]) | amount}</div>
|
||||
%endfor
|
||||
</div>
|
||||
|
||||
<div class="act_as_row">
|
||||
<div class="act_as_cell"><b>${_('Percents')}</b></div>
|
||||
<div class="act_as_cell"></div>
|
||||
<div class="act_as_cell"></div>
|
||||
%for classif in ranges:
|
||||
<div class="act_as_cell amount percent_line classif">${formatLang(percents[classif]) | amount}%</div>
|
||||
%endfor
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
%endif
|
||||
%endfor
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,173 +0,0 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%page args="account, formatLang" />
|
||||
%if account.grouped_ledger_lines and partners_order[account.id]:
|
||||
<%
|
||||
account_total_debit = 0.0
|
||||
account_total_credit = 0.0
|
||||
account_balance_cumul = 0.0
|
||||
account_balance_cumul_curr = 0.0
|
||||
%>
|
||||
%for partner_name, p_id, p_ref, p_name in partners_order[account.id]:
|
||||
<div class="account_title bg" style="width: 1080px; margin-top:
|
||||
20px; font-size: 12px;">${account.code} - ${account.name} -- ${partner_name or _('No Partner')} </div>
|
||||
|
||||
|
||||
|
||||
%for curr, grouped_lines in account.grouped_ledger_lines.get(p_id, []):
|
||||
<%
|
||||
total_debit = 0.0
|
||||
total_credit = 0.0
|
||||
cumul_balance = 0.0
|
||||
cumul_balance_curr = 0.0
|
||||
|
||||
part_cumul_balance = 0.0
|
||||
part_cumul_balance_curr = 0.0
|
||||
%>
|
||||
<div class="act_as_table list_table" style="margin-top: 5px;">
|
||||
<div class="act_as_caption account_title">
|
||||
<b>${curr or company.currency_id.name}</b>
|
||||
</div>
|
||||
<div class="act_as_thead">
|
||||
<div class="act_as_row labels">
|
||||
## date
|
||||
<div class="act_as_cell first_column" style="width: 60px;">${_('Date')}</div>
|
||||
## period
|
||||
<div class="act_as_cell" style="width: 70px;">${_('Period')}</div>
|
||||
## move
|
||||
<div class="act_as_cell" style="width: 100px;">${_('Entry')}</div>
|
||||
## journal
|
||||
<div class="act_as_cell" style="width: 70px;">${_('Journal')}</div>
|
||||
## move reference
|
||||
<div class="act_as_cell" style="width: 100px;">${_('Reference')}</div>
|
||||
## label
|
||||
<div class="act_as_cell" style="width: 180px;">${_('Label')}</div>
|
||||
## reconcile
|
||||
<div class="act_as_cell" style="width: 80px;">${_('Rec.')}</div>
|
||||
## maturity
|
||||
<div class="act_as_cell" style="width: 60px;">${_('Due Date')}</div>
|
||||
## debit
|
||||
<div class="act_as_cell amount" style="width: 80px;">${_('Debit')}</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount" style="width: 80px;">${_('Credit')}</div>
|
||||
## balance cumulated
|
||||
<div class="act_as_cell amount" style="width: 80px;">${_('Cumul. Bal.')}</div>
|
||||
## currency balance
|
||||
<div class="act_as_cell amount sep_left" style="width: 80px;">${_('Curr. Balance')}</div>
|
||||
## curency code
|
||||
<div class="act_as_cell amount" style="width: 30px; text-align: right;">${_('Curr.')}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="act_as_tbody">
|
||||
<%
|
||||
total_debit = 0.0
|
||||
total_credit = 0.0
|
||||
%>
|
||||
<%!
|
||||
def amount(text):
|
||||
return text.replace('-', '‑') # replace by a non-breaking hyphen (it will not word-wrap between hyphen and numbers)
|
||||
%>
|
||||
%for line in grouped_lines:
|
||||
<%
|
||||
total_debit += line.get('debit') or 0.0
|
||||
total_credit += line.get('credit') or 0.0
|
||||
|
||||
label_elements = [line.get('lname') or '']
|
||||
if line.get('invoice_number'):
|
||||
label_elements.append("(%s)" % (line['invoice_number'],))
|
||||
label = ' '.join(label_elements)
|
||||
%>
|
||||
<div class="act_as_row lines ${line.get('is_from_previous_periods') and 'open_invoice_previous_line' or ''} ${line.get('is_clearance_line') and 'clearance_line' or ''}">
|
||||
## date
|
||||
<div class="act_as_cell first_column">${formatLang(line.get('ldate') or '', date=True)}</div>
|
||||
## period
|
||||
<div class="act_as_cell">${line.get('period_code') or ''}</div>
|
||||
## move
|
||||
<div class="act_as_cell">${line.get('move_name') or ''}</div>
|
||||
## journal
|
||||
<div class="act_as_cell">${line.get('jcode') or ''}</div>
|
||||
## move reference
|
||||
<div class="act_as_cell">${line.get('lref') or ''}</div>
|
||||
## label
|
||||
<div class="act_as_cell">${label}</div>
|
||||
## reconcile
|
||||
<div class="act_as_cell">${line.get('rec_name') or ''}</div>
|
||||
## maturity date
|
||||
<div class="act_as_cell">${formatLang(line.get('date_maturity') or '', date=True)}</div>
|
||||
## debit
|
||||
<div class="act_as_cell amount">${formatLang(line.get('debit') or 0.0) | amount }</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount">${formatLang(line.get('credit') or 0.0) | amount }</div>
|
||||
## balance cumulated
|
||||
<% cumul_balance += line.get('balance') or 0.0 %>
|
||||
<div class="act_as_cell amount" style="padding-right: 1px;">${formatLang(cumul_balance) | amount }</div>
|
||||
## currency balance
|
||||
<div class="act_as_cell sep_left amount">${formatLang(line.get('amount_currency') or 0.0) | amount }</div>
|
||||
## curency code
|
||||
<div class="act_as_cell" style="text-align: right; ">${line.get('currency_code') or ''}</div>
|
||||
</div>
|
||||
%endfor
|
||||
<div class="act_as_row lines labels">
|
||||
## date
|
||||
<div class="act_as_cell first_column"></div>
|
||||
## period
|
||||
<div class="act_as_cell"></div>
|
||||
## move
|
||||
<div class="act_as_cell"></div>
|
||||
## journal
|
||||
<div class="act_as_cell"></div>
|
||||
## move reference
|
||||
<div class="act_as_cell"></div>
|
||||
## label
|
||||
<div class="act_as_cell">${_('Cumulated Balance on Partner')}</div>
|
||||
## reconcile
|
||||
<div class="act_as_cell"></div>
|
||||
## maturity date
|
||||
<div class="act_as_cell"></div>
|
||||
## debit
|
||||
<div class="act_as_cell amount">${formatLang(total_debit) | amount }</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount">${formatLang(total_credit) | amount }</div>
|
||||
## balance cumulated
|
||||
<div class="act_as_cell amount" style="padding-right: 1px;">${formatLang(cumul_balance) | amount }</div>
|
||||
%if account.currency_id:
|
||||
## currency balance
|
||||
<div class="act_as_cell sep_left amount" style="padding-right: 1px;">${formatLang(cumul_balance_curr) | amount }</div>
|
||||
%else:
|
||||
<div class="act_as_cell sep_left amount" style="padding-right: 1px;">${ u'-' }</div>
|
||||
%endif
|
||||
## curency code
|
||||
<div class="act_as_cell" style="text-align: right; ">${ account.currency_id.name if account.currency_id else u'' }</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%
|
||||
account_total_debit += total_debit
|
||||
account_total_credit += total_credit
|
||||
account_balance_cumul += cumul_balance
|
||||
account_balance_cumul_curr += cumul_balance_curr
|
||||
%>
|
||||
%endfor
|
||||
%endfor
|
||||
<div class="act_as_table list_table" style="margin-top:5px;">
|
||||
<div class="act_as_row labels" style="font-weight: bold; font-size: 12px;">
|
||||
<div class="act_as_cell first_column" style="width: 450px;">${account.code} - ${account.name}</div>
|
||||
## label
|
||||
<div class="act_as_cell" style="width: 320px;">${_("Cumulated Balance on Account")}</div>
|
||||
## debit
|
||||
<div class="act_as_cell amount" style="width: 80px;">${ formatLang(account_total_debit) | amount }</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount" style="width: 80px;">${ formatLang(account_total_credit) | amount }</div>
|
||||
## balance cumulated
|
||||
<div class="act_as_cell amount" style="width: 80px; ">${ formatLang(account_balance_cumul) | amount }</div>
|
||||
## currency balance cumulated
|
||||
%if account.currency_id:
|
||||
<div class="act_as_cell amount sep_left" style="width: 80px;">${ formatLang(account_balance_cumul_curr) | amount }</div>
|
||||
%else:
|
||||
<div class="act_as_cell amount sep_left" style="width: 80px; padding-right: 1px;">${ u'-' }</div>
|
||||
%endif
|
||||
## curency code
|
||||
<div class="act_as_cell amount" style="width: 30px; text-align: right;">${ account.currency_id.name if account.currency_id else u'' }</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
%endif
|
|
@ -1,183 +0,0 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%page args="account, formatLang" />
|
||||
%if ledger_lines[account.id] and partners_order[account.id]:
|
||||
<%
|
||||
account_total_debit = 0.0
|
||||
account_total_credit = 0.0
|
||||
account_balance_cumul = 0.0
|
||||
account_balance_cumul_curr = 0.0
|
||||
%>
|
||||
|
||||
<div class="account_title bg" style="width: 1080px; margin-top: 20px; font-size: 12px;">${account.code} - ${account.name}</div>
|
||||
|
||||
%for partner_name, p_id, p_ref, p_name in partners_order[account.id]:
|
||||
<%
|
||||
total_debit = 0.0
|
||||
total_credit = 0.0
|
||||
cumul_balance = 0.0
|
||||
cumul_balance_curr = 0.0
|
||||
|
||||
part_cumul_balance = 0.0
|
||||
part_cumul_balance_curr = 0.0
|
||||
%>
|
||||
<div class="act_as_table list_table" style="margin-top: 5px;">
|
||||
<div class="act_as_caption account_title">
|
||||
${partner_name or _('No Partner')}
|
||||
</div>
|
||||
<div class="act_as_thead">
|
||||
<div class="act_as_row labels">
|
||||
## date
|
||||
<div class="act_as_cell first_column" style="width: 60px;">${_('Date')}</div>
|
||||
## period
|
||||
<div class="act_as_cell" style="width: 70px;">${_('Period')}</div>
|
||||
## move
|
||||
<div class="act_as_cell" style="width: 100px;">${_('Entry')}</div>
|
||||
## journal
|
||||
<div class="act_as_cell" style="width: 70px;">${_('Journal')}</div>
|
||||
## partner
|
||||
<div class="act_as_cell" style="width: 120px;">${_('Partner')}</div>
|
||||
## move reference
|
||||
<div class="act_as_cell" style="width: 100px;">${_('Reference')}</div>
|
||||
## label
|
||||
<div class="act_as_cell" style="width: 180px;">${_('Label')}</div>
|
||||
## reconcile
|
||||
<div class="act_as_cell" style="width: 80px;">${_('Rec.')}</div>
|
||||
## maturity
|
||||
<div class="act_as_cell" style="width: 60px;">${_('Due Date')}</div>
|
||||
## debit
|
||||
<div class="act_as_cell amount" style="width: 80px;">${_('Debit')}</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount" style="width: 80px;">${_('Credit')}</div>
|
||||
## balance cumulated
|
||||
<div class="act_as_cell amount" style="width: 80px;">${_('Cumul. Bal.')}</div>
|
||||
%if amount_currency(data):
|
||||
## currency balance
|
||||
<div class="act_as_cell amount sep_left" style="width: 80px;">${_('Curr. Balance')}</div>
|
||||
## curency code
|
||||
<div class="act_as_cell amount" style="width: 30px; text-align: right;">${_('Curr.')}</div>
|
||||
%endif
|
||||
</div>
|
||||
</div>
|
||||
<div class="act_as_tbody">
|
||||
<%
|
||||
total_debit = 0.0
|
||||
total_credit = 0.0
|
||||
%>
|
||||
<%!
|
||||
def amount(text):
|
||||
return text.replace('-', '‑') # replace by a non-breaking hyphen (it will not word-wrap between hyphen and numbers)
|
||||
%>
|
||||
%for line in ledger_lines[account.id].get(p_id, []):
|
||||
<%
|
||||
total_debit += line.get('debit') or 0.0
|
||||
total_credit += line.get('credit') or 0.0
|
||||
|
||||
label_elements = [line.get('lname') or '']
|
||||
if line.get('invoice_number'):
|
||||
label_elements.append("(%s)" % (line['invoice_number'],))
|
||||
label = ' '.join(label_elements)
|
||||
%>
|
||||
<div class="act_as_row lines ${line.get('is_from_previous_periods') and 'open_invoice_previous_line' or ''} ${line.get('is_clearance_line') and 'clearance_line' or ''}">
|
||||
## date
|
||||
<div class="act_as_cell first_column">${formatLang(line.get('ldate') or '', date=True)}</div>
|
||||
## period
|
||||
<div class="act_as_cell">${line.get('period_code') or ''}</div>
|
||||
## move
|
||||
<div class="act_as_cell">${line.get('move_name') or ''}</div>
|
||||
## journal
|
||||
<div class="act_as_cell">${line.get('jcode') or ''}</div>
|
||||
## partner
|
||||
<div class="act_as_cell overflow_ellipsis">${line.get('partner_name') or ''}</div>
|
||||
## move reference
|
||||
<div class="act_as_cell">${line.get('lref') or ''}</div>
|
||||
## label
|
||||
<div class="act_as_cell">${label}</div>
|
||||
## reconcile
|
||||
<div class="act_as_cell">${line.get('rec_name') or ''}</div>
|
||||
## maturity date
|
||||
<div class="act_as_cell">${formatLang(line.get('date_maturity') or '', date=True)}</div>
|
||||
## debit
|
||||
<div class="act_as_cell amount">${formatLang(line.get('debit') or 0.0) | amount }</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount">${formatLang(line.get('credit') or 0.0) | amount }</div>
|
||||
## balance cumulated
|
||||
<% cumul_balance += line.get('balance') or 0.0 %>
|
||||
<div class="act_as_cell amount" style="padding-right: 1px;">${formatLang(cumul_balance) | amount }</div>
|
||||
%if amount_currency(data):
|
||||
## currency balance
|
||||
<div class="act_as_cell sep_left amount">${formatLang(line.get('amount_currency') or 0.0) | amount }</div>
|
||||
## curency code
|
||||
<div class="act_as_cell" style="text-align: right; ">${line.get('currency_code') or ''}</div>
|
||||
%endif
|
||||
</div>
|
||||
%endfor
|
||||
<div class="act_as_row lines labels">
|
||||
## date
|
||||
<div class="act_as_cell first_column"></div>
|
||||
## period
|
||||
<div class="act_as_cell"></div>
|
||||
## move
|
||||
<div class="act_as_cell"></div>
|
||||
## journal
|
||||
<div class="act_as_cell"></div>
|
||||
## partner
|
||||
<div class="act_as_cell"></div>
|
||||
## move reference
|
||||
<div class="act_as_cell"></div>
|
||||
## label
|
||||
<div class="act_as_cell">${_('Cumulated Balance on Partner')}</div>
|
||||
## reconcile
|
||||
<div class="act_as_cell"></div>
|
||||
## maturity date
|
||||
<div class="act_as_cell"></div>
|
||||
## debit
|
||||
<div class="act_as_cell amount">${formatLang(total_debit) | amount }</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount">${formatLang(total_credit) | amount }</div>
|
||||
## balance cumulated
|
||||
<div class="act_as_cell amount" style="padding-right: 1px;">${formatLang(cumul_balance) | amount }</div>
|
||||
%if amount_currency(data):
|
||||
%if account.currency_id:
|
||||
## currency balance
|
||||
<div class="act_as_cell sep_left amount" style="padding-right: 1px;">${formatLang(cumul_balance_curr) | amount }</div>
|
||||
%else:
|
||||
<div class="act_as_cell sep_left amount" style="padding-right: 1px;">${ u'-' }</div>
|
||||
%endif
|
||||
## curency code
|
||||
<div class="act_as_cell" style="text-align: right; ">${ account.currency_id.name if account.currency_id else u'' }</div>
|
||||
%endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%
|
||||
account_total_debit += total_debit
|
||||
account_total_credit += total_credit
|
||||
account_balance_cumul += cumul_balance
|
||||
account_balance_cumul_curr += cumul_balance_curr
|
||||
%>
|
||||
%endfor
|
||||
<div class="act_as_table list_table" style="margin-top:5px;">
|
||||
<div class="act_as_row labels" style="font-weight: bold; font-size: 12px;">
|
||||
<div class="act_as_cell first_column" style="width: 520px;">${account.code} - ${account.name}</div>
|
||||
## label
|
||||
<div class="act_as_cell" style="width: 320px;">${_("Cumulated Balance on Account")}</div>
|
||||
## debit
|
||||
<div class="act_as_cell amount" style="width: 80px;">${ formatLang(account_total_debit) | amount }</div>
|
||||
## credit
|
||||
<div class="act_as_cell amount" style="width: 80px;">${ formatLang(account_total_credit) | amount }</div>
|
||||
## balance cumulated
|
||||
<div class="act_as_cell amount" style="width: 80px; ">${ formatLang(account_balance_cumul) | amount }</div>
|
||||
%if amount_currency(data):
|
||||
## currency balance cumulated
|
||||
%if account.currency_id:
|
||||
<div class="act_as_cell amount sep_left" style="width: 80px;">${ formatLang(account_balance_cumul_curr) | amount }</div>
|
||||
%else:
|
||||
<div class="act_as_cell amount sep_left" style="width: 80px; padding-right: 1px;">${ u'-' }</div>
|
||||
%endif
|
||||
## curency code
|
||||
<div class="act_as_cell amount" style="width: 30px; text-align: right;">${ account.currency_id.name if account.currency_id else u'' }</div>
|
||||
%endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
%endif
|
|
@ -1,93 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Guewen Baconnier
|
||||
# Copyright Camptocamp SA 2011
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from openerp import pooler
|
||||
from openerp.report import report_sxw
|
||||
from openerp.tools.translate import _
|
||||
from .common_balance_reports import CommonBalanceReportHeaderWebkit
|
||||
from .webkit_parser_header_fix import HeaderFooterTextWebKitParser
|
||||
|
||||
|
||||
def sign(number):
|
||||
return cmp(number, 0)
|
||||
|
||||
|
||||
class TrialBalanceWebkit(report_sxw.rml_parse,
|
||||
CommonBalanceReportHeaderWebkit):
|
||||
|
||||
def __init__(self, cursor, uid, name, context):
|
||||
super(TrialBalanceWebkit, self).__init__(cursor, uid, name,
|
||||
context=context)
|
||||
self.pool = pooler.get_pool(self.cr.dbname)
|
||||
self.cursor = self.cr
|
||||
|
||||
company = self.pool.get('res.users').browse(self.cr, uid, uid,
|
||||
context=context).company_id
|
||||
header_report_name = ' - '.join((_('TRIAL BALANCE'), company.name,
|
||||
company.currency_id.name))
|
||||
|
||||
footer_date_time = self.formatLang(str(datetime.today()),
|
||||
date_time=True)
|
||||
|
||||
self.localcontext.update({
|
||||
'cr': cursor,
|
||||
'uid': uid,
|
||||
'report_name': _('Trial Balance'),
|
||||
'display_account': self._get_display_account,
|
||||
'display_account_raw': self._get_display_account_raw,
|
||||
'filter_form': self._get_filter,
|
||||
'target_move': self._get_target_move,
|
||||
'display_target_move': self._get_display_target_move,
|
||||
'accounts': self._get_accounts_br,
|
||||
'additional_args': [
|
||||
('--header-font-name', 'Helvetica'),
|
||||
('--footer-font-name', 'Helvetica'),
|
||||
('--header-font-size', '10'),
|
||||
('--footer-font-size', '6'),
|
||||
('--header-left', header_report_name),
|
||||
('--header-spacing', '2'),
|
||||
('--footer-left', footer_date_time),
|
||||
('--footer-right', ' '.join((_('Page'), '[page]', _('of'),
|
||||
'[topage]'))),
|
||||
('--footer-line',),
|
||||
],
|
||||
})
|
||||
|
||||
def set_context(self, objects, data, ids, report_type=None):
|
||||
"""Populate a ledger_lines attribute on each browse record that will
|
||||
be used by mako template"""
|
||||
objects, new_ids, context_report_values = self.\
|
||||
compute_balance_data(data)
|
||||
|
||||
self.localcontext.update(context_report_values)
|
||||
|
||||
return super(TrialBalanceWebkit, self).set_context(
|
||||
objects, data, new_ids, report_type=report_type)
|
||||
|
||||
HeaderFooterTextWebKitParser(
|
||||
'report.account.account_report_trial_balance_webkit',
|
||||
'account.account',
|
||||
'addons/account_financial_report_webkit/report/templates/\
|
||||
account_report_trial_balance.mako',
|
||||
parser=TrialBalanceWebkit)
|
|
@ -1,279 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)
|
||||
#
|
||||
# Author: Guewen Baconnier (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.
|
||||
#
|
||||
##############################################################################
|
||||
from mako.template import Template
|
||||
from mako.lookup import TemplateLookup
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
import logging
|
||||
from functools import partial
|
||||
|
||||
|
||||
from mako import exceptions
|
||||
from openerp.osv.orm import except_orm
|
||||
from openerp.tools.translate import _
|
||||
from openerp import pooler
|
||||
from openerp import tools
|
||||
from openerp.addons.report_webkit import webkit_report
|
||||
from openerp.addons.report_webkit.report_helper import WebKitHelper
|
||||
from openerp.modules.module import get_module_resource
|
||||
|
||||
_logger = logging.getLogger('financial.reports.webkit')
|
||||
|
||||
# Class used only as a workaround to bug:
|
||||
# http://code.google.com/p/wkhtmltopdf/issues/detail?id=656
|
||||
|
||||
# html headers and footers do not work on big files (hundreds of pages) so we
|
||||
# replace them by text headers and footers passed as arguments to wkhtmltopdf
|
||||
# this class has to be removed once the bug is fixed
|
||||
|
||||
# in your report class, to print headers and footers as text, you have to add
|
||||
# them in the localcontext with a key 'additional_args'
|
||||
# for instance:
|
||||
# header_report_name = _('PARTNER LEDGER')
|
||||
# footer_date_time = self.formatLang(str(datetime.today()),
|
||||
# date_time=True)
|
||||
# self.localcontext.update({
|
||||
# 'additional_args': [
|
||||
# ('--header-font-name', 'Helvetica'),
|
||||
# ('--footer-font-name', 'Helvetica'),
|
||||
# ('--header-font-size', '10'),
|
||||
# ('--footer-font-size', '7'),
|
||||
# ('--header-left', header_report_name),
|
||||
# ('--footer-left', footer_date_time),
|
||||
# ('--footer-right', ' '.join((_('Page'), '[page]', _('of'),
|
||||
# '[topage]'))),
|
||||
# ('--footer-line',),
|
||||
# ],
|
||||
# })
|
||||
|
||||
|
||||
# redefine mako_template as this is overriden by jinja since saas-1
|
||||
# from openerp.addons.report_webkit.webkit_report import mako_template
|
||||
|
||||
|
||||
def mako_template(text):
|
||||
"""Build a Mako template.
|
||||
|
||||
This template uses UTF-8 encoding
|
||||
"""
|
||||
tmp_lookup = TemplateLookup(
|
||||
) # we need it in order to allow inclusion and inheritance
|
||||
return Template(text, input_encoding='utf-8', output_encoding='utf-8',
|
||||
lookup=tmp_lookup)
|
||||
|
||||
|
||||
class HeaderFooterTextWebKitParser(webkit_report.WebKitParser):
|
||||
|
||||
def generate_pdf(self, comm_path, report_xml, header, footer, html_list,
|
||||
webkit_header=False, parser_instance=False):
|
||||
"""Call webkit in order to generate pdf"""
|
||||
if not webkit_header:
|
||||
webkit_header = report_xml.webkit_header
|
||||
fd, out_filename = tempfile.mkstemp(suffix=".pdf",
|
||||
prefix="webkit.tmp.")
|
||||
file_to_del = [out_filename]
|
||||
if comm_path:
|
||||
command = [comm_path]
|
||||
else:
|
||||
command = ['wkhtmltopdf']
|
||||
|
||||
command.append('--quiet')
|
||||
# default to UTF-8 encoding. Use <meta charset="latin-1"> to override.
|
||||
command.extend(['--encoding', 'utf-8'])
|
||||
|
||||
if webkit_header.margin_top:
|
||||
command.extend(
|
||||
['--margin-top',
|
||||
str(webkit_header.margin_top).replace(',', '.')])
|
||||
if webkit_header.margin_bottom:
|
||||
command.extend(
|
||||
['--margin-bottom',
|
||||
str(webkit_header.margin_bottom).replace(',', '.')])
|
||||
if webkit_header.margin_left:
|
||||
command.extend(
|
||||
['--margin-left',
|
||||
str(webkit_header.margin_left).replace(',', '.')])
|
||||
if webkit_header.margin_right:
|
||||
command.extend(
|
||||
['--margin-right',
|
||||
str(webkit_header.margin_right).replace(',', '.')])
|
||||
if webkit_header.orientation:
|
||||
command.extend(
|
||||
['--orientation',
|
||||
str(webkit_header.orientation).replace(',', '.')])
|
||||
if webkit_header.format:
|
||||
command.extend(
|
||||
['--page-size',
|
||||
str(webkit_header.format).replace(',', '.')])
|
||||
|
||||
if parser_instance.localcontext.get('additional_args', False):
|
||||
for arg in parser_instance.localcontext['additional_args']:
|
||||
command.extend(arg)
|
||||
|
||||
count = 0
|
||||
for html in html_list:
|
||||
with tempfile.NamedTemporaryFile(suffix="%d.body.html" % count,
|
||||
delete=False) as html_file:
|
||||
count += 1
|
||||
html_file.write(self._sanitize_html(html))
|
||||
file_to_del.append(html_file.name)
|
||||
command.append(html_file.name)
|
||||
command.append(out_filename)
|
||||
stderr_fd, stderr_path = tempfile.mkstemp(text=True)
|
||||
file_to_del.append(stderr_path)
|
||||
try:
|
||||
status = subprocess.call(command, stderr=stderr_fd)
|
||||
os.close(stderr_fd) # ensure flush before reading
|
||||
stderr_fd = None # avoid closing again in finally block
|
||||
fobj = open(stderr_path, 'r')
|
||||
error_message = fobj.read()
|
||||
fobj.close()
|
||||
if not error_message:
|
||||
error_message = _('No diagnosis message was provided')
|
||||
else:
|
||||
error_message = _(
|
||||
'The following diagnosis message was provided:\n') + \
|
||||
error_message
|
||||
if status:
|
||||
raise except_orm(_('Webkit error'),
|
||||
_("The command 'wkhtmltopdf' failed with \
|
||||
error code = %s. Message: %s") %
|
||||
(status, error_message))
|
||||
with open(out_filename, 'rb') as pdf_file:
|
||||
pdf = pdf_file.read()
|
||||
os.close(fd)
|
||||
finally:
|
||||
if stderr_fd is not None:
|
||||
os.close(stderr_fd)
|
||||
for f_to_del in file_to_del:
|
||||
try:
|
||||
os.unlink(f_to_del)
|
||||
except (OSError, IOError), exc:
|
||||
_logger.error('cannot remove file %s: %s', f_to_del, exc)
|
||||
return pdf
|
||||
|
||||
# override needed to keep the attachments' storing procedure
|
||||
def create_single_pdf(self, cursor, uid, ids, data, report_xml,
|
||||
context=None):
|
||||
"""generate the PDF"""
|
||||
|
||||
if context is None:
|
||||
context = {}
|
||||
htmls = []
|
||||
if report_xml.report_type != 'webkit':
|
||||
return super(HeaderFooterTextWebKitParser, self
|
||||
).create_single_pdf(cursor, uid, ids, data,
|
||||
report_xml, context=context)
|
||||
|
||||
parser_instance = self.parser(cursor,
|
||||
uid,
|
||||
self.name2,
|
||||
context=context)
|
||||
|
||||
self.pool = pooler.get_pool(cursor.dbname)
|
||||
objs = self.getObjects(cursor, uid, ids, context)
|
||||
parser_instance.set_context(objs, data, ids, report_xml.report_type)
|
||||
|
||||
template = False
|
||||
|
||||
if report_xml.report_file:
|
||||
path = get_module_resource(
|
||||
*report_xml.report_file.split(os.path.sep))
|
||||
if os.path.exists(path):
|
||||
template = file(path).read()
|
||||
if not template and report_xml.report_webkit_data:
|
||||
template = report_xml.report_webkit_data
|
||||
if not template:
|
||||
raise except_orm(
|
||||
_('Error!'), _('Webkit Report template not found !'))
|
||||
header = report_xml.webkit_header.html
|
||||
|
||||
if not header and report_xml.header:
|
||||
raise except_orm(
|
||||
_('No header defined for this Webkit report!'),
|
||||
_('Please set a header in company settings.')
|
||||
)
|
||||
|
||||
css = report_xml.webkit_header.css
|
||||
if not css:
|
||||
css = ''
|
||||
|
||||
translate_call = partial(self.translate_call, parser_instance)
|
||||
# default_filters=['unicode', 'entity'] can be used to set global
|
||||
# filter
|
||||
body_mako_tpl = mako_template(template)
|
||||
helper = WebKitHelper(cursor, uid, report_xml.id, context)
|
||||
if report_xml.precise_mode:
|
||||
for obj in objs:
|
||||
parser_instance.localcontext['objects'] = [obj]
|
||||
try:
|
||||
html = body_mako_tpl.render(helper=helper,
|
||||
css=css,
|
||||
_=translate_call,
|
||||
**parser_instance.localcontext)
|
||||
htmls.append(html)
|
||||
except Exception:
|
||||
msg = exceptions.text_error_template().render()
|
||||
_logger.error(msg)
|
||||
raise except_orm(_('Webkit render'), msg)
|
||||
else:
|
||||
try:
|
||||
html = body_mako_tpl.render(helper=helper,
|
||||
css=css,
|
||||
_=translate_call,
|
||||
**parser_instance.localcontext)
|
||||
htmls.append(html)
|
||||
except Exception:
|
||||
msg = exceptions.text_error_template().render()
|
||||
_logger.error(msg)
|
||||
raise except_orm(_('Webkit render'), msg)
|
||||
|
||||
# NO html footer and header because we write them as text with
|
||||
# wkhtmltopdf
|
||||
head = foot = False
|
||||
|
||||
if report_xml.webkit_debug:
|
||||
try:
|
||||
deb = body_mako_tpl.render(helper=helper,
|
||||
css=css,
|
||||
_debug=tools.ustr("\n".join(htmls)),
|
||||
_=translate_call,
|
||||
**parser_instance.localcontext)
|
||||
except Exception:
|
||||
msg = exceptions.text_error_template().render()
|
||||
_logger.error(msg)
|
||||
raise except_orm(_('Webkit render'), msg)
|
||||
return (deb, 'html')
|
||||
bin = self.get_lib(cursor, uid)
|
||||
pdf = self.generate_pdf(bin, report_xml, head, foot, htmls,
|
||||
parser_instance=parser_instance)
|
||||
return (pdf, 'pdf')
|
|
@ -1,42 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<menuitem icon="STOCK_PRINT" name="General Ledger"
|
||||
parent="account.final_accounting_reports" action="action_account_general_ledger_menu_webkit"
|
||||
groups="account.group_account_manager,account.group_account_user" id="account.menu_general_ledger"/>
|
||||
|
||||
<menuitem icon="STOCK_PRINT" name="Trial Balance"
|
||||
parent="account.final_accounting_reports" action="action_account_trial_balance_menu_webkit"
|
||||
groups="account.group_account_manager,account.group_account_user" id="account.menu_general_Balance_report"/>
|
||||
|
||||
<menuitem icon="STOCK_PRINT" name="Partner Ledger"
|
||||
parent="account.next_id_22" action="action_account_partners_ledger_menu_webkit"
|
||||
groups="account.group_account_manager,account.group_account_user" id="account.menu_account_partner_ledger"/>
|
||||
|
||||
<menuitem icon="STOCK_PRINT" name="Partner Balance"
|
||||
parent="account.next_id_22" action="action_account_partner_balance_menu_webkit"
|
||||
groups="account.group_account_manager,account.group_account_user" id="account.menu_account_partner_balance_report"/>
|
||||
|
||||
<menuitem icon="STOCK_PRINT" name="Aged Partner Balance"
|
||||
parent="account.next_id_22" action="action_account_aged_trial_balance_menu_webkit"
|
||||
groups="account.group_account_manager,account.group_account_user" id="account.menu_aged_trial_balance"/>
|
||||
|
||||
<menuitem icon="STOCK_PRINT" name="Open Invoices"
|
||||
parent="account.next_id_22" action="action_account_open_invoices_menu_webkit"
|
||||
groups="account.group_account_manager,account.group_account_user" id="menu_account_open_invoices"/>
|
||||
|
||||
<menuitem icon="STOCK_PRINT" name="Journals"
|
||||
parent="account.menu_journals_report" action="action_account_print_journal_menu_webkit"
|
||||
groups="account.group_account_manager,account.group_account_user" id="account.menu_account_print_journal"/>
|
||||
|
||||
<!--
|
||||
Hide Sale / Purchase Journals menu, replaced by a unique
|
||||
"Journals" menu
|
||||
-->
|
||||
<record id="account.menu_account_print_sale_purchase_journal" model="ir.ui.menu">
|
||||
<field name="groups_id" eval="[(4, ref('base.group_no_one')), ]"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Binary file not shown.
Before Width: | Height: | Size: 15 KiB |
|
@ -1,3 +0,0 @@
|
|||
-
|
||||
In order to test the last_rec_date behavior we will create a move and reconcile it
|
||||
-
|
|
@ -1,56 +0,0 @@
|
|||
-
|
||||
In order to test the PDF Aged Partner Balance Report webkit wizard I will print report with default setting
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'until_date': '%s-12-31' %(datetime.now().year),
|
||||
'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'period_from': ref('account.period_1'),
|
||||
'period_to': ref('account.period_12')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_aged_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Aged Partner Balance Report webkit wizard I will print report with filters and currency
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted',
|
||||
'amount_currency': True, 'result_selection': 'customer_supplier',
|
||||
'period_from': ref('account.period_1'),
|
||||
'period_to': ref('account.period_12')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_aged_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Aged Partner Balance Report webkit wizard I will print report with filters on partners
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted',
|
||||
'amount_currency': True, 'result_selection': 'customer_supplier',
|
||||
'partner_ids': [ref('base.res_partner_2'), ref('base.res_partner_1')],
|
||||
'period_from': ref('account.period_1'),
|
||||
'period_to': ref('account.period_12')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_aged_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Aged Partner Balance Report webkit wizard I will print report with filters on periods
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted',
|
||||
'amount_currency': True, 'result_selection': 'customer_supplier',
|
||||
'filter': 'filter_period',
|
||||
'period_from': ref('account.period_1'),
|
||||
'period_to': ref('account.period_12')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_aged_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
|
@ -1,65 +0,0 @@
|
|||
-
|
||||
In order to test the PDF General Ledger webkit wizard I will print report with default setting
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0')}
|
||||
ctx.update({'model': 'account.account','active_ids':[ref('account.chart0')],'active_id':ref('account.chart0')})
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_general_ledger_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF General Ledger webkit wizard I will print report with posted move
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'target_move': 'posted'}
|
||||
ctx.update({'model': 'account.account','active_ids':[ref('account.chart0')],'active_id':ref('account.chart0')})
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_general_ledger_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF General Ledger webkit wizard I will print report with transactions or non zero balance
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'display_account': 'bal_mix'}
|
||||
ctx.update({'model': 'account.account','active_ids':[ref('account.chart0')],'active_id':ref('account.chart0')})
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_general_ledger_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF General Ledger webkit wizard I will print report with inital balance and currency ammount
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'amount_currency': 1}
|
||||
ctx.update({'model': 'account.account','active_ids':[ref('account.chart0')],'active_id':ref('account.chart0')})
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_general_ledger_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
#Filter by date
|
||||
-
|
||||
In order to test the PDF General Ledger webkit wizard I will print report with inital balance and currency ammount and I filter by date of the first tree month
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'),'amount_currency': 1, 'chart_account_id': 1, 'date_from': '%s-01-01' %(datetime.now().year),
|
||||
'date_to':'%s-04-01' %(datetime.now().year), 'display_account': 'bal_all', 'filter': 'filter_date',}
|
||||
ctx.update({'model': 'account.account','active_ids':[ref('account.chart0')],'active_id':ref('account.chart0')})
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_general_ledger_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF General Ledger webkit wizard I will print report with inital balance and currency ammount and I filter by date of the first tree month
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'),'amount_currency': 1, 'chart_account_id': 1, 'date_from': '%s-01-01' %(datetime.now().year),
|
||||
'date_to':'%s-04-01' %(datetime.now().year), 'display_account': 'bal_all', 'filter': 'filter_date',}
|
||||
ctx.update({'model': 'account.account','active_ids':[ref('account.chart0')],'active_id':ref('account.chart0')})
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_general_ledger_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
# I still have to parse report content but for this I need accounting data on multiple exercises and faor all fiscal year
|
|
@ -1,60 +0,0 @@
|
|||
-
|
||||
In order to test the PDF Open Invoices Report webkit wizard I will print report with default setting
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'until_date': '%s-12-31' %(datetime.now().year)}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_open_invoices_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Open Invoices Report webkit wizard I will print report with filters and currency
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted',
|
||||
'amount_currency': True, 'result_selection': 'customer_supplier'}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_open_invoices_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Open Invoices Report webkit wizard I will print report with filters on partners
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted',
|
||||
'amount_currency': True, 'result_selection': 'customer_supplier',
|
||||
'partner_ids': [ref('base.res_partner_2'), ref('base.res_partner_1')]}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_open_invoices_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Open Invoices Report webkit wizard I will print report with filters on periods
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted',
|
||||
'amount_currency': True, 'result_selection': 'customer_supplier',
|
||||
'filter': 'filter_period', 'period_from': ref('account.period_1'), 'period_to': ref('account.period_12')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_open_invoices_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Open Invoices Report webkit wizard I will print report with filters on dates
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted',
|
||||
'amount_currency': True, 'result_selection': 'customer_supplier',
|
||||
'filter': 'filter_date', 'date_from': '%s-01-01' %(datetime.now().year), 'date_to': '%s-12-31' %(datetime.now().year)}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_open_invoices_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
|
@ -1,67 +0,0 @@
|
|||
-
|
||||
In order to test the PDF Partner Balance webkit wizard I will print report with default setting
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_partner_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Partner Balance webkit wizard I will print report as if we print it from an account
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0')}
|
||||
ctx.update({'model': 'account.account','active_ids':[ref('account.assets_view'), ref('account.liabilities_view')],'active_id': ref('account.assets_view')})
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_partner_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Partner Balance webkit wizard I will print report with filters on period
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'filter': 'filter_period', 'period_from': ref('account.period_1'), 'period_to': ref('account.period_12')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_partner_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Partner Balance webkit wizard I will print report with filters on dates
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'filter': 'filter_date', 'date_from': '%s-01-01' %(datetime.now().year), 'date_to': '%s-12-31' %(datetime.now().year)}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_partner_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Partner Balance webkit wizard I will print report with one comparison filtered by year
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'comp0_filter': 'filter_year', 'comp0_fiscalyear_id': ref('account.data_fiscalyear')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_partner_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Partner Balance webkit wizard I will print report with all comparisons filtered by year, period and date
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'comp0_filter': 'filter_year', 'comp0_fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'comp1_filter': 'filter_period', 'comp1_period_from': ref('account.period_1'), 'comp1_period_to': ref('account.period_12'),
|
||||
'comp2_filter': 'filter_date', 'comp2_date_from': '%s-01-01' %(datetime.now().year), 'comp2_date_to': '%s-12-31' %(datetime.now().year)
|
||||
}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_partner_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
|
@ -1,60 +0,0 @@
|
|||
-
|
||||
In order to test the PDF Partner Ledger webkit wizard I will print report with default setting
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'until_date': '%s-12-31' %(datetime.now().year)}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_partners_ledger_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Partner Ledger webkit wizard I will print report with filters and currency
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted',
|
||||
'amount_currency': True, 'result_selection': 'customer_supplier'}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_partners_ledger_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Partner Ledger webkit wizard I will print report with filters on partners
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted',
|
||||
'amount_currency': True, 'result_selection': 'customer_supplier',
|
||||
'partner_ids': [ref('base.res_partner_2'), ref('base.res_partner_1')]}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_partners_ledger_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Partner Ledger webkit wizard I will print report with filters on periods
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted',
|
||||
'amount_currency': True, 'result_selection': 'customer_supplier',
|
||||
'filter': 'filter_period', 'period_from': ref('account.period_1'), 'period_to': ref('account.period_12')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_partners_ledger_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Partner Ledger webkit wizard I will print report with filters on dates
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted',
|
||||
'amount_currency': True, 'result_selection': 'customer_supplier',
|
||||
'filter': 'filter_date', 'date_from': '%s-01-01' %(datetime.now().year), 'date_to': '%s-12-31' %(datetime.now().year)}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_partners_ledger_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
|
@ -1,67 +0,0 @@
|
|||
-
|
||||
In order to test the PDF Trial Balance webkit wizard I will print report with default setting
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Trial Balance webkit wizard I will print report as if we print it from an account
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0')}
|
||||
ctx.update({'model': 'account.account','active_ids':[ref('account.assets_view'), ref('account.liabilities_view')],'active_id': ref('account.assets_view')})
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Trial Balance webkit wizard I will print report with filters on period
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'filter': 'filter_period', 'period_from': ref('account.period_1'), 'period_to': ref('account.period_12')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Trial Balance webkit wizard I will print report with filters on dates
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'filter': 'filter_date', 'date_from': '%s-01-01' %(datetime.now().year), 'date_to': '%s-12-31' %(datetime.now().year)}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Trial Balance webkit wizard I will print report with one comparison filtered by year
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'comp0_filter': 'filter_year', 'comp0_fiscalyear_id': ref('account.data_fiscalyear')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
||||
|
||||
-
|
||||
In order to test the PDF Trial Balance webkit wizard I will print report with all comparisons filtered by year, period and date
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'comp0_filter': 'filter_year', 'comp0_fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'comp1_filter': 'filter_period', 'comp1_period_from': ref('account.period_1'), 'comp1_period_to': ref('account.period_12'),
|
||||
'comp2_filter': 'filter_date', 'comp2_date_from': '%s-01-01' %(datetime.now().year), 'comp2_date_to': '%s-12-31' %(datetime.now().year)
|
||||
}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_account_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, our_module='account_financial_report_webkit')
|
|
@ -1,30 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Nicolas Bessi. Copyright Camptocamp SA
|
||||
# Copyright (C) 2012 SYLEAM Info Services (<http://www.syleam.fr/>)
|
||||
# Sebastien LANGE <sebastien.lange@syleam.fr>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from . import balance_common
|
||||
from . import general_ledger_wizard
|
||||
from . import partners_ledger_wizard
|
||||
from . import trial_balance_wizard
|
||||
from . import partner_balance_wizard
|
||||
from . import open_invoices_wizard
|
||||
from . import print_journal
|
||||
from . import aged_partner_balance_wizard
|
|
@ -1,90 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Nicolas Bessi
|
||||
# Copyright 2014 Camptocamp SA
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from datetime import date
|
||||
from openerp.osv import orm, fields
|
||||
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT as DATE_FORMAT
|
||||
|
||||
|
||||
class AccountAgedTrialBalance(orm.TransientModel):
|
||||
"""Will launch age partner balance report.
|
||||
This report is based on Open Invoice Report
|
||||
and share a lot of knowledge with him
|
||||
"""
|
||||
|
||||
_inherit = "open.invoices.webkit"
|
||||
_name = "account.aged.trial.balance.webkit"
|
||||
_description = "Aged partner balanced"
|
||||
|
||||
def _get_current_fiscalyear(self, cr, uid, context=None):
|
||||
user_obj = self.pool['res.users']
|
||||
company = user_obj.browse(cr, uid, uid, context=context).company_id
|
||||
fyear_obj = self.pool['account.period']
|
||||
today = date.today().strftime(DATE_FORMAT)
|
||||
fyear_ids = fyear_obj.search(
|
||||
cr, uid,
|
||||
[('date_start', '>=', today),
|
||||
('date_stop', '<=', today),
|
||||
('company_id', '=', company.id)],
|
||||
limit=1,
|
||||
context=context)
|
||||
if fyear_ids:
|
||||
return fyear_ids[0]
|
||||
|
||||
_columns = {
|
||||
'filter': fields.selection(
|
||||
[('filter_period', 'Periods')],
|
||||
"Filter by",
|
||||
required=True),
|
||||
'fiscalyear_id': fields.many2one(
|
||||
'account.fiscalyear',
|
||||
'Fiscal Year',
|
||||
required=True),
|
||||
'period_to': fields.many2one('account.period', 'End Period',
|
||||
required=True),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'filter': 'filter_period',
|
||||
'fiscalyear_id': _get_current_fiscalyear,
|
||||
}
|
||||
|
||||
def onchange_fiscalyear(self, cr, uid, ids, fiscalyear=False,
|
||||
period_id=False, date_to=False, until_date=False,
|
||||
context=None):
|
||||
res = super(AccountAgedTrialBalance, self).onchange_fiscalyear(
|
||||
cr, uid, ids, fiscalyear=fiscalyear, period_id=period_id,
|
||||
date_to=date_to, until_date=until_date, context=context
|
||||
)
|
||||
filters = self.onchange_filter(cr, uid, ids, filter='filter_period',
|
||||
fiscalyear_id=fiscalyear,
|
||||
context=context)
|
||||
res['value'].update({
|
||||
'period_from': filters['value']['period_from'],
|
||||
'period_to': filters['value']['period_to'],
|
||||
})
|
||||
return res
|
||||
|
||||
def _print_report(self, cr, uid, ids, data, context=None):
|
||||
# we update form with display account value
|
||||
data = self.pre_print_report(cr, uid, ids, data, context=context)
|
||||
return {'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account.account_aged_trial_balance_webkit',
|
||||
'datas': data}
|
|
@ -1,75 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="account_aged_trial_balance_webkit" model="ir.ui.view">
|
||||
<field name="name">Aged Partner Balance Report</field>
|
||||
<field name="model">account.aged.trial.balance.webkit</field>
|
||||
<field name="inherit_id" ref="account.account_common_report_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
|
||||
<xpath expr="/form/label[@string='']" position="replace">
|
||||
<separator string="Aged Partner Balance" colspan="4"/>
|
||||
<label nolabel="1"
|
||||
colspan="4"
|
||||
string="This report list partner open balances and indicate when payment is (or was) supposed to be completed"/>
|
||||
</xpath>
|
||||
<field name="chart_account_id" position='attributes'>
|
||||
<attribute name="colspan">4</attribute>
|
||||
</field>
|
||||
<xpath expr="//field[@name='target_move']" position="after">
|
||||
<newline/>
|
||||
<field name="result_selection" colspan="4"/>
|
||||
</xpath>
|
||||
<xpath expr="/form/notebook[1]" position="after">
|
||||
<separator string="Clearance Analysis Options" colspan="4"/>
|
||||
<newline/>
|
||||
<field name="until_date"/>
|
||||
</xpath>
|
||||
<page name="filters" position="after">
|
||||
<page string="Partners Filters" name="partners">
|
||||
<separator string="Print only" colspan="4"/>
|
||||
<field name="partner_ids" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
</page>
|
||||
<page name="filters" position="attributes">
|
||||
<attribute name="string">Time Filters</attribute>
|
||||
</page>
|
||||
<page name="journal_ids" position="attributes">
|
||||
<attribute name="invisible">True</attribute>
|
||||
</page>
|
||||
<field name="fiscalyear_id" position="attributes">
|
||||
<attribute name="on_change">onchange_fiscalyear(fiscalyear_id, period_to, date_to, until_date)</attribute>
|
||||
</field>
|
||||
<field name="filter" position="attributes">
|
||||
<attribute name="invisible">True</attribute>
|
||||
</field>
|
||||
<field name="period_from" position="attributes">
|
||||
<attribute name="invisible">True</attribute>
|
||||
</field>
|
||||
<field name="period_to" position="attributes">
|
||||
<attribute name="on_change">onchange_period_to(fiscalyear_id, period_to, date_to, until_date)</attribute>
|
||||
</field>
|
||||
<field name="period_to" position="attributes">
|
||||
<attribute name="String">At the end of</attribute>
|
||||
</field>
|
||||
<field name="period_to" position="attributes">
|
||||
<attribute name="domain">[('fiscalyear_id', '=', fiscalyear_id), ('special', '=', False)]</attribute>
|
||||
</field>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_aged_trial_balance_menu_webkit"
|
||||
model="ir.actions.act_window">
|
||||
<field name="name">Aged partner balance</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">account.aged.trial.balance.webkit</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="account_aged_trial_balance_webkit"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,408 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)
|
||||
#
|
||||
# Author: Guewen Baconnier (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 lxml import etree
|
||||
from datetime import datetime
|
||||
from openerp.osv import fields, orm
|
||||
from openerp.tools.translate import _
|
||||
|
||||
|
||||
def previous_year_date(date, nb_prev=1):
|
||||
if not date:
|
||||
return False
|
||||
parsed_date = datetime.strptime(date, '%Y-%m-%d')
|
||||
previous_date = datetime(year=parsed_date.year - nb_prev,
|
||||
month=parsed_date.month,
|
||||
day=parsed_date.day)
|
||||
return previous_date
|
||||
|
||||
|
||||
class AccountBalanceCommonWizard(orm.TransientModel):
|
||||
|
||||
"""Will launch trial balance report and pass required args"""
|
||||
|
||||
_inherit = "account.common.account.report"
|
||||
_name = "account.common.balance.report"
|
||||
_description = "Common Balance Report"
|
||||
|
||||
# an update module should be done if changed
|
||||
# in order to create fields in db
|
||||
COMPARISON_LEVEL = 3
|
||||
|
||||
COMPARE_SELECTION = [('filter_no', 'No Comparison'),
|
||||
('filter_year', 'Fiscal Year'),
|
||||
('filter_date', 'Date'),
|
||||
('filter_period', 'Periods'),
|
||||
('filter_opening', 'Opening Only')]
|
||||
|
||||
M2O_DYNAMIC_FIELDS = [f % index for f in ["comp%s_fiscalyear_id",
|
||||
"comp%s_period_from",
|
||||
"comp%s_period_to"]
|
||||
for index in range(COMPARISON_LEVEL)]
|
||||
SIMPLE_DYNAMIC_FIELDS = [f % index for f in ["comp%s_filter",
|
||||
"comp%s_date_from",
|
||||
"comp%s_date_to"]
|
||||
for index in range(COMPARISON_LEVEL)]
|
||||
DYNAMIC_FIELDS = M2O_DYNAMIC_FIELDS + SIMPLE_DYNAMIC_FIELDS
|
||||
|
||||
def _get_account_ids(self, cr, uid, context=None):
|
||||
res = False
|
||||
if context.get('active_model', False) == 'account.account' \
|
||||
and context.get('active_ids', False):
|
||||
res = context['active_ids']
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'account_ids': fields.many2many(
|
||||
'account.account', string='Filter on accounts',
|
||||
help="Only selected accounts will be printed. Leave empty to \
|
||||
print all accounts."),
|
||||
'filter': fields.selection(
|
||||
[('filter_no', 'No Filters'),
|
||||
('filter_date', 'Date'),
|
||||
('filter_period', 'Periods'),
|
||||
('filter_opening', 'Opening Only')],
|
||||
"Filter by",
|
||||
required=True,
|
||||
help='Filter by date: no opening balance will be displayed. '
|
||||
'(opening balance can only be computed based on period to be \
|
||||
correct).'),
|
||||
}
|
||||
|
||||
for index in range(COMPARISON_LEVEL):
|
||||
_columns.update(
|
||||
{"comp%s_filter" % index:
|
||||
fields.selection(
|
||||
COMPARE_SELECTION, string='Compare By', required=True),
|
||||
"comp%s_fiscalyear_id" % index:
|
||||
fields.many2one('account.fiscalyear', 'Fiscal Year'),
|
||||
"comp%s_period_from" % index:
|
||||
fields.many2one('account.period', 'Start Period'),
|
||||
"comp%s_period_to" % index:
|
||||
fields.many2one('account.period', 'End Period'),
|
||||
"comp%s_date_from" % index:
|
||||
fields.date("Start Date"),
|
||||
"comp%s_date_to" % index:
|
||||
fields.date("End Date")})
|
||||
|
||||
_defaults = {
|
||||
'account_ids': _get_account_ids,
|
||||
}
|
||||
|
||||
def _check_fiscalyear(self, cr, uid, ids, context=None):
|
||||
obj = self.read(
|
||||
cr, uid, ids[0], ['fiscalyear_id', 'filter'], context=context)
|
||||
if not obj['fiscalyear_id'] and obj['filter'] == 'filter_no':
|
||||
return False
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
(_check_fiscalyear,
|
||||
'When no Fiscal year is selected, you must choose to filter by \
|
||||
periods or by date.', ['filter']),
|
||||
]
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
"""
|
||||
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(AccountBalanceCommonWizard, self).default_get(
|
||||
cr, uid, fields, context=context)
|
||||
for index in range(self.COMPARISON_LEVEL):
|
||||
field = "comp%s_filter" % (index,)
|
||||
if not res.get(field, False):
|
||||
res[field] = 'filter_no'
|
||||
return res
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form',
|
||||
context=None, toolbar=False, submenu=False):
|
||||
res = super(AccountBalanceCommonWizard, self).fields_view_get(
|
||||
cr, uid, view_id, view_type, context=context, toolbar=toolbar,
|
||||
submenu=submenu)
|
||||
|
||||
res['fields'].update(self.fields_get(cr, uid,
|
||||
allfields=self.DYNAMIC_FIELDS,
|
||||
context=context, write_access=True))
|
||||
|
||||
eview = etree.fromstring(res['arch'])
|
||||
placeholder = eview.xpath("//page[@name='placeholder']")
|
||||
if placeholder:
|
||||
placeholder = placeholder[0]
|
||||
for index in range(self.COMPARISON_LEVEL):
|
||||
page = etree.Element(
|
||||
'page',
|
||||
{'name': "comp%s" % index,
|
||||
'string': _("Comparison %s") % (index + 1, )})
|
||||
group = etree.Element('group')
|
||||
page.append(group)
|
||||
|
||||
def modifiers_and_append(elem):
|
||||
orm.setup_modifiers(elem)
|
||||
group.append(elem)
|
||||
|
||||
modifiers_and_append(etree.Element(
|
||||
'field',
|
||||
{'name': "comp%s_filter" % index,
|
||||
'on_change': "onchange_comp_filter(%(index)s, filter,\
|
||||
comp%(index)s_filter, fiscalyear_id, date_from, date_to)"
|
||||
% {'index': index}}))
|
||||
modifiers_and_append(etree.Element(
|
||||
'field',
|
||||
{'name': "comp%s_fiscalyear_id" % index,
|
||||
'attrs':
|
||||
"{'required': [('comp%(index)s_filter','in',\
|
||||
('filter_year','filter_opening'))],"
|
||||
" 'invisible': [('comp%(index)s_filter','not in',\
|
||||
('filter_year','filter_opening'))]}" % {'index': index}}))
|
||||
|
||||
dates_attrs = "{'required': [('comp%(index)s_filter','=',\
|
||||
'filter_date')], " \
|
||||
" 'invisible': [('comp%(index)s_filter','!=',\
|
||||
'filter_date')]}" % {
|
||||
'index': index}
|
||||
modifiers_and_append(etree.Element(
|
||||
'separator',
|
||||
{'string': _('Dates'),
|
||||
'colspan': '4',
|
||||
'attrs': dates_attrs}))
|
||||
modifiers_and_append(etree.Element(
|
||||
'field',
|
||||
{'name': "comp%s_date_from" % index,
|
||||
'attrs': dates_attrs}))
|
||||
modifiers_and_append(etree.Element(
|
||||
'field',
|
||||
{'name': "comp%s_date_to" % index,
|
||||
'attrs': dates_attrs}))
|
||||
|
||||
periods_attrs = "{'required': [('comp%(index)s_filter','=',\
|
||||
'filter_period')]," \
|
||||
" 'invisible': [('comp%(index)s_filter','!=',\
|
||||
'filter_period')]}" % {
|
||||
'index': index}
|
||||
periods_domain = "[('special', '=', False)]"
|
||||
modifiers_and_append(etree.Element(
|
||||
'separator',
|
||||
{'string': _('Periods'),
|
||||
'colspan': '4',
|
||||
'attrs': periods_attrs}))
|
||||
modifiers_and_append(etree.Element(
|
||||
'field',
|
||||
{'name': "comp%s_period_from" % index,
|
||||
'attrs': periods_attrs,
|
||||
'domain': periods_domain}))
|
||||
modifiers_and_append(etree.Element(
|
||||
'field',
|
||||
{'name': "comp%s_period_to" % index,
|
||||
'attrs': periods_attrs,
|
||||
'domain': periods_domain}))
|
||||
|
||||
placeholder.addprevious(page)
|
||||
placeholder.getparent().remove(placeholder)
|
||||
res['arch'] = etree.tostring(eview)
|
||||
return res
|
||||
|
||||
def onchange_filter(self, cr, uid, ids, filter='filter_no',
|
||||
fiscalyear_id=False, context=None):
|
||||
res = {}
|
||||
if filter == 'filter_no':
|
||||
res['value'] = {'period_from': False,
|
||||
'period_to': False,
|
||||
'date_from': False,
|
||||
'date_to': False}
|
||||
if filter == 'filter_date':
|
||||
if fiscalyear_id:
|
||||
fyear = self.pool.get('account.fiscalyear').browse(
|
||||
cr, uid, fiscalyear_id, context=context)
|
||||
date_from = fyear.date_start
|
||||
date_to = fyear.date_stop > time.strftime(
|
||||
'%Y-%m-%d') and time.strftime('%Y-%m-%d') \
|
||||
or fyear.date_stop
|
||||
else:
|
||||
date_from, date_to = time.strftime(
|
||||
'%Y-01-01'), time.strftime('%Y-%m-%d')
|
||||
res['value'] = {'period_from': False, 'period_to':
|
||||
False, 'date_from': date_from, 'date_to': date_to}
|
||||
if filter == 'filter_period' and fiscalyear_id:
|
||||
start_period = end_period = False
|
||||
cr.execute('''
|
||||
SELECT * FROM (SELECT p.id
|
||||
FROM account_period p
|
||||
LEFT JOIN account_fiscalyear f
|
||||
ON (p.fiscalyear_id = f.id)
|
||||
WHERE f.id = %s
|
||||
AND COALESCE(p.special, FALSE) = FALSE
|
||||
ORDER BY p.date_start ASC
|
||||
LIMIT 1) AS period_start
|
||||
UNION ALL
|
||||
SELECT * FROM (SELECT p.id
|
||||
FROM account_period p
|
||||
LEFT JOIN account_fiscalyear f
|
||||
ON (p.fiscalyear_id = f.id)
|
||||
WHERE f.id = %s
|
||||
AND p.date_start < NOW()
|
||||
AND COALESCE(p.special, FALSE) = FALSE
|
||||
ORDER BY p.date_stop DESC
|
||||
LIMIT 1) AS period_stop''',
|
||||
(fiscalyear_id, fiscalyear_id))
|
||||
periods = [i[0] for i in cr.fetchall()]
|
||||
if periods:
|
||||
start_period = end_period = periods[0]
|
||||
if len(periods) > 1:
|
||||
end_period = periods[1]
|
||||
res['value'] = {'period_from': start_period, 'period_to':
|
||||
end_period, 'date_from': False, 'date_to': False}
|
||||
return res
|
||||
|
||||
def onchange_comp_filter(self, cr, uid, ids, index,
|
||||
main_filter='filter_no', comp_filter='filter_no',
|
||||
fiscalyear_id=False, start_date=False,
|
||||
stop_date=False, context=None):
|
||||
res = {}
|
||||
fy_obj = self.pool.get('account.fiscalyear')
|
||||
last_fiscalyear_id = False
|
||||
if fiscalyear_id:
|
||||
fiscalyear = fy_obj.browse(cr, uid, fiscalyear_id, context=context)
|
||||
last_fiscalyear_ids = fy_obj.search(
|
||||
cr, uid, [('date_stop', '<', fiscalyear.date_start)],
|
||||
limit=self.COMPARISON_LEVEL, order='date_start desc',
|
||||
context=context)
|
||||
if last_fiscalyear_ids:
|
||||
if len(last_fiscalyear_ids) > index:
|
||||
# first element for the comparison 1, second element for
|
||||
# the comparison 2
|
||||
last_fiscalyear_id = last_fiscalyear_ids[index]
|
||||
|
||||
fy_id_field = "comp%s_fiscalyear_id" % (index,)
|
||||
period_from_field = "comp%s_period_from" % (index,)
|
||||
period_to_field = "comp%s_period_to" % (index,)
|
||||
date_from_field = "comp%s_date_from" % (index,)
|
||||
date_to_field = "comp%s_date_to" % (index,)
|
||||
|
||||
if comp_filter == 'filter_no':
|
||||
res['value'] = {
|
||||
fy_id_field: False,
|
||||
period_from_field: False,
|
||||
period_to_field: False,
|
||||
date_from_field: False,
|
||||
date_to_field: False
|
||||
}
|
||||
if comp_filter in ('filter_year', 'filter_opening'):
|
||||
res['value'] = {
|
||||
fy_id_field: last_fiscalyear_id,
|
||||
period_from_field: False,
|
||||
period_to_field: False,
|
||||
date_from_field: False,
|
||||
date_to_field: False
|
||||
}
|
||||
if comp_filter == 'filter_date':
|
||||
dates = {}
|
||||
if main_filter == 'filter_date':
|
||||
dates = {
|
||||
'date_start': previous_year_date(start_date, index + 1).
|
||||
strftime('%Y-%m-%d'),
|
||||
'date_stop': previous_year_date(stop_date, index + 1).
|
||||
strftime('%Y-%m-%d'),
|
||||
}
|
||||
elif last_fiscalyear_id:
|
||||
dates = fy_obj.read(
|
||||
cr, uid, last_fiscalyear_id, ['date_start', 'date_stop'],
|
||||
context=context)
|
||||
|
||||
res['value'] = {fy_id_field: False,
|
||||
period_from_field: False,
|
||||
period_to_field: False,
|
||||
date_from_field: dates.get('date_start', False),
|
||||
date_to_field: dates.get('date_stop', False)}
|
||||
if comp_filter == 'filter_period' and last_fiscalyear_id:
|
||||
start_period = end_period = False
|
||||
cr.execute('''
|
||||
SELECT * FROM (SELECT p.id
|
||||
FROM account_period p
|
||||
LEFT JOIN account_fiscalyear f
|
||||
ON (p.fiscalyear_id = f.id)
|
||||
WHERE f.id = %(fiscalyear)s
|
||||
AND COALESCE(p.special, FALSE) = FALSE
|
||||
ORDER BY p.date_start ASC
|
||||
LIMIT 1) AS period_start
|
||||
UNION ALL
|
||||
SELECT * FROM (SELECT p.id
|
||||
FROM account_period p
|
||||
LEFT JOIN account_fiscalyear f
|
||||
ON (p.fiscalyear_id = f.id)
|
||||
WHERE f.id = %(fiscalyear)s
|
||||
AND p.date_start < NOW()
|
||||
AND COALESCE(p.special, FALSE) = FALSE
|
||||
ORDER BY p.date_stop DESC
|
||||
LIMIT 1) AS period_stop''',
|
||||
{'fiscalyear': last_fiscalyear_id})
|
||||
periods = [i[0] for i in cr.fetchall()]
|
||||
if periods and len(periods) > 1:
|
||||
start_period = end_period = periods[0]
|
||||
if len(periods) > 1:
|
||||
end_period = periods[1]
|
||||
res['value'] = {fy_id_field: False,
|
||||
period_from_field: start_period,
|
||||
period_to_field: end_period,
|
||||
date_from_field: False,
|
||||
date_to_field: False}
|
||||
return res
|
||||
|
||||
def pre_print_report(self, cr, uid, ids, data, context=None):
|
||||
data = super(AccountBalanceCommonWizard, self).pre_print_report(
|
||||
cr, uid, ids, data, context)
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
# will be used to attach the report on the main account
|
||||
data['ids'] = [data['form']['chart_account_id']]
|
||||
|
||||
fields_to_read = ['account_ids', ]
|
||||
fields_to_read += self.DYNAMIC_FIELDS
|
||||
vals = self.read(cr, uid, ids, fields_to_read, context=context)[0]
|
||||
|
||||
# extract the id from the m2o tuple (id, name)
|
||||
for field in self.M2O_DYNAMIC_FIELDS:
|
||||
if isinstance(vals[field], tuple):
|
||||
vals[field] = vals[field][0]
|
||||
|
||||
vals['max_comparison'] = self.COMPARISON_LEVEL
|
||||
data['form'].update(vals)
|
||||
return data
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- inheriting views from more than 2 differents inherited models like
|
||||
trial.balance.webkit -> account.common.balance.report -> account.common.account.report
|
||||
is not supported so we have to copy paste the same view for trial balance, balance sheet
|
||||
-->
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,156 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Nicolas Bessi, Guewen Baconnier
|
||||
# Copyright Camptocamp SA 2011
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
|
||||
from openerp.osv import fields, orm
|
||||
|
||||
|
||||
class AccountReportGeneralLedgerWizard(orm.TransientModel):
|
||||
|
||||
"""Will launch general ledger report and pass required args"""
|
||||
|
||||
_inherit = "account.common.account.report"
|
||||
_name = "general.ledger.webkit"
|
||||
_description = "General Ledger Report"
|
||||
|
||||
def _get_account_ids(self, cr, uid, context=None):
|
||||
res = False
|
||||
if context.get('active_model', False) == 'account.account' \
|
||||
and context.get('active_ids', False):
|
||||
res = context['active_ids']
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'amount_currency': fields.boolean("With Currency",
|
||||
help="It adds the currency column"),
|
||||
|
||||
'display_account': fields.selection(
|
||||
[('bal_all', 'All'),
|
||||
('bal_mix', 'With transactions or non zero balance')],
|
||||
'Display accounts',
|
||||
required=True),
|
||||
'account_ids': fields.many2many(
|
||||
'account.account', string='Filter on accounts',
|
||||
help="""Only selected accounts will be printed. Leave empty to
|
||||
print all accounts."""),
|
||||
'centralize': fields.boolean(
|
||||
'Activate Centralization',
|
||||
help='Uncheck to display all the details of centralized accounts.')
|
||||
}
|
||||
_defaults = {
|
||||
'amount_currency': False,
|
||||
'display_account': 'bal_mix',
|
||||
'account_ids': _get_account_ids,
|
||||
'centralize': True,
|
||||
}
|
||||
|
||||
def _check_fiscalyear(self, cr, uid, ids, context=None):
|
||||
obj = self.read(
|
||||
cr, uid, ids[0], ['fiscalyear_id', 'filter'], context=context)
|
||||
if not obj['fiscalyear_id'] and obj['filter'] == 'filter_no':
|
||||
return False
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
(_check_fiscalyear,
|
||||
'When no Fiscal year is selected, you must choose to filter by \
|
||||
periods or by date.', ['filter']),
|
||||
]
|
||||
|
||||
def pre_print_report(self, cr, uid, ids, data, context=None):
|
||||
data = super(AccountReportGeneralLedgerWizard, self).pre_print_report(
|
||||
cr, uid, ids, data, context)
|
||||
# will be used to attach the report on the main account
|
||||
data['ids'] = [data['form']['chart_account_id']]
|
||||
vals = self.read(cr, uid, ids,
|
||||
['amount_currency',
|
||||
'display_account',
|
||||
'account_ids',
|
||||
'centralize'],
|
||||
context=context)[0]
|
||||
data['form'].update(vals)
|
||||
return data
|
||||
|
||||
def onchange_filter(self, cr, uid, ids, filter='filter_no',
|
||||
fiscalyear_id=False, context=None):
|
||||
res = {}
|
||||
if filter == 'filter_no':
|
||||
res['value'] = {
|
||||
'period_from': False,
|
||||
'period_to': False,
|
||||
'date_from': False,
|
||||
'date_to': False,
|
||||
}
|
||||
if filter == 'filter_date':
|
||||
if fiscalyear_id:
|
||||
fyear = self.pool.get('account.fiscalyear').browse(
|
||||
cr, uid, fiscalyear_id, context=context)
|
||||
date_from = fyear.date_start
|
||||
date_to = fyear.date_stop > time.strftime(
|
||||
'%Y-%m-%d') and time.strftime('%Y-%m-%d') \
|
||||
or fyear.date_stop
|
||||
else:
|
||||
date_from, date_to = time.strftime(
|
||||
'%Y-01-01'), time.strftime('%Y-%m-%d')
|
||||
res['value'] = {
|
||||
'period_from': False,
|
||||
'period_to': False,
|
||||
'date_from': date_from,
|
||||
'date_to': date_to
|
||||
}
|
||||
if filter == 'filter_period' and fiscalyear_id:
|
||||
start_period = end_period = False
|
||||
cr.execute('''
|
||||
SELECT * FROM (SELECT p.id
|
||||
FROM account_period p
|
||||
LEFT JOIN account_fiscalyear f
|
||||
ON (p.fiscalyear_id = f.id)
|
||||
WHERE f.id = %s
|
||||
AND COALESCE(p.special, FALSE) = FALSE
|
||||
ORDER BY p.date_start ASC
|
||||
LIMIT 1) AS period_start
|
||||
UNION ALL
|
||||
SELECT * FROM (SELECT p.id
|
||||
FROM account_period p
|
||||
LEFT JOIN account_fiscalyear f
|
||||
ON (p.fiscalyear_id = f.id)
|
||||
WHERE f.id = %s
|
||||
AND p.date_start < NOW()
|
||||
AND COALESCE(p.special, FALSE) = FALSE
|
||||
ORDER BY p.date_stop DESC
|
||||
LIMIT 1) AS period_stop''',
|
||||
(fiscalyear_id, fiscalyear_id))
|
||||
periods = [i[0] for i in cr.fetchall()]
|
||||
if periods:
|
||||
start_period = end_period = periods[0]
|
||||
if len(periods) > 1:
|
||||
end_period = periods[1]
|
||||
res['value'] = {'period_from': start_period, 'period_to':
|
||||
end_period, 'date_from': False, 'date_to': False}
|
||||
return res
|
||||
|
||||
def _print_report(self, cursor, uid, ids, data, context=None):
|
||||
# we update form with display account value
|
||||
data = self.pre_print_report(cursor, uid, ids, data, context=context)
|
||||
return {'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account.account_report_general_ledger_webkit',
|
||||
'datas': data}
|
|
@ -1,88 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="account_report_general_ledger_view_webkit" model="ir.ui.view">
|
||||
<field name="name">General Ledger</field>
|
||||
<field name="model">general.ledger.webkit</field>
|
||||
<field name="inherit_id" ref="account.account_common_report_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="/form/label[@string='']" position="replace">
|
||||
<separator string="General Ledger" colspan="4"/>
|
||||
<label nolabel="1" colspan="4" string="This report allows you to print or generate a pdf of your general ledger with details of all your account journals"/>
|
||||
</xpath>
|
||||
<field name="chart_account_id" position='attributes'>
|
||||
<attribute name="colspan">4</attribute>
|
||||
</field>
|
||||
<form position="inside">
|
||||
<field name="display_account" invisible="True"/>
|
||||
</form>
|
||||
<page name="filters" position="after">
|
||||
<page string="Accounts Filters" name="accounts">
|
||||
<separator string="Print only" colspan="4"/>
|
||||
<field name="account_ids" colspan="4" nolabel="1">
|
||||
<tree>
|
||||
<field name="code"/>
|
||||
<field name="name"/>
|
||||
<field name="type"/>
|
||||
<field name="company_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Layout Options" name="layout_options">
|
||||
<group colspan="4" col="2">
|
||||
<field name="amount_currency"/>
|
||||
<field name="centralize"/>
|
||||
</group>
|
||||
</page>
|
||||
</page>
|
||||
<page name="journal_ids" position="attributes">
|
||||
<attribute name="invisible">True</attribute>
|
||||
</page>
|
||||
<page name="filters" position="attributes">
|
||||
<attribute name="string">Time Filters</attribute>
|
||||
</page>
|
||||
<field name="period_from" position="attributes">
|
||||
<attribute name="domain">[('fiscalyear_id', '=', fiscalyear_id), ('special', '=', False)]</attribute>
|
||||
</field>
|
||||
<field name="period_to" position="attributes">
|
||||
<attribute name="domain">[('fiscalyear_id', '=', fiscalyear_id), ('special', '=', False)]</attribute>
|
||||
</field>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="account_report_general_ledger_view_inherit" model="ir.ui.view">
|
||||
<field name="name">General Ledger</field>
|
||||
<field name="model">general.ledger.webkit</field>
|
||||
<field name="inherit_id" ref="account.account_report_general_ledger_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="fiscalyear_id" position="replace">
|
||||
<field name="fiscalyear_id" on_change="onchange_fiscalyear(fiscalyear_id)"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_general_ledger_menu_webkit" model="ir.actions.act_window">
|
||||
<field name="name">General Ledger</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">general.ledger.webkit</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="account_report_general_ledger_view_webkit"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="action_account_general_ledger_values_webkit">
|
||||
<field name="model_id" ref="account.model_account_account"/>
|
||||
<field name="name">General Ledger</field>
|
||||
<field name="key2">client_print_multi</field>
|
||||
<field name="value"
|
||||
eval="'ir.actions.act_window,' +str(ref('action_account_general_ledger_menu_webkit'))"/>
|
||||
<field name="key">action</field>
|
||||
<field name="model">account.account</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,148 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Guewen Baconnier
|
||||
# Copyright Camptocamp SA 2012
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from openerp.osv import fields, orm
|
||||
|
||||
|
||||
class AccountReportOpenInvoicesWizard(orm.TransientModel):
|
||||
|
||||
"""Will launch partner ledger report and pass required args"""
|
||||
|
||||
_inherit = "partners.ledger.webkit"
|
||||
_name = "open.invoices.webkit"
|
||||
_description = "Open Invoices Report"
|
||||
|
||||
_columns = {
|
||||
'group_by_currency': fields.boolean('Group Partner by currency'),
|
||||
'until_date': fields.date(
|
||||
"Clearance date",
|
||||
required=True,
|
||||
help="""The clearance date is essentially a tool used for debtors
|
||||
provisionning calculation.
|
||||
|
||||
By default, this date is equal to the the end date (ie: 31/12/2011 if you
|
||||
select fy 2011).
|
||||
|
||||
By amending the clearance date, you will be, for instance, able to answer the
|
||||
question : 'based on my last year end debtors open invoices, which invoices
|
||||
are still unpaid today (today is my clearance date)?'
|
||||
""")}
|
||||
|
||||
def _check_until_date(self, cr, uid, ids, context=None):
|
||||
def get_key_id(obj, field):
|
||||
return obj.get(field) and obj[field][0] or False
|
||||
|
||||
obj = self.read(cr, uid, ids[0], [
|
||||
'fiscalyear_id', 'period_to', 'date_to', 'until_date'],
|
||||
context=context)
|
||||
min_date = self.default_until_date(cr, uid, ids,
|
||||
get_key_id(obj, 'fiscalyear_id'),
|
||||
get_key_id(obj, 'period_to'),
|
||||
obj['date_to'],
|
||||
context=context)
|
||||
if min_date and obj['until_date'] < min_date:
|
||||
return False
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
(_check_until_date, 'Clearance date must be the very last date of the \
|
||||
last period or later.', ['until_date']),
|
||||
]
|
||||
|
||||
def default_until_date(self, cr, uid, ids, fiscalyear_id=False,
|
||||
period_id=False, date_to=False, context=None):
|
||||
res_date = False
|
||||
# first priority: period or date filters
|
||||
if period_id:
|
||||
res_date = self.pool.get('account.period').read(
|
||||
cr, uid, period_id, ['date_stop'],
|
||||
context=context)['date_stop']
|
||||
elif date_to:
|
||||
res_date = date_to
|
||||
elif fiscalyear_id:
|
||||
res_date = self.pool.get('account.fiscalyear').read(
|
||||
cr, uid, fiscalyear_id, ['date_stop'],
|
||||
context=context)['date_stop']
|
||||
return res_date
|
||||
|
||||
def onchange_fiscalyear(self, cr, uid, ids, fiscalyear=False,
|
||||
period_id=False, date_to=False, until_date=False,
|
||||
context=None):
|
||||
res = {'value': {}}
|
||||
res['value']['until_date'] = self.default_until_date(
|
||||
cr, uid, ids,
|
||||
fiscalyear_id=fiscalyear,
|
||||
period_id=period_id,
|
||||
date_to=date_to,
|
||||
context=context)
|
||||
return res
|
||||
|
||||
def onchange_date_to(self, cr, uid, ids, fiscalyear=False, period_id=False,
|
||||
date_to=False, until_date=False, context=None):
|
||||
res = {'value': {}}
|
||||
res['value']['until_date'] = self.default_until_date(
|
||||
cr, uid, ids,
|
||||
fiscalyear_id=fiscalyear,
|
||||
period_id=period_id,
|
||||
date_to=date_to,
|
||||
context=context)
|
||||
return res
|
||||
|
||||
def onchange_period_to(self, cr, uid, ids, fiscalyear=False,
|
||||
period_id=False, date_to=False, until_date=False,
|
||||
context=None):
|
||||
res = {'value': {}}
|
||||
res['value']['until_date'] = self.default_until_date(
|
||||
cr, uid, ids,
|
||||
fiscalyear_id=fiscalyear,
|
||||
period_id=period_id,
|
||||
date_to=date_to,
|
||||
context=context)
|
||||
return res
|
||||
|
||||
def onchange_filter(self, cr, uid, ids, filter='filter_no',
|
||||
fiscalyear_id=False, context=None):
|
||||
res = super(AccountReportOpenInvoicesWizard, self).onchange_filter(
|
||||
cr, uid, ids, filter=filter, fiscalyear_id=fiscalyear_id,
|
||||
context=context)
|
||||
if res.get('value', False):
|
||||
res['value']['until_date'] = self.default_until_date(
|
||||
cr, uid, ids,
|
||||
fiscalyear_id=fiscalyear_id,
|
||||
period_id=res['value'].get('period_to', False),
|
||||
date_to=res['value'].get('date_to', False),
|
||||
context=context)
|
||||
return res
|
||||
|
||||
def pre_print_report(self, cr, uid, ids, data, context=None):
|
||||
data = super(AccountReportOpenInvoicesWizard, self).pre_print_report(
|
||||
cr, uid, ids, data, context)
|
||||
vals = self.read(cr, uid, ids,
|
||||
['until_date', 'group_by_currency'],
|
||||
context=context)[0]
|
||||
data['form'].update(vals)
|
||||
return data
|
||||
|
||||
def _print_report(self, cr, uid, ids, data, context=None):
|
||||
# we update form with display account value
|
||||
data = self.pre_print_report(cr, uid, ids, data, context=context)
|
||||
return {'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account.account_report_open_invoices_webkit',
|
||||
'datas': data}
|
|
@ -1,75 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="account_open_invoices_view_webkit" model="ir.ui.view">
|
||||
<field name="name">Open Invoices Report</field>
|
||||
<field name="model">open.invoices.webkit</field>
|
||||
<field name="inherit_id" ref="account.account_common_report_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="/form/label[@string='']" position="replace">
|
||||
<separator string="Open Invoices" colspan="4"/>
|
||||
<label nolabel="1" colspan="4" string="This report allows you to print or generate a pdf of your open invoices per partner with details of all your payable/receivable account. Exclude full reconciled journal items."/>
|
||||
</xpath>
|
||||
<field name="chart_account_id" position='attributes'>
|
||||
<attribute name="colspan">4</attribute>
|
||||
</field>
|
||||
<xpath expr="//field[@name='target_move']" position="after">
|
||||
<newline/>
|
||||
<field name="result_selection" colspan="4"/>
|
||||
</xpath>
|
||||
<xpath expr="/form/notebook[1]" position="after">
|
||||
<separator string="Clearance Analysis Options" colspan="4"/>
|
||||
<newline/>
|
||||
<field name="until_date"/>
|
||||
</xpath>
|
||||
<page name="filters" position="after">
|
||||
<page string="Partners Filters" name="partners">
|
||||
<separator string="Print only" colspan="4"/>
|
||||
<field name="partner_ids" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
<page string="Layout Options" name="layout_options">
|
||||
<group>
|
||||
<field name="amount_currency"/>
|
||||
<field name="group_by_currency"/>
|
||||
</group>
|
||||
</page>
|
||||
</page>
|
||||
<page name="filters" position="attributes">
|
||||
<attribute name="string">Time Filters</attribute>
|
||||
</page>
|
||||
<page name="journal_ids" position="attributes">
|
||||
<attribute name="invisible">True</attribute>
|
||||
</page>
|
||||
<field name="fiscalyear_id" position="attributes">
|
||||
<attribute name="on_change">onchange_fiscalyear(fiscalyear_id, period_to, date_to, until_date)</attribute>
|
||||
</field>
|
||||
<field name="date_to" position="attributes">
|
||||
<attribute name="on_change">onchange_date_to(fiscalyear_id, period_to, date_to, until_date)</attribute>
|
||||
</field>
|
||||
<field name="period_to" position="attributes">
|
||||
<attribute name="on_change">onchange_period_to(fiscalyear_id, period_to, date_to, until_date)</attribute>
|
||||
</field>
|
||||
<field name="period_from" position="attributes">
|
||||
<attribute name="domain">[('fiscalyear_id', '=', fiscalyear_id), ('special', '=', False)]</attribute>
|
||||
</field>
|
||||
<field name="period_to" position="attributes">
|
||||
<attribute name="domain">[('fiscalyear_id', '=', fiscalyear_id), ('special', '=', False)]</attribute>
|
||||
</field>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_open_invoices_menu_webkit" model="ir.actions.act_window">
|
||||
<field name="name">Open Invoices Report</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">open.invoices.webkit</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="account_open_invoices_view_webkit"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,64 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Guewen Baconnier
|
||||
# Copyright Camptocamp SA 2011
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import fields, orm
|
||||
|
||||
|
||||
class AccountPartnerBalanceWizard(orm.TransientModel):
|
||||
|
||||
"""Will launch partner balance report and pass required args"""
|
||||
|
||||
_inherit = "account.common.balance.report"
|
||||
_name = "partner.balance.webkit"
|
||||
_description = "Partner Balance Report"
|
||||
|
||||
_columns = {
|
||||
'result_selection': fields.selection(
|
||||
[('customer', 'Receivable Accounts'),
|
||||
('supplier', 'Payable Accounts'),
|
||||
('customer_supplier', 'Receivable and Payable Accounts')],
|
||||
"Partner's", required=True),
|
||||
'partner_ids': fields.many2many(
|
||||
'res.partner', string='Filter on partner',
|
||||
help="Only selected partners will be printed. \
|
||||
Leave empty to print all partners."),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'result_selection': 'customer_supplier',
|
||||
}
|
||||
|
||||
def pre_print_report(self, cr, uid, ids, data, context=None):
|
||||
data = super(AccountPartnerBalanceWizard, self).\
|
||||
pre_print_report(cr, uid, ids, data, context)
|
||||
vals = self.read(cr, uid, ids,
|
||||
['result_selection', 'partner_ids'],
|
||||
context=context)[0]
|
||||
data['form'].update(vals)
|
||||
return data
|
||||
|
||||
def _print_report(self, cursor, uid, ids, data, context=None):
|
||||
# we update form with display account value
|
||||
data = self.pre_print_report(cursor, uid, ids, data, context=context)
|
||||
|
||||
return {'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account.account_report_partner_balance_webkit',
|
||||
'datas': data}
|
|
@ -1,84 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- inheriting views from more than 2 differents inherited models like
|
||||
partner.balance.webkit -> account.common.balance.report -> account.common.account.report
|
||||
is not supported so we have to copy paste the same view for partner balance, balance sheet
|
||||
-->
|
||||
<record id="account_partner_balance_view_webkit" model="ir.ui.view">
|
||||
<field name="name">Partner Balance</field>
|
||||
<field name="model">partner.balance.webkit</field>
|
||||
<field name="inherit_id" ref="account.account_common_report_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="/form/label[@string='']" position="replace">
|
||||
<separator string="Partner Balance" colspan="4"/>
|
||||
<label nolabel="1" colspan="4" string="This report is an analysis done by a partner, It is a PDF report containing one line per partner representing the cumulative credit balance"/>
|
||||
</xpath>
|
||||
<field name="chart_account_id" position='attributes'>
|
||||
<attribute name="colspan">4</attribute>
|
||||
</field>
|
||||
<field name="target_move" position="after">
|
||||
<newline/>
|
||||
<field name="result_selection" colspan="4"/>
|
||||
</field>
|
||||
<page name="filters" position="after">
|
||||
<page string="Accounts Filters" name="accounts">
|
||||
<separator string="Print only" colspan="4"/>
|
||||
<field name="account_ids" colspan="4" nolabel="1" domain="[('type', 'in', ['receivable', 'payable'])]">
|
||||
<tree>
|
||||
<field name="code"/>
|
||||
<field name="name"/>
|
||||
<field name="type"/>
|
||||
<field name="company_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Partners Filters" name="accounts">
|
||||
<separator string="Print only" colspan="4"/>
|
||||
<field name="partner_ids" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
<page name="placeholder"/>
|
||||
</page>
|
||||
<page name="journal_ids" position="attributes">
|
||||
<attribute name="invisible">True</attribute>
|
||||
</page>
|
||||
<page name="filters" position="attributes">
|
||||
<attribute name="string">Time Filters</attribute>
|
||||
</page>
|
||||
<field name="period_from" position="attributes">
|
||||
<attribute name="domain">[('fiscalyear_id', '=', fiscalyear_id), ('special', '=', False)]</attribute>
|
||||
</field>
|
||||
<field name="period_to" position="attributes">
|
||||
<attribute name="domain">[('fiscalyear_id', '=', fiscalyear_id), ('special', '=', False)]</attribute>
|
||||
</field>
|
||||
<field name="fiscalyear_id" position="attributes">
|
||||
<attribute name="attrs">{'required': [('filter', '=', 'filter_opening')]}</attribute>
|
||||
</field>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_partner_balance_menu_webkit" model="ir.actions.act_window">
|
||||
<field name="name">Partner Balance</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">partner.balance.webkit</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="account_partner_balance_view_webkit"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="action_account_partner_balance_values_webkit">
|
||||
<field name="model_id" ref="account.model_account_account"/>
|
||||
<field name="name">Partner Balance</field>
|
||||
<field name="key2">client_print_multi</field>
|
||||
<field name="value"
|
||||
eval="'ir.actions.act_window,' +str(ref('action_account_partner_balance_menu_webkit'))"/>
|
||||
<field name="key">action</field>
|
||||
<field name="model">account.account</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,140 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Nicolas Bessi, Guewen Baconnier
|
||||
# Copyright Camptocamp SA 2011
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import time
|
||||
|
||||
from openerp.osv import fields, orm
|
||||
|
||||
|
||||
class AccountReportPartnersLedgerWizard(orm.TransientModel):
|
||||
|
||||
"""Will launch partner ledger report and pass required args"""
|
||||
|
||||
_inherit = "account.common.partner.report"
|
||||
_name = "partners.ledger.webkit"
|
||||
_description = "Partner Ledger Report"
|
||||
|
||||
_columns = {
|
||||
'amount_currency': fields.boolean("With Currency",
|
||||
help="It adds the currency column"),
|
||||
'partner_ids': fields.many2many(
|
||||
'res.partner',
|
||||
string='Filter on partner',
|
||||
help="Only selected partners will be printed. "
|
||||
"Leave empty to print all partners."),
|
||||
'filter': fields.selection(
|
||||
[('filter_no', 'No Filters'),
|
||||
('filter_date', 'Date'),
|
||||
('filter_period', 'Periods')], "Filter by", required=True,
|
||||
help='Filter by date: no opening balance will be displayed. '
|
||||
'(opening balance can only be computed based on period to be \
|
||||
correct).'),
|
||||
}
|
||||
_defaults = {
|
||||
'amount_currency': False,
|
||||
'result_selection': 'customer_supplier',
|
||||
}
|
||||
|
||||
def _check_fiscalyear(self, cr, uid, ids, context=None):
|
||||
obj = self.read(
|
||||
cr, uid, ids[0], ['fiscalyear_id', 'filter'], context=context)
|
||||
if not obj['fiscalyear_id'] and obj['filter'] == 'filter_no':
|
||||
return False
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
(_check_fiscalyear,
|
||||
'When no Fiscal year is selected, you must choose to '
|
||||
'filter by periods or by date.',
|
||||
['filter']),
|
||||
]
|
||||
|
||||
def onchange_filter(self, cr, uid, ids, filter='filter_no',
|
||||
fiscalyear_id=False, context=None):
|
||||
res = {}
|
||||
if filter == 'filter_no':
|
||||
res['value'] = {'period_from': False,
|
||||
'period_to': False,
|
||||
'date_from': False,
|
||||
'date_to': False}
|
||||
|
||||
if filter == 'filter_date':
|
||||
if fiscalyear_id:
|
||||
fyear = self.pool.get('account.fiscalyear').browse(
|
||||
cr, uid, fiscalyear_id, context=context)
|
||||
date_from = fyear.date_start
|
||||
date_to = fyear.date_stop > time.strftime(
|
||||
'%Y-%m-%d') and time.strftime('%Y-%m-%d') \
|
||||
or fyear.date_stop
|
||||
else:
|
||||
date_from, date_to = time.strftime(
|
||||
'%Y-01-01'), time.strftime('%Y-%m-%d')
|
||||
res['value'] = {'period_from': False, 'period_to':
|
||||
False, 'date_from': date_from, 'date_to': date_to}
|
||||
if filter == 'filter_period' and fiscalyear_id:
|
||||
start_period = end_period = False
|
||||
cr.execute('''
|
||||
SELECT * FROM (SELECT p.id
|
||||
FROM account_period p
|
||||
LEFT JOIN account_fiscalyear f
|
||||
ON (p.fiscalyear_id = f.id)
|
||||
WHERE f.id = %s
|
||||
AND COALESCE(p.special, FALSE) = FALSE
|
||||
ORDER BY p.date_start ASC
|
||||
LIMIT 1) AS period_start
|
||||
UNION ALL
|
||||
SELECT * FROM (SELECT p.id
|
||||
FROM account_period p
|
||||
LEFT JOIN account_fiscalyear f
|
||||
ON (p.fiscalyear_id = f.id)
|
||||
WHERE f.id = %s
|
||||
AND p.date_start < NOW()
|
||||
AND COALESCE(p.special, FALSE) = FALSE
|
||||
ORDER BY p.date_stop DESC
|
||||
LIMIT 1) AS period_stop''',
|
||||
(fiscalyear_id, fiscalyear_id))
|
||||
periods = [i[0] for i in cr.fetchall()]
|
||||
if periods:
|
||||
start_period = end_period = periods[0]
|
||||
if len(periods) > 1:
|
||||
end_period = periods[1]
|
||||
res['value'] = {'period_from': start_period, 'period_to':
|
||||
end_period, 'date_from': False, 'date_to': False}
|
||||
return res
|
||||
|
||||
def pre_print_report(self, cr, uid, ids, data, context=None):
|
||||
data = super(AccountReportPartnersLedgerWizard, self).pre_print_report(
|
||||
cr, uid, ids, data, context)
|
||||
if context is None:
|
||||
context = {}
|
||||
# will be used to attach the report on the main account
|
||||
data['ids'] = [data['form']['chart_account_id']]
|
||||
vals = self.read(cr, uid, ids,
|
||||
['amount_currency', 'partner_ids'],
|
||||
context=context)[0]
|
||||
data['form'].update(vals)
|
||||
return data
|
||||
|
||||
def _print_report(self, cursor, uid, ids, data, context=None):
|
||||
# we update form with display account value
|
||||
data = self.pre_print_report(cursor, uid, ids, data, context=context)
|
||||
return {'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account.account_report_partners_ledger_webkit',
|
||||
'datas': data}
|
|
@ -1,70 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="account_partner_ledger_view_webkit" model="ir.ui.view">
|
||||
<field name="name">Partner Ledger</field>
|
||||
<field name="model">partners.ledger.webkit</field>
|
||||
<field name="inherit_id" ref="account.account_common_report_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="/form/label[@string='']" position="replace">
|
||||
<separator string="Partner Ledger" colspan="4"/>
|
||||
<label nolabel="1" colspan="4" string="This report allows you to print or generate a pdf of your partner ledger with details of all your payable/receivable account"/>
|
||||
</xpath>
|
||||
<field name="chart_account_id" position='attributes'>
|
||||
<attribute name="colspan">4</attribute>
|
||||
</field>
|
||||
<xpath expr="//field[@name='target_move']" position="after">
|
||||
<newline/>
|
||||
<field name="result_selection" colspan="4"/>
|
||||
</xpath>
|
||||
<page name="filters" position="after">
|
||||
<page string="Partners Filters" name="partners">
|
||||
<separator string="Print only" colspan="4"/>
|
||||
<field name="partner_ids" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
<page string="Layout Options" name="layout_options">
|
||||
<group colspan="4" col="2">
|
||||
<field name="amount_currency"/>
|
||||
</group>
|
||||
</page>
|
||||
</page>
|
||||
<page name="filters" position="attributes">
|
||||
<attribute name="string">Time Filters</attribute>
|
||||
</page>
|
||||
<page name="journal_ids" position="attributes">
|
||||
<attribute name="invisible">True</attribute>
|
||||
</page>
|
||||
<field name="period_from" position="attributes">
|
||||
<attribute name="domain">[('fiscalyear_id', '=', fiscalyear_id), ('special', '=', False)]</attribute>
|
||||
</field>
|
||||
<field name="period_to" position="attributes">
|
||||
<attribute name="domain">[('fiscalyear_id', '=', fiscalyear_id), ('special', '=', False)]</attribute>
|
||||
</field>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_partners_ledger_menu_webkit" model="ir.actions.act_window">
|
||||
<field name="name">Partner Ledger</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">partners.ledger.webkit</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="account_partner_ledger_view_webkit"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="action_account_partners_ledger_values_webkit">
|
||||
<field name="model_id" ref="account.model_account_account"/>
|
||||
<field name="name">Partner Ledger</field>
|
||||
<field name="key2">client_print_multi</field>
|
||||
<field name="value"
|
||||
eval="'ir.actions.act_window,' +str(ref('action_account_partners_ledger_menu_webkit'))"/>
|
||||
<field name="key">action</field>
|
||||
<field name="model">account.account</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,131 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# account_financial_report_webkit module for OpenERP
|
||||
# Copyright (C) 2012 SYLEAM Info Services (<http://www.syleam.fr/>)
|
||||
# Sebastien LANGE <sebastien.lange@syleam.fr>
|
||||
#
|
||||
# This file is a part of account_financial_report_webkit
|
||||
#
|
||||
# account_financial_report_webkit 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.
|
||||
#
|
||||
# account_financial_report_webkit 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import fields, orm
|
||||
import time
|
||||
|
||||
|
||||
class AccountReportPrintJournalWizard(orm.TransientModel):
|
||||
|
||||
"""Will launch print journal report and pass requiered args"""
|
||||
|
||||
_inherit = "account.common.account.report"
|
||||
_name = "print.journal.webkit"
|
||||
_description = "Journals Report"
|
||||
|
||||
_columns = {
|
||||
'amount_currency': fields.boolean("With Currency",
|
||||
help="It adds the currency column"),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'amount_currency': False,
|
||||
'journal_ids': False,
|
||||
'filter': 'filter_period',
|
||||
}
|
||||
|
||||
def _check_fiscalyear(self, cr, uid, ids, context=None):
|
||||
obj = self.read(cr, uid, ids[0], ['fiscalyear_id', 'filter'],
|
||||
context=context)
|
||||
if not obj['fiscalyear_id'] and obj['filter'] == 'filter_no':
|
||||
return False
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
(_check_fiscalyear, 'When no Fiscal year is selected, you must choose \
|
||||
to filter by periods or by date.', ['filter']),
|
||||
]
|
||||
|
||||
def pre_print_report(self, cr, uid, ids, data, context=None):
|
||||
data = super(AccountReportPrintJournalWizard, self).\
|
||||
pre_print_report(cr, uid, ids, data, context)
|
||||
# will be used to attach the report on the main account
|
||||
data['ids'] = [data['form']['chart_account_id']]
|
||||
vals = self.read(cr, uid, ids,
|
||||
['amount_currency',
|
||||
'display_account',
|
||||
'journal_ids'],
|
||||
context=context)[0]
|
||||
data['form'].update(vals)
|
||||
return data
|
||||
|
||||
def onchange_filter(self, cr, uid, ids, filter='filter_no',
|
||||
fiscalyear_id=False, context=None):
|
||||
res = {}
|
||||
if filter == 'filter_no':
|
||||
res['value'] = {'period_from': False,
|
||||
'period_to': False,
|
||||
'date_from': False,
|
||||
'date_to': False}
|
||||
if filter == 'filter_date':
|
||||
if fiscalyear_id:
|
||||
fyear = self.pool.get('account.fiscalyear').browse(
|
||||
cr, uid, fiscalyear_id, context=context)
|
||||
date_from = fyear.date_start
|
||||
date_to = fyear.date_stop > time.strftime(
|
||||
'%Y-%m-%d') and time.strftime('%Y-%m-%d') \
|
||||
or fyear.date_stop
|
||||
else:
|
||||
date_from, date_to = time.strftime(
|
||||
'%Y-01-01'), time.strftime('%Y-%m-%d')
|
||||
res['value'] = {'period_from': False, 'period_to':
|
||||
False, 'date_from': date_from, 'date_to': date_to}
|
||||
if filter == 'filter_period' and fiscalyear_id:
|
||||
start_period = end_period = False
|
||||
cr.execute('''
|
||||
SELECT * FROM (SELECT p.id
|
||||
FROM account_period p
|
||||
LEFT JOIN account_fiscalyear f
|
||||
ON (p.fiscalyear_id = f.id)
|
||||
WHERE f.id = %s
|
||||
AND COALESCE(p.special, FALSE) = FALSE
|
||||
ORDER BY p.date_start ASC
|
||||
LIMIT 1) AS period_start
|
||||
UNION ALL
|
||||
SELECT * FROM (SELECT p.id
|
||||
FROM account_period p
|
||||
LEFT JOIN account_fiscalyear f
|
||||
ON (p.fiscalyear_id = f.id)
|
||||
WHERE f.id = %s
|
||||
AND p.date_start < NOW()
|
||||
AND COALESCE(p.special, FALSE) = FALSE
|
||||
ORDER BY p.date_stop DESC
|
||||
LIMIT 1) AS period_stop''',
|
||||
(fiscalyear_id, fiscalyear_id))
|
||||
periods = [i[0] for i in cr.fetchall()]
|
||||
if periods:
|
||||
start_period = end_period = periods[0]
|
||||
if len(periods) > 1:
|
||||
end_period = periods[1]
|
||||
res['value'] = {'period_from': start_period, 'period_to':
|
||||
end_period, 'date_from': False, 'date_to': False}
|
||||
return res
|
||||
|
||||
def _print_report(self, cursor, uid, ids, data, context=None):
|
||||
context = context or {}
|
||||
# we update form with display account value
|
||||
data = self.pre_print_report(cursor, uid, ids, data, context=context)
|
||||
return {'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account.account_report_print_journal_webkit',
|
||||
'datas': data}
|
|
@ -1,89 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
##############################################################################
|
||||
#
|
||||
# account_financial_report_webkit module for OpenERP, Webkit based extended report financial report
|
||||
# Copyright (C) 2012 SYLEAM Info Services ([http://www.syleam.fr/])
|
||||
# Sebastien LANGE [sebastien.lange@syleam.fr]
|
||||
#
|
||||
# This file is a part of account_financial_report_webkit
|
||||
#
|
||||
# account_financial_report_webkit 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.
|
||||
#
|
||||
# account_financial_report_webkit 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 [http://www.gnu.org/licenses/].
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
<record id="account_report_print_journal_view_webkit" model="ir.ui.view">
|
||||
<field name="name">Journals</field>
|
||||
<field name="model">print.journal.webkit</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account.account_common_report_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="/form/label[@string='']" position="replace">
|
||||
<separator string="Journals" colspan="4"/>
|
||||
<label nolabel="1" colspan="4" string="This report allows you to print or generate a pdf of your print journal with details of all your account journals"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='target_move']" position="after">
|
||||
<field name="amount_currency"/>
|
||||
<newline/>
|
||||
<field name="filter" on_change="onchange_filter(filter, fiscalyear_id)" colspan="4" invisible="1"/>
|
||||
<separator string="Periods" colspan="4"/>
|
||||
<field name="period_from" domain="[('fiscalyear_id', '=', fiscalyear_id)]" required="1" colspan="4"/>
|
||||
<field name="period_to" domain="[('fiscalyear_id', '=', fiscalyear_id)]" required="1" colspan="4"/>
|
||||
<separator string="Journals" colspan="4"/>
|
||||
<field name="journal_ids" colspan="4" nolabel="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//page[@name='filters']" position="replace">
|
||||
</xpath>
|
||||
<xpath expr="//page[@name='journal_ids']" position="replace">
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="account_report_print_journal_view_inherit" model="ir.ui.view">
|
||||
<field name="name">Journals</field>
|
||||
<field name="model">print.journal.webkit</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account.account_report_print_journal"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="fiscalyear_id" position="replace">
|
||||
<field name="fiscalyear_id" on_change="onchange_fiscalyear(fiscalyear_id)"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_print_journal_menu_webkit" model="ir.actions.act_window">
|
||||
<field name="name">Journals</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">print.journal.webkit</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="account_report_print_journal_view_webkit"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="action_account_print_journal_values_webkit">
|
||||
<field name="model_id" ref="account.model_account_account"/>
|
||||
<field name="name">Journals</field>
|
||||
<field name="key2">client_print_multi</field>
|
||||
<field name="value"
|
||||
eval="'ir.actions.act_window,' +str(ref('action_account_print_journal_menu_webkit'))"/>
|
||||
<field name="key">action</field>
|
||||
<field name="model">account.journal.period</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,39 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Guewen Baconnier
|
||||
# Copyright Camptocamp SA 2011
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm
|
||||
|
||||
|
||||
class AccountTrialBalanceWizard(orm.TransientModel):
|
||||
"""Will launch trial balance report and pass required args"""
|
||||
|
||||
_inherit = "account.common.balance.report"
|
||||
_name = "trial.balance.webkit"
|
||||
_description = "Trial Balance Report"
|
||||
|
||||
def _print_report(self, cursor, uid, ids, data, context=None):
|
||||
context = context or {}
|
||||
# we update form with display account value
|
||||
data = self.pre_print_report(cursor, uid, ids, data, context=context)
|
||||
|
||||
return {'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account.account_report_trial_balance_webkit',
|
||||
'datas': data}
|
|
@ -1,76 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- inheriting views from more than 2 differents inherited models like
|
||||
trial.balance.webkit -> account.common.balance.report -> account.common.account.report
|
||||
is not supported so we have to copy paste the same view for trial balance, balance sheet
|
||||
-->
|
||||
<record id="account_trial_balance_view_webkit" model="ir.ui.view">
|
||||
<field name="name">Trial Balance</field>
|
||||
<field name="model">trial.balance.webkit</field>
|
||||
<field name="inherit_id" ref="account.account_common_report_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="/form/label[@string='']" position="replace">
|
||||
<separator string="Trial Balance" colspan="4"/>
|
||||
<label nolabel="1" colspan="4" string="This report allows you to print or generate a pdf of your trial balance allowing you to quickly check the balance of each of your accounts in a single report"/>
|
||||
</xpath>
|
||||
<field name="chart_account_id" position='attributes'>
|
||||
<attribute name="colspan">4</attribute>
|
||||
</field>
|
||||
<page name="filters" position="after">
|
||||
<page string="Accounts Filters" name="accounts">
|
||||
<separator string="Print only" colspan="4"/>
|
||||
<field name="account_ids" colspan="4" nolabel="1" domain="[('type', '=', 'view')]">
|
||||
<tree>
|
||||
<field name="code"/>
|
||||
<field name="name"/>
|
||||
<field name="type"/>
|
||||
<field name="company_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page name="placeholder"/>
|
||||
</page>
|
||||
<page name="journal_ids" position="attributes">
|
||||
<attribute name="invisible">True</attribute>
|
||||
</page>
|
||||
<page name="filters" position="attributes">
|
||||
<attribute name="string">Time Filters</attribute>
|
||||
</page>
|
||||
<field name="period_from" position="attributes">
|
||||
<attribute name="domain">[('fiscalyear_id', '=', fiscalyear_id), ('special', '=', False)]</attribute>
|
||||
</field>
|
||||
<field name="period_to" position="attributes">
|
||||
<attribute name="domain">[('fiscalyear_id', '=', fiscalyear_id), ('special', '=', False)]</attribute>
|
||||
</field>
|
||||
<field name="fiscalyear_id" position="attributes">
|
||||
<attribute name="attrs">{'required': [('filter', '=', 'filter_opening')]}</attribute>
|
||||
</field>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_trial_balance_menu_webkit" model="ir.actions.act_window">
|
||||
<field name="name">Trial Balance</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">trial.balance.webkit</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="account_trial_balance_view_webkit"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="action_account_trial_balance_values_webkit">
|
||||
<field name="model_id" ref="account.model_account_account"/>
|
||||
<field name="name">Trial Balance</field>
|
||||
<field name="key2">client_print_multi</field>
|
||||
<field name="value"
|
||||
eval="'ir.actions.act_window,' +str(ref('action_account_trial_balance_menu_webkit'))"/>
|
||||
<field name="key">action</field>
|
||||
<field name="model">account.account</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" ?>
|
||||
<openerp>
|
||||
<data> </data>
|
||||
</openerp>
|
|
@ -1,29 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
try:
|
||||
from . import wizard
|
||||
from . import report
|
||||
except ImportError:
|
||||
import logging
|
||||
logging.getLogger('openerp.module').warning('''report_xls not available in
|
||||
addons path. account_financial_report_webkit_xls will not be usable''')
|
|
@ -1,54 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
{
|
||||
'name': 'Add XLS export to accounting reports',
|
||||
'version': '8.0.0.4.0',
|
||||
'license': 'AGPL-3',
|
||||
'author': "Noviat,Odoo Community Association (OCA)",
|
||||
'category': 'Generic Modules/Accounting',
|
||||
'description': """
|
||||
|
||||
This module adds XLS export to the following accounting reports:
|
||||
- general ledger
|
||||
- trial balance
|
||||
- partner ledger
|
||||
- partner balance
|
||||
- open invoices
|
||||
|
||||
""",
|
||||
'depends': ['report_xls', 'account_financial_report_webkit'],
|
||||
'demo': [],
|
||||
'data': [
|
||||
'wizard/general_ledger_wizard_view.xml',
|
||||
'wizard/trial_balance_wizard_view.xml',
|
||||
'wizard/partners_ledger_wizard_view.xml',
|
||||
'wizard/partners_balance_wizard_view.xml',
|
||||
'wizard/open_invoices_wizard_view.xml',
|
||||
],
|
||||
'test': ['tests/general_ledger.yml',
|
||||
'tests/partner_ledger.yml',
|
||||
'tests/trial_balance.yml',
|
||||
'tests/partner_balance.yml',
|
||||
'tests/open_invoices.yml'],
|
||||
'active': False,
|
||||
'installable': False,
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from . import general_ledger_xls
|
||||
from . import trial_balance_xls
|
||||
from . import partners_balance_xls
|
||||
from . import partner_ledger_xls
|
||||
from . import open_invoices_xls
|
|
@ -1,347 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import xlwt
|
||||
from datetime import datetime
|
||||
from openerp.addons.report_xls.report_xls import report_xls
|
||||
from openerp.addons.report_xls.utils import rowcol_to_cell
|
||||
from openerp.addons.account_financial_report_webkit.report.general_ledger \
|
||||
import GeneralLedgerWebkit
|
||||
from openerp.tools.translate import _
|
||||
# import logging
|
||||
# _logger = logging.getLogger(__name__)
|
||||
|
||||
_column_sizes = [
|
||||
('date', 12),
|
||||
('period', 12),
|
||||
('move', 20),
|
||||
('journal', 12),
|
||||
('account_code', 12),
|
||||
('partner', 30),
|
||||
('label', 45),
|
||||
('counterpart', 30),
|
||||
('debit', 15),
|
||||
('credit', 15),
|
||||
('cumul_bal', 15),
|
||||
('curr_bal', 15),
|
||||
('curr_code', 7),
|
||||
]
|
||||
|
||||
|
||||
class general_ledger_xls(report_xls):
|
||||
column_sizes = [x[1] for x in _column_sizes]
|
||||
|
||||
def generate_xls_report(self, _p, _xs, data, objects, wb):
|
||||
|
||||
ws = wb.add_sheet(_p.report_name[:31])
|
||||
ws.panes_frozen = True
|
||||
ws.remove_splits = True
|
||||
ws.portrait = 0 # Landscape
|
||||
ws.fit_width_to_pages = 1
|
||||
row_pos = 0
|
||||
|
||||
# set print header/footer
|
||||
ws.header_str = self.xls_headers['standard']
|
||||
ws.footer_str = self.xls_footers['standard']
|
||||
|
||||
# cf. account_report_general_ledger.mako
|
||||
initial_balance_text = {'initial_balance': _('Computed'),
|
||||
'opening_balance': _('Opening Entries'),
|
||||
False: _('No')}
|
||||
|
||||
# Title
|
||||
cell_style = xlwt.easyxf(_xs['xls_title'])
|
||||
report_name = ' - '.join([_p.report_name.upper(),
|
||||
_p.company.partner_id.name,
|
||||
_p.company.currency_id.name])
|
||||
c_specs = [
|
||||
('report_name', 1, 0, 'text', report_name),
|
||||
]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, row_style=cell_style)
|
||||
|
||||
# write empty row to define column sizes
|
||||
c_sizes = self.column_sizes
|
||||
c_specs = [('empty%s' % i, 1, c_sizes[i], 'text', None)
|
||||
for i in range(0, len(c_sizes))]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, set_column_size=True)
|
||||
|
||||
# Header Table
|
||||
cell_format = _xs['bold'] + _xs['fill_blue'] + _xs['borders_all']
|
||||
cell_style = xlwt.easyxf(cell_format)
|
||||
cell_style_center = xlwt.easyxf(cell_format + _xs['center'])
|
||||
c_specs = [
|
||||
('coa', 2, 0, 'text', _('Chart of Account')),
|
||||
('fy', 1, 0, 'text', _('Fiscal Year')),
|
||||
('df', 3, 0, 'text', _p.filter_form(data) ==
|
||||
'filter_date' and _('Dates Filter') or _('Periods Filter')),
|
||||
('af', 1, 0, 'text', _('Accounts Filter')),
|
||||
('tm', 2, 0, 'text', _('Target Moves')),
|
||||
('ib', 2, 0, 'text', _('Initial Balance')),
|
||||
|
||||
]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, row_style=cell_style_center)
|
||||
|
||||
cell_format = _xs['borders_all']
|
||||
cell_style = xlwt.easyxf(cell_format)
|
||||
cell_style_center = xlwt.easyxf(cell_format + _xs['center'])
|
||||
c_specs = [
|
||||
('coa', 2, 0, 'text', _p.chart_account.name),
|
||||
('fy', 1, 0, 'text', _p.fiscalyear.name if _p.fiscalyear else '-'),
|
||||
]
|
||||
df = _('From') + ': '
|
||||
if _p.filter_form(data) == 'filter_date':
|
||||
df += _p.start_date if _p.start_date else u''
|
||||
else:
|
||||
df += _p.start_period.name if _p.start_period else u''
|
||||
df += ' ' + _('To') + ': '
|
||||
if _p.filter_form(data) == 'filter_date':
|
||||
df += _p.stop_date if _p.stop_date else u''
|
||||
else:
|
||||
df += _p.stop_period.name if _p.stop_period else u''
|
||||
c_specs += [
|
||||
('df', 3, 0, 'text', df),
|
||||
('af', 1, 0, 'text', _p.accounts(data) and ', '.join(
|
||||
[account.code for account in _p.accounts(data)]) or _('All')),
|
||||
('tm', 2, 0, 'text', _p.display_target_move(data)),
|
||||
('ib', 2, 0, 'text', initial_balance_text[
|
||||
_p.initial_balance_mode]),
|
||||
]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, row_style=cell_style_center)
|
||||
ws.set_horz_split_pos(row_pos)
|
||||
row_pos += 1
|
||||
|
||||
# Column Title Row
|
||||
cell_format = _xs['bold']
|
||||
c_title_cell_style = xlwt.easyxf(cell_format)
|
||||
|
||||
# Column Header Row
|
||||
cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all']
|
||||
c_hdr_cell_style = xlwt.easyxf(cell_format)
|
||||
c_hdr_cell_style_right = xlwt.easyxf(cell_format + _xs['right'])
|
||||
c_hdr_cell_style_center = xlwt.easyxf(cell_format + _xs['center'])
|
||||
c_hdr_cell_style_decimal = xlwt.easyxf(
|
||||
cell_format + _xs['right'],
|
||||
num_format_str=report_xls.decimal_format)
|
||||
|
||||
# Column Initial Balance Row
|
||||
cell_format = _xs['italic'] + _xs['borders_all']
|
||||
c_init_cell_style = xlwt.easyxf(cell_format)
|
||||
c_init_cell_style_decimal = xlwt.easyxf(
|
||||
cell_format + _xs['right'],
|
||||
num_format_str=report_xls.decimal_format)
|
||||
|
||||
c_specs = [
|
||||
('date', 1, 0, 'text', _('Date'), None, c_hdr_cell_style),
|
||||
('period', 1, 0, 'text', _('Period'), None, c_hdr_cell_style),
|
||||
('move', 1, 0, 'text', _('Entry'), None, c_hdr_cell_style),
|
||||
('journal', 1, 0, 'text', _('Journal'), None, c_hdr_cell_style),
|
||||
('account_code', 1, 0, 'text',
|
||||
_('Account'), None, c_hdr_cell_style),
|
||||
('partner', 1, 0, 'text', _('Partner'), None, c_hdr_cell_style),
|
||||
('label', 1, 0, 'text', _('Label'), None, c_hdr_cell_style),
|
||||
('counterpart', 1, 0, 'text',
|
||||
_('Counterpart'), None, c_hdr_cell_style),
|
||||
('debit', 1, 0, 'text', _('Debit'), None, c_hdr_cell_style_right),
|
||||
('credit', 1, 0, 'text', _('Credit'),
|
||||
None, c_hdr_cell_style_right),
|
||||
('cumul_bal', 1, 0, 'text', _('Cumul. Bal.'),
|
||||
None, c_hdr_cell_style_right),
|
||||
]
|
||||
if _p.amount_currency(data):
|
||||
c_specs += [
|
||||
('curr_bal', 1, 0, 'text', _('Curr. Bal.'),
|
||||
None, c_hdr_cell_style_right),
|
||||
('curr_code', 1, 0, 'text', _('Curr.'),
|
||||
None, c_hdr_cell_style_center),
|
||||
]
|
||||
c_hdr_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
|
||||
# cell styles for ledger lines
|
||||
ll_cell_format = _xs['borders_all']
|
||||
ll_cell_style = xlwt.easyxf(ll_cell_format)
|
||||
ll_cell_style_center = xlwt.easyxf(ll_cell_format + _xs['center'])
|
||||
ll_cell_style_date = xlwt.easyxf(
|
||||
ll_cell_format + _xs['left'],
|
||||
num_format_str=report_xls.date_format)
|
||||
ll_cell_style_decimal = xlwt.easyxf(
|
||||
ll_cell_format + _xs['right'],
|
||||
num_format_str=report_xls.decimal_format)
|
||||
|
||||
cnt = 0
|
||||
for account in objects:
|
||||
|
||||
display_initial_balance = _p['init_balance'][account.id] and \
|
||||
(_p['init_balance'][account.id].get(
|
||||
'debit', 0.0) != 0.0 or
|
||||
_p['init_balance'][account.id].get('credit', 0.0) != 0.0)
|
||||
display_ledger_lines = _p['ledger_lines'][account.id]
|
||||
|
||||
if _p.display_account_raw(data) == 'all' or \
|
||||
(display_ledger_lines or display_initial_balance):
|
||||
# TO DO : replace cumul amounts by xls formulas
|
||||
cnt += 1
|
||||
cumul_debit = 0.0
|
||||
cumul_credit = 0.0
|
||||
cumul_balance = 0.0
|
||||
cumul_balance_curr = 0.0
|
||||
c_specs = [
|
||||
('acc_title', 11, 0, 'text',
|
||||
' - '.join([account.code, account.name])),
|
||||
]
|
||||
row_data = self.xls_row_template(
|
||||
c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, c_title_cell_style)
|
||||
row_pos = self.xls_write_row(ws, row_pos, c_hdr_data)
|
||||
row_start = row_pos
|
||||
|
||||
if display_initial_balance:
|
||||
init_balance = _p['init_balance'][account.id]
|
||||
cumul_debit = init_balance.get('debit') or 0.0
|
||||
cumul_credit = init_balance.get('credit') or 0.0
|
||||
cumul_balance = init_balance.get('init_balance') or 0.0
|
||||
cumul_balance_curr = init_balance.get(
|
||||
'init_balance_currency') or 0.0
|
||||
c_specs = [('empty%s' % x, 1, 0, 'text', None)
|
||||
for x in range(6)]
|
||||
c_specs += [
|
||||
('init_bal', 1, 0, 'text', _('Initial Balance')),
|
||||
('counterpart', 1, 0, 'text', None),
|
||||
('debit', 1, 0, 'number', cumul_debit,
|
||||
None, c_init_cell_style_decimal),
|
||||
('credit', 1, 0, 'number', cumul_credit,
|
||||
None, c_init_cell_style_decimal),
|
||||
('cumul_bal', 1, 0, 'number', cumul_balance,
|
||||
None, c_init_cell_style_decimal),
|
||||
]
|
||||
if _p.amount_currency(data):
|
||||
c_specs += [
|
||||
('curr_bal', 1, 0, 'number', cumul_balance_curr,
|
||||
None, c_init_cell_style_decimal),
|
||||
('curr_code', 1, 0, 'text', None),
|
||||
]
|
||||
row_data = self.xls_row_template(
|
||||
c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, c_init_cell_style)
|
||||
|
||||
for line in _p['ledger_lines'][account.id]:
|
||||
|
||||
cumul_debit += line.get('debit') or 0.0
|
||||
cumul_credit += line.get('credit') or 0.0
|
||||
cumul_balance_curr += line.get('amount_currency') or 0.0
|
||||
cumul_balance += line.get('balance') or 0.0
|
||||
label_elements = [line.get('lname') or '']
|
||||
if line.get('invoice_number'):
|
||||
label_elements.append(
|
||||
"(%s)" % (line['invoice_number'],))
|
||||
label = ' '.join(label_elements)
|
||||
|
||||
if line.get('ldate'):
|
||||
c_specs = [
|
||||
('ldate', 1, 0, 'date', datetime.strptime(
|
||||
line['ldate'], '%Y-%m-%d'), None,
|
||||
ll_cell_style_date),
|
||||
]
|
||||
else:
|
||||
c_specs = [
|
||||
('ldate', 1, 0, 'text', None),
|
||||
]
|
||||
c_specs += [
|
||||
('period', 1, 0, 'text',
|
||||
line.get('period_code') or ''),
|
||||
('move', 1, 0, 'text', line.get('move_name') or ''),
|
||||
('journal', 1, 0, 'text', line.get('jcode') or ''),
|
||||
('account_code', 1, 0, 'text', account.code),
|
||||
('partner', 1, 0, 'text',
|
||||
line.get('partner_name') or ''),
|
||||
('label', 1, 0, 'text', label),
|
||||
('counterpart', 1, 0, 'text',
|
||||
line.get('counterparts') or ''),
|
||||
('debit', 1, 0, 'number', line.get('debit', 0.0),
|
||||
None, ll_cell_style_decimal),
|
||||
('credit', 1, 0, 'number', line.get('credit', 0.0),
|
||||
None, ll_cell_style_decimal),
|
||||
('cumul_bal', 1, 0, 'number', cumul_balance,
|
||||
None, ll_cell_style_decimal),
|
||||
]
|
||||
if _p.amount_currency(data):
|
||||
c_specs += [
|
||||
('curr_bal', 1, 0, 'number', line.get(
|
||||
'amount_currency') or 0.0, None,
|
||||
ll_cell_style_decimal),
|
||||
('curr_code', 1, 0, 'text', line.get(
|
||||
'currency_code') or '', None,
|
||||
ll_cell_style_center),
|
||||
]
|
||||
row_data = self.xls_row_template(
|
||||
c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, ll_cell_style)
|
||||
|
||||
debit_start = rowcol_to_cell(row_start, 8)
|
||||
debit_end = rowcol_to_cell(row_pos - 1, 8)
|
||||
debit_formula = 'SUM(' + debit_start + ':' + debit_end + ')'
|
||||
credit_start = rowcol_to_cell(row_start, 9)
|
||||
credit_end = rowcol_to_cell(row_pos - 1, 9)
|
||||
credit_formula = 'SUM(' + credit_start + ':' + credit_end + ')'
|
||||
balance_debit = rowcol_to_cell(row_pos, 8)
|
||||
balance_credit = rowcol_to_cell(row_pos, 9)
|
||||
balance_formula = balance_debit + '-' + balance_credit
|
||||
c_specs = [
|
||||
('acc_title', 7, 0, 'text',
|
||||
' - '.join([account.code, account.name])),
|
||||
('cum_bal', 1, 0, 'text',
|
||||
_('Cumulated Balance on Account'),
|
||||
None, c_hdr_cell_style_right),
|
||||
('debit', 1, 0, 'number', None,
|
||||
debit_formula, c_hdr_cell_style_decimal),
|
||||
('credit', 1, 0, 'number', None,
|
||||
credit_formula, c_hdr_cell_style_decimal),
|
||||
('balance', 1, 0, 'number', None,
|
||||
balance_formula, c_hdr_cell_style_decimal),
|
||||
]
|
||||
if _p.amount_currency(data):
|
||||
if account.currency_id:
|
||||
c_specs += [('curr_bal', 1, 0, 'number',
|
||||
cumul_balance_curr, None,
|
||||
c_hdr_cell_style_decimal)]
|
||||
else:
|
||||
c_specs += [('curr_bal', 1, 0, 'text', None)]
|
||||
c_specs += [('curr_code', 1, 0, 'text', None)]
|
||||
row_data = self.xls_row_template(
|
||||
c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, c_hdr_cell_style)
|
||||
row_pos += 1
|
||||
|
||||
general_ledger_xls('report.account.account_report_general_ledger_xls',
|
||||
'account.account',
|
||||
parser=GeneralLedgerWebkit)
|
|
@ -1,828 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import xlwt
|
||||
from datetime import datetime
|
||||
from openerp.addons.report_xls.report_xls import report_xls
|
||||
from openerp.addons.report_xls.utils import rowcol_to_cell
|
||||
from openerp.addons.account_financial_report_webkit.report.open_invoices \
|
||||
import PartnersOpenInvoicesWebkit
|
||||
from openerp.tools.translate import _
|
||||
# import logging
|
||||
# _logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class open_invoices_xls(report_xls):
|
||||
column_sizes = [12, 12, 20, 15, 30, 30, 14, 14, 14, 14, 14, 14, 10]
|
||||
|
||||
def global_initializations(self, wb, _p, xlwt, _xs, objects, data):
|
||||
# this procedure will initialise variables and Excel cell styles and
|
||||
# return them as global ones
|
||||
self.ws = wb.add_sheet(_p.report_name[:31])
|
||||
self.ws.panes_frozen = True
|
||||
self.ws.remove_splits = True
|
||||
self.ws.portrait = 0 # Landscape
|
||||
self.ws.fit_width_to_pages = 1
|
||||
self.ws.header_str = self.xls_headers['standard']
|
||||
self.ws.footer_str = self.xls_footers['standard']
|
||||
# -------------------------------------------------------
|
||||
# number of columns is 11 in case of normal report, 13 in case the
|
||||
# option currency is selected and 12 in case of the regroup by currency
|
||||
# option is checked
|
||||
group_lines = False
|
||||
# search if the regroup option is selected by browsing the accounts
|
||||
# defined in objects - see account_report_open_invoices.mako
|
||||
for acc in objects:
|
||||
if hasattr(acc, 'grouped_ledger_lines'):
|
||||
group_lines = True
|
||||
if group_lines:
|
||||
self.nbr_columns = 12
|
||||
elif _p.amount_currency(data) and not group_lines:
|
||||
self.nbr_columns = 13
|
||||
else:
|
||||
self.nbr_columns = 11
|
||||
# -------------------------------------------------------
|
||||
# cell style for report title
|
||||
self.style_font12 = xlwt.easyxf(_xs['xls_title'])
|
||||
# -------------------------------------------------------
|
||||
self.style_default = xlwt.easyxf(_xs['borders_all'])
|
||||
# -------------------------------------------------------
|
||||
self.style_default_italic = xlwt.easyxf(
|
||||
_xs['borders_all'] + _xs['italic'])
|
||||
# -------------------------------------------------------
|
||||
self.style_bold = xlwt.easyxf(_xs['bold'] + _xs['borders_all'])
|
||||
# -------------------------------------------------------
|
||||
# cell style for header titles: 'Chart of accounts' - 'Fiscal year' ...
|
||||
self.style_bold_blue_center = xlwt.easyxf(
|
||||
_xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] +
|
||||
_xs['center'])
|
||||
# -------------------------------------------------------
|
||||
# cell style for header data: 'Chart of accounts' - 'Fiscal year' ...
|
||||
self.style_center = xlwt.easyxf(
|
||||
_xs['borders_all'] + _xs['wrap'] + _xs['center'])
|
||||
# -------------------------------------------------------
|
||||
# cell style for columns titles 'Date'- 'Period' - 'Entry'...
|
||||
self.style_yellow_bold = xlwt.easyxf(
|
||||
_xs['bold'] + _xs['fill'] + _xs['borders_all'])
|
||||
# -------------------------------------------------------
|
||||
# cell style for columns titles 'Date'- 'Period' - 'Entry'...
|
||||
self.style_yellow_bold_right = xlwt.easyxf(
|
||||
_xs['bold'] + _xs['fill'] + _xs['borders_all'] + _xs['right'])
|
||||
# -------------------------------------------------------
|
||||
self.style_right = xlwt.easyxf(_xs['borders_all'] + _xs['right'])
|
||||
# -------------------------------------------------------
|
||||
self.style_right_italic = xlwt.easyxf(
|
||||
_xs['borders_all'] + _xs['right'] + _xs['italic'])
|
||||
# -------------------------------------------------------
|
||||
self.style_decimal = xlwt.easyxf(
|
||||
_xs['borders_all'] + _xs['right'],
|
||||
num_format_str=report_xls.decimal_format)
|
||||
# -------------------------------------------------------
|
||||
self.style_decimal_italic = xlwt.easyxf(
|
||||
_xs['borders_all'] + _xs['right'] + _xs['italic'],
|
||||
num_format_str=report_xls.decimal_format)
|
||||
# -------------------------------------------------------
|
||||
self.style_date = xlwt.easyxf(
|
||||
_xs['borders_all'] + _xs['left'],
|
||||
num_format_str=report_xls.date_format)
|
||||
# -------------------------------------------------------
|
||||
self.style_date_italic = xlwt.easyxf(
|
||||
_xs['borders_all'] + _xs['left'] + _xs['italic'],
|
||||
num_format_str=report_xls.date_format)
|
||||
# -------------------------------------------------------
|
||||
cell_format = _xs['xls_title'] + _xs['bold'] + \
|
||||
_xs['fill'] + _xs['borders_all']
|
||||
self.style_account_title = xlwt.easyxf(cell_format)
|
||||
self.style_account_title_right = xlwt.easyxf(
|
||||
cell_format + _xs['right'])
|
||||
self.style_account_title_decimal = xlwt.easyxf(
|
||||
cell_format + _xs['right'],
|
||||
num_format_str=report_xls.decimal_format)
|
||||
# -------------------------------------------------------
|
||||
cell_format = _xs['bold']
|
||||
self.style_partner_row = xlwt.easyxf(cell_format)
|
||||
# -------------------------------------------------------
|
||||
cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all']
|
||||
self.style_partner_cumul = xlwt.easyxf(cell_format)
|
||||
self.style_partner_cumul_right = xlwt.easyxf(
|
||||
cell_format + _xs['right'])
|
||||
self.style_partner_cumul_decimal = xlwt.easyxf(
|
||||
cell_format + _xs['right'],
|
||||
num_format_str=report_xls.decimal_format)
|
||||
|
||||
# print the first line "OPEN INVOICE REPORT - db name - Currency
|
||||
def print_title(self, _p, row_position):
|
||||
report_name = ' - '.join([_p.report_name.upper(),
|
||||
_p.company.partner_id.name,
|
||||
_p.company.currency_id.name])
|
||||
c_specs = [('report_name', self.nbr_columns, 0, 'text', report_name), ]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
self.ws, row_position, row_data, row_style=self.style_font12)
|
||||
return row_position
|
||||
|
||||
# send an empty row to the Excel document
|
||||
def print_empty_row(self, row_position):
|
||||
c_sizes = self.column_sizes
|
||||
c_specs = [('empty%s' % i, 1, c_sizes[i], 'text', None)
|
||||
for i in range(0, len(c_sizes))]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
self.ws, row_position, row_data, set_column_size=True)
|
||||
return row_position
|
||||
|
||||
# Fill in the titles of the header summary tables: Chart of account -
|
||||
# Fiscal year - ...
|
||||
def print_header_titles(self, _p, data, row_position):
|
||||
c_specs = [
|
||||
('coa', 2, 0, 'text', _('Chart of Account'),
|
||||
None, self.style_bold_blue_center),
|
||||
('fy', 2, 0, 'text', _('Fiscal Year'),
|
||||
None, self.style_bold_blue_center),
|
||||
('df', 2, 0, 'text', _p.filter_form(data) == 'filter_date' and _(
|
||||
'Dates Filter') or _('Periods Filter'), None,
|
||||
self.style_bold_blue_center),
|
||||
('cd', 1 if self.nbr_columns == 11 else 2, 0, 'text',
|
||||
_('Clearance Date'), None, self.style_bold_blue_center),
|
||||
('af', 2, 0, 'text', _('Accounts Filter'),
|
||||
None, self.style_bold_blue_center),
|
||||
('tm', 3 if self.nbr_columns == 13 else 2, 0, 'text',
|
||||
_('Target Moves'), None, self.style_bold_blue_center),
|
||||
]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
self.ws, row_position, row_data,
|
||||
row_style=self.style_bold_blue_center)
|
||||
return row_position
|
||||
|
||||
# Fill in the data of the header summary tables: Chart of account - Fiscal
|
||||
# year - ...
|
||||
def print_header_data(self, _p, data, row_position):
|
||||
c_specs = [
|
||||
('coa', 2, 0, 'text', _p.chart_account.name,
|
||||
None, self.style_center),
|
||||
('fy', 2, 0, 'text', _p.fiscalyear.name if _p.fiscalyear else '-',
|
||||
None, self.style_center),
|
||||
]
|
||||
df = _('From') + ': '
|
||||
if _p.filter_form(data) == 'filter_date':
|
||||
df += _p.start_date if _p.start_date else u''
|
||||
else:
|
||||
df += _p.start_period.name if _p.start_period else u''
|
||||
df += ' ' + _('To') + ': '
|
||||
if _p.filter_form(data) == 'filter_date':
|
||||
df += _p.stop_date if _p.stop_date else u''
|
||||
else:
|
||||
df += _p.stop_period.name if _p.stop_period else u''
|
||||
c_specs += [
|
||||
('df', 2, 0, 'text', df, None, self.style_center),
|
||||
('cd', 1 if self.nbr_columns == 11 else 2, 0, 'text',
|
||||
_p.date_until, None, self.style_center), # clearance date
|
||||
('af', 2, 0, 'text', _('Custom Filter')
|
||||
if _p.partner_ids else _p.display_partner_account(data), None,
|
||||
self.style_center),
|
||||
('tm', 3 if self.nbr_columns == 13 else 2, 0, 'text',
|
||||
_p.display_target_move(data), None, self.style_center),
|
||||
]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
self.ws, row_position, row_data, row_style=self.style_center)
|
||||
return row_position
|
||||
|
||||
# Fill in a row with the titles of the columns for the invoice lines: Date
|
||||
# - Period - Entry -...
|
||||
def print_columns_title(self, _p, row_position, data, group_lines=False):
|
||||
c_specs = [
|
||||
('date', 1, 0, 'text', _('Date'), None, self.style_yellow_bold),
|
||||
('period', 1, 0, 'text', _('Period'),
|
||||
None, self.style_yellow_bold),
|
||||
('entry', 1, 0, 'text', _('Entry'), None, self.style_yellow_bold),
|
||||
('journal', 1, 0, 'text', _('Journal'),
|
||||
None, self.style_yellow_bold),
|
||||
]
|
||||
if not group_lines:
|
||||
c_specs += [('partner', 1, 0, 'text', _('Partner'),
|
||||
None, self.style_yellow_bold), ]
|
||||
c_specs += [
|
||||
('label', 1, 0, 'text', _('Label'), None, self.style_yellow_bold),
|
||||
('rec', 1, 0, 'text', _('Rec.'), None, self.style_yellow_bold),
|
||||
('due_date', 1, 0, 'text', _('Due Date'),
|
||||
None, self.style_yellow_bold),
|
||||
('debit', 1, 0, 'text', _('Debit'),
|
||||
None, self.style_yellow_bold_right),
|
||||
('credit', 1, 0, 'text', _('Credit'),
|
||||
None, self.style_yellow_bold_right),
|
||||
('cumul', 1, 0, 'text', _('Cumul. Bal.'),
|
||||
None, self.style_yellow_bold_right),
|
||||
]
|
||||
if group_lines:
|
||||
c_specs += [
|
||||
('currbal', 1, 0, 'text', _('Curr. Balance'),
|
||||
None, self.style_yellow_bold_right),
|
||||
('curr', 1, 0, 'text', _('Curr.'),
|
||||
None, self.style_yellow_bold_right),
|
||||
]
|
||||
else:
|
||||
if _p.amount_currency(data):
|
||||
c_specs += [
|
||||
('currbal', 1, 0, 'text', _('Curr. Balance'),
|
||||
None, self.style_yellow_bold_right),
|
||||
('curr', 1, 0, 'text', _('Curr.'),
|
||||
None, self.style_yellow_bold_right),
|
||||
]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
self.ws, row_position, row_data, row_style=self.style_yellow_bold)
|
||||
return row_position
|
||||
|
||||
# Fill in a row with the code and the name of an account + the partner
|
||||
# name in case of currency regrouping
|
||||
def print_row_code_account(self, regroupmode, account, row_position,
|
||||
partner_name):
|
||||
if regroupmode == "regroup":
|
||||
c_specs = [('acc_title', self.nbr_columns, 0, 'text',
|
||||
' - '.join([account.code,
|
||||
account.name,
|
||||
partner_name or _('No partner')])), ]
|
||||
else:
|
||||
c_specs = [
|
||||
('acc_title', self.nbr_columns, 0, 'text', ' - '.
|
||||
join([account.code, account.name])), ]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
self.ws, row_position, row_data, self.style_account_title)
|
||||
return row_position + 1
|
||||
|
||||
def print_row_partner(self, row_position, partner_name):
|
||||
c_specs = [
|
||||
('partner', self.nbr_columns, 0, 'text',
|
||||
partner_name or _('No partner')), ]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
self.ws, row_position, row_data, self.style_partner_row)
|
||||
return row_position
|
||||
|
||||
def print_group_currency(self, row_position, curr, _p):
|
||||
c_specs = [
|
||||
('curr', self.nbr_columns, 0, 'text',
|
||||
curr or _p.company.currency_id.name), ]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
self.ws, row_position, row_data, self.style_bold)
|
||||
return row_position
|
||||
|
||||
# Fill in rows of invoice line
|
||||
def print_lines(self, row_position, account, line, _p, data, line_number):
|
||||
|
||||
label_elements = [line.get('lname') or '']
|
||||
if line.get('invoice_number'):
|
||||
label_elements.append("(%s)" % (line['invoice_number'],))
|
||||
label = ' '.join(label_elements)
|
||||
|
||||
# Mako: <div class="act_as_row lines
|
||||
# ${line.get('is_from_previous_periods') and
|
||||
# 'open_invoice_previous_line' or ''} ${line.get('is_clearance_line')
|
||||
# and 'clearance_line' or ''}">
|
||||
if line.get('is_from_previous_periods') \
|
||||
or line.get('is_clearance_line'):
|
||||
style_line_default = self.style_default_italic
|
||||
style_line_right = self.style_right_italic
|
||||
style_line_date = self.style_date_italic
|
||||
style_line_decimal = self.style_decimal_italic
|
||||
else:
|
||||
style_line_default = self.style_default
|
||||
style_line_right = self.style_right
|
||||
style_line_date = self.style_date
|
||||
style_line_decimal = self.style_decimal
|
||||
if line.get('ldate'):
|
||||
c_specs = [('date', 1, 0, 'date', datetime.strptime(
|
||||
line['ldate'], '%Y-%m-%d'), None, style_line_date)]
|
||||
else:
|
||||
c_specs = [('date', 1, 0, 'text', None)]
|
||||
c_specs += [
|
||||
('period_code', 1, 0, 'text', line.get('period_code') or ''),
|
||||
('entry', 1, 0, 'text', line.get('move_name') or ''),
|
||||
('journal', 1, 0, 'text', line.get('jcode') or ''),
|
||||
('partner', 1, 0, 'text', line.get('partner_name') or ''),
|
||||
('label', 1, 0, 'text', label),
|
||||
('rec', 1, 0, 'text', line.get('rec_name') or ''),
|
||||
]
|
||||
if line.get('date_maturity'):
|
||||
c_specs += [('datedue', 1, 0, 'date',
|
||||
datetime.strptime(line['date_maturity'], '%Y-%m-%d'),
|
||||
None, style_line_date)]
|
||||
else:
|
||||
c_specs += [('datedue', 1, 0, 'text', None)]
|
||||
c_specs += [
|
||||
('debit', 1, 0, 'number', line.get('debit') or 0.0, None,
|
||||
style_line_decimal),
|
||||
('credit', 1, 0, 'number', line.get('credit') or 0.0, None,
|
||||
style_line_decimal),
|
||||
]
|
||||
|
||||
# determine the formula of the cumulated balance
|
||||
debit_cell = rowcol_to_cell(row_position, 8)
|
||||
credit_cell = rowcol_to_cell(row_position, 9)
|
||||
previous_balance = rowcol_to_cell(row_position - 1, 10)
|
||||
|
||||
# if it is the first line, the balance is only debit - credit
|
||||
if line_number == 1:
|
||||
cumul_balance = debit_cell + '-' + credit_cell
|
||||
# cumulate debit - credit and balance of previous line
|
||||
else:
|
||||
cumul_balance = debit_cell + '-' + \
|
||||
credit_cell + '+' + previous_balance
|
||||
|
||||
c_specs += [('cumul', 1, 0, 'number', None,
|
||||
cumul_balance, style_line_decimal)]
|
||||
|
||||
if _p.amount_currency(data):
|
||||
if account.currency_id:
|
||||
c_specs += [
|
||||
('curramount', 1, 0, 'number',
|
||||
line.get('amount_currency') or 0.0, None,
|
||||
style_line_decimal),
|
||||
('currcode', 1, 0, 'text', line[
|
||||
'currency_code'], None, style_line_right),
|
||||
]
|
||||
else:
|
||||
c_specs += [
|
||||
('curramount', 1, 0, 'text', '-', None, style_line_right),
|
||||
('currcode', 1, 0, 'text', '', None, style_line_right),
|
||||
]
|
||||
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
self.ws, row_position, row_data, style_line_default)
|
||||
return row_position
|
||||
|
||||
# Fill in rows of invoice line when the option currency regroup is
|
||||
# selecself.wsd
|
||||
def print_group_lines(self, row_position, account, line, _p, line_number):
|
||||
|
||||
label_elements = [line.get('lname') or '']
|
||||
if line.get('invoice_number'):
|
||||
label_elements.append("(%s)" % (line['invoice_number'],))
|
||||
label = ' '.join(label_elements)
|
||||
# Mako: <div class="act_as_row lines
|
||||
# ${line.get('is_from_previous_periods') and
|
||||
# 'open_invoice_previous_line' or ''} ${line.get('is_clearance_line')
|
||||
# and 'clearance_line' or ''}">
|
||||
if line.get('is_from_previous_periods') or \
|
||||
line.get('is_clearance_line'):
|
||||
style_line_default = self.style_default_italic
|
||||
style_line_right = self.style_right_italic
|
||||
style_line_date = self.style_date_italic
|
||||
style_line_decimal = self.style_decimal_italic
|
||||
else:
|
||||
style_line_default = self.style_default
|
||||
style_line_right = self.style_right
|
||||
style_line_date = self.style_date
|
||||
style_line_decimal = self.style_decimal
|
||||
|
||||
debit_cell = rowcol_to_cell(row_position, 7)
|
||||
credit_cell = rowcol_to_cell(row_position, 8)
|
||||
previous_balance = rowcol_to_cell(row_position - 1, 9)
|
||||
|
||||
# if it is the first line, the balance is only debit - credit
|
||||
if line_number == 1:
|
||||
cumul_balance = debit_cell + '-' + credit_cell
|
||||
# cumulate devit - credit and balance of previous line
|
||||
else:
|
||||
cumul_balance = debit_cell + '-' + \
|
||||
credit_cell + '+' + previous_balance
|
||||
|
||||
if line.get('ldate'):
|
||||
c_specs = [('date', 1, 0, 'date', datetime.strptime(
|
||||
line['ldate'], '%Y-%m-%d'), None, style_line_date)]
|
||||
else:
|
||||
c_specs = [('date', 1, 0, 'text', None)]
|
||||
c_specs += [
|
||||
('period_code', 1, 0, 'text', line.get('period_code') or ''),
|
||||
('entry', 1, 0, 'text', line.get('move_name') or ''),
|
||||
('journal', 1, 0, 'text', line.get('jcode') or ''),
|
||||
('label', 1, 0, 'text', label),
|
||||
('rec', 1, 0, 'text', line.get('rec_name') or ''),
|
||||
]
|
||||
if line.get('date_maturity'):
|
||||
c_specs += [('datedue', 1, 0, 'date',
|
||||
datetime.strptime(line['date_maturity'], '%Y-%m-%d'),
|
||||
None, style_line_date)]
|
||||
else:
|
||||
c_specs += [('datedue', 1, 0, 'text', None)]
|
||||
c_specs += [
|
||||
('debit', 1, 0, 'number', line.get('debit') or 0.0, None,
|
||||
style_line_decimal),
|
||||
('credit', 1, 0, 'number', line.get('credit') or 0.0, None,
|
||||
style_line_decimal),
|
||||
('cumul', 1, 0, 'number', None, cumul_balance, style_line_decimal),
|
||||
]
|
||||
if account.currency_id:
|
||||
c_specs += [
|
||||
('curramount', 1, 0, 'number',
|
||||
line.get('amount_currency') or 0.0, None, style_line_decimal),
|
||||
('currcode', 1, 0, 'text',
|
||||
line.get('currency_code') or '', None, style_line_right),
|
||||
]
|
||||
else:
|
||||
c_specs += [
|
||||
('curramount', 1, 0, 'text', '-', None, style_line_right),
|
||||
('currcode', 1, 0, 'text', '', None, style_line_right),
|
||||
]
|
||||
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
self.ws, row_position, row_data, style_line_default)
|
||||
return (row_position, cumul_balance)
|
||||
|
||||
# print by partner the totals and cumulated balance (Excel formulas)
|
||||
def print_cumul_partner(self, row_position, row_start_partner, account, _p,
|
||||
data):
|
||||
|
||||
# the text "Cumulated Balance on Partner starts in column 4 when
|
||||
# selecting the option regroup by currency, 5 in the other case
|
||||
start_col = 5
|
||||
|
||||
debit_partner_start = rowcol_to_cell(row_start_partner, start_col + 3)
|
||||
debit_partner_end = rowcol_to_cell(row_position - 1, start_col + 3)
|
||||
debit_partner_total = 'SUM(' + debit_partner_start + \
|
||||
':' + debit_partner_end + ')'
|
||||
|
||||
credit_partner_start = rowcol_to_cell(row_start_partner, start_col + 4)
|
||||
credit_partner_end = rowcol_to_cell(row_position - 1, start_col + 4)
|
||||
credit_partner_total = 'SUM(' + credit_partner_start + \
|
||||
':' + credit_partner_end + ')'
|
||||
|
||||
bal_curr_start = rowcol_to_cell(row_start_partner, start_col + 6)
|
||||
bal_curr_end = rowcol_to_cell(row_position - 1, start_col + 6)
|
||||
cumul_balance_curr = 'SUM(' + bal_curr_start + ':' + bal_curr_end + ')'
|
||||
|
||||
bal_partner_debit = rowcol_to_cell(row_position, start_col + 3)
|
||||
bal_partner_credit = rowcol_to_cell(row_position, start_col + 4)
|
||||
bal_partner_total = bal_partner_debit + '-' + bal_partner_credit
|
||||
|
||||
c_specs = [('empty%s' % x, 1, 0, 'text', None)
|
||||
for x in range(start_col)]
|
||||
|
||||
c_specs += [
|
||||
('init_bal', 1, 0, 'text', _('Cumulated Balance on Partner')),
|
||||
('rec', 1, 0, 'text', None),
|
||||
('empty5', 1, 0, 'text', None),
|
||||
('debit', 1, 0, 'number', None,
|
||||
debit_partner_total, self.style_partner_cumul_decimal),
|
||||
('credit', 1, 0, 'number', None,
|
||||
credit_partner_total, self.style_partner_cumul_decimal),
|
||||
('cumul_bal', 1, 0, 'number', None,
|
||||
bal_partner_total, self.style_partner_cumul_decimal),
|
||||
]
|
||||
if _p.amount_currency(data):
|
||||
if account.currency_id:
|
||||
c_specs += [('cumul_bal_curr', 1, 0, 'number', None,
|
||||
cumul_balance_curr,
|
||||
self.style_partner_cumul_decimal),
|
||||
('curr_name', 1, 0, 'text',
|
||||
account.currency_id.name,
|
||||
None, self.style_partner_cumul_right),
|
||||
]
|
||||
else:
|
||||
c_specs += [('cumul_bal_curr', 1, 0, 'text', '-', None,
|
||||
self.style_partner_cumul_right),
|
||||
('curr_name', 1, 0, 'text', '',
|
||||
None, self.style_partner_cumul_right)
|
||||
]
|
||||
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
self.ws, row_position, row_data, self.style_partner_cumul)
|
||||
return row_position + 1
|
||||
|
||||
# print by partner the totals and cumulated balance (Excel formulas) when
|
||||
# the option currency regroup is selected
|
||||
def print_group_cumul_partner(self, row_position, row_start_partner,
|
||||
account, _p, data):
|
||||
|
||||
# the text "Cumulated Balance on Partner starts in column 4 when
|
||||
# selecting the option regroup by currency, 5 in the other case
|
||||
start_col = 4
|
||||
|
||||
debit_partner_start = rowcol_to_cell(row_start_partner, start_col + 3)
|
||||
debit_partner_end = rowcol_to_cell(row_position - 1, start_col + 3)
|
||||
debit_partner_total = 'SUM(' + debit_partner_start + \
|
||||
':' + debit_partner_end + ')'
|
||||
|
||||
credit_partner_start = rowcol_to_cell(row_start_partner, start_col + 4)
|
||||
credit_partner_end = rowcol_to_cell(row_position - 1, start_col + 4)
|
||||
credit_partner_total = 'SUM(' + credit_partner_start + \
|
||||
':' + credit_partner_end + ')'
|
||||
|
||||
bal_curr_start = rowcol_to_cell(row_start_partner, start_col + 5)
|
||||
bal_curr_end = rowcol_to_cell(row_position - 1, start_col + 5)
|
||||
cumul_balance_curr = 'SUM(' + bal_curr_start + ':' + bal_curr_end + ')'
|
||||
|
||||
bal_partner_debit = rowcol_to_cell(row_position, start_col + 3)
|
||||
bal_partner_credit = rowcol_to_cell(row_position, start_col + 4)
|
||||
bal_partner_total = bal_partner_debit + '-' + bal_partner_credit
|
||||
|
||||
c_specs = [('empty%s' % x, 1, 0, 'text', None)
|
||||
for x in range(start_col)]
|
||||
|
||||
c_specs += [
|
||||
# , style_bold_italic),
|
||||
('init_bal', 1, 0, 'text', _('Cumulated Balance on Partner')),
|
||||
('rec', 1, 0, 'text', None),
|
||||
('empty5', 1, 0, 'text', None),
|
||||
('debit', 1, 0, 'number', None,
|
||||
debit_partner_total, self.style_partner_cumul_decimal),
|
||||
('credit', 1, 0, 'number', None,
|
||||
credit_partner_total, self.style_partner_cumul_decimal),
|
||||
('cumul_bal', 1, 0, 'number', None,
|
||||
bal_partner_total, self.style_partner_cumul_decimal),
|
||||
]
|
||||
if account.currency_id:
|
||||
c_specs += [
|
||||
('cumul_bal_curr', 1, 0, 'number', None,
|
||||
cumul_balance_curr, self.style_partner_cumul_decimal),
|
||||
('curr_name', 1, 0, 'text', account.currency_id.name,
|
||||
None, self.style_partner_cumul_right),
|
||||
]
|
||||
else:
|
||||
c_specs += [
|
||||
('cumul_bal_curr', 1, 0, 'text', "-",
|
||||
None, self.style_partner_cumul_right),
|
||||
('curr_name', 1, 0, 'text', "",
|
||||
None, self.style_partner_cumul_right),
|
||||
]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
self.ws, row_position, row_data, self.style_partner_cumul)
|
||||
return row_position + 1
|
||||
|
||||
# print by account the totals of the credit and debit + balance calculation
|
||||
def print_cumul_account(self, row_position, row_start_account, account, _p,
|
||||
data):
|
||||
|
||||
# This procedure will create an Excel sumif function that will check
|
||||
# in the column "label" for the "Cumulated Balance.." string and make a
|
||||
# sum of the debit & credit data
|
||||
# the text "Cumulated Balance on Partner starts in column 4 when
|
||||
# selecting the option regroup by currency, 5 in the other case
|
||||
start_col = 5
|
||||
|
||||
# range in which we search for the text "Cumulated Balance on Partner"
|
||||
reference_start = rowcol_to_cell(row_start_account, start_col)
|
||||
reference_stop = rowcol_to_cell(row_position - 1, start_col)
|
||||
|
||||
# range in which we make the sum of all the cumulated balance lines
|
||||
# (debit)
|
||||
range_debit_start = rowcol_to_cell(row_start_account, start_col + 3)
|
||||
range_debit_stop = rowcol_to_cell(row_position - 1, start_col + 3)
|
||||
|
||||
# range in which we make the sum of all the cumulated balance lines
|
||||
# (crebit)
|
||||
range_credit_start = rowcol_to_cell(row_start_account, start_col + 4)
|
||||
range_credit_stop = rowcol_to_cell(row_position - 1, start_col + 4)
|
||||
|
||||
search_key = _('Cumulated Balance on Partner')
|
||||
total_debit_account = 'SUMIF(' + reference_start + ':' + \
|
||||
reference_stop + ';"' + search_key + '";' + range_debit_start + \
|
||||
':' + range_debit_stop + ')'
|
||||
total_credit_account = 'SUMIF(' + reference_start + ':' + \
|
||||
reference_stop + ';"' + search_key + '";' + range_credit_start + \
|
||||
':' + range_credit_stop + ')'
|
||||
|
||||
bal_account_debit = rowcol_to_cell(row_position, start_col + 3)
|
||||
bal_account_credit = rowcol_to_cell(row_position, start_col + 4)
|
||||
bal_account_total = bal_account_debit + '-' + bal_account_credit
|
||||
|
||||
bal_curr_start = rowcol_to_cell(row_start_account, start_col + 6)
|
||||
bal_curr_end = rowcol_to_cell(row_position - 1, start_col + 6)
|
||||
cumul_balance_curr = 'SUMIF(' + reference_start + ':' + \
|
||||
reference_stop + ';"' + search_key + '";' + \
|
||||
bal_curr_start + ':' + bal_curr_end + ')'
|
||||
|
||||
c_specs = [
|
||||
('acc_title', start_col, 0, 'text',
|
||||
' - '.join([account.code, account.name])),
|
||||
('init_bal', 2, 0, 'text',
|
||||
_('Cumulated Balance on Account')),
|
||||
('empty2', 1, 0, 'text', None),
|
||||
('debit', 1, 0, 'number', None,
|
||||
total_debit_account, self.style_account_title_decimal),
|
||||
('credit', 1, 0, 'number', None,
|
||||
total_credit_account, self.style_account_title_decimal),
|
||||
('balance', 1, 0, 'number', None,
|
||||
bal_account_total, self.style_account_title_decimal),
|
||||
]
|
||||
if _p.amount_currency(data):
|
||||
if account.currency_id:
|
||||
c_specs += [('cumul_bal_curr', 1, 0, 'number', None,
|
||||
cumul_balance_curr),
|
||||
('curr_name', 1, 0, 'text',
|
||||
account.currency_id.name,
|
||||
None, self.style_account_title_right),
|
||||
]
|
||||
else:
|
||||
c_specs += [('cumul_bal_curr', 1, 0, 'text', "-", None,
|
||||
self.style_account_title_right),
|
||||
('curr_name', 1, 0, 'text', "",
|
||||
None, self.style_account_title_right)
|
||||
]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
self.ws, row_position, row_data, self.style_account_title)
|
||||
return row_position + 1
|
||||
|
||||
# print by account the totals of the credit and debit + balance calculation
|
||||
def print_group_cumul_account(self, row_position, row_start_account,
|
||||
account):
|
||||
# This procedure will create an Excel sumif function that will check
|
||||
# in the column "label" for the "Cumulated Balance.." string and make a
|
||||
# sum of the debit & credit data
|
||||
# the text "Cumulated Balance on Partner starts in column 4 when
|
||||
# selecting the option regroup by currency, 5 in the other case
|
||||
start_col = 4
|
||||
|
||||
# range in which we search for the text "Cumulated Balance on Partner"
|
||||
reference_start = rowcol_to_cell(row_start_account, start_col)
|
||||
reference_stop = rowcol_to_cell(row_position - 1, start_col)
|
||||
|
||||
# range in which we make the sum of all the cumulated balance lines
|
||||
# (debit)
|
||||
range_debit_start = rowcol_to_cell(row_start_account, start_col + 3)
|
||||
range_debit_stop = rowcol_to_cell(row_position - 1, start_col + 3)
|
||||
|
||||
# range in which we make the sum of all the cumulated balance lines
|
||||
# (crebit)
|
||||
range_credit_start = rowcol_to_cell(row_start_account, start_col + 4)
|
||||
range_credit_stop = rowcol_to_cell(row_position - 1, start_col + 4)
|
||||
|
||||
search_key = _('Cumulated Balance on Partner')
|
||||
total_debit_account = 'SUMIF(' + reference_start + ':' + \
|
||||
reference_stop + ';"' + search_key + '";' + range_debit_start + \
|
||||
':' + range_debit_stop + ')'
|
||||
total_credit_account = 'SUMIF(' + reference_start + ':' + \
|
||||
reference_stop + ';"' + search_key + '";' + range_credit_start + \
|
||||
':' + range_credit_stop + ')'
|
||||
|
||||
bal_account_debit = rowcol_to_cell(row_position, start_col + 3)
|
||||
bal_account_credit = rowcol_to_cell(row_position, start_col + 4)
|
||||
bal_account_total = bal_account_debit + '-' + bal_account_credit
|
||||
|
||||
bal_curr_start = rowcol_to_cell(row_start_account, start_col + 6)
|
||||
bal_curr_end = rowcol_to_cell(row_position - 1, start_col + 6)
|
||||
cumul_balance_curr = 'SUMIF(' + reference_start + ':' + \
|
||||
reference_stop + ';"' + search_key + '";' + \
|
||||
bal_curr_start + ':' + bal_curr_end + ')'
|
||||
|
||||
c_specs = [
|
||||
('acc_title', start_col, 0, 'text',
|
||||
' - '.join([account.code, account.name])),
|
||||
('init_bal', 2, 0, 'text',
|
||||
_('Cumulated Balance on Account')),
|
||||
('empty2', 1, 0, 'text', None),
|
||||
('debit', 1, 0, 'number', None,
|
||||
total_debit_account, self.style_account_title_decimal),
|
||||
('credit', 1, 0, 'number', None,
|
||||
total_credit_account, self.style_account_title_decimal),
|
||||
('balance', 1, 0, 'number', None,
|
||||
bal_account_total, self.style_account_title_decimal),
|
||||
]
|
||||
if account.currency_id:
|
||||
c_specs += [('cumul_bal_curr', 1, 0, 'number', None,
|
||||
cumul_balance_curr, self.style_account_title_decimal),
|
||||
('curr_name', 1, 0, 'text', account.currency_id.name,
|
||||
None, self.style_account_title_decimal),
|
||||
]
|
||||
else:
|
||||
c_specs += [('cumul_bal_curr', 1, 0, 'text', "-", None,
|
||||
self.style_account_title_right),
|
||||
('curr_name', 1, 0, 'text', "",
|
||||
None, self.style_account_title_right)
|
||||
]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
self.ws, row_position, row_data, self.style_account_title)
|
||||
return row_position + 1
|
||||
|
||||
# export the invoice AR/AP lines when the option currency regroup is
|
||||
# selected
|
||||
def print_grouped_line_report(self, row_pos, account, _xs, xlwt, _p, data):
|
||||
|
||||
if account.grouped_ledger_lines and \
|
||||
_p['partners_order'][account.id]:
|
||||
row_start_account = row_pos
|
||||
|
||||
for partner_name, p_id, p_ref, p_name \
|
||||
in _p['partners_order'][account.id]:
|
||||
row_pos = self.print_row_code_account(
|
||||
"regroup", account, row_pos, partner_name)
|
||||
|
||||
for curr, grouped_lines in account.grouped_ledger_lines.\
|
||||
get(p_id, []):
|
||||
|
||||
row_pos = self.print_group_currency(row_pos, curr, _p)
|
||||
# Print row: Titles "Date-Period-Entry-Journal..."
|
||||
row_pos = self.print_columns_title(
|
||||
_p, row_pos, data, group_lines=True)
|
||||
|
||||
row_pos_start = row_pos
|
||||
line_number = 0
|
||||
for line in grouped_lines:
|
||||
line_number += 1
|
||||
row_pos, cumul_balance = self.print_group_lines(
|
||||
row_pos, account, line, _p, line_number)
|
||||
row_pos = self.print_group_cumul_partner(
|
||||
row_pos, row_pos_start, account, _p, data)
|
||||
|
||||
row_pos = self.print_group_cumul_account(
|
||||
row_pos, row_start_account, account)
|
||||
|
||||
return row_pos
|
||||
|
||||
# export the invoice AR/AP lines
|
||||
def print_ledger_lines(self, row_pos, account, _xs, xlwt, _p, data):
|
||||
|
||||
if _p['ledger_lines'][account.id] \
|
||||
and _p['partners_order'][account.id]:
|
||||
|
||||
row_start_account = row_pos
|
||||
|
||||
# Print account line: code - account
|
||||
row_pos = self.print_row_code_account(
|
||||
"noregroup", account, row_pos, "")
|
||||
for partner_name, p_id, p_ref, p_name \
|
||||
in _p['partners_order'][account.id]:
|
||||
|
||||
# Print partner row
|
||||
row_pos = self.print_row_partner(row_pos, partner_name)
|
||||
# Print row: Titles "Date-Period-Entry-Journal..."
|
||||
row_pos = self.print_columns_title(
|
||||
_p, row_pos, data, group_lines=False)
|
||||
|
||||
row_pos_start = row_pos
|
||||
line_number = 0
|
||||
for line in _p['ledger_lines'][account.id].get(p_id, []):
|
||||
line_number += 1
|
||||
# print ledger lines
|
||||
row_pos = self.print_lines(
|
||||
row_pos, account, line, _p, data, line_number)
|
||||
row_pos = self.print_cumul_partner(
|
||||
row_pos, row_pos_start, account, _p, data)
|
||||
|
||||
row_pos = self.print_cumul_account(
|
||||
row_pos, row_start_account, account, _p, data)
|
||||
|
||||
return row_pos
|
||||
|
||||
def generate_xls_report(self, _p, _xs, data, objects, wb): # main function
|
||||
|
||||
# Initializations
|
||||
self.global_initializations(wb, _p, xlwt, _xs, objects, data)
|
||||
row_pos = 0
|
||||
# Print Title
|
||||
row_pos = self.print_title(_p, row_pos)
|
||||
# Print empty row to define column sizes
|
||||
row_pos = self.print_empty_row(row_pos)
|
||||
# Print Header Table titles (Fiscal Year - Accounts Filter - Periods
|
||||
# Filter...)
|
||||
row_pos = self.print_header_titles(_p, data, row_pos)
|
||||
# Print Header Table data
|
||||
row_pos = self.print_header_data(_p, data, row_pos)
|
||||
# Freeze the line
|
||||
self.ws.set_horz_split_pos(row_pos)
|
||||
# Print empty row
|
||||
row_pos = self.print_empty_row(row_pos)
|
||||
|
||||
for acc in objects:
|
||||
if hasattr(acc, 'grouped_ledger_lines'):
|
||||
# call xls equivalent of
|
||||
# "grouped_by_curr_open_invoices_inclusion.mako.html"
|
||||
row_pos = self.print_grouped_line_report(
|
||||
row_pos, acc, _xs, xlwt, _p, data)
|
||||
else:
|
||||
# call xls equivalent of "open_invoices_inclusion.mako.html"
|
||||
row_pos = self.print_ledger_lines(
|
||||
row_pos, acc, _xs, xlwt, _p, data)
|
||||
row_pos += 1
|
||||
|
||||
open_invoices_xls('report.account.account_report_open_invoices_xls',
|
||||
'account.account', parser=PartnersOpenInvoicesWebkit)
|
|
@ -1,461 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import xlwt
|
||||
from datetime import datetime
|
||||
from openerp.addons.report_xls.report_xls import report_xls
|
||||
from openerp.addons.report_xls.utils import rowcol_to_cell
|
||||
from openerp.addons.account_financial_report_webkit.report.partners_ledger \
|
||||
import PartnersLedgerWebkit
|
||||
from openerp.tools.translate import _
|
||||
# import logging
|
||||
# _logger = logging.getLogger(__name__)
|
||||
|
||||
_column_sizes = [
|
||||
('date', 12),
|
||||
('period', 12),
|
||||
('move', 20),
|
||||
('journal', 12),
|
||||
('partner', 30),
|
||||
('label', 58),
|
||||
('rec', 12),
|
||||
('debit', 15),
|
||||
('credit', 15),
|
||||
('cumul_bal', 15),
|
||||
('curr_bal', 15),
|
||||
('curr_code', 7),
|
||||
]
|
||||
|
||||
|
||||
class partner_ledger_xls(report_xls):
|
||||
column_sizes = [x[1] for x in _column_sizes]
|
||||
|
||||
def generate_xls_report(self, _p, _xs, data, objects, wb):
|
||||
|
||||
ws = wb.add_sheet(_p.report_name[:31])
|
||||
ws.panes_frozen = True
|
||||
ws.remove_splits = True
|
||||
ws.portrait = 0 # Landscape
|
||||
ws.fit_width_to_pages = 1
|
||||
row_pos = 0
|
||||
|
||||
# set print header/footer
|
||||
ws.header_str = self.xls_headers['standard']
|
||||
ws.footer_str = self.xls_footers['standard']
|
||||
|
||||
# cf. account_report_partner_ledger.mako
|
||||
initial_balance_text = {'initial_balance': _('Computed'),
|
||||
'opening_balance': _('Opening Entries'),
|
||||
False: _('No')}
|
||||
|
||||
# Title
|
||||
cell_style = xlwt.easyxf(_xs['xls_title'])
|
||||
report_name = ' - '.join([_p.report_name.upper(),
|
||||
_p.company.partner_id.name,
|
||||
_p.company.currency_id.name])
|
||||
c_specs = [
|
||||
('report_name', 1, 0, 'text', report_name),
|
||||
]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, row_style=cell_style)
|
||||
|
||||
# write empty row to define column sizes
|
||||
c_sizes = self.column_sizes
|
||||
c_specs = [('empty%s' % i, 1, c_sizes[i], 'text', None)
|
||||
for i in range(0, len(c_sizes))]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, set_column_size=True)
|
||||
|
||||
# Header Table
|
||||
nbr_columns = 10
|
||||
if _p.amount_currency(data):
|
||||
nbr_columns = 12
|
||||
cell_format = _xs['bold'] + _xs['fill_blue'] + _xs['borders_all']
|
||||
cell_style = xlwt.easyxf(cell_format)
|
||||
cell_style_center = xlwt.easyxf(cell_format + _xs['center'])
|
||||
c_specs = [
|
||||
('coa', 2, 0, 'text', _('Chart of Account')),
|
||||
('fy', 1, 0, 'text', _('Fiscal Year')),
|
||||
('df', 2, 0, 'text', _p.filter_form(data) ==
|
||||
'filter_date' and _('Dates Filter') or _('Periods Filter')),
|
||||
('af', 1, 0, 'text', _('Accounts Filter')),
|
||||
('tm', 2, 0, 'text', _('Target Moves')),
|
||||
('ib', nbr_columns - 8, 0, 'text', _('Initial Balance')),
|
||||
|
||||
]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, row_style=cell_style_center)
|
||||
|
||||
cell_format = _xs['borders_all']
|
||||
cell_style = xlwt.easyxf(cell_format)
|
||||
cell_style_center = xlwt.easyxf(cell_format + _xs['center'])
|
||||
c_specs = [
|
||||
('coa', 2, 0, 'text', _p.chart_account.name),
|
||||
('fy', 1, 0, 'text', _p.fiscalyear.name if _p.fiscalyear else '-'),
|
||||
]
|
||||
df = _('From') + ': '
|
||||
if _p.filter_form(data) == 'filter_date':
|
||||
df += _p.start_date if _p.start_date else u''
|
||||
else:
|
||||
df += _p.start_period.name if _p.start_period else u''
|
||||
df += ' ' + _('To') + ': '
|
||||
if _p.filter_form(data) == 'filter_date':
|
||||
df += _p.stop_date if _p.stop_date else u''
|
||||
else:
|
||||
df += _p.stop_period.name if _p.stop_period else u''
|
||||
c_specs += [
|
||||
('df', 2, 0, 'text', df),
|
||||
('af', 1, 0, 'text', _('Custom Filter')
|
||||
if _p.partner_ids else _p.display_partner_account(data)),
|
||||
('tm', 2, 0, 'text', _p.display_target_move(data)),
|
||||
('ib', nbr_columns - 8, 0, 'text',
|
||||
initial_balance_text[_p.initial_balance_mode]),
|
||||
]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, row_style=cell_style_center)
|
||||
ws.set_horz_split_pos(row_pos)
|
||||
row_pos += 1
|
||||
|
||||
# Account Title Row
|
||||
cell_format = _xs['xls_title'] + _xs['bold'] + \
|
||||
_xs['fill'] + _xs['borders_all']
|
||||
account_cell_style = xlwt.easyxf(cell_format)
|
||||
account_cell_style_right = xlwt.easyxf(cell_format + _xs['right'])
|
||||
account_cell_style_decimal = xlwt.easyxf(
|
||||
cell_format + _xs['right'],
|
||||
num_format_str=report_xls.decimal_format)
|
||||
|
||||
# Column Title Row
|
||||
cell_format = _xs['bold']
|
||||
c_title_cell_style = xlwt.easyxf(cell_format)
|
||||
|
||||
# Column Header Row
|
||||
cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all']
|
||||
c_hdr_cell_style = xlwt.easyxf(cell_format)
|
||||
c_hdr_cell_style_right = xlwt.easyxf(cell_format + _xs['right'])
|
||||
c_hdr_cell_style_center = xlwt.easyxf(cell_format + _xs['center'])
|
||||
|
||||
# Column Initial Balance Row
|
||||
cell_format = _xs['italic'] + _xs['borders_all']
|
||||
c_init_cell_style = xlwt.easyxf(cell_format)
|
||||
c_init_cell_style_decimal = xlwt.easyxf(
|
||||
cell_format + _xs['right'],
|
||||
num_format_str=report_xls.decimal_format)
|
||||
|
||||
# Column Cumulated balance Row
|
||||
cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all']
|
||||
c_cumul_cell_style = xlwt.easyxf(cell_format)
|
||||
c_cumul_cell_style_right = xlwt.easyxf(cell_format + _xs['right'])
|
||||
c_cumul_cell_style_center = xlwt.easyxf(cell_format + _xs['center'])
|
||||
c_cumul_cell_style_decimal = xlwt.easyxf(
|
||||
cell_format + _xs['right'],
|
||||
num_format_str=report_xls.decimal_format)
|
||||
|
||||
# Column Partner Row
|
||||
cell_format = _xs['bold']
|
||||
c_part_cell_style = xlwt.easyxf(cell_format)
|
||||
|
||||
c_specs = [
|
||||
('date', 1, 0, 'text', _('Date'), None, c_hdr_cell_style),
|
||||
('period', 1, 0, 'text', _('Period'), None, c_hdr_cell_style),
|
||||
('move', 1, 0, 'text', _('Entry'), None, c_hdr_cell_style),
|
||||
('journal', 1, 0, 'text', _('Journal'), None, c_hdr_cell_style),
|
||||
('partner', 1, 0, 'text', _('Partner'), None, c_hdr_cell_style),
|
||||
('label', 1, 0, 'text', _('Label'), None, c_hdr_cell_style),
|
||||
('rec', 1, 0, 'text', _('Rec.'), None, c_hdr_cell_style),
|
||||
('debit', 1, 0, 'text', _('Debit'), None, c_hdr_cell_style_right),
|
||||
('credit', 1, 0, 'text', _('Credit'),
|
||||
None, c_hdr_cell_style_right),
|
||||
('cumul_bal', 1, 0, 'text', _('Cumul. Bal.'),
|
||||
None, c_hdr_cell_style_right),
|
||||
]
|
||||
if _p.amount_currency(data):
|
||||
c_specs += [
|
||||
('curr_bal', 1, 0, 'text', _('Curr. Bal.'),
|
||||
None, c_hdr_cell_style_right),
|
||||
('curr_code', 1, 0, 'text', _('Curr.'),
|
||||
None, c_hdr_cell_style_center),
|
||||
]
|
||||
c_hdr_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
|
||||
# cell styles for ledger lines
|
||||
ll_cell_format = _xs['borders_all']
|
||||
ll_cell_style = xlwt.easyxf(ll_cell_format)
|
||||
ll_cell_style_center = xlwt.easyxf(ll_cell_format + _xs['center'])
|
||||
ll_cell_style_date = xlwt.easyxf(
|
||||
ll_cell_format + _xs['left'],
|
||||
num_format_str=report_xls.date_format)
|
||||
ll_cell_style_decimal = xlwt.easyxf(
|
||||
ll_cell_format + _xs['right'],
|
||||
num_format_str=report_xls.decimal_format)
|
||||
|
||||
cnt = 0
|
||||
for account in objects:
|
||||
if _p['ledger_lines'].get(account.id, False) or \
|
||||
_p['init_balance'].get(account.id, False):
|
||||
if not _p['partners_order'].get(account.id, False):
|
||||
continue
|
||||
cnt += 1
|
||||
account_total_debit = 0.0
|
||||
account_total_credit = 0.0
|
||||
account_balance_cumul = 0.0
|
||||
account_balance_cumul_curr = 0.0
|
||||
c_specs = [
|
||||
('acc_title', nbr_columns, 0, 'text',
|
||||
' - '.join([account.code, account.name]), None,
|
||||
account_cell_style),
|
||||
]
|
||||
row_data = self.xls_row_template(
|
||||
c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, c_title_cell_style)
|
||||
row_pos += 1
|
||||
|
||||
for partner_name, p_id, p_ref, p_name in \
|
||||
_p['partners_order'][account.id]:
|
||||
|
||||
total_debit = 0.0
|
||||
total_credit = 0.0
|
||||
cumul_balance = 0.0
|
||||
cumul_balance_curr = 0.0
|
||||
part_cumul_balance = 0.0
|
||||
part_cumul_balance_curr = 0.0
|
||||
c_specs = [
|
||||
('partner_title', nbr_columns, 0, 'text',
|
||||
partner_name or _('No Partner'), None,
|
||||
c_part_cell_style),
|
||||
]
|
||||
row_data = self.xls_row_template(
|
||||
c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, c_title_cell_style)
|
||||
row_pos = self.xls_write_row(ws, row_pos, c_hdr_data)
|
||||
row_start_partner = row_pos
|
||||
|
||||
total_debit = _p['init_balance'][account.id].get(
|
||||
p_id, {}).get('debit') or 0.0
|
||||
total_credit = _p['init_balance'][account.id].get(
|
||||
p_id, {}).get('credit') or 0.0
|
||||
|
||||
init_line = False
|
||||
if _p.initial_balance_mode and \
|
||||
(total_debit or total_credit):
|
||||
init_line = True
|
||||
|
||||
part_cumul_balance = \
|
||||
_p['init_balance'][account.id].get(
|
||||
p_id, {}).get('init_balance') or 0.0
|
||||
part_cumul_balance_curr = \
|
||||
_p['init_balance'][account.id].get(
|
||||
p_id, {}).get('init_balance_currency') or 0.0
|
||||
balance_forward_currency = \
|
||||
_p['init_balance'][account.id].get(
|
||||
p_id, {}).get('currency_name') or ''
|
||||
|
||||
cumul_balance += part_cumul_balance
|
||||
cumul_balance_curr += part_cumul_balance_curr
|
||||
|
||||
debit_cell = rowcol_to_cell(row_pos, 7)
|
||||
credit_cell = rowcol_to_cell(row_pos, 8)
|
||||
init_bal_formula = debit_cell + '-' + credit_cell
|
||||
|
||||
# Print row 'Initial Balance' by partn
|
||||
c_specs = [('empty%s' % x, 1, 0, 'text', None)
|
||||
for x in range(5)]
|
||||
c_specs += [
|
||||
('init_bal', 1, 0, 'text', _('Initial Balance')),
|
||||
('rec', 1, 0, 'text', None),
|
||||
('debit', 1, 0, 'number', total_debit,
|
||||
None, c_init_cell_style_decimal),
|
||||
('credit', 1, 0, 'number', total_credit,
|
||||
None, c_init_cell_style_decimal),
|
||||
('cumul_bal', 1, 0, 'number', None,
|
||||
init_bal_formula, c_init_cell_style_decimal),
|
||||
]
|
||||
if _p.amount_currency(data):
|
||||
c_specs += [
|
||||
('curr_bal', 1, 0, 'number',
|
||||
part_cumul_balance_curr,
|
||||
None, c_init_cell_style_decimal),
|
||||
('curr_code', 1, 0, 'text',
|
||||
balance_forward_currency),
|
||||
]
|
||||
row_data = self.xls_row_template(
|
||||
c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, c_init_cell_style)
|
||||
|
||||
for line in _p['ledger_lines'][account.id].get(p_id, []):
|
||||
|
||||
total_debit += line.get('debit') or 0.0
|
||||
total_credit += line.get('credit') or 0.0
|
||||
|
||||
label_elements = [line.get('lname') or '']
|
||||
if line.get('invoice_number'):
|
||||
label_elements.append(
|
||||
"(%s)" % (line['invoice_number'],))
|
||||
label = ' '.join(label_elements)
|
||||
cumul_balance += line.get('balance') or 0.0
|
||||
|
||||
if init_line or row_pos > row_start_partner:
|
||||
cumbal_formula = rowcol_to_cell(
|
||||
row_pos - 1, 9) + '+'
|
||||
else:
|
||||
cumbal_formula = ''
|
||||
debit_cell = rowcol_to_cell(row_pos, 7)
|
||||
credit_cell = rowcol_to_cell(row_pos, 8)
|
||||
cumbal_formula += debit_cell + '-' + credit_cell
|
||||
# Print row ledger line data #
|
||||
|
||||
if line.get('ldate'):
|
||||
c_specs = [
|
||||
('ldate', 1, 0, 'date', datetime.strptime(
|
||||
line['ldate'], '%Y-%m-%d'), None,
|
||||
ll_cell_style_date),
|
||||
]
|
||||
else:
|
||||
c_specs = [
|
||||
('ldate', 1, 0, 'text', None),
|
||||
]
|
||||
c_specs += [
|
||||
('period', 1, 0, 'text',
|
||||
line.get('period_code') or ''),
|
||||
('move', 1, 0, 'text',
|
||||
line.get('move_name') or ''),
|
||||
('journal', 1, 0, 'text', line.get('jcode') or ''),
|
||||
('partner', 1, 0, 'text',
|
||||
line.get('partner_name') or ''),
|
||||
('label', 1, 0, 'text', label),
|
||||
('rec_name', 1, 0, 'text',
|
||||
line.get('rec_name') or ''),
|
||||
('debit', 1, 0, 'number', line.get('debit'),
|
||||
None, ll_cell_style_decimal),
|
||||
('credit', 1, 0, 'number', line.get('credit'),
|
||||
None, ll_cell_style_decimal),
|
||||
('cumul_bal', 1, 0, 'number', None,
|
||||
cumbal_formula, ll_cell_style_decimal),
|
||||
]
|
||||
if _p.amount_currency(data):
|
||||
c_specs += [
|
||||
('curr_bal', 1, 0, 'number', line.get(
|
||||
'amount_currency') or 0.0, None,
|
||||
ll_cell_style_decimal),
|
||||
('curr_code', 1, 0, 'text', line.get(
|
||||
'currency_code') or '', None,
|
||||
ll_cell_style_center),
|
||||
]
|
||||
row_data = self.xls_row_template(
|
||||
c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, ll_cell_style)
|
||||
# end for line
|
||||
|
||||
# Print row Cumulated Balance by partner #
|
||||
debit_partner_start = rowcol_to_cell(row_start_partner, 7)
|
||||
debit_partner_end = rowcol_to_cell(row_pos - 1, 7)
|
||||
debit_partner_total = 'SUM(' + debit_partner_start + \
|
||||
':' + debit_partner_end + ')'
|
||||
|
||||
credit_partner_start = rowcol_to_cell(row_start_partner, 8)
|
||||
credit_partner_end = rowcol_to_cell(row_pos - 1, 8)
|
||||
credit_partner_total = 'SUM(' + credit_partner_start + \
|
||||
':' + credit_partner_end + ')'
|
||||
|
||||
bal_partner_debit = rowcol_to_cell(row_pos, 7)
|
||||
bal_partner_credit = rowcol_to_cell(row_pos, 8)
|
||||
bal_partner_total = bal_partner_debit + \
|
||||
'-' + bal_partner_credit
|
||||
|
||||
c_specs = [('empty%s' % x, 1, 0, 'text', None)
|
||||
for x in range(5)]
|
||||
c_specs += [
|
||||
('init_bal', 1, 0, 'text',
|
||||
_('Cumulated balance on Partner')),
|
||||
('rec', 1, 0, 'text', None),
|
||||
('debit', 1, 0, 'number', None,
|
||||
debit_partner_total, c_cumul_cell_style_decimal),
|
||||
('credit', 1, 0, 'number', None,
|
||||
credit_partner_total, c_cumul_cell_style_decimal),
|
||||
('cumul_bal', 1, 0, 'number', None,
|
||||
bal_partner_total, c_cumul_cell_style_decimal),
|
||||
]
|
||||
if _p.amount_currency(data):
|
||||
if account.currency_id:
|
||||
c_specs += [('curr_bal', 1, 0, 'number',
|
||||
cumul_balance_curr or 0.0, None,
|
||||
c_cumul_cell_style_decimal)]
|
||||
else:
|
||||
c_specs += [('curr_bal', 1, 0, 'text',
|
||||
'-', None, c_cumul_cell_style_right)]
|
||||
c_specs += [('curr_code', 1, 0, 'text',
|
||||
account.currency_id.name if
|
||||
account.currency_id else u'', None,
|
||||
c_cumul_cell_style_center)]
|
||||
row_data = self.xls_row_template(
|
||||
c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, c_cumul_cell_style)
|
||||
row_pos += 1
|
||||
account_total_debit += total_debit
|
||||
account_total_credit += total_credit
|
||||
account_balance_cumul += cumul_balance
|
||||
account_balance_cumul_curr += cumul_balance_curr
|
||||
|
||||
# Print row Cumulated Balance by account #
|
||||
c_specs = [
|
||||
('acc_title', 5, 0, 'text', ' - '.
|
||||
join([account.code, account.name])), ]
|
||||
c_specs += [
|
||||
('label', 1, 0, 'text', _('Cumulated balance on Account')),
|
||||
('rec', 1, 0, 'text', None),
|
||||
('debit', 1, 0, 'number', account_total_debit,
|
||||
None, account_cell_style_decimal),
|
||||
('credit', 1, 0, 'number', account_total_credit,
|
||||
None, account_cell_style_decimal),
|
||||
('cumul_bal', 1, 0, 'number', account_balance_cumul,
|
||||
None, account_cell_style_decimal),
|
||||
]
|
||||
if _p.amount_currency(data):
|
||||
if account.currency_id:
|
||||
c_specs += [('curr_bal', 1, 0, 'number',
|
||||
account_balance_cumul_curr or 0.0, None,
|
||||
account_cell_style_decimal)]
|
||||
else:
|
||||
c_specs += [('curr_bal', 1, 0, 'text',
|
||||
'-', None, account_cell_style_right)]
|
||||
c_specs += [('curr_code', 1, 0, 'text',
|
||||
account.currency_id.name if
|
||||
account.currency_id else u'', None,
|
||||
account_cell_style)]
|
||||
row_data = self.xls_row_template(
|
||||
c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, account_cell_style)
|
||||
row_pos += 2
|
||||
|
||||
partner_ledger_xls('report.account.account_report_partner_ledger_xls',
|
||||
'account.account',
|
||||
parser=PartnersLedgerWebkit)
|
|
@ -1,432 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import xlwt
|
||||
from openerp.addons.report_xls.report_xls import report_xls
|
||||
from openerp.addons.report_xls.utils import rowcol_to_cell
|
||||
from openerp.addons.account_financial_report_webkit.report.partner_balance \
|
||||
import PartnerBalanceWebkit
|
||||
from openerp.tools.translate import _
|
||||
# import logging
|
||||
# _logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def display_line(all_comparison_lines):
|
||||
return any([line.get('balance') for line in all_comparison_lines])
|
||||
|
||||
|
||||
class partners_balance_xls(report_xls):
|
||||
column_sizes = [12, 40, 25, 17, 17, 17, 17, 17]
|
||||
|
||||
def print_title(self, ws, _p, row_position, xlwt, _xs):
|
||||
cell_style = xlwt.easyxf(_xs['xls_title'])
|
||||
report_name = ' - '.join([_p.report_name.upper(),
|
||||
_p.company.partner_id.name,
|
||||
_p.company.currency_id.name])
|
||||
c_specs = [
|
||||
('report_name', 1, 0, 'text', report_name),
|
||||
]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
ws, row_position, row_data, row_style=cell_style)
|
||||
return row_position
|
||||
|
||||
def print_empty_row(self, ws, row_position):
|
||||
c_sizes = self.column_sizes
|
||||
c_specs = [('empty%s' % i, 1, c_sizes[i], 'text', None)
|
||||
for i in range(0, len(c_sizes))]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
ws, row_position, row_data, set_column_size=True)
|
||||
return row_position
|
||||
|
||||
def print_header_titles(self, ws, _p, data, row_position, xlwt, _xs):
|
||||
cell_format = _xs['bold'] + _xs['fill_blue'] + _xs['borders_all']
|
||||
cell_style = xlwt.easyxf(cell_format)
|
||||
cell_style_center = xlwt.easyxf(cell_format + _xs['center'])
|
||||
|
||||
c_specs = [
|
||||
('fy', 1, 0, 'text', _('Fiscal Year'), None, cell_style_center),
|
||||
('af', 1, 0, 'text', _('Accounts Filter'),
|
||||
None, cell_style_center),
|
||||
('df', 1, 0, 'text', _p.filter_form(data) == 'filter_date' and _(
|
||||
'Dates Filter') or _('Periods Filter'), None,
|
||||
cell_style_center),
|
||||
('pf', 1, 0, 'text', _('Partners Filter'),
|
||||
None, cell_style_center),
|
||||
('tm', 1, 0, 'text', _('Target Moves'), None, cell_style_center),
|
||||
('ib', 1, 0, 'text', _('Initial Balance'),
|
||||
None, cell_style_center),
|
||||
('coa', 1, 0, 'text', _('Chart of Account'),
|
||||
None, cell_style_center),
|
||||
]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
ws, row_position, row_data, row_style=cell_style)
|
||||
return row_position
|
||||
|
||||
def print_header_data(self, ws, _p, data, row_position, xlwt, _xs,
|
||||
initial_balance_text):
|
||||
cell_format = _xs['borders_all'] + _xs['wrap'] + _xs['top']
|
||||
cell_style = xlwt.easyxf(cell_format)
|
||||
cell_style_center = xlwt.easyxf(cell_format + _xs['center'])
|
||||
c_specs = [
|
||||
('fy', 1, 0, 'text', _p.fiscalyear.name if _p.fiscalyear else '-',
|
||||
None, cell_style_center),
|
||||
('af', 1, 0, 'text', _p.accounts(data) and ', '.join(
|
||||
[account.code for account in _p.accounts(data)]) or _('All'),
|
||||
None, cell_style_center),
|
||||
]
|
||||
df = _('From') + ': '
|
||||
if _p.filter_form(data) == 'filter_date':
|
||||
df += _p.start_date if _p.start_date else u''
|
||||
else:
|
||||
df += _p.start_period.name if _p.start_period else u''
|
||||
df += ' ' + _('\nTo') + ': '
|
||||
if _p.filter_form(data) == 'filter_date':
|
||||
df += _p.stop_date if _p.stop_date else u''
|
||||
else:
|
||||
df += _p.stop_period.name if _p.stop_period else u''
|
||||
c_specs += [
|
||||
('df', 1, 0, 'text', df, None, cell_style_center),
|
||||
('tm', 1, 0, 'text', _p.display_partner_account(
|
||||
data), None, cell_style_center),
|
||||
('pf', 1, 0, 'text', _p.display_target_move(
|
||||
data), None, cell_style_center),
|
||||
('ib', 1, 0, 'text', initial_balance_text[
|
||||
_p.initial_balance_mode], None, cell_style_center),
|
||||
('coa', 1, 0, 'text', _p.chart_account.name,
|
||||
None, cell_style_center),
|
||||
]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
ws, row_position, row_data, row_style=cell_style)
|
||||
return row_position
|
||||
|
||||
def print_comparison_header(self, _xs, xlwt, row_position, _p, ws,
|
||||
initial_balance_text):
|
||||
cell_format_ct = _xs['bold'] + _xs['fill_blue'] + _xs['borders_all']
|
||||
cell_style_ct = xlwt.easyxf(cell_format_ct)
|
||||
c_specs = [('ct', 7, 0, 'text', _('Comparisons'))]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
ws, row_position, row_data, row_style=cell_style_ct)
|
||||
cell_format = _xs['borders_all'] + _xs['wrap'] + _xs['top']
|
||||
cell_style_center = xlwt.easyxf(cell_format)
|
||||
for index, params in enumerate(_p.comp_params):
|
||||
c_specs = [
|
||||
('c', 2, 0, 'text', _('Comparison') + str(index + 1) +
|
||||
' (C' + str(index + 1) + ')')]
|
||||
if params['comparison_filter'] == 'filter_date':
|
||||
c_specs += [
|
||||
('f', 2, 0, 'text',
|
||||
_('Dates Filter') + ': ' +
|
||||
_p.formatLang(params['start'], date=True) + ' - ' +
|
||||
_p.formatLang(params['stop'], date=True))]
|
||||
elif params['comparison_filter'] == 'filter_period':
|
||||
c_specs += [('f', 2, 0, 'text', _('Periods Filter') +
|
||||
': ' + params['start'].name + ' - ' +
|
||||
params['stop'].name)]
|
||||
else:
|
||||
c_specs += [('f', 2, 0, 'text', _('Fiscal Year') +
|
||||
': ' + params['fiscalyear'].name)]
|
||||
c_specs += [('ib', 2, 0, 'text', _('Initial Balance') +
|
||||
': ' +
|
||||
initial_balance_text[params['initial_balance_mode']])]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
ws, row_position, row_data, row_style=cell_style_center)
|
||||
return row_position
|
||||
|
||||
def print_account_header(self, ws, _p, _xs, xlwt, row_position):
|
||||
cell_format = _xs['bold'] + _xs['fill'] + \
|
||||
_xs['borders_all'] + _xs['wrap'] + _xs['top']
|
||||
cell_style = xlwt.easyxf(cell_format)
|
||||
cell_style_right = xlwt.easyxf(cell_format + _xs['right'])
|
||||
cell_style_center = xlwt.easyxf(cell_format + _xs['center'])
|
||||
if len(_p.comp_params) == 2:
|
||||
account_span = 3
|
||||
else:
|
||||
account_span = _p.initial_balance_mode and 2 or 3
|
||||
c_specs = [
|
||||
('account', account_span, 0, 'text', _('Account / Partner Name')),
|
||||
('code', 1, 0, 'text', _('Code / Ref')),
|
||||
]
|
||||
if _p.comparison_mode == 'no_comparison':
|
||||
if _p.initial_balance_mode:
|
||||
c_specs += [('init_bal', 1, 0, 'text',
|
||||
_('Initial Balance'), None, cell_style_right)]
|
||||
c_specs += [
|
||||
('debit', 1, 0, 'text', _('Debit'), None, cell_style_right),
|
||||
('credit', 1, 0, 'text', _('Credit'), None, cell_style_right),
|
||||
]
|
||||
|
||||
if _p.comparison_mode == 'no_comparison' or not _p.fiscalyear:
|
||||
c_specs += [('balance', 1, 0, 'text',
|
||||
_('Balance'), None, cell_style_right)]
|
||||
else:
|
||||
c_specs += [('balance_fy', 1, 0, 'text', _('Balance %s') %
|
||||
_p.fiscalyear.name, None, cell_style_right)]
|
||||
if _p.comparison_mode in ('single', 'multiple'):
|
||||
for index in range(_p.nb_comparison):
|
||||
if _p.comp_params[index][
|
||||
'comparison_filter'] == 'filter_year' \
|
||||
and _p.comp_params[index].get('fiscalyear', False):
|
||||
c_specs += [('balance_%s' % index, 1, 0, 'text',
|
||||
_('Balance %s') %
|
||||
_p.comp_params[index]['fiscalyear'].name,
|
||||
None, cell_style_right)]
|
||||
else:
|
||||
c_specs += [('balance_%s' % index, 1, 0, 'text',
|
||||
_('Balance C%s') % (index + 1), None,
|
||||
cell_style_right)]
|
||||
if _p.comparison_mode == 'single':
|
||||
c_specs += [
|
||||
('diff', 1, 0, 'text', _('Difference'),
|
||||
None, cell_style_right),
|
||||
('diff_percent', 1, 0, 'text',
|
||||
_('% Difference'), None, cell_style_center),
|
||||
]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
ws, row_position, row_data, row_style=cell_style)
|
||||
return row_position
|
||||
|
||||
def print_row_code_account(self, ws, current_account, row_position, _xs,
|
||||
xlwt):
|
||||
cell_format = _xs['xls_title'] + _xs['bold'] + \
|
||||
_xs['fill'] + _xs['borders_all']
|
||||
cell_style = xlwt.easyxf(cell_format)
|
||||
c_specs = [
|
||||
('acc_title', 7, 0, 'text', ' - '.join([current_account.code,
|
||||
current_account.name])), ]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
ws, row_position, row_data, cell_style)
|
||||
return row_position
|
||||
|
||||
def print_account_totals(self, _xs, xlwt, ws, row_start_account,
|
||||
row_position, current_account, _p):
|
||||
cell_format = _xs['bold'] + _xs['fill'] + \
|
||||
_xs['borders_all'] + _xs['wrap'] + _xs['top']
|
||||
cell_style = xlwt.easyxf(cell_format)
|
||||
cell_style_decimal = xlwt.easyxf(
|
||||
cell_format + _xs['right'],
|
||||
num_format_str=report_xls.decimal_format)
|
||||
c_specs = [
|
||||
('acc_title', 2, 0, 'text', current_account.name),
|
||||
('code', 1, 0, 'text', current_account.code),
|
||||
]
|
||||
for column in range(3, 7):
|
||||
# in case of one single comparison, the column 6 will contain
|
||||
# percentages
|
||||
if (_p.comparison_mode == 'single' and column == 6):
|
||||
total_diff = rowcol_to_cell(row_position, column - 1)
|
||||
total_balance = rowcol_to_cell(row_position, column - 2)
|
||||
account_formula = 'Round(' + total_diff + \
|
||||
'/' + total_balance + '*100;0)'
|
||||
else:
|
||||
account_start = rowcol_to_cell(row_start_account, column)
|
||||
account_end = rowcol_to_cell(row_position - 1, column)
|
||||
account_formula = 'Round(SUM(' + \
|
||||
account_start + ':' + account_end + ');2)'
|
||||
c_specs += [('total%s' % column, 1, 0, 'text', None,
|
||||
account_formula, None, cell_style_decimal)]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_position = self.xls_write_row(
|
||||
ws, row_position, row_data, cell_style)
|
||||
return row_position + 1
|
||||
|
||||
def generate_xls_report(self, _p, _xs, data, objects, wb):
|
||||
|
||||
# Initialisations
|
||||
ws = wb.add_sheet(_p.report_name[:31])
|
||||
ws.panes_frozen = True
|
||||
ws.remove_splits = True
|
||||
ws.portrait = 0 # Landscape
|
||||
ws.fit_width_to_pages = 1
|
||||
row_pos = 0
|
||||
ws.header_str = self.xls_headers['standard']
|
||||
ws.footer_str = self.xls_footers['standard']
|
||||
|
||||
# Print Title
|
||||
row_pos = self.print_title(ws, _p, row_pos, xlwt, _xs)
|
||||
# Print empty row to define column sizes
|
||||
row_pos = self.print_empty_row(ws, row_pos)
|
||||
# Print Header Table titles (Fiscal Year - Accounts Filter - Periods
|
||||
# Filter...)
|
||||
row_pos = self.print_header_titles(ws, _p, data, row_pos, xlwt, _xs)
|
||||
|
||||
initial_balance_text = {
|
||||
'initial_balance': _('Computed'),
|
||||
'opening_balance': _('Opening Entries'),
|
||||
False: _('No')} # cf. account_report_partner_balance.mako
|
||||
# Print Header Table data
|
||||
row_pos = self.print_header_data(
|
||||
ws, _p, data, row_pos, xlwt, _xs, initial_balance_text)
|
||||
# Print comparison header table
|
||||
if _p.comparison_mode in ('single', 'multiple'):
|
||||
row_pos += 1
|
||||
row_pos = self.print_comparison_header(
|
||||
_xs, xlwt, row_pos, _p, ws, initial_balance_text)
|
||||
|
||||
# Freeze the line
|
||||
ws.set_horz_split_pos(row_pos)
|
||||
|
||||
# cell styles for account data
|
||||
regular_cell_format = _xs['borders_all']
|
||||
regular_cell_style = xlwt.easyxf(regular_cell_format)
|
||||
regular_cell_style_decimal = xlwt.easyxf(
|
||||
regular_cell_format + _xs['right'],
|
||||
num_format_str=report_xls.decimal_format)
|
||||
|
||||
row_pos += 1
|
||||
for current_account in objects:
|
||||
|
||||
partners_order = _p['partners_order_accounts']\
|
||||
.get(current_account.id, False)
|
||||
|
||||
# do not display accounts without partners
|
||||
if not partners_order:
|
||||
continue
|
||||
|
||||
comparisons = _p['comparisons_accounts']\
|
||||
.get(current_account.id, False)
|
||||
|
||||
# in multiple columns mode, we do not want to print accounts
|
||||
# without any rows
|
||||
if _p.comparison_mode in ('single', 'multiple'):
|
||||
all_comparison_lines = [comp['partners_amounts'][partner_id[1]]
|
||||
for partner_id in partners_order
|
||||
for comp in comparisons]
|
||||
if not display_line(all_comparison_lines):
|
||||
continue
|
||||
|
||||
current_partner_amounts = _p['partners_amounts_accounts']\
|
||||
.get(current_account.id, False)
|
||||
|
||||
if _p.comparison_mode in ('single', 'multiple'):
|
||||
comparison_total = {}
|
||||
for i, comp in enumerate(comparisons):
|
||||
comparison_total[i] = {'balance': 0.0}
|
||||
|
||||
# print row: Code - Account name
|
||||
row_pos = self.print_row_code_account(
|
||||
ws, current_account, row_pos, _xs, xlwt)
|
||||
row_account_start = row_pos
|
||||
# Print row: Titles "Account/Partner Name-Code/ref-Initial
|
||||
# Balance-Debit-Credit-Balance" or "Account/Partner
|
||||
# Name-Code/ref-Balance Year-Balance Year2-Balance C2-Balance C3"
|
||||
row_pos = self.print_account_header(ws, _p, _xs, xlwt, row_pos)
|
||||
|
||||
for (partner_code_name, partner_id, partner_ref, partner_name) \
|
||||
in partners_order:
|
||||
partner = current_partner_amounts.get(partner_id, {})
|
||||
# in single mode, we have to display all the partners even if
|
||||
# their balance is 0.0 because the initial balance should match
|
||||
# with the previous year closings
|
||||
# in multiple columns mode, we do not want to print partners
|
||||
# which have a balance at 0.0 in each comparison column
|
||||
if _p.comparison_mode in ('single', 'multiple'):
|
||||
all_comparison_lines = [comp['partners_amounts']
|
||||
[partner_id]
|
||||
for comp in comparisons
|
||||
if comp['partners_amounts'].
|
||||
get(partner_id)]
|
||||
if not display_line(all_comparison_lines):
|
||||
continue
|
||||
|
||||
# display data row
|
||||
if len(_p.comp_params) == 2:
|
||||
account_span = 3
|
||||
else:
|
||||
account_span = _p.initial_balance_mode and 2 or 3
|
||||
|
||||
c_specs = [('acc_title', account_span, 0, 'text',
|
||||
partner_name if partner_name else
|
||||
_('Unallocated'))]
|
||||
c_specs += [('partner_ref', 1, 0, 'text',
|
||||
partner_ref if partner_ref else '')]
|
||||
if _p.comparison_mode == 'no_comparison':
|
||||
bal_formula = ''
|
||||
if _p.initial_balance_mode:
|
||||
init_bal_cell = rowcol_to_cell(row_pos, 3)
|
||||
bal_formula = init_bal_cell + '+'
|
||||
debit_col = 4
|
||||
c_specs += [
|
||||
('init_bal', 1, 0, 'number', partner.get(
|
||||
'init_balance', 0.0), None,
|
||||
regular_cell_style_decimal),
|
||||
]
|
||||
else:
|
||||
debit_col = 3
|
||||
c_specs += [
|
||||
('debit', 1, 0, 'number', partner.get('debit', 0.0),
|
||||
None, regular_cell_style_decimal),
|
||||
('credit', 1, 0, 'number', partner.get('credit', 0.0),
|
||||
None, regular_cell_style_decimal),
|
||||
]
|
||||
debit_cell = rowcol_to_cell(row_pos, debit_col)
|
||||
credit_cell = rowcol_to_cell(row_pos, debit_col + 1)
|
||||
bal_formula += debit_cell + '-' + credit_cell
|
||||
c_specs += [('bal', 1, 0, 'number', None,
|
||||
bal_formula, regular_cell_style_decimal), ]
|
||||
else:
|
||||
c_specs += [('bal', 1, 0, 'number', partner.get('balance',
|
||||
0.0),
|
||||
None, regular_cell_style_decimal), ]
|
||||
|
||||
if _p.comparison_mode in ('single', 'multiple'):
|
||||
for i, comp in enumerate(comparisons):
|
||||
comp_partners = comp['partners_amounts']
|
||||
balance = diff = percent_diff = 0
|
||||
if comp_partners.get(partner_id):
|
||||
balance = comp_partners[partner_id]['balance']
|
||||
diff = comp_partners[partner_id]['diff']
|
||||
percent_diff = comp_partners[
|
||||
partner_id]['percent_diff']
|
||||
comparison_total[i]['balance'] += balance
|
||||
c_specs += [('balance_%s' % i, 1, 0, 'number',
|
||||
balance, None,
|
||||
regular_cell_style_decimal), ]
|
||||
# no diff in multiple comparisons because it shows too much
|
||||
# data
|
||||
if _p.comparison_mode == 'single':
|
||||
c_specs += [('balance_diff', 1, 0, 'number',
|
||||
diff, None, regular_cell_style_decimal), ]
|
||||
if percent_diff is False:
|
||||
c_specs += [('balance', 1, 0, 'number',
|
||||
diff, None, regular_cell_style_decimal), ]
|
||||
else:
|
||||
c_specs += [('perc_diff', 1, 0, 'number',
|
||||
int(round(percent_diff))), ]
|
||||
row_data = self.xls_row_template(
|
||||
c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, regular_cell_style)
|
||||
|
||||
row_pos = self.print_account_totals(
|
||||
_xs, xlwt, ws, row_account_start, row_pos, current_account, _p)
|
||||
|
||||
partners_balance_xls('report.account.account_report_partner_balance_xls',
|
||||
'account.account',
|
||||
parser=PartnerBalanceWebkit)
|
|
@ -1,324 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import xlwt
|
||||
from openerp.addons.report_xls.report_xls import report_xls
|
||||
from openerp.addons.report_xls.utils import rowcol_to_cell
|
||||
from openerp.addons.account_financial_report_webkit.report.trial_balance \
|
||||
import TrialBalanceWebkit
|
||||
from openerp.tools.translate import _
|
||||
# import logging
|
||||
# _logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class trial_balance_xls(report_xls):
|
||||
column_sizes = [12, 60, 17, 17, 17, 17, 17, 17]
|
||||
|
||||
def generate_xls_report(self, _p, _xs, data, objects, wb):
|
||||
|
||||
ws = wb.add_sheet(_p.report_name[:31])
|
||||
ws.panes_frozen = True
|
||||
ws.remove_splits = True
|
||||
ws.portrait = 0 # Landscape
|
||||
ws.fit_width_to_pages = 1
|
||||
row_pos = 0
|
||||
|
||||
# set print header/footer
|
||||
ws.header_str = self.xls_headers['standard']
|
||||
ws.footer_str = self.xls_footers['standard']
|
||||
|
||||
# cf. account_report_trial_balance.mako
|
||||
initial_balance_text = {'initial_balance': _('Computed'),
|
||||
'opening_balance': _('Opening Entries'),
|
||||
False: _('No')}
|
||||
|
||||
# Title
|
||||
cell_style = xlwt.easyxf(_xs['xls_title'])
|
||||
report_name = ' - '.join([_p.report_name.upper(),
|
||||
_p.company.partner_id.name,
|
||||
_p.company.currency_id.name])
|
||||
c_specs = [
|
||||
('report_name', 1, 0, 'text', report_name),
|
||||
]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, row_style=cell_style)
|
||||
|
||||
# write empty row to define column sizes
|
||||
c_sizes = self.column_sizes
|
||||
c_specs = [('empty%s' % i, 1, c_sizes[i], 'text', None)
|
||||
for i in range(0, len(c_sizes))]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, set_column_size=True)
|
||||
|
||||
# Header Table
|
||||
cell_format = _xs['bold'] + _xs['fill_blue'] + _xs['borders_all']
|
||||
cell_style = xlwt.easyxf(cell_format)
|
||||
cell_style_center = xlwt.easyxf(cell_format + _xs['center'])
|
||||
c_specs = [
|
||||
('fy', 1, 0, 'text', _('Fiscal Year')),
|
||||
('af', 2, 0, 'text', _('Accounts Filter')),
|
||||
('df', 1, 0, 'text', _p.filter_form(data) ==
|
||||
'filter_date' and _('Dates Filter') or _('Periods Filter')),
|
||||
('tm', 2, 0, 'text', _('Target Moves'), None, cell_style_center),
|
||||
('ib', 1, 0, 'text', _('Initial Balance'),
|
||||
None, cell_style_center),
|
||||
('coa', 1, 0, 'text', _('Chart of Account'),
|
||||
None, cell_style_center),
|
||||
]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, row_style=cell_style)
|
||||
|
||||
cell_format = _xs['borders_all'] + _xs['wrap'] + _xs['top']
|
||||
cell_style = xlwt.easyxf(cell_format)
|
||||
cell_style_center = xlwt.easyxf(cell_format + _xs['center'])
|
||||
c_specs = [
|
||||
('fy', 1, 0, 'text', _p.fiscalyear.name if _p.fiscalyear else '-'),
|
||||
('af', 2, 0, 'text', _p.accounts(data) and ', '.join(
|
||||
[account.code for account in _p.accounts(data)]) or _('All')),
|
||||
]
|
||||
df = _('From') + ': '
|
||||
if _p.filter_form(data) == 'filter_date':
|
||||
df += _p.start_date if _p.start_date else u''
|
||||
else:
|
||||
df += _p.start_period.name if _p.start_period else u''
|
||||
df += ' ' + _('\nTo') + ': '
|
||||
if _p.filter_form(data) == 'filter_date':
|
||||
df += _p.stop_date if _p.stop_date else u''
|
||||
else:
|
||||
df += _p.stop_period.name if _p.stop_period else u''
|
||||
c_specs += [
|
||||
('df', 1, 0, 'text', df),
|
||||
('tm', 2, 0, 'text', _p.display_target_move(
|
||||
data), None, cell_style_center),
|
||||
('ib', 1, 0, 'text', initial_balance_text[
|
||||
_p.initial_balance_mode], None, cell_style_center),
|
||||
('coa', 1, 0, 'text', _p.chart_account.name,
|
||||
None, cell_style_center),
|
||||
]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, row_style=cell_style)
|
||||
|
||||
# comparison header table
|
||||
if _p.comparison_mode in ('single', 'multiple'):
|
||||
row_pos += 1
|
||||
cell_format_ct = _xs['bold'] + \
|
||||
_xs['fill_blue'] + _xs['borders_all']
|
||||
cell_style_ct = xlwt.easyxf(cell_format_ct)
|
||||
c_specs = [('ct', 8, 0, 'text', _('Comparisons'))]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, row_style=cell_style_ct)
|
||||
cell_style_center = xlwt.easyxf(cell_format)
|
||||
for index, params in enumerate(_p.comp_params):
|
||||
c_specs = [
|
||||
('c', 3, 0, 'text', _('Comparison') + str(index + 1) +
|
||||
' (C' + str(index + 1) + ')')]
|
||||
if params['comparison_filter'] == 'filter_date':
|
||||
c_specs += [('f', 3, 0, 'text', _('Dates Filter') + ': ' +
|
||||
_p.formatLang(
|
||||
params['start'], date=True) + ' - ' +
|
||||
_p.formatLang(params['stop'], date=True))]
|
||||
elif params['comparison_filter'] == 'filter_period':
|
||||
c_specs += [('f', 3, 0, 'text', _('Periods Filter') +
|
||||
': ' + params['start'].name + ' - ' +
|
||||
params['stop'].name)]
|
||||
else:
|
||||
c_specs += [('f', 3, 0, 'text', _('Fiscal Year') +
|
||||
': ' + params['fiscalyear'].name)]
|
||||
c_specs += [('ib', 2, 0, 'text', _('Initial Balance') +
|
||||
': ' +
|
||||
initial_balance_text[
|
||||
params['initial_balance_mode']])]
|
||||
row_data = self.xls_row_template(
|
||||
c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, row_style=cell_style_center)
|
||||
|
||||
row_pos += 1
|
||||
|
||||
# Column Header Row
|
||||
cell_format = _xs['bold'] + _xs['fill_blue'] + \
|
||||
_xs['borders_all'] + _xs['wrap'] + _xs['top']
|
||||
cell_style = xlwt.easyxf(cell_format)
|
||||
cell_style_right = xlwt.easyxf(cell_format + _xs['right'])
|
||||
cell_style_center = xlwt.easyxf(cell_format + _xs['center'])
|
||||
if len(_p.comp_params) == 2:
|
||||
account_span = 3
|
||||
else:
|
||||
account_span = _p.initial_balance_mode and 2 or 3
|
||||
c_specs = [
|
||||
('code', 1, 0, 'text', _('Code')),
|
||||
('account', account_span, 0, 'text', _('Account')),
|
||||
]
|
||||
if _p.comparison_mode == 'no_comparison':
|
||||
if _p.initial_balance_mode:
|
||||
c_specs += [('init_bal', 1, 0, 'text',
|
||||
_('Initial Balance'), None, cell_style_right)]
|
||||
c_specs += [
|
||||
('debit', 1, 0, 'text', _('Debit'), None, cell_style_right),
|
||||
('credit', 1, 0, 'text', _('Credit'), None, cell_style_right),
|
||||
]
|
||||
|
||||
if _p.comparison_mode == 'no_comparison' or not _p.fiscalyear:
|
||||
c_specs += [('balance', 1, 0, 'text',
|
||||
_('Balance'), None, cell_style_right)]
|
||||
else:
|
||||
c_specs += [('balance_fy', 1, 0, 'text', _('Balance %s') %
|
||||
_p.fiscalyear.name, None, cell_style_right)]
|
||||
if _p.comparison_mode in ('single', 'multiple'):
|
||||
for index in range(_p.nb_comparison):
|
||||
if _p.comp_params[index][
|
||||
'comparison_filter'] == 'filter_year' \
|
||||
and _p.comp_params[index].get('fiscalyear', False):
|
||||
c_specs += [('balance_%s' % index, 1, 0, 'text',
|
||||
_('Balance %s') %
|
||||
_p.comp_params[index]['fiscalyear'].name,
|
||||
None, cell_style_right)]
|
||||
else:
|
||||
c_specs += [('balance_%s' % index, 1, 0, 'text',
|
||||
_('Balance C%s') % (index + 1), None,
|
||||
cell_style_right)]
|
||||
if _p.comparison_mode == 'single':
|
||||
c_specs += [
|
||||
('diff', 1, 0, 'text', _('Difference'),
|
||||
None, cell_style_right),
|
||||
('diff_percent', 1, 0, 'text',
|
||||
_('% Difference'), None, cell_style_center),
|
||||
]
|
||||
c_specs += [('type', 1, 0, 'text', _('Type'), None, cell_style_center)]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, row_style=cell_style)
|
||||
ws.set_horz_split_pos(row_pos)
|
||||
|
||||
last_child_consol_ids = []
|
||||
|
||||
# cell styles for account data
|
||||
view_cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all']
|
||||
view_cell_style = xlwt.easyxf(view_cell_format)
|
||||
view_cell_style_center = xlwt.easyxf(view_cell_format + _xs['center'])
|
||||
view_cell_style_decimal = xlwt.easyxf(
|
||||
view_cell_format + _xs['right'],
|
||||
num_format_str=report_xls.decimal_format)
|
||||
view_cell_style_pct = xlwt.easyxf(
|
||||
view_cell_format + _xs['center'], num_format_str='0')
|
||||
regular_cell_format = _xs['borders_all']
|
||||
regular_cell_style = xlwt.easyxf(regular_cell_format)
|
||||
regular_cell_style_center = xlwt.easyxf(
|
||||
regular_cell_format + _xs['center'])
|
||||
regular_cell_style_decimal = xlwt.easyxf(
|
||||
regular_cell_format + _xs['right'],
|
||||
num_format_str=report_xls.decimal_format)
|
||||
regular_cell_style_pct = xlwt.easyxf(
|
||||
regular_cell_format + _xs['center'], num_format_str='0')
|
||||
|
||||
for current_account in objects:
|
||||
|
||||
if not _p['to_display_accounts'][current_account.id]:
|
||||
continue
|
||||
|
||||
if current_account.type == 'view':
|
||||
cell_style = view_cell_style
|
||||
cell_style_center = view_cell_style_center
|
||||
cell_style_decimal = view_cell_style_decimal
|
||||
cell_style_pct = view_cell_style_pct
|
||||
else:
|
||||
cell_style = regular_cell_style
|
||||
cell_style_center = regular_cell_style_center
|
||||
cell_style_decimal = regular_cell_style_decimal
|
||||
cell_style_pct = regular_cell_style_pct
|
||||
|
||||
comparisons = _p['comparisons_accounts'][current_account.id]
|
||||
|
||||
if current_account.id not in last_child_consol_ids:
|
||||
# current account is a not a consolidation child: use its own
|
||||
# level
|
||||
last_child_consol_ids = [
|
||||
child_consol_id.id for child_consol_id in
|
||||
current_account.child_consol_ids]
|
||||
|
||||
c_specs = [
|
||||
('code', 1, 0, 'text', current_account.code),
|
||||
('account', account_span, 0, 'text', current_account.name),
|
||||
]
|
||||
if _p.comparison_mode == 'no_comparison':
|
||||
|
||||
debit_cell = rowcol_to_cell(row_pos, 4)
|
||||
credit_cell = rowcol_to_cell(row_pos, 5)
|
||||
bal_formula = debit_cell + '-' + credit_cell
|
||||
|
||||
if _p.initial_balance_mode:
|
||||
init_cell = rowcol_to_cell(row_pos, 3)
|
||||
debit_cell = rowcol_to_cell(row_pos, 4)
|
||||
credit_cell = rowcol_to_cell(row_pos, 5)
|
||||
bal_formula = init_cell + '+' + \
|
||||
debit_cell + '-' + credit_cell
|
||||
c_specs += [('init_bal', 1, 0, 'number',
|
||||
_p['init_balance_'
|
||||
'accounts'][current_account.id],
|
||||
None,
|
||||
cell_style_decimal)]
|
||||
c_specs += [
|
||||
('debit', 1, 0, 'number',
|
||||
_p['debit_accounts'][current_account.id],
|
||||
None, cell_style_decimal),
|
||||
('credit', 1, 0, 'number',
|
||||
_p['credit_accounts'][current_account.id],
|
||||
None, cell_style_decimal),
|
||||
]
|
||||
c_specs += [('balance', 1, 0, 'number', None,
|
||||
bal_formula, cell_style_decimal)]
|
||||
else:
|
||||
c_specs += [('balance', 1, 0, 'number',
|
||||
_p['balance_accounts'][current_account.id],
|
||||
None, cell_style_decimal)]
|
||||
|
||||
if _p.comparison_mode in ('single', 'multiple'):
|
||||
c = 1
|
||||
for comp_account in comparisons:
|
||||
c_specs += [('balance_%s' % c, 1, 0, 'number',
|
||||
comp_account['balance'], None,
|
||||
cell_style_decimal)]
|
||||
c += 1
|
||||
if _p.comparison_mode == 'single':
|
||||
c_specs += [
|
||||
('diff', 1, 0, 'number', comp_account[
|
||||
'diff'], None, cell_style_decimal),
|
||||
('diff_percent', 1, 0, 'number', comp_account[
|
||||
'percent_diff'] and
|
||||
comp_account['percent_diff'] or 0, None,
|
||||
cell_style_pct),
|
||||
]
|
||||
|
||||
c_specs += [('type', 1, 0, 'text',
|
||||
current_account.type, None, cell_style_center)]
|
||||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
|
||||
row_pos = self.xls_write_row(
|
||||
ws, row_pos, row_data, row_style=cell_style)
|
||||
|
||||
trial_balance_xls('report.account.account_report_trial_balance_xls',
|
||||
'account.account',
|
||||
parser=TrialBalanceWebkit)
|
Binary file not shown.
Before Width: | Height: | Size: 22 KiB |
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 55 KiB |
|
@ -1,65 +0,0 @@
|
|||
-
|
||||
In order to test the Excel General Ledger webkit wizard I will print report with default setting
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0')}
|
||||
ctx.update({'model': 'account.account','active_ids':[ref('account.chart0')],'active_id':ref('account.chart0')})
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_general_ledger_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export',our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel General Ledger webkit wizard I will print report with posted move
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'target_move': 'posted'}
|
||||
ctx.update({'model': 'account.account','active_ids':[ref('account.chart0')],'active_id':ref('account.chart0')})
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_general_ledger_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export',our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel General Ledger webkit wizard I will print report with transactions or non zero balance
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'display_account': 'bal_mix'}
|
||||
ctx.update({'model': 'account.account','active_ids':[ref('account.chart0')],'active_id':ref('account.chart0')})
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_general_ledger_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export',our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel General Ledger webkit wizard I will print report with inital balance and currency ammount
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'amount_currency': 1}
|
||||
ctx.update({'model': 'account.account','active_ids':[ref('account.chart0')],'active_id':ref('account.chart0')})
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_general_ledger_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export',our_module='account_financial_report_webkit_xls')
|
||||
|
||||
#Filter by date
|
||||
-
|
||||
In order to test the Excel General Ledger webkit wizard I will print report with inital balance and currency ammount and I filter by date of the first tree month
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'),'amount_currency': 1, 'chart_account_id': 1, 'date_from': '%s-01-01' %(datetime.now().year),
|
||||
'date_to':'%s-04-01' %(datetime.now().year), 'display_account': 'bal_all', 'filter': 'filter_date',}
|
||||
ctx.update({'model': 'account.account','active_ids':[ref('account.chart0')],'active_id':ref('account.chart0')})
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_general_ledger_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export',our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel General Ledger webkit wizard I will print report with inital balance and currency ammount and I filter by date of the first tree month
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'),'amount_currency': 1, 'chart_account_id': 1, 'date_from': '%s-01-01' %(datetime.now().year),
|
||||
'date_to':'%s-04-01' %(datetime.now().year), 'display_account': 'bal_all', 'filter': 'filter_date',}
|
||||
ctx.update({'model': 'account.account','active_ids':[ref('account.chart0')],'active_id':ref('account.chart0')})
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_general_ledger_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export',our_module='account_financial_report_webkit_xls')
|
||||
# I still have to parse report content but for this I need accounting data on multiple exercises and faor all fiscal year
|
|
@ -1,60 +0,0 @@
|
|||
-
|
||||
In order to test the Excel Open Invoices Report webkit wizard I will print report with default setting
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'until_date': '%s-12-31' %(datetime.now().year)}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_open_invoices_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export',our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel Open Invoices Report webkit wizard I will print report with filters and currency
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted',
|
||||
'amount_currency': True, 'result_selection': 'customer_supplier'}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_open_invoices_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export',our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel Open Invoices Report webkit wizard I will print report with filters on partners
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted',
|
||||
'amount_currency': True, 'result_selection': 'customer_supplier',
|
||||
'partner_ids': [ref('base.res_partner_2'), ref('base.res_partner_1')]}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_open_invoices_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export',our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel Open Invoices Report webkit wizard I will print report with filters on periods
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted',
|
||||
'amount_currency': True, 'result_selection': 'customer_supplier',
|
||||
'filter': 'filter_period', 'period_from': ref('account.period_1'), 'period_to': ref('account.period_12')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_open_invoices_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export',our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel Open Invoices Report webkit wizard I will print report with filters on dates
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted',
|
||||
'amount_currency': True, 'result_selection': 'customer_supplier',
|
||||
'filter': 'filter_date', 'date_from': '%s-01-01' %(datetime.now().year), 'date_to': '%s-12-31' %(datetime.now().year)}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_open_invoices_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export',our_module='account_financial_report_webkit_xls')
|
|
@ -1,67 +0,0 @@
|
|||
-
|
||||
In order to test the Excel Partner Balance webkit wizard I will print report with default setting
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_partner_balance_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export', our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel Partner Balance webkit wizard I will print report as if we print it from an account
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0')}
|
||||
ctx.update({'model': 'account.account','active_ids':[ref('account.assets_view'), ref('account.liabilities_view')],'active_id': ref('account.assets_view')})
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_partner_balance_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export', our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel Partner Balance webkit wizard I will print report with filters on period
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'filter': 'filter_period', 'period_from': ref('account.period_1'), 'period_to': ref('account.period_12')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_partner_balance_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export', our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel Partner Balance webkit wizard I will print report with filters on dates
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'filter': 'filter_date', 'date_from': '%s-01-01' %(datetime.now().year), 'date_to': '%s-12-31' %(datetime.now().year)}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_partner_balance_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export', our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel Partner Balance webkit wizard I will print report with one comparison filtered by year
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'comp0_filter': 'filter_year', 'comp0_fiscalyear_id': ref('account.data_fiscalyear')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_partner_balance_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export', our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel Partner Balance webkit wizard I will print report with all comparisons filtered by year, period and date
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'comp0_filter': 'filter_year', 'comp0_fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'comp1_filter': 'filter_period', 'comp1_period_from': ref('account.period_1'), 'comp1_period_to': ref('account.period_12'),
|
||||
'comp2_filter': 'filter_date', 'comp2_date_from': '%s-01-01' %(datetime.now().year), 'comp2_date_to': '%s-12-31' %(datetime.now().year)
|
||||
}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_partner_balance_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export',our_module='account_financial_report_webkit_xls')
|
|
@ -1,60 +0,0 @@
|
|||
-
|
||||
In order to test the Excel Partner Ledger webkit wizard I will print report with default setting
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'until_date': '%s-12-31' %(datetime.now().year)}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_partners_ledger_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export',our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel Partner Ledger webkit wizard I will print report with filters and currency
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted',
|
||||
'amount_currency': True, 'result_selection': 'customer_supplier'}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_partners_ledger_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export',our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel Partner Ledger webkit wizard I will print report with filters on partners
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted',
|
||||
'amount_currency': True, 'result_selection': 'customer_supplier',
|
||||
'partner_ids': [ref('base.res_partner_2'), ref('base.res_partner_1')]}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_partners_ledger_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export',our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel Partner Ledger webkit wizard I will print report with filters on periods
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted',
|
||||
'amount_currency': True, 'result_selection': 'customer_supplier',
|
||||
'filter': 'filter_period', 'period_from': ref('account.period_1'), 'period_to': ref('account.period_12')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_partners_ledger_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export',our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel Partner Ledger webkit wizard I will print report with filters on dates
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'until_date': '%s-12-31' %(datetime.now().year), 'target_move': 'posted',
|
||||
'amount_currency': True, 'result_selection': 'customer_supplier',
|
||||
'filter': 'filter_date', 'date_from': '%s-01-01' %(datetime.now().year), 'date_to': '%s-12-31' %(datetime.now().year)}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_partners_ledger_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export',our_module='account_financial_report_webkit_xls')
|
|
@ -1,67 +0,0 @@
|
|||
-
|
||||
In order to test the Excel Trial Balance webkit wizard I will print report with default setting
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_trial_balance_menu_webkit',wiz_data=data_dict, wiz_buttons='xls_export', context=ctx, our_module='')
|
||||
|
||||
-
|
||||
In order to test the Excel Trial Balance webkit wizard I will print report as if we print it from an account
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0')}
|
||||
ctx.update({'model': 'account.account','active_ids':[ref('account.assets_view'), ref('account.liabilities_view')],'active_id': ref('account.assets_view')})
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export', our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel Trial Balance webkit wizard I will print report with filters on period
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'filter': 'filter_period', 'period_from': ref('account.period_1'), 'period_to': ref('account.period_12')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export', our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel Trial Balance webkit wizard I will print report with filters on dates
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'filter': 'filter_date', 'date_from': '%s-01-01' %(datetime.now().year), 'date_to': '%s-12-31' %(datetime.now().year)}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export', our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel Trial Balance webkit wizard I will print report with one comparison filtered by year
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'comp0_filter': 'filter_year', 'comp0_fiscalyear_id': ref('account.data_fiscalyear')}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export', our_module='account_financial_report_webkit_xls')
|
||||
|
||||
-
|
||||
In order to test the Excel Trial Balance webkit wizard I will print report with all comparisons filtered by year, period and date
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from datetime import datetime
|
||||
ctx={'xls_export':1}
|
||||
data_dict = {'chart_account_id':ref('account.chart0'), 'fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'comp0_filter': 'filter_year', 'comp0_fiscalyear_id': ref('account.data_fiscalyear'),
|
||||
'comp1_filter': 'filter_period', 'comp1_period_from': ref('account.period_1'), 'comp1_period_to': ref('account.period_12'),
|
||||
'comp2_filter': 'filter_date', 'comp2_date_from': '%s-01-01' %(datetime.now().year), 'comp2_date_to': '%s-12-31' %(datetime.now().year)
|
||||
}
|
||||
from openerp.tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'account_financial_report_webkit.action_account_trial_balance_menu_webkit',wiz_data=data_dict, context=ctx, wiz_buttons='xls_export', our_module='account_financial_report_webkit_xls')
|
|
@ -1,27 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from . import general_ledger_wizard
|
||||
from . import trial_balance_wizard
|
||||
from . import partners_balance_wizard
|
||||
from . import partners_ledger_wizard
|
||||
from . import open_invoices_wizard
|
|
@ -1,44 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm
|
||||
# import logging
|
||||
# _logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class general_ledger_webkit_wizard(orm.TransientModel):
|
||||
_inherit = 'general.ledger.webkit'
|
||||
|
||||
def xls_export(self, cr, uid, ids, context=None):
|
||||
return self.check_report(cr, uid, ids, context=context)
|
||||
|
||||
def _print_report(self, cr, uid, ids, data, context=None):
|
||||
context = context or {}
|
||||
if context.get('xls_export'):
|
||||
# we update form with display account value
|
||||
data = self.pre_print_report(cr, uid, ids, data, context=context)
|
||||
return {'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account.account_report_general_ledger_xls',
|
||||
'datas': data}
|
||||
else:
|
||||
return super(general_ledger_webkit_wizard, self)._print_report(
|
||||
cr, uid, ids, data, context=context)
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="general_ledger_webkit_xls_wizard_view" model="ir.ui.view">
|
||||
<field name="name">general.ledger.webkit.xls</field>
|
||||
<field name="model">general.ledger.webkit</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account_financial_report_webkit.account_report_general_ledger_view_webkit"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="/form/label[contains(@string,'generate a pdf')]" position="replace">
|
||||
<label nolabel="1" colspan="4" string="This report allows you to generate a pdf or xls of your general ledger with details of all your account journals"/>
|
||||
</xpath>
|
||||
<xpath expr="/form/group[@col='4']" position='attributes'>
|
||||
<attribute name="col">6</attribute>
|
||||
</xpath>
|
||||
<button string="Print" position="after">
|
||||
<button icon="gtk-execute" name="xls_export" string="Export" type="object" context="{'xls_export':1}" colspan="2"/>
|
||||
</button>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,44 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm
|
||||
# import logging
|
||||
# _logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class open_invoices_webkit_wizard(orm.TransientModel):
|
||||
_inherit = 'open.invoices.webkit'
|
||||
|
||||
def xls_export(self, cr, uid, ids, context=None):
|
||||
return self.check_report(cr, uid, ids, context=context)
|
||||
|
||||
def _print_report(self, cr, uid, ids, data, context=None):
|
||||
context = context or {}
|
||||
if context.get('xls_export'):
|
||||
# we update form with display account value
|
||||
data = self.pre_print_report(cr, uid, ids, data, context=context)
|
||||
return {'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account.account_report_open_invoices_xls',
|
||||
'datas': data}
|
||||
else:
|
||||
return super(open_invoices_webkit_wizard, self)._print_report(
|
||||
cr, uid, ids, data, context=context)
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="open_invoices_webkit_xls_wizard_view" model="ir.ui.view">
|
||||
<field name="name">open.invoices.webkit.xls</field>
|
||||
<field name="model">open.invoices.webkit</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account_financial_report_webkit.account_open_invoices_view_webkit"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="/form/label[contains(@string,'generate a pdf')]" position="replace">
|
||||
<label nolabel="1" colspan="4" string="This report allows you to generate a pdf or xls of your open invoices per partner with details of all your payable/receivable account. Exclude full reconciled journal items."/>
|
||||
</xpath>
|
||||
<xpath expr="/form/group[@col='4']" position='attributes'>
|
||||
<attribute name="col">6</attribute>
|
||||
</xpath>
|
||||
<button string="Print" position="after">
|
||||
<button icon="gtk-execute" name="xls_export" string="Export" type="object" context="{'xls_export':1}" colspan="2"/>
|
||||
</button>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,45 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm
|
||||
# import logging
|
||||
# _logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class partner_balance_wizard(orm.TransientModel):
|
||||
_inherit = 'partner.balance.webkit'
|
||||
|
||||
def xls_export(self, cr, uid, ids, context=None):
|
||||
return self.check_report(cr, uid, ids, context=context)
|
||||
|
||||
def _print_report(self, cr, uid, ids, data, context=None):
|
||||
context = context or {}
|
||||
if context.get('xls_export'):
|
||||
# we update form with display account value
|
||||
data = self.pre_print_report(cr, uid, ids, data, context=context)
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account.account_report_partner_balance_xls',
|
||||
'datas': data}
|
||||
else:
|
||||
return super(partner_balance_wizard, self)._print_report(
|
||||
cr, uid, ids, data, context=context)
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="partners_balance_webkit_xls_wizard_view" model="ir.ui.view">
|
||||
<field name="name">partner.balance.webkit.xls</field>
|
||||
<field name="model">partner.balance.webkit</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account_financial_report_webkit.account_partner_balance_view_webkit"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="/form/label[contains(@string,'is an analysis')]" position="replace">
|
||||
<label nolabel="1" colspan="4" string="This report allows you to generate a pdf or xls of your partner balance allowing you to quickly check the balance of each of your accounts in a single report"/>
|
||||
</xpath>
|
||||
<xpath expr="/form/group[@col='4']" position='attributes'>
|
||||
<attribute name="col">6</attribute>
|
||||
</xpath>
|
||||
<button string="Print" position="after">
|
||||
<button icon="gtk-execute" name="xls_export" string="Export" type="object" context="{'xls_export':1}" colspan="2"/>
|
||||
</button>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,44 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm
|
||||
# import logging
|
||||
# _logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class partner_ledger_webkit_wizard(orm.TransientModel):
|
||||
_inherit = 'partners.ledger.webkit'
|
||||
|
||||
def xls_export(self, cr, uid, ids, context=None):
|
||||
return self.check_report(cr, uid, ids, context=context)
|
||||
|
||||
def _print_report(self, cr, uid, ids, data, context=None):
|
||||
context = context or {}
|
||||
if context.get('xls_export'):
|
||||
# we update form with display account value
|
||||
data = self.pre_print_report(cr, uid, ids, data, context=context)
|
||||
return {'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account.account_report_partner_ledger_xls',
|
||||
'datas': data}
|
||||
else:
|
||||
return super(partner_ledger_webkit_wizard, self)._print_report(
|
||||
cr, uid, ids, data, context=context)
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="partner_ledger_webkit_xls_wizard_view" model="ir.ui.view">
|
||||
<field name="name">partners.ledger.webkit.xls</field>
|
||||
<field name="model">partners.ledger.webkit</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account_financial_report_webkit.account_partner_ledger_view_webkit"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="/form/label[contains(@string,'generate a pdf')]" position="replace">
|
||||
<label nolabel="1" colspan="4" string="This report allows you to generate a pdf or xls of your partner ledger with details of all your account journals"/>
|
||||
</xpath>
|
||||
<xpath expr="/form/group[@col='4']" position='attributes'>
|
||||
<attribute name="col">6</attribute>
|
||||
</xpath>
|
||||
<button string="Print" position="after">
|
||||
<button icon="gtk-execute" name="xls_export" string="Export" type="object" context="{'xls_export':1}" colspan="2"/>
|
||||
</button>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,44 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
#
|
||||
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm
|
||||
# import logging
|
||||
# _logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class trial_balance_wizard(orm.TransientModel):
|
||||
_inherit = 'trial.balance.webkit'
|
||||
|
||||
def xls_export(self, cr, uid, ids, context=None):
|
||||
return self.check_report(cr, uid, ids, context=context)
|
||||
|
||||
def _print_report(self, cr, uid, ids, data, context=None):
|
||||
context = context or {}
|
||||
if context.get('xls_export'):
|
||||
# we update form with display account value
|
||||
data = self.pre_print_report(cr, uid, ids, data, context=context)
|
||||
return {'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account.account_report_trial_balance_xls',
|
||||
'datas': data}
|
||||
else:
|
||||
return super(trial_balance_wizard, self)._print_report(
|
||||
cr, uid, ids, data, context=context)
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="trial_balance_webkit_xls_wizard_view" model="ir.ui.view">
|
||||
<field name="name">trial.balance.webkit.xls</field>
|
||||
<field name="model">trial.balance.webkit</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account_financial_report_webkit.account_trial_balance_view_webkit"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="/form/label[contains(@string,'generate a pdf')]" position="replace">
|
||||
<label nolabel="1" colspan="4" string="This report allows you to generate a pdf or xls of your trial balance allowing you to quickly check the balance of each of your accounts in a single report"/>
|
||||
</xpath>
|
||||
<xpath expr="/form/group[@col='4']" position='attributes'>
|
||||
<attribute name="col">6</attribute>
|
||||
</xpath>
|
||||
<button string="Print" position="after">
|
||||
<button icon="gtk-execute" name="xls_export" string="Export" type="object" context="{'xls_export':1}" colspan="2"/>
|
||||
</button>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue