Browse Source
[MRG] [MIGR] Migration of the module account_financial_report_webkit to OpenERP 7.0
pull/7/merge
[MRG] [MIGR] Migration of the module account_financial_report_webkit to OpenERP 7.0
pull/7/merge
Joel Grand-Guillaume
12 years ago
39 changed files with 390 additions and 693 deletions
-
152account_financial_report_webkit/__openerp__.py
-
14account_financial_report_webkit/account.py
-
24account_financial_report_webkit/account_move_line.py
-
23account_financial_report_webkit/account_move_line_view.xml
-
1account_financial_report_webkit/account_view.xml
-
1account_financial_report_webkit/report/__init__.py
-
20account_financial_report_webkit/report/common_balance_reports.py
-
13account_financial_report_webkit/report/common_partner_balance_reports.py
-
16account_financial_report_webkit/report/common_partner_reports.py
-
40account_financial_report_webkit/report/common_reports.py
-
17account_financial_report_webkit/report/general_ledger.py
-
20account_financial_report_webkit/report/open_invoices.py
-
12account_financial_report_webkit/report/partner_balance.py
-
16account_financial_report_webkit/report/partners_ledger.py
-
115account_financial_report_webkit/report/profit_loss.py
-
14account_financial_report_webkit/report/report.xml
-
2account_financial_report_webkit/report/templates/account_report_general_ledger.mako
-
2account_financial_report_webkit/report/templates/account_report_open_invoices.mako
-
2account_financial_report_webkit/report/templates/account_report_partner_balance.mako
-
2account_financial_report_webkit/report/templates/account_report_partners_ledger.mako
-
2account_financial_report_webkit/report/templates/account_report_profit_loss.mako
-
2account_financial_report_webkit/report/templates/account_report_trial_balance.mako
-
14account_financial_report_webkit/report/trial_balance.py
-
51account_financial_report_webkit/report/webkit_parser_header_fix.py
-
BINaccount_financial_report_webkit/static/src/img/icon.png
-
1account_financial_report_webkit/wizard/__init__.py
-
138account_financial_report_webkit/wizard/balance_common.py
-
2account_financial_report_webkit/wizard/balance_common_view.xml
-
30account_financial_report_webkit/wizard/general_ledger_wizard.py
-
8account_financial_report_webkit/wizard/general_ledger_wizard_view.xml
-
33account_financial_report_webkit/wizard/open_invoices_wizard.py
-
2account_financial_report_webkit/wizard/open_invoices_wizard_view.xml
-
15account_financial_report_webkit/wizard/partner_balance_wizard.py
-
6account_financial_report_webkit/wizard/partner_balance_wizard_view.xml
-
26account_financial_report_webkit/wizard/partners_ledger_wizard.py
-
6account_financial_report_webkit/wizard/partners_ledger_wizard_view.xml
-
166account_financial_report_webkit/wizard/profit_loss_wizard.py
-
72account_financial_report_webkit/wizard/profit_loss_wizard_view.xml
-
3account_financial_report_webkit/wizard/trial_balance_wizard_view.xml
@ -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> |
|
@ -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) |
|
After Width: 256 | Height: 256 | Size: 15 KiB |
@ -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> |
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue