[MRG] [MIGR] Migration of the module account_financial_report_webkit to OpenERP 7.0
commit
79e015a895
|
@ -18,12 +18,13 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
|
||||||
{
|
{
|
||||||
'name': 'Webkit based extended report financial report',
|
'name': 'Financial Reports - Webkit',
|
||||||
'description': """
|
'description': """
|
||||||
This module replace the following standard openerp financial reports :
|
Financial Reports - Webkit
|
||||||
|
==========================
|
||||||
|
|
||||||
|
This module adds or replaces the following standard OpenERP financial reports:
|
||||||
- General ledger
|
- General ledger
|
||||||
- Trial Balance (simple or comparative view)
|
- Trial Balance (simple or comparative view)
|
||||||
- Partner ledger
|
- Partner ledger
|
||||||
|
@ -32,72 +33,102 @@ This module replace the following standard openerp financial reports :
|
||||||
|
|
||||||
|
|
||||||
Main improvements per report:
|
Main improvements per report:
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
* The General ledger: details of all entries posted in your books sorted by account.
|
The General ledger: details of all entries posted in your books sorted by account.
|
||||||
- Filter by account in the wizard (no need to go to the Chart of account to do this anymore)
|
|
||||||
or by view account (the report will display all regular children account) ie: you can select all P&L accounts.
|
|
||||||
- The report will now print only account with movements OR with a balance not null. No more endless
|
|
||||||
report with accounts with no data. (field: display account is hidden)
|
|
||||||
- initial balance calculation on the fly if no open entry posted
|
|
||||||
- Thanks to a new checkbox in account form, you will have possibility to centralize any accounts you like.
|
|
||||||
Ie: 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 displayed for each transaction (3 accounts max.) to ease searching.
|
|
||||||
- Better ergonomy on the wizard: important information at the top, filters in the middle, options
|
|
||||||
at the bottom or separate tab, more specific filtering on a other tabs. No more unique wizard layout
|
|
||||||
for all financial reports (ie: 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 account is available in the wizard (no need to go to the
|
||||||
- Filter by partner now possible
|
Chart of Accounts to do this anymore) or by View account (the report
|
||||||
- Now you can see accounts then Partner with subtotals for each account allowing you to check you data
|
will display all regular children accounts) i.e. you can select all
|
||||||
with trial balance and partner balance for instance & accounts are ordered the same way than in the Chart of account
|
P&L accounts.
|
||||||
- period have been added (date only is uncompleted since date can be outside period)
|
* The report only prints accounts with moves OR with a non
|
||||||
- Reconciliation code added
|
null balance. No more endless report with empty accounts (field:
|
||||||
- subtotal by account
|
display account is hidden)
|
||||||
- alpha sorting (same in partner balance)
|
* 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
|
||||||
|
|
||||||
* Open invoice report : other version of the partner ledger showing unreconciled / partially reconcies entries
|
The partner ledger: details of entries relative to payable &
|
||||||
(added on the 20/01/2012)
|
receivable accounts posted in your books sorted by account and
|
||||||
- Possibility to print unreconciled transactions only at any date in the past (thanks to the brand-new field:
|
partner.
|
||||||
last_rec_date which calculated the last move line reconciled date). No more pain to get open invoices at the last closing date.
|
|
||||||
- no initial balance calculated because the report shows open invoices from previous years.
|
|
||||||
|
|
||||||
* The Trial balance: list of account with balances
|
* Filter by partner now available
|
||||||
- you can either see the column : Initial balance , debit, credit , end balance or compare balances over 4 periods of your choice
|
* Now you can see Accounts then Partner with subtotals for each
|
||||||
- You can select the filter opening to get the opening trial balance only
|
account allowing you to check you data with trial balance and
|
||||||
- If you create a extra virtual charts (using consolidated account) of account for your P&L and your balance sheet,
|
partner balance for instance. Accounts are ordered in the same way as
|
||||||
you can print your statutory accounts (with comparision over years for ex.)
|
in the Chart of account
|
||||||
- If you compare 2 periods, you will get differences in value and % also
|
* 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)
|
||||||
|
|
||||||
* The Partner balance: list of account with balances
|
Open invoice report : other version of the partner ledger showing
|
||||||
- subtotal by account & partner
|
unreconciled / partially reconciled entries.
|
||||||
- alpha sorting (same in partner balance)
|
|
||||||
|
* 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)
|
||||||
|
|
||||||
Limitations:
|
Limitations:
|
||||||
In order to run properly this module make sure you have installed the librairie ‘wkhtmltopdf’
|
------------
|
||||||
for the pdf rendering (this library path must be added to you company settings).
|
|
||||||
|
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
|
Initial balances in these reports are based either on opening entry
|
||||||
posted in the opening period or calculated on the fly. So make sure,
|
posted in the opening period or computed on the fly. So make sure
|
||||||
your past accounting opening entries are in a opening period.
|
that your past accounting opening entries are in an opening period.
|
||||||
Initials balances are not calculated when using date filter (since a
|
Initials balances are not computed when using the Date filter (since a
|
||||||
date can be outside its logical period and IB could be different by
|
date can be outside its logical period and the initial balance could
|
||||||
date Vs IB by period) The opening period is assumed to be the 01.01 of
|
be different when computed by data or by initial balance for the
|
||||||
the year with an opening flag and the first period of the year must
|
period). The opening period is assumed to be the Jan. 1st of the year
|
||||||
starts also the 01.01
|
with an opening flag and the first period of the year must start also
|
||||||
|
on Jan 1st.
|
||||||
|
|
||||||
Totals for amount in currencies are affective if the partner belong to
|
Totals for amounts in currencies are effective if the partner belongs to
|
||||||
an account with a secondary currency.
|
an account with a secondary currency.
|
||||||
|
|
||||||
html headers and footers are deactivated for these reports because of
|
HTML headers and footers are deactivated for these reports because of
|
||||||
an issue of wkhtmltopdf :
|
an issue in wkhtmltopdf
|
||||||
http://code.google.com/p/wkhtmltopdf/issues/detail?id=656 Instead, the
|
(http://code.google.com/p/wkhtmltopdf/issues/detail?id=656) Instead,
|
||||||
header and footer are created as text with arguments passed to
|
the header and footer are created as text with arguments passed to
|
||||||
wkhtmltopdf. The texts are defined inside the report classes.
|
wkhtmltopdf. The texts are defined inside the report classes.
|
||||||
|
|
||||||
""",
|
""",
|
||||||
'version': '1.0',
|
'version': '1.0',
|
||||||
'author': 'Camptocamp',
|
'author': 'Camptocamp',
|
||||||
|
'license': 'AGPL-3',
|
||||||
'category': 'Finance',
|
'category': 'Finance',
|
||||||
'website': 'http://www.camptocamp.com',
|
'website': 'http://www.camptocamp.com',
|
||||||
'images': [
|
'images': [
|
||||||
|
@ -107,7 +138,6 @@ wkhtmltopdf. The texts are defined inside the report classes.
|
||||||
'init_xml': [],
|
'init_xml': [],
|
||||||
'demo_xml' : [],
|
'demo_xml' : [],
|
||||||
'update_xml': ['account_view.xml',
|
'update_xml': ['account_view.xml',
|
||||||
'account_move_line_view.xml',
|
|
||||||
'data/financial_webkit_header.xml',
|
'data/financial_webkit_header.xml',
|
||||||
'report/report.xml',
|
'report/report.xml',
|
||||||
'wizard/wizard.xml',
|
'wizard/wizard.xml',
|
||||||
|
@ -118,7 +148,6 @@ wkhtmltopdf. The texts are defined inside the report classes.
|
||||||
'wizard/partner_balance_wizard_view.xml',
|
'wizard/partner_balance_wizard_view.xml',
|
||||||
'wizard/open_invoices_wizard_view.xml',
|
'wizard/open_invoices_wizard_view.xml',
|
||||||
'report_menus.xml',
|
'report_menus.xml',
|
||||||
# 'wizard/profit_loss_wizard_view.xml',
|
|
||||||
],
|
],
|
||||||
# tests order matter
|
# tests order matter
|
||||||
'test': ['tests/general_ledger.yml',
|
'test': ['tests/general_ledger.yml',
|
||||||
|
@ -129,4 +158,5 @@ wkhtmltopdf. The texts are defined inside the report classes.
|
||||||
#'tests/account_move_line.yml'
|
#'tests/account_move_line.yml'
|
||||||
'active': False,
|
'active': False,
|
||||||
'installable': True,
|
'installable': True,
|
||||||
|
'application': True,
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,18 +28,20 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from osv import osv, fields
|
from openerp.osv import fields, orm
|
||||||
|
|
||||||
|
|
||||||
class AccountAccount(osv.osv):
|
class AccountAccount(orm.Model):
|
||||||
_inherit = 'account.account'
|
_inherit = 'account.account'
|
||||||
|
|
||||||
_columns = {
|
_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.")
|
'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 = {
|
_defaults = {
|
||||||
'centralized': False,
|
'centralized': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountAccount()
|
|
||||||
|
|
|
@ -19,11 +19,11 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from osv import fields, osv
|
from openerp.osv import fields, orm
|
||||||
from tools.translate import _
|
from openerp.tools.translate import _
|
||||||
|
|
||||||
|
|
||||||
class AccountMoveLine(osv.osv):
|
class AccountMoveLine(orm.Model):
|
||||||
"""Overriding Account move line in order to add last_rec_date.
|
"""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"""
|
Last rec date is the date of the last reconciliation (full or partial) account move line"""
|
||||||
_inherit = 'account.move.line'
|
_inherit = 'account.move.line'
|
||||||
|
@ -46,7 +46,6 @@ class AccountMoveLine(osv.osv):
|
||||||
" ORDER BY date DESC LIMIT 1)"
|
" ORDER BY date DESC LIMIT 1)"
|
||||||
" WHERE last_rec_date is null;")
|
" WHERE last_rec_date is null;")
|
||||||
|
|
||||||
|
|
||||||
def _get_move_line_from_line_rec(self, cr, uid, ids, context=None):
|
def _get_move_line_from_line_rec(self, cr, uid, ids, context=None):
|
||||||
moves = []
|
moves = []
|
||||||
for reconcile in self.pool.get('account.move.reconcile').browse(cr, uid, ids, context=context):
|
for reconcile in self.pool.get('account.move.reconcile').browse(cr, uid, ids, context=context):
|
||||||
|
@ -83,7 +82,4 @@ class AccountMoveLine(osv.osv):
|
||||||
type='date',
|
type='date',
|
||||||
multi='all',
|
multi='all',
|
||||||
help="the date of the last reconciliation (full or partial) account move line"),
|
help="the date of the last reconciliation (full or partial) account move line"),
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountMoveLine()
|
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<openerp>
|
|
||||||
<data>
|
|
||||||
<record model="ir.ui.view" id="last_rec_date_form">
|
|
||||||
<!-- must be unique in this module. -->
|
|
||||||
<field name="name">last_rec_date_form</field>
|
|
||||||
<field name="model">account.move.line</field>
|
|
||||||
<!--parent python entity -->
|
|
||||||
<field name="inherit_id" ref="account.view_move_line_form"/>
|
|
||||||
<!-- modulename.view -->
|
|
||||||
<field name="type">form</field>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<separator string="Internal Note" colspan="4" position="before">
|
|
||||||
<separator string="Misc."/>
|
|
||||||
<newline/>
|
|
||||||
<group>
|
|
||||||
<field name="last_rec_date" readonly="1"/>
|
|
||||||
</group>
|
|
||||||
</separator>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</data>
|
|
||||||
</openerp>
|
|
|
@ -5,7 +5,6 @@
|
||||||
<field name="name">account.account.form.webkit</field>
|
<field name="name">account.account.form.webkit</field>
|
||||||
<field name="model">account.account</field>
|
<field name="model">account.account</field>
|
||||||
<field name="inherit_id" ref="account.view_account_form"/>
|
<field name="inherit_id" ref="account.view_account_form"/>
|
||||||
<field name="type">form</field>
|
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<data>
|
<data>
|
||||||
<field name="active" position="after">
|
<field name="active" position="after">
|
||||||
|
|
|
@ -8,4 +8,3 @@ from . import webkit_parser_header_fix
|
||||||
from . import trial_balance
|
from . import trial_balance
|
||||||
from . import partner_balance
|
from . import partner_balance
|
||||||
from . import open_invoices
|
from . import open_invoices
|
||||||
#from . import account_report_profit_loss
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
from operator import add
|
from operator import add
|
||||||
|
|
||||||
from common_reports import CommonReportHeaderWebkit
|
from .common_reports import CommonReportHeaderWebkit
|
||||||
|
|
||||||
|
|
||||||
class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit):
|
class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit):
|
||||||
|
@ -73,12 +73,17 @@ class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit):
|
||||||
'all_fiscalyear': True})
|
'all_fiscalyear': True})
|
||||||
|
|
||||||
if use_period_ids:
|
if use_period_ids:
|
||||||
ctx.update({'periods': period_ids,})
|
ctx.update({'periods': period_ids})
|
||||||
elif main_filter == 'filter_date':
|
elif main_filter == 'filter_date':
|
||||||
ctx.update({'date_from': start,
|
ctx.update({'date_from': start,
|
||||||
'date_to': stop})
|
'date_to': stop})
|
||||||
|
|
||||||
accounts = account_obj.read(self.cursor, self.uid, account_ids, ['type','code','name','debit','credit', 'balance', 'parent_id','level','child_id'], ctx)
|
accounts = account_obj.read(
|
||||||
|
self.cursor,
|
||||||
|
self.uid,
|
||||||
|
account_ids,
|
||||||
|
['type', 'code', 'name', 'debit', 'credit', 'balance', 'parent_id', 'level', 'child_id'],
|
||||||
|
ctx)
|
||||||
|
|
||||||
accounts_by_id = {}
|
accounts_by_id = {}
|
||||||
for account in accounts:
|
for account in accounts:
|
||||||
|
@ -86,7 +91,10 @@ class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit):
|
||||||
# sum for top level views accounts
|
# sum for top level views accounts
|
||||||
child_ids = account_obj._get_children_and_consol(self.cursor, self.uid, account['id'], ctx)
|
child_ids = account_obj._get_children_and_consol(self.cursor, self.uid, account['id'], ctx)
|
||||||
if child_ids:
|
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 ]
|
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)
|
top_init_balance = reduce(add, child_init_balances)
|
||||||
account['init_balance'] = top_init_balance
|
account['init_balance'] = top_init_balance
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from operator import add
|
from operator import add
|
||||||
|
|
||||||
from common_balance_reports import CommonBalanceReportHeaderWebkit
|
from .common_balance_reports import CommonBalanceReportHeaderWebkit
|
||||||
from common_partner_reports import CommonPartnersReportHeaderWebkit
|
from .common_partner_reports import CommonPartnersReportHeaderWebkit
|
||||||
|
|
||||||
|
|
||||||
class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit, CommonPartnersReportHeaderWebkit):
|
class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit, CommonPartnersReportHeaderWebkit):
|
||||||
|
@ -95,21 +95,22 @@ class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit, Co
|
||||||
FROM account_move_line"""
|
FROM account_move_line"""
|
||||||
sql_joins = ''
|
sql_joins = ''
|
||||||
sql_where = "WHERE account_move_line.account_id = %(account_id)s AND account_move_line.state = 'valid' "
|
sql_where = "WHERE account_move_line.account_id = %(account_id)s AND account_move_line.state = 'valid' "
|
||||||
sql_conditions, search_params = getattr(self, '_get_query_params_from_'+filter_from+'s')(start, stop, mode=mode)
|
method = getattr(self, '_get_query_params_from_' + filter_from + 's')
|
||||||
|
sql_conditions, search_params = method(start, stop, mode=mode)
|
||||||
sql_where += sql_conditions
|
sql_where += sql_conditions
|
||||||
|
|
||||||
if partner_filter_ids:
|
if partner_filter_ids:
|
||||||
sql_where += " AND account_move_line.partner_id in %(partner_ids)s"
|
sql_where += " AND account_move_line.partner_id in %(partner_ids)s"
|
||||||
search_params.update({'partner_ids': tuple(partner_filter_ids),})
|
search_params.update({'partner_ids': tuple(partner_filter_ids)})
|
||||||
|
|
||||||
if target_move == 'posted':
|
if target_move == 'posted':
|
||||||
sql_joins += "INNER JOIN account_move ON account_move_line.move_id = account_move.id"
|
sql_joins += "INNER JOIN account_move ON account_move_line.move_id = account_move.id"
|
||||||
sql_where += " AND account_move.state = %(target_move)s"
|
sql_where += " AND account_move.state = %(target_move)s"
|
||||||
search_params.update({'target_move': target_move,})
|
search_params.update({'target_move': target_move})
|
||||||
|
|
||||||
sql_groupby = "GROUP BY account_move_line.partner_id"
|
sql_groupby = "GROUP BY account_move_line.partner_id"
|
||||||
|
|
||||||
search_params.update({'account_id': account_id,})
|
search_params.update({'account_id': account_id})
|
||||||
query = ' '.join((sql_select, sql_joins, sql_where, sql_groupby))
|
query = ' '.join((sql_select, sql_joins, sql_where, sql_groupby))
|
||||||
|
|
||||||
self.cursor.execute(query, search_params)
|
self.cursor.execute(query, search_params)
|
||||||
|
|
|
@ -26,7 +26,7 @@ from collections import defaultdict
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
|
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||||
from common_reports import CommonReportHeaderWebkit
|
from .common_reports import CommonReportHeaderWebkit
|
||||||
|
|
||||||
|
|
||||||
class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
|
class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
|
||||||
|
@ -164,7 +164,8 @@ class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
|
||||||
sql_where = " WHERE account_move_line.account_id = %(account_ids)s " \
|
sql_where = " WHERE account_move_line.account_id = %(account_ids)s " \
|
||||||
" AND account_move_line.state = 'valid' "
|
" AND account_move_line.state = 'valid' "
|
||||||
|
|
||||||
sql_conditions, search_params = getattr(self, '_get_query_params_from_'+filter_from+'s')(start, stop)
|
method = getattr(self, '_get_query_params_from_' + filter_from + 's')
|
||||||
|
sql_conditions, search_params = method(start, stop)
|
||||||
|
|
||||||
sql_where += sql_conditions
|
sql_where += sql_conditions
|
||||||
|
|
||||||
|
@ -178,7 +179,7 @@ class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
|
||||||
if target_move == 'posted':
|
if target_move == 'posted':
|
||||||
sql_joins += "INNER JOIN account_move ON account_move_line.move_id = account_move.id"
|
sql_joins += "INNER JOIN account_move ON account_move_line.move_id = account_move.id"
|
||||||
sql_where += " AND account_move.state = %(target_move)s"
|
sql_where += " AND account_move.state = %(target_move)s"
|
||||||
search_params.update({'target_move': target_move,})
|
search_params.update({'target_move': target_move})
|
||||||
|
|
||||||
search_params.update({
|
search_params.update({
|
||||||
'account_ids': account_id,
|
'account_ids': account_id,
|
||||||
|
@ -247,9 +248,11 @@ class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
|
||||||
|
|
||||||
if not period_ids:
|
if not period_ids:
|
||||||
period_ids = [-1]
|
period_ids = [-1]
|
||||||
search_param = {'date_start': start_period.date_start,
|
search_param = {
|
||||||
|
'date_start': start_period.date_start,
|
||||||
'period_ids': tuple(period_ids),
|
'period_ids': tuple(period_ids),
|
||||||
'account_ids': tuple(account_ids),}
|
'account_ids': tuple(account_ids),
|
||||||
|
}
|
||||||
sql = ("SELECT ml.id, ml.account_id, ml.partner_id "
|
sql = ("SELECT ml.id, ml.account_id, ml.partner_id "
|
||||||
"FROM account_move_line ml "
|
"FROM account_move_line ml "
|
||||||
"INNER JOIN account_account a "
|
"INNER JOIN account_account a "
|
||||||
|
@ -325,4 +328,3 @@ class CommonPartnersReportHeaderWebkit(CommonReportHeaderWebkit):
|
||||||
if not res:
|
if not res:
|
||||||
return []
|
return []
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
|
@ -24,13 +24,13 @@
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from openerp.osv import osv
|
||||||
|
from openerp.tools.translate import _
|
||||||
from openerp.addons.account.report.common_report_header import common_report_header
|
from openerp.addons.account.report.common_report_header import common_report_header
|
||||||
from osv import osv
|
|
||||||
from tools.translate import _
|
|
||||||
|
|
||||||
|
|
||||||
_logger = logging.getLogger('financial.reports.webkit')
|
_logger = logging.getLogger('financial.reports.webkit')
|
||||||
|
|
||||||
|
|
||||||
class CommonReportHeaderWebkit(common_report_header):
|
class CommonReportHeaderWebkit(common_report_header):
|
||||||
"""Define common helper for financial report"""
|
"""Define common helper for financial report"""
|
||||||
|
|
||||||
|
@ -109,8 +109,6 @@ class CommonReportHeaderWebkit(common_report_header):
|
||||||
def _get_form_param(self, param, data, default=False):
|
def _get_form_param(self, param, data, default=False):
|
||||||
return data.get('form', {}).get(param, default)
|
return data.get('form', {}).get(param, default)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
####################Account and account line filter helper #################
|
####################Account and account line filter helper #################
|
||||||
|
|
||||||
def sort_accounts_with_structure(self, root_account_ids, account_ids, context=None):
|
def sort_accounts_with_structure(self, root_account_ids, account_ids, context=None):
|
||||||
|
@ -501,7 +499,7 @@ WHERE move_id in %s"""
|
||||||
try:
|
try:
|
||||||
self.cursor.execute(sql, (account_id, limit, tuple(move_ids)))
|
self.cursor.execute(sql, (account_id, limit, tuple(move_ids)))
|
||||||
res = self.cursor.fetchall()
|
res = self.cursor.fetchall()
|
||||||
except Exception, exc:
|
except Exception as exc:
|
||||||
self.cursor.rollback()
|
self.cursor.rollback()
|
||||||
raise
|
raise
|
||||||
return res and dict(res) or {}
|
return res and dict(res) or {}
|
||||||
|
|
|
@ -19,15 +19,16 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from report import report_sxw
|
|
||||||
from tools.translate import _
|
|
||||||
import pooler
|
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from common_reports import CommonReportHeaderWebkit
|
from openerp.report import report_sxw
|
||||||
from webkit_parser_header_fix import HeaderFooterTextWebKitParser
|
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):
|
class GeneralLedgerWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
import pooler
|
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from report import report_sxw
|
from report import report_sxw
|
||||||
|
@ -27,21 +26,23 @@ from itertools import groupby
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from mako.template import Template
|
from mako.template import Template
|
||||||
|
|
||||||
from tools.translate import _
|
|
||||||
|
|
||||||
|
import openerp.addons
|
||||||
|
from openerp import pooler
|
||||||
from openerp.osv import osv
|
from openerp.osv import osv
|
||||||
from common_partner_reports import CommonPartnersReportHeaderWebkit
|
from openerp.tools.translate import _
|
||||||
from webkit_parser_header_fix import HeaderFooterTextWebKitParser
|
|
||||||
from openerp.addons.report_webkit import report_helper
|
from openerp.addons.report_webkit import report_helper
|
||||||
import addons
|
from .common_partner_reports import CommonPartnersReportHeaderWebkit
|
||||||
|
from .webkit_parser_header_fix import HeaderFooterTextWebKitParser
|
||||||
|
|
||||||
|
|
||||||
def get_mako_template(obj, *args):
|
def get_mako_template(obj, *args):
|
||||||
template_path = addons.get_module_resource(*args)
|
template_path = openerp.addons.get_module_resource(*args)
|
||||||
return Template(filename=template_path, input_encoding='utf-8')
|
return Template(filename=template_path, input_encoding='utf-8')
|
||||||
|
|
||||||
report_helper.WebKitHelper.get_mako_template = get_mako_template
|
report_helper.WebKitHelper.get_mako_template = get_mako_template
|
||||||
|
|
||||||
|
|
||||||
class PartnersOpenInvoicesWebkit(report_sxw.rml_parse, CommonPartnersReportHeaderWebkit):
|
class PartnersOpenInvoicesWebkit(report_sxw.rml_parse, CommonPartnersReportHeaderWebkit):
|
||||||
|
|
||||||
def __init__(self, cursor, uid, name, context):
|
def __init__(self, cursor, uid, name, context):
|
||||||
|
@ -77,7 +78,6 @@ class PartnersOpenInvoicesWebkit(report_sxw.rml_parse, CommonPartnersReportHeade
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
def _group_lines_by_currency(self, account_br):
|
def _group_lines_by_currency(self, account_br):
|
||||||
account_br.grouped_ledger_lines = {}
|
account_br.grouped_ledger_lines = {}
|
||||||
if not account_br.ledger_lines:
|
if not account_br.ledger_lines:
|
||||||
|
|
|
@ -20,13 +20,13 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
|
||||||
from report import report_sxw
|
|
||||||
from tools.translate import _
|
|
||||||
import pooler
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from common_partner_balance_reports import CommonPartnerBalanceReportHeaderWebkit
|
from openerp import pooler
|
||||||
from webkit_parser_header_fix import HeaderFooterTextWebKitParser
|
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):
|
class PartnerBalanceWebkit(report_sxw.rml_parse, CommonPartnerBalanceReportHeaderWebkit):
|
||||||
|
|
|
@ -18,16 +18,16 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
import pooler
|
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from report import report_sxw
|
|
||||||
from osv import osv
|
|
||||||
from tools.translate import _
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from common_partner_reports import CommonPartnersReportHeaderWebkit
|
from openerp import pooler
|
||||||
from webkit_parser_header_fix import HeaderFooterTextWebKitParser
|
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):
|
class PartnersLedgerWebkit(report_sxw.rml_parse, CommonPartnersReportHeaderWebkit):
|
||||||
|
|
|
@ -1,115 +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/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
import pooler
|
|
||||||
|
|
||||||
from report import report_sxw
|
|
||||||
from tools.translate import _
|
|
||||||
from datetime import datetime
|
|
||||||
from common_balance_reports import CommonBalanceReportHeaderWebkit
|
|
||||||
from webkit_parser_header_fix import HeaderFooterTextWebKitParser
|
|
||||||
|
|
||||||
|
|
||||||
class ProfitLossWebkit(report_sxw.rml_parse, CommonBalanceReportHeaderWebkit):
|
|
||||||
|
|
||||||
def __init__(self, cursor, uid, name, context):
|
|
||||||
super(ProfitLossWebkit, 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((_('PROFIT AND LOSS'), 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': _('Profit and Loss'),
|
|
||||||
'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,
|
|
||||||
'numbers_display': self._get_numbers_display,
|
|
||||||
'level_print': self._get_level_print,
|
|
||||||
'level_bold': self._get_level_bold,
|
|
||||||
'level_italic': self._get_level_italic,
|
|
||||||
'level_size': self._get_level_size,
|
|
||||||
'level_underline': self._get_level_underline,
|
|
||||||
'level_uppercase': self._get_level_uppercase,
|
|
||||||
'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_level_print(self, data, level):
|
|
||||||
return self._get_form_param("level%s_print" % (level,), data)
|
|
||||||
|
|
||||||
def _get_level_bold(self, data, level):
|
|
||||||
return self._get_form_param("level%s_bold" % (level,), data)
|
|
||||||
|
|
||||||
def _get_level_italic(self, data, level):
|
|
||||||
return self._get_form_param("level%s_italic" % (level,), data)
|
|
||||||
|
|
||||||
def _get_level_size(self, data, level):
|
|
||||||
return self._get_form_param("level%s_size" % (level,), data)
|
|
||||||
|
|
||||||
def _get_level_underline(self, data, level):
|
|
||||||
return self._get_form_param("level%s_underline" % (level,), data)
|
|
||||||
|
|
||||||
def _get_level_uppercase(self, data, level):
|
|
||||||
return self._get_form_param("level%s_uppercase" % (level,), data)
|
|
||||||
|
|
||||||
def _update_levels(self, objects):
|
|
||||||
# start leveling from 0
|
|
||||||
levels = [account['current']['level'] for account in objects]
|
|
||||||
min_level = min(levels)
|
|
||||||
|
|
||||||
for account in objects:
|
|
||||||
account['current']['level'] -= min_level
|
|
||||||
return objects
|
|
||||||
|
|
||||||
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, filter_report_type=['expense', 'income'])
|
|
||||||
|
|
||||||
objects = self._update_levels(objects)
|
|
||||||
|
|
||||||
self.localcontext.update(context_report_values)
|
|
||||||
|
|
||||||
return super(ProfitLossWebkit, self).set_context(objects, data, new_ids,
|
|
||||||
report_type=report_type)
|
|
||||||
|
|
||||||
HeaderFooterTextWebKitParser('report.account.account_report_profit_loss_webkit',
|
|
||||||
'account.account',
|
|
||||||
'addons/account_financial_report_webkit/report/templates/account_report_profit_loss.mako',
|
|
||||||
parser=ProfitLossWebkit)
|
|
|
@ -111,19 +111,5 @@
|
||||||
<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"/>
|
<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>
|
||||||
|
|
||||||
<!--<record id="account_report_profit_loss_webkit" model="ir.actions.report.xml">-->
|
|
||||||
<!--<field name="report_type">webkit</field>-->
|
|
||||||
<!--<field name="report_name">account.account_report_profit_loss_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">Profit and Loss Webkit</field>-->
|
|
||||||
<!--<field name="report_rml">account_financial_report_webkit/report/templates/account_report_profit_loss.mako</field>-->
|
|
||||||
<!--<field name="report_file">account_financial_report_webkit/report/templates/account_report_profit_loss.mako</field>-->
|
|
||||||
<!--<field name="webkit_header" ref="financial_portrait_header"/>-->
|
|
||||||
<!--</record>-->
|
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
return text.replace('-', '‑') # replace by a non-breaking hyphen (it will not word-wrap between hyphen and numbers)
|
return text.replace('-', '‑') # replace by a non-breaking hyphen (it will not word-wrap between hyphen and numbers)
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<%setLang(user.context_lang)%>
|
<%setLang(user.lang)%>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
initial_balance_text = {'initial_balance': _('Computed'), 'opening_balance': _('Opening Entries'), False: _('No')}
|
initial_balance_text = {'initial_balance': _('Computed'), 'opening_balance': _('Opening Entries'), False: _('No')}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
<% context.lookup.put_template('open_invoices_inclusion.mako.html', template1) %>
|
<% 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') %>
|
<% 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) %>
|
<% context.lookup.put_template('grouped_by_curr_open_invoices_inclusion.mako.html', template2) %>
|
||||||
<%setLang(user.context_lang)%>
|
<%setLang(user.lang)%>
|
||||||
|
|
||||||
<div class="act_as_table data_table">
|
<div class="act_as_table data_table">
|
||||||
<div class="act_as_row labels">
|
<div class="act_as_row labels">
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
return any([line.get('balance') for line in all_comparison_lines])
|
return any([line.get('balance') for line in all_comparison_lines])
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<%setLang(user.context_lang)%>
|
<%setLang(user.lang)%>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
initial_balance_text = {'initial_balance': _('Computed'), 'opening_balance': _('Opening Entries'), False: _('No')}
|
initial_balance_text = {'initial_balance': _('Computed'), 'opening_balance': _('Opening Entries'), False: _('No')}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
return text.replace('-', '‑') # replace by a non-breaking hyphen (it will not word-wrap between hyphen and numbers)
|
return text.replace('-', '‑') # replace by a non-breaking hyphen (it will not word-wrap between hyphen and numbers)
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<%setLang(user.context_lang)%>
|
<%setLang(user.lang)%>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
initial_balance_text = {'initial_balance': _('Computed'), 'opening_balance': _('Opening Entries'), False: _('No')}
|
initial_balance_text = {'initial_balance': _('Computed'), 'opening_balance': _('Opening Entries'), False: _('No')}
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
${output}
|
${output}
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%setLang(user.context_lang)%>
|
<%setLang(user.lang)%>
|
||||||
|
|
||||||
<div class="act_as_table data_table">
|
<div class="act_as_table data_table">
|
||||||
<div class="act_as_row labels">
|
<div class="act_as_row labels">
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
return text.replace('-', '‑') # replace by a non-breaking hyphen (it will not word-wrap between hyphen and numbers)
|
return text.replace('-', '‑') # replace by a non-breaking hyphen (it will not word-wrap between hyphen and numbers)
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<%setLang(user.context_lang)%>
|
<%setLang(user.lang)%>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
initial_balance_text = {'initial_balance': _('Computed'), 'opening_balance': _('Opening Entries'), False: _('No')}
|
initial_balance_text = {'initial_balance': _('Computed'), 'opening_balance': _('Opening Entries'), False: _('No')}
|
||||||
|
|
|
@ -20,17 +20,19 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
|
||||||
from report import report_sxw
|
|
||||||
from tools.translate import _
|
|
||||||
import pooler
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from common_balance_reports import CommonBalanceReportHeaderWebkit
|
from openerp import pooler
|
||||||
from webkit_parser_header_fix import HeaderFooterTextWebKitParser
|
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):
|
def sign(number):
|
||||||
return cmp(number, 0)
|
return cmp(number, 0)
|
||||||
|
|
||||||
|
|
||||||
class TrialBalanceWebkit(report_sxw.rml_parse, CommonBalanceReportHeaderWebkit):
|
class TrialBalanceWebkit(report_sxw.rml_parse, CommonBalanceReportHeaderWebkit):
|
||||||
|
|
||||||
def __init__(self, cursor, uid, name, context):
|
def __init__(self, cursor, uid, name, context):
|
||||||
|
|
|
@ -34,12 +34,12 @@ import time
|
||||||
import pooler
|
import pooler
|
||||||
import tools
|
import tools
|
||||||
import logging
|
import logging
|
||||||
import openerp.addons
|
|
||||||
|
|
||||||
|
|
||||||
from mako import exceptions
|
from mako import exceptions
|
||||||
from osv.osv import except_osv
|
from openerp.osv.osv import except_osv
|
||||||
from tools.translate import _
|
from openerp.tools.translate import _
|
||||||
|
from openerp import addons
|
||||||
from openerp.addons.report_webkit import webkit_report
|
from openerp.addons.report_webkit import webkit_report
|
||||||
from openerp.addons.report_webkit.webkit_report import mako_template
|
from openerp.addons.report_webkit.webkit_report import mako_template
|
||||||
from openerp.addons.report_webkit.report_helper import WebKitHelper
|
from openerp.addons.report_webkit.report_helper import WebKitHelper
|
||||||
|
@ -79,7 +79,6 @@ class HeaderFooterTextWebKitParser(webkit_report.WebKitParser):
|
||||||
webkit_header = report_xml.webkit_header
|
webkit_header = report_xml.webkit_header
|
||||||
tmp_dir = tempfile.gettempdir()
|
tmp_dir = tempfile.gettempdir()
|
||||||
out_filename = tempfile.mktemp(suffix=".pdf", prefix="webkit.tmp.")
|
out_filename = tempfile.mktemp(suffix=".pdf", prefix="webkit.tmp.")
|
||||||
files = []
|
|
||||||
file_to_del = [out_filename]
|
file_to_del = [out_filename]
|
||||||
if comm_path:
|
if comm_path:
|
||||||
command = [comm_path]
|
command = [comm_path]
|
||||||
|
@ -120,8 +119,8 @@ class HeaderFooterTextWebKitParser(webkit_report.WebKitParser):
|
||||||
file_to_del.append(stderr_path)
|
file_to_del.append(stderr_path)
|
||||||
try:
|
try:
|
||||||
status = subprocess.call(command, stderr=stderr_fd)
|
status = subprocess.call(command, stderr=stderr_fd)
|
||||||
os.close(stderr_fd) # force flush
|
os.close(stderr_fd) # ensure flush before reading
|
||||||
stderr_fd = None # avoid closing again in finally
|
stderr_fd = None # avoid closing again in finally block
|
||||||
fobj = open(stderr_path, 'r')
|
fobj = open(stderr_path, 'r')
|
||||||
error_message = fobj.read()
|
error_message = fobj.read()
|
||||||
fobj.close()
|
fobj.close()
|
||||||
|
@ -167,7 +166,7 @@ class HeaderFooterTextWebKitParser(webkit_report.WebKitParser):
|
||||||
template = False
|
template = False
|
||||||
|
|
||||||
if report_xml.report_file:
|
if report_xml.report_file:
|
||||||
path =openerp.addons.get_module_resource(report_xml.report_file)
|
path = addons.get_module_resource(*report_xml.report_file.split(os.path.sep))
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
template = file(path).read()
|
template = file(path).read()
|
||||||
if not template and report_xml.report_webkit_data:
|
if not template and report_xml.report_webkit_data:
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
|
@ -24,4 +24,3 @@ from . import partners_ledger_wizard
|
||||||
from . import trial_balance_wizard
|
from . import trial_balance_wizard
|
||||||
from . import partner_balance_wizard
|
from . import partner_balance_wizard
|
||||||
from . import open_invoices_wizard
|
from . import open_invoices_wizard
|
||||||
#from . import account_report_profit_loss_wizard
|
|
||||||
|
|
|
@ -30,10 +30,11 @@
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from osv import fields, osv
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
from tools.translate import _
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from openerp.osv import fields, orm
|
||||||
|
from openerp.tools.translate import _
|
||||||
|
|
||||||
|
|
||||||
def previous_year_date(date, nb_prev=1):
|
def previous_year_date(date, nb_prev=1):
|
||||||
if not date:
|
if not date:
|
||||||
|
@ -44,7 +45,8 @@ def previous_year_date(date, nb_prev=1):
|
||||||
day=parsed_date.day)
|
day=parsed_date.day)
|
||||||
return previous_date
|
return previous_date
|
||||||
|
|
||||||
class AccountBalanceCommonWizard(osv.osv_memory):
|
|
||||||
|
class AccountBalanceCommonWizard(orm.TransientModel):
|
||||||
"""Will launch trial balance report and pass required args"""
|
"""Will launch trial balance report and pass required args"""
|
||||||
|
|
||||||
_inherit = "account.common.account.report"
|
_inherit = "account.common.account.report"
|
||||||
|
@ -63,7 +65,7 @@ class AccountBalanceCommonWizard(osv.osv_memory):
|
||||||
|
|
||||||
M2O_DYNAMIC_FIELDS = [f % index for f in ["comp%s_fiscalyear_id",
|
M2O_DYNAMIC_FIELDS = [f % index for f in ["comp%s_fiscalyear_id",
|
||||||
"comp%s_period_from",
|
"comp%s_period_from",
|
||||||
"comp%s_period_to",]
|
"comp%s_period_to"]
|
||||||
for index in range(COMPARISON_LEVEL)]
|
for index in range(COMPARISON_LEVEL)]
|
||||||
SIMPLE_DYNAMIC_FIELDS = [f % index for f in ["comp%s_filter",
|
SIMPLE_DYNAMIC_FIELDS = [f % index for f in ["comp%s_filter",
|
||||||
"comp%s_date_from",
|
"comp%s_date_from",
|
||||||
|
@ -83,17 +85,21 @@ class AccountBalanceCommonWizard(osv.osv_memory):
|
||||||
'filter': fields.selection([('filter_no', 'No Filters'),
|
'filter': fields.selection([('filter_no', 'No Filters'),
|
||||||
('filter_date', 'Date'),
|
('filter_date', 'Date'),
|
||||||
('filter_period', 'Periods'),
|
('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 calculated based on period to be correct).'),
|
('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):
|
for index in range(COMPARISON_LEVEL):
|
||||||
_columns.update(
|
_columns.update(
|
||||||
{"comp%s_filter" % (index,): fields.selection(COMPARE_SELECTION, string='Compare By', required=True),
|
{"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_fiscalyear_id" % index: fields.many2one('account.fiscalyear', 'Fiscal Year'),
|
||||||
"comp%s_period_from" % (index,): fields.many2one('account.period', 'Start Period'),
|
"comp%s_period_from" % index: fields.many2one('account.period', 'Start Period'),
|
||||||
"comp%s_period_to" % (index,): fields.many2one('account.period', 'End Period'),
|
"comp%s_period_to" % index: fields.many2one('account.period', 'End Period'),
|
||||||
"comp%s_date_from" % (index,): fields.date("Start Date"),
|
"comp%s_date_from" % index: fields.date("Start Date"),
|
||||||
"comp%s_date_to" % (index,): fields.date("End Date"),})
|
"comp%s_date_to" % index: fields.date("End Date")})
|
||||||
|
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'account_ids': _get_account_ids,
|
'account_ids': _get_account_ids,
|
||||||
|
@ -141,27 +147,62 @@ class AccountBalanceCommonWizard(osv.osv_memory):
|
||||||
if placeholder:
|
if placeholder:
|
||||||
placeholder = placeholder[0]
|
placeholder = placeholder[0]
|
||||||
for index in range(self.COMPARISON_LEVEL):
|
for index in range(self.COMPARISON_LEVEL):
|
||||||
page = etree.Element('page', {'name': "comp%s" % (index,), 'string': _("Comparison %s") % (index+1,)})
|
page = etree.Element(
|
||||||
page.append(etree.Element('field', {'name': "comp%s_filter" % (index,),
|
'page',
|
||||||
'colspan': '4',
|
{'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}}))
|
'on_change': "onchange_comp_filter(%(index)s, filter, comp%(index)s_filter, fiscalyear_id, date_from, date_to)" % {'index': index}}))
|
||||||
page.append(etree.Element('field', {'name': "comp%s_fiscalyear_id" % (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',
|
'colspan': '4',
|
||||||
'attrs': "{'required': [('comp%(index)s_filter','in',('filter_year','filter_opening'))], 'readonly':[('comp%(index)s_filter','not in',('filter_year','filter_opening'))]}" % {'index': index}}))
|
'attrs': dates_attrs}))
|
||||||
page.append(etree.Element('separator', {'string': _('Dates'), 'colspan':'4'}))
|
modifiers_and_append(etree.Element(
|
||||||
page.append(etree.Element('field', {'name': "comp%s_date_from" % (index,), 'colspan':'4',
|
'field',
|
||||||
'attrs': "{'required': [('comp%(index)s_filter','=','filter_date')], 'readonly':[('comp%(index)s_filter','!=','filter_date')]}" % {'index': index}}))
|
{'name': "comp%s_date_from" % index,
|
||||||
page.append(etree.Element('field', {'name': "comp%s_date_to" % (index,), 'colspan':'4',
|
'attrs': dates_attrs}))
|
||||||
'attrs': "{'required': [('comp%(index)s_filter','=','filter_date')], 'readonly':[('comp%(index)s_filter','!=','filter_date')]}" % {'index': index}}))
|
modifiers_and_append(etree.Element(
|
||||||
page.append(etree.Element('separator', {'string': _('Periods'), 'colspan':'4'}))
|
'field',
|
||||||
page.append(etree.Element('field', {'name': "comp%s_period_from" % (index,),
|
{'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',
|
'colspan': '4',
|
||||||
'attrs': "{'required': [('comp%(index)s_filter','=','filter_period')], 'readonly':[('comp%(index)s_filter','!=','filter_period')]}" % {'index': index},
|
'attrs': periods_attrs}))
|
||||||
'domain': "[('special', '=', False)]"}))
|
modifiers_and_append(etree.Element(
|
||||||
page.append(etree.Element('field', {'name': "comp%s_period_to" % (index,),
|
'field',
|
||||||
'colspan': '4',
|
{'name': "comp%s_period_from" % index,
|
||||||
'attrs': "{'required': [('comp%(index)s_filter','=','filter_period')], 'readonly':[('comp%(index)s_filter','!=','filter_period')]}" % {'index': index},
|
'attrs': periods_attrs,
|
||||||
'domain': "[('special', '=', False)]"}))
|
'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.addprevious(page)
|
||||||
placeholder.getparent().remove(placeholder)
|
placeholder.getparent().remove(placeholder)
|
||||||
|
@ -226,15 +267,28 @@ class AccountBalanceCommonWizard(osv.osv_memory):
|
||||||
date_to_field = "comp%s_date_to" % (index,)
|
date_to_field = "comp%s_date_to" % (index,)
|
||||||
|
|
||||||
if comp_filter == 'filter_no':
|
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}
|
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'):
|
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}
|
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':
|
if comp_filter == 'filter_date':
|
||||||
dates = {}
|
dates = {}
|
||||||
if main_filter == 'filter_date':
|
if main_filter == 'filter_date':
|
||||||
dates = {
|
dates = {
|
||||||
'date_start': previous_year_date(start_date, index + 1).strftime('%Y-%m-%d'),
|
'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'),}
|
'date_stop': previous_year_date(stop_date, index + 1).strftime('%Y-%m-%d'),
|
||||||
|
}
|
||||||
elif last_fiscalyear_id:
|
elif last_fiscalyear_id:
|
||||||
dates = fy_obj.read(cr, uid, last_fiscalyear_id, ['date_start', 'date_stop'], context=context)
|
dates = fy_obj.read(cr, uid, last_fiscalyear_id, ['date_start', 'date_stop'], context=context)
|
||||||
|
|
||||||
|
@ -291,5 +345,3 @@ class AccountBalanceCommonWizard(osv.osv_memory):
|
||||||
vals['max_comparison'] = self.COMPARISON_LEVEL
|
vals['max_comparison'] = self.COMPARISON_LEVEL
|
||||||
data['form'].update(vals)
|
data['form'].update(vals)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
AccountBalanceCommonWizard()
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
<!-- inheriting views from more than 2 differents inherited models like
|
<!-- inheriting views from more than 2 differents inherited models like
|
||||||
trial.balance.webkit -> account.common.balance.report -> account.common.account.report
|
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, profit & loss
|
is not supported so we have to copy paste the same view for trial balance, balance sheet
|
||||||
-->
|
-->
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
|
|
|
@ -21,12 +21,11 @@
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from osv import fields, osv
|
from openerp.osv import fields, orm
|
||||||
|
|
||||||
|
|
||||||
class AccountReportGeneralLedgerWizard(osv.osv_memory):
|
class AccountReportGeneralLedgerWizard(orm.TransientModel):
|
||||||
"""Will launch general ledger report and pass requiered args"""
|
"""Will launch general ledger report and pass required args"""
|
||||||
|
|
||||||
|
|
||||||
_inherit = "account.common.account.report"
|
_inherit = "account.common.account.report"
|
||||||
_name = "general.ledger.webkit"
|
_name = "general.ledger.webkit"
|
||||||
|
@ -69,8 +68,6 @@ class AccountReportGeneralLedgerWizard(osv.osv_memory):
|
||||||
|
|
||||||
def pre_print_report(self, cr, uid, ids, data, context=None):
|
def pre_print_report(self, cr, uid, ids, data, context=None):
|
||||||
data = super(AccountReportGeneralLedgerWizard, self).pre_print_report(cr, uid, ids, data, context)
|
data = super(AccountReportGeneralLedgerWizard, 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
|
# will be used to attach the report on the main account
|
||||||
data['ids'] = [data['form']['chart_account_id']]
|
data['ids'] = [data['form']['chart_account_id']]
|
||||||
vals = self.read(cr, uid, ids,
|
vals = self.read(cr, uid, ids,
|
||||||
|
@ -85,7 +82,12 @@ class AccountReportGeneralLedgerWizard(osv.osv_memory):
|
||||||
def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None):
|
def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None):
|
||||||
res = {}
|
res = {}
|
||||||
if filter == 'filter_no':
|
if filter == 'filter_no':
|
||||||
res['value'] = {'period_from': False, 'period_to': False, 'date_from': False ,'date_to': False}
|
res['value'] = {
|
||||||
|
'period_from': False,
|
||||||
|
'period_to': False,
|
||||||
|
'date_from': False,
|
||||||
|
'date_to': False,
|
||||||
|
}
|
||||||
if filter == 'filter_date':
|
if filter == 'filter_date':
|
||||||
if fiscalyear_id:
|
if fiscalyear_id:
|
||||||
fyear = self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id, context=context)
|
fyear = self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id, context=context)
|
||||||
|
@ -93,7 +95,12 @@ class AccountReportGeneralLedgerWizard(osv.osv_memory):
|
||||||
date_to = fyear.date_stop > time.strftime('%Y-%m-%d') and time.strftime('%Y-%m-%d') or fyear.date_stop
|
date_to = fyear.date_stop > time.strftime('%Y-%m-%d') and time.strftime('%Y-%m-%d') or fyear.date_stop
|
||||||
else:
|
else:
|
||||||
date_from, date_to = time.strftime('%Y-01-01'), time.strftime('%Y-%m-%d')
|
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}
|
res['value'] = {
|
||||||
|
'period_from': False,
|
||||||
|
'period_to': False,
|
||||||
|
'date_from': date_from,
|
||||||
|
'date_to': date_to
|
||||||
|
}
|
||||||
if filter == 'filter_period' and fiscalyear_id:
|
if filter == 'filter_period' and fiscalyear_id:
|
||||||
start_period = end_period = False
|
start_period = end_period = False
|
||||||
cr.execute('''
|
cr.execute('''
|
||||||
|
@ -122,11 +129,8 @@ class AccountReportGeneralLedgerWizard(osv.osv_memory):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _print_report(self, cursor, uid, ids, data, context=None):
|
def _print_report(self, cursor, uid, ids, data, context=None):
|
||||||
context = context or {}
|
|
||||||
# we update form with display account value
|
# we update form with display account value
|
||||||
data = self.pre_print_report(cursor, uid, ids, data, context=context)
|
data = self.pre_print_report(cursor, uid, ids, data, context=context)
|
||||||
return {'type': 'ir.actions.report.xml',
|
return {'type': 'ir.actions.report.xml',
|
||||||
'report_name': 'account.account_report_general_ledger_webkit',
|
'report_name': 'account.account_report_general_ledger_webkit',
|
||||||
'datas': data}
|
'datas': data}
|
||||||
|
|
||||||
AccountReportGeneralLedgerWizard()
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
<record id="account_report_general_ledger_view_webkit" model="ir.ui.view">
|
<record id="account_report_general_ledger_view_webkit" model="ir.ui.view">
|
||||||
<field name="name">General Ledger</field>
|
<field name="name">General Ledger</field>
|
||||||
<field name="model">general.ledger.webkit</field>
|
<field name="model">general.ledger.webkit</field>
|
||||||
<field name="type">form</field>
|
|
||||||
<field name="inherit_id" ref="account.account_common_report_view"/>
|
<field name="inherit_id" ref="account.account_common_report_view"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<data>
|
<data>
|
||||||
|
@ -32,8 +31,10 @@
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
<page string="Layout Options" name="layout_options">
|
<page string="Layout Options" name="layout_options">
|
||||||
|
<group colspan="4" col="2">
|
||||||
<field name="amount_currency"/>
|
<field name="amount_currency"/>
|
||||||
<field name="centralize"/>
|
<field name="centralize"/>
|
||||||
|
</group>
|
||||||
</page>
|
</page>
|
||||||
</page>
|
</page>
|
||||||
<page name="journal_ids" position="attributes">
|
<page name="journal_ids" position="attributes">
|
||||||
|
@ -55,7 +56,6 @@
|
||||||
<record id="account_report_general_ledger_view_inherit" model="ir.ui.view">
|
<record id="account_report_general_ledger_view_inherit" model="ir.ui.view">
|
||||||
<field name="name">General Ledger</field>
|
<field name="name">General Ledger</field>
|
||||||
<field name="model">general.ledger.webkit</field>
|
<field name="model">general.ledger.webkit</field>
|
||||||
<field name="type">form</field>
|
|
||||||
<field name="inherit_id" ref="account.account_report_general_ledger_view"/>
|
<field name="inherit_id" ref="account.account_report_general_ledger_view"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="fiscalyear_id" position="replace">
|
<field name="fiscalyear_id" position="replace">
|
||||||
|
|
|
@ -18,10 +18,10 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
from osv import fields, osv
|
from openerp.osv import fields, orm
|
||||||
|
|
||||||
|
|
||||||
class AccountReportOpenInvoicesWizard(osv.osv_memory):
|
class AccountReportOpenInvoicesWizard(orm.TransientModel):
|
||||||
"""Will launch partner ledger report and pass required args"""
|
"""Will launch partner ledger report and pass required args"""
|
||||||
|
|
||||||
_inherit = "partners.ledger.webkit"
|
_inherit = "partners.ledger.webkit"
|
||||||
|
@ -57,38 +57,38 @@ By amending the clearance date, you will be, for instance, able to answer the qu
|
||||||
(_check_until_date, 'Clearance date must be the very last date of the last period or later.', ['until_date']),
|
(_check_until_date, 'Clearance date must be the very last date of the last period or later.', ['until_date']),
|
||||||
]
|
]
|
||||||
|
|
||||||
def default_until_date(self, cursor, uid, ids, fiscalyear_id=False, period_id=False, date_to=False, context=None):
|
def default_until_date(self, cr, uid, ids, fiscalyear_id=False, period_id=False, date_to=False, context=None):
|
||||||
res_date = False
|
res_date = False
|
||||||
# first priority: period or date filters
|
# first priority: period or date filters
|
||||||
if period_id:
|
if period_id:
|
||||||
res_date = self.pool.get('account.period').read(cursor, uid, period_id, ['date_stop'], context=context)['date_stop']
|
res_date = self.pool.get('account.period').read(cr, uid, period_id, ['date_stop'], context=context)['date_stop']
|
||||||
elif date_to:
|
elif date_to:
|
||||||
res_date = date_to
|
res_date = date_to
|
||||||
elif fiscalyear_id:
|
elif fiscalyear_id:
|
||||||
res_date = self.pool.get('account.fiscalyear').read(cursor, uid, fiscalyear_id, ['date_stop'], context=context)['date_stop']
|
res_date = self.pool.get('account.fiscalyear').read(cr, uid, fiscalyear_id, ['date_stop'], context=context)['date_stop']
|
||||||
return res_date
|
return res_date
|
||||||
|
|
||||||
def onchange_fiscalyear(self, cursor, uid, ids, fiscalyear=False, period_id=False, date_to=False, until_date=False, context=None):
|
def onchange_fiscalyear(self, cr, uid, ids, fiscalyear=False, period_id=False, date_to=False, until_date=False, context=None):
|
||||||
res = {'value': {}}
|
res = {'value': {}}
|
||||||
res['value']['until_date'] = self.default_until_date(cursor, uid, ids,
|
res['value']['until_date'] = self.default_until_date(cr, uid, ids,
|
||||||
fiscalyear_id=fiscalyear,
|
fiscalyear_id=fiscalyear,
|
||||||
period_id=period_id,
|
period_id=period_id,
|
||||||
date_to=date_to,
|
date_to=date_to,
|
||||||
context=context)
|
context=context)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def onchange_date_to(self, cursor, uid, ids, fiscalyear=False, period_id=False, date_to=False, until_date=False, context=None):
|
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': {}}
|
||||||
res['value']['until_date'] = self.default_until_date(cursor, uid, ids,
|
res['value']['until_date'] = self.default_until_date(cr, uid, ids,
|
||||||
fiscalyear_id=fiscalyear,
|
fiscalyear_id=fiscalyear,
|
||||||
period_id=period_id,
|
period_id=period_id,
|
||||||
date_to=date_to,
|
date_to=date_to,
|
||||||
context=context)
|
context=context)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def onchange_period_to(self, cursor, uid, ids, fiscalyear=False, period_id=False, date_to=False, until_date=False, context=None):
|
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': {}}
|
||||||
res['value']['until_date'] = self.default_until_date(cursor, uid, ids,
|
res['value']['until_date'] = self.default_until_date(cr, uid, ids,
|
||||||
fiscalyear_id=fiscalyear,
|
fiscalyear_id=fiscalyear,
|
||||||
period_id=period_id,
|
period_id=period_id,
|
||||||
date_to=date_to,
|
date_to=date_to,
|
||||||
|
@ -107,20 +107,15 @@ By amending the clearance date, you will be, for instance, able to answer the qu
|
||||||
|
|
||||||
def pre_print_report(self, cr, uid, ids, data, context=None):
|
def pre_print_report(self, cr, uid, ids, data, context=None):
|
||||||
data = super(AccountReportOpenInvoicesWizard, self).pre_print_report(cr, uid, ids, data, context)
|
data = super(AccountReportOpenInvoicesWizard, self).pre_print_report(cr, uid, ids, data, context)
|
||||||
if context is None:
|
|
||||||
context = {}
|
|
||||||
vals = self.read(cr, uid, ids,
|
vals = self.read(cr, uid, ids,
|
||||||
['until_date', 'group_by_currency'],
|
['until_date', 'group_by_currency'],
|
||||||
context=context)[0]
|
context=context)[0]
|
||||||
data['form'].update(vals)
|
data['form'].update(vals)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _print_report(self, cursor, uid, ids, data, context=None):
|
def _print_report(self, cr, uid, ids, data, context=None):
|
||||||
context = context or {}
|
|
||||||
# we update form with display account value
|
# we update form with display account value
|
||||||
data = self.pre_print_report(cursor, uid, ids, data, context=context)
|
data = self.pre_print_report(cr, uid, ids, data, context=context)
|
||||||
return {'type': 'ir.actions.report.xml',
|
return {'type': 'ir.actions.report.xml',
|
||||||
'report_name': 'account.account_report_open_invoices_webkit',
|
'report_name': 'account.account_report_open_invoices_webkit',
|
||||||
'datas': data}
|
'datas': data}
|
||||||
|
|
||||||
AccountReportOpenInvoicesWizard()
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
<record id="account_open_invoices_view_webkit" model="ir.ui.view">
|
<record id="account_open_invoices_view_webkit" model="ir.ui.view">
|
||||||
<field name="name">Open Invoices Report</field>
|
<field name="name">Open Invoices Report</field>
|
||||||
<field name="model">open.invoices.webkit</field>
|
<field name="model">open.invoices.webkit</field>
|
||||||
<field name="type">form</field>
|
|
||||||
<field name="inherit_id" ref="account.account_common_report_view"/>
|
<field name="inherit_id" ref="account.account_common_report_view"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<data>
|
<data>
|
||||||
|
@ -17,6 +16,7 @@
|
||||||
<attribute name="colspan">4</attribute>
|
<attribute name="colspan">4</attribute>
|
||||||
</field>
|
</field>
|
||||||
<xpath expr="//field[@name='target_move']" position="after">
|
<xpath expr="//field[@name='target_move']" position="after">
|
||||||
|
<newline/>
|
||||||
<field name="result_selection" colspan="4"/>
|
<field name="result_selection" colspan="4"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="/form/notebook[1]" position="after">
|
<xpath expr="/form/notebook[1]" position="after">
|
||||||
|
|
|
@ -19,10 +19,10 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from osv import fields, osv
|
from openerp.osv import fields, orm
|
||||||
|
|
||||||
|
|
||||||
class AccountPartnerBalanceWizard(osv.osv_memory):
|
class AccountPartnerBalanceWizard(orm.TransientModel):
|
||||||
"""Will launch partner balance report and pass required args"""
|
"""Will launch partner balance report and pass required args"""
|
||||||
|
|
||||||
_inherit = "account.common.balance.report"
|
_inherit = "account.common.balance.report"
|
||||||
|
@ -44,8 +44,6 @@ class AccountPartnerBalanceWizard(osv.osv_memory):
|
||||||
|
|
||||||
def pre_print_report(self, cr, uid, ids, data, context=None):
|
def pre_print_report(self, cr, uid, ids, data, context=None):
|
||||||
data = super(AccountPartnerBalanceWizard, self).pre_print_report(cr, uid, ids, data, context)
|
data = super(AccountPartnerBalanceWizard, self).pre_print_report(cr, uid, ids, data, context)
|
||||||
if context is None:
|
|
||||||
context = {}
|
|
||||||
vals = self.read(cr, uid, ids,
|
vals = self.read(cr, uid, ids,
|
||||||
['result_selection', 'partner_ids'],
|
['result_selection', 'partner_ids'],
|
||||||
context=context)[0]
|
context=context)[0]
|
||||||
|
@ -53,12 +51,9 @@ class AccountPartnerBalanceWizard(osv.osv_memory):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _print_report(self, cursor, uid, ids, data, context=None):
|
def _print_report(self, cursor, uid, ids, data, context=None):
|
||||||
context = context or {}
|
|
||||||
# we update form with display account value
|
# we update form with display account value
|
||||||
data = self.pre_print_report(cursor, uid, ids, data, context=context)
|
data = self.pre_print_report(cursor, uid, ids, data, context=context)
|
||||||
|
|
||||||
return {'type': 'ir.actions.report.xml',
|
return {'type': 'ir.actions.report.xml',
|
||||||
'report_name': 'account.account_report_partner_balance_webkit',
|
'report_name': 'account.account_report_partner_balance_webkit',
|
||||||
'datas': data}
|
'datas': data}
|
||||||
|
|
||||||
AccountPartnerBalanceWizard()
|
|
||||||
|
|
|
@ -4,12 +4,11 @@
|
||||||
|
|
||||||
<!-- inheriting views from more than 2 differents inherited models like
|
<!-- inheriting views from more than 2 differents inherited models like
|
||||||
partner.balance.webkit -> account.common.balance.report -> account.common.account.report
|
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, profit & loss
|
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">
|
<record id="account_partner_balance_view_webkit" model="ir.ui.view">
|
||||||
<field name="name">Partner Balance</field>
|
<field name="name">Partner Balance</field>
|
||||||
<field name="model">partner.balance.webkit</field>
|
<field name="model">partner.balance.webkit</field>
|
||||||
<field name="type">form</field>
|
|
||||||
<field name="inherit_id" ref="account.account_common_report_view"/>
|
<field name="inherit_id" ref="account.account_common_report_view"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<data>
|
<data>
|
||||||
|
@ -21,6 +20,7 @@
|
||||||
<attribute name="colspan">4</attribute>
|
<attribute name="colspan">4</attribute>
|
||||||
</field>
|
</field>
|
||||||
<field name="target_move" position="after">
|
<field name="target_move" position="after">
|
||||||
|
<newline/>
|
||||||
<field name="result_selection" colspan="4"/>
|
<field name="result_selection" colspan="4"/>
|
||||||
</field>
|
</field>
|
||||||
<page name="filters" position="after">
|
<page name="filters" position="after">
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from osv import fields, osv
|
from openerp.osv import fields, orm
|
||||||
|
|
||||||
|
|
||||||
class AccountReportPartnersLedgerWizard(osv.osv_memory):
|
class AccountReportPartnersLedgerWizard(orm.TransientModel):
|
||||||
"""Will launch partner ledger report and pass required args"""
|
"""Will launch partner ledger report and pass required args"""
|
||||||
|
|
||||||
_inherit = "account.common.partner.report"
|
_inherit = "account.common.partner.report"
|
||||||
|
@ -34,10 +34,13 @@ class AccountReportPartnersLedgerWizard(osv.osv_memory):
|
||||||
'amount_currency': fields.boolean("With Currency",
|
'amount_currency': fields.boolean("With Currency",
|
||||||
help="It adds the currency column"),
|
help="It adds the currency column"),
|
||||||
'partner_ids': fields.many2many('res.partner', string='Filter on partner',
|
'partner_ids': fields.many2many('res.partner', string='Filter on partner',
|
||||||
help="Only selected partners will be printed. Leave empty to print all partners."),
|
help="Only selected partners will be printed. "
|
||||||
|
"Leave empty to print all partners."),
|
||||||
'filter': fields.selection([('filter_no', 'No Filters'),
|
'filter': fields.selection([('filter_no', 'No Filters'),
|
||||||
('filter_date', 'Date'),
|
('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 calculated based on period to be correct).'),
|
('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 = {
|
_defaults = {
|
||||||
'amount_currency': False,
|
'amount_currency': False,
|
||||||
|
@ -51,13 +54,17 @@ class AccountReportPartnersLedgerWizard(osv.osv_memory):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
_constraints = [
|
_constraints = [
|
||||||
(_check_fiscalyear, 'When no Fiscal year is selected, you must choose to filter by periods or by date.', ['filter']),
|
(_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):
|
def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None):
|
||||||
res = {}
|
res = {}
|
||||||
if filter == 'filter_no':
|
if filter == 'filter_no':
|
||||||
res['value'] = {'period_from': False, 'period_to': False, 'date_from': False, 'date_to': False}
|
res['value'] = {'period_from': False, 'period_to': False, 'date_from': False, 'date_to': False}
|
||||||
|
|
||||||
if filter == 'filter_date':
|
if filter == 'filter_date':
|
||||||
if fiscalyear_id:
|
if fiscalyear_id:
|
||||||
fyear = self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id, context=context)
|
fyear = self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id, context=context)
|
||||||
|
@ -100,17 +107,14 @@ class AccountReportPartnersLedgerWizard(osv.osv_memory):
|
||||||
# will be used to attach the report on the main account
|
# will be used to attach the report on the main account
|
||||||
data['ids'] = [data['form']['chart_account_id']]
|
data['ids'] = [data['form']['chart_account_id']]
|
||||||
vals = self.read(cr, uid, ids,
|
vals = self.read(cr, uid, ids,
|
||||||
['amount_currency', 'partner_ids',],
|
['amount_currency', 'partner_ids'],
|
||||||
context=context)[0]
|
context=context)[0]
|
||||||
data['form'].update(vals)
|
data['form'].update(vals)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _print_report(self, cursor, uid, ids, data, context=None):
|
def _print_report(self, cursor, uid, ids, data, context=None):
|
||||||
context = context or {}
|
|
||||||
# we update form with display account value
|
# we update form with display account value
|
||||||
data = self.pre_print_report(cursor, uid, ids, data, context=context)
|
data = self.pre_print_report(cursor, uid, ids, data, context=context)
|
||||||
return {'type': 'ir.actions.report.xml',
|
return {'type': 'ir.actions.report.xml',
|
||||||
'report_name': 'account.account_report_partners_ledger_webkit',
|
'report_name': 'account.account_report_partners_ledger_webkit',
|
||||||
'datas': data}
|
'datas': data}
|
||||||
|
|
||||||
AccountReportPartnersLedgerWizard()
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
<record id="account_partner_ledger_view_webkit" model="ir.ui.view">
|
<record id="account_partner_ledger_view_webkit" model="ir.ui.view">
|
||||||
<field name="name">Partner Ledger</field>
|
<field name="name">Partner Ledger</field>
|
||||||
<field name="model">partners.ledger.webkit</field>
|
<field name="model">partners.ledger.webkit</field>
|
||||||
<field name="type">form</field>
|
|
||||||
<field name="inherit_id" ref="account.account_common_report_view"/>
|
<field name="inherit_id" ref="account.account_common_report_view"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<data>
|
<data>
|
||||||
|
@ -17,6 +16,7 @@
|
||||||
<attribute name="colspan">4</attribute>
|
<attribute name="colspan">4</attribute>
|
||||||
</field>
|
</field>
|
||||||
<xpath expr="//field[@name='target_move']" position="after">
|
<xpath expr="//field[@name='target_move']" position="after">
|
||||||
|
<newline/>
|
||||||
<field name="result_selection" colspan="4"/>
|
<field name="result_selection" colspan="4"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<page name="filters" position="after">
|
<page name="filters" position="after">
|
||||||
|
@ -25,7 +25,9 @@
|
||||||
<field name="partner_ids" colspan="4" nolabel="1"/>
|
<field name="partner_ids" colspan="4" nolabel="1"/>
|
||||||
</page>
|
</page>
|
||||||
<page string="Layout Options" name="layout_options">
|
<page string="Layout Options" name="layout_options">
|
||||||
|
<group colspan="4" col="2">
|
||||||
<field name="amount_currency"/>
|
<field name="amount_currency"/>
|
||||||
|
</group>
|
||||||
</page>
|
</page>
|
||||||
</page>
|
</page>
|
||||||
<page name="filters" position="attributes">
|
<page name="filters" position="attributes">
|
||||||
|
|
|
@ -1,166 +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 lxml import etree
|
|
||||||
from tools.translate import _
|
|
||||||
from osv import fields, osv
|
|
||||||
|
|
||||||
LEVEL_STYLES = 6
|
|
||||||
|
|
||||||
DEFAULT_STYLES = {
|
|
||||||
'print': [True, True, True, True, True, True],
|
|
||||||
'size': [12, 11, 10, 9, 9, 9],
|
|
||||||
'bold': [True, True, True, False, False, False],
|
|
||||||
'italic': [False, False, False, False, False, False],
|
|
||||||
'underline': [False, False, False, False, False, False],
|
|
||||||
'uppercase': [True, True, False, False, False, False],
|
|
||||||
}
|
|
||||||
|
|
||||||
class AccountProfitAndLossLedgerWizard(osv.osv_memory):
|
|
||||||
"""Will launch trial balance report and pass required args"""
|
|
||||||
|
|
||||||
_inherit = "account.common.balance.report"
|
|
||||||
_name = "profit.loss.webkit"
|
|
||||||
_description = "Profit and Loss Report"
|
|
||||||
|
|
||||||
_columns = {
|
|
||||||
'numbers_display': fields.selection([('normal', 'Normal'), ('round', 'Round (No decimal)'), ('kilo', 'Kilo')], 'Numbers Display', required=True)
|
|
||||||
}
|
|
||||||
|
|
||||||
_defaults = {
|
|
||||||
'numbers_display': 'normal',
|
|
||||||
}
|
|
||||||
|
|
||||||
def view_init(self, cr, uid, fields_list, context=None):
|
|
||||||
"""
|
|
||||||
Creates view dynamically and adding fields at runtime.
|
|
||||||
@param self: The object pointer.
|
|
||||||
@param cr: A database cursor
|
|
||||||
@param uid: ID of the user currently logged in
|
|
||||||
@param context: A standard dictionary
|
|
||||||
@return: New arch of view with new columns.
|
|
||||||
"""
|
|
||||||
res = super(AccountProfitAndLossLedgerWizard, self).view_init(cr, uid, fields_list, context=context)
|
|
||||||
for index in range(LEVEL_STYLES):
|
|
||||||
# create columns for each comparison page
|
|
||||||
self._columns.update({
|
|
||||||
"level%s_print" % (index,):
|
|
||||||
fields.boolean('Print'),
|
|
||||||
"level%s_size" % (index,):
|
|
||||||
fields.integer('Size', required=True),
|
|
||||||
"level%s_bold" % (index,):
|
|
||||||
fields.boolean('Bold'),
|
|
||||||
"level%s_italic" % (index,):
|
|
||||||
fields.boolean('Italic'),
|
|
||||||
"level%s_underline" % (index,):
|
|
||||||
fields.boolean('Underline'),
|
|
||||||
"level%s_uppercase" % (index,):
|
|
||||||
fields.boolean('Uppercase'),
|
|
||||||
})
|
|
||||||
return res
|
|
||||||
|
|
||||||
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(AccountProfitAndLossLedgerWizard, self).default_get(cr, uid, fields, context=context)
|
|
||||||
|
|
||||||
for key, values in DEFAULT_STYLES.iteritems():
|
|
||||||
for index in range(LEVEL_STYLES):
|
|
||||||
field = "level%s_%s" % (index, key)
|
|
||||||
if not res.get(field, False):
|
|
||||||
res[field] = values[index]
|
|
||||||
return res
|
|
||||||
|
|
||||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
|
||||||
res = super(AccountProfitAndLossLedgerWizard, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu)
|
|
||||||
|
|
||||||
eview = etree.fromstring(res['arch'])
|
|
||||||
placeholder = eview.xpath("//group[@name='levels']")
|
|
||||||
if placeholder:
|
|
||||||
placeholder = placeholder[0]
|
|
||||||
for index in range(LEVEL_STYLES):
|
|
||||||
# add fields
|
|
||||||
res['fields']["level%s_print" % (index,)] = {'string': "Print", 'type': 'boolean'}
|
|
||||||
res['fields']["level%s_size" % (index,)] = {'string': "Size", 'type': 'integer', 'required': True}
|
|
||||||
res['fields']["level%s_bold" % (index,)] = {'string': "Bold", 'type': 'boolean',}
|
|
||||||
res['fields']["level%s_italic" % (index,)] = {'string': "Italic", 'type': 'boolean',}
|
|
||||||
res['fields']["level%s_underline" % (index,)] = {'string': "Underline", 'type': 'boolean',}
|
|
||||||
res['fields']["level%s_uppercase" % (index,)] = {'string': "Uppercase", 'type': 'boolean'}
|
|
||||||
|
|
||||||
common_attrs = "{'readonly': [('level%(index)s_print', '=', False)]}" % {'index': index}
|
|
||||||
group = etree.Element('group', {'name': "group_level_%s" % (index,), 'colspan':'4', 'col': '10'})
|
|
||||||
group.append(etree.Element('separator', {'string': _('Level %s') % (index+1,), 'colspan':'2'}))
|
|
||||||
group.append(etree.Element('field', {'name': "level%s_print" % (index,), 'colspan': '8'}))
|
|
||||||
group.append(etree.Element('field', {'name': "level%s_size" % (index,), 'attrs': common_attrs}))
|
|
||||||
group.append(etree.Element('field', {'name': "level%s_bold" % (index,), 'attrs': common_attrs}))
|
|
||||||
group.append(etree.Element('field', {'name': "level%s_italic" % (index,), 'attrs': common_attrs}))
|
|
||||||
group.append(etree.Element('field', {'name': "level%s_underline" % (index,), 'attrs': common_attrs}))
|
|
||||||
group.append(etree.Element('field', {'name': "level%s_uppercase" % (index,), 'attrs': common_attrs}))
|
|
||||||
|
|
||||||
placeholder.append(group)
|
|
||||||
res['arch'] = etree.tostring(eview)
|
|
||||||
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)
|
|
||||||
|
|
||||||
fields_to_read = ['numbers_display',]
|
|
||||||
|
|
||||||
# comparison fields
|
|
||||||
for index in range(LEVEL_STYLES):
|
|
||||||
fields_to_read.extend([
|
|
||||||
"level%s_print" % (index,),
|
|
||||||
"level%s_size" % (index,),
|
|
||||||
"level%s_bold" % (index,),
|
|
||||||
"level%s_italic" % (index,),
|
|
||||||
"level%s_underline" % (index,),
|
|
||||||
"level%s_uppercase" % (index,),
|
|
||||||
])
|
|
||||||
|
|
||||||
vals = self.read(cursor, uid, ids, fields_to_read,context=context)[0]
|
|
||||||
|
|
||||||
data['form'].update(vals)
|
|
||||||
return {'type': 'ir.actions.report.xml',
|
|
||||||
'report_name': 'account.account_report_profit_loss_webkit',
|
|
||||||
'datas': data}
|
|
||||||
|
|
||||||
AccountProfitAndLossLedgerWizard()
|
|
|
@ -1,72 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<openerp>
|
|
||||||
<data>
|
|
||||||
|
|
||||||
<record id="account_profit_loss_view_webkit" model="ir.ui.view">
|
|
||||||
<field name="name">Profit and Loss Webkit</field>
|
|
||||||
<field name="model">profit.loss.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="Profit and Loss" colspan="4"/>
|
|
||||||
<label nolabel="1" colspan="4" string="The Profit and Loss report gives you an overview of your company profit and loss in a single document"/>
|
|
||||||
</xpath>
|
|
||||||
<field name="chart_account_id" position='attributes'>
|
|
||||||
<attribute name="colspan">4</attribute>
|
|
||||||
</field>
|
|
||||||
<page name="filters" position="after">
|
|
||||||
<page string="Display Options" name="display">
|
|
||||||
<field name="numbers_display" colspan="4"/>
|
|
||||||
<group name="levels" colspan="4"/>
|
|
||||||
</page>
|
|
||||||
<page string="Accounts Filters" name="accounts">
|
|
||||||
<separator string="Print only" colspan="4"/>
|
|
||||||
<field name="account_ids" colspan="4" nolabel="1" domain="[('type', '=', 'view'), ('user_type.report_type', 'in', ('expense', 'income'))]">
|
|
||||||
<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>
|
|
||||||
</data>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="action_account_profit_loss_menu_webkit" model="ir.actions.act_window">
|
|
||||||
<field name="name">Profit and Loss Webkit</field>
|
|
||||||
<field name="type">ir.actions.act_window</field>
|
|
||||||
<field name="res_model">profit.loss.webkit</field>
|
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">form</field>
|
|
||||||
<field name="view_id" ref="account_profit_loss_view_webkit"/>
|
|
||||||
<field name="target">new</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<!-- Profit & Loss report has not been tested, work in progress -->
|
|
||||||
|
|
||||||
<!--<record model="ir.values" id="action_account_profit_loss_values_webkit">-->
|
|
||||||
<!--<field name="model_id" ref="account.model_account_account"/>-->
|
|
||||||
<!--<field name="object" eval="1"/>-->
|
|
||||||
<!--<field name="name">Profit and Loss Webkit</field>-->
|
|
||||||
<!--<field name="key2">client_print_multi</field>-->
|
|
||||||
<!--<field name="value"-->
|
|
||||||
<!--eval="'ir.actions.act_window,' +str(ref('action_account_profit_loss_menu_webkit'))"/>-->
|
|
||||||
<!--<field name="key">action</field>-->
|
|
||||||
<!--<field name="model">account.account</field>-->
|
|
||||||
<!--</record>-->
|
|
||||||
|
|
||||||
<!--<menuitem icon="STOCK_PRINT" name="Profit and Loss Webkit"-->
|
|
||||||
<!--parent="account.final_accounting_reports" action="action_account_profit_loss_menu_webkit"-->
|
|
||||||
<!--groups="account.group_account_manager,account.group_account_user" id="menu_profit_loss_webkit"/>-->
|
|
||||||
|
|
||||||
</data>
|
|
||||||
</openerp>
|
|
|
@ -4,12 +4,11 @@
|
||||||
|
|
||||||
<!-- inheriting views from more than 2 differents inherited models like
|
<!-- inheriting views from more than 2 differents inherited models like
|
||||||
trial.balance.webkit -> account.common.balance.report -> account.common.account.report
|
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, profit & loss
|
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">
|
<record id="account_trial_balance_view_webkit" model="ir.ui.view">
|
||||||
<field name="name">Trial Balance</field>
|
<field name="name">Trial Balance</field>
|
||||||
<field name="model">trial.balance.webkit</field>
|
<field name="model">trial.balance.webkit</field>
|
||||||
<field name="type">form</field>
|
|
||||||
<field name="inherit_id" ref="account.account_common_report_view"/>
|
<field name="inherit_id" ref="account.account_common_report_view"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<data>
|
<data>
|
||||||
|
|
Loading…
Reference in New Issue