diff --git a/account_financial_report_webkit/__openerp__.py b/account_financial_report_webkit/__openerp__.py index 5b21d08d..6a3e648c 100644 --- a/account_financial_report_webkit/__openerp__.py +++ b/account_financial_report_webkit/__openerp__.py @@ -117,7 +117,6 @@ wkhtmltopdf. The texts are defined inside the report classes. 'wizard/partner_balance_wizard_view.xml', 'wizard/open_invoices_wizard_view.xml', 'report_menus.xml', -# 'wizard/profit_loss_wizard_view.xml', ], # tests order matter 'test': ['tests/general_ledger.yml', diff --git a/account_financial_report_webkit/report/__init__.py b/account_financial_report_webkit/report/__init__.py index d7d7cf9a..0934d98f 100644 --- a/account_financial_report_webkit/report/__init__.py +++ b/account_financial_report_webkit/report/__init__.py @@ -8,4 +8,3 @@ from . import webkit_parser_header_fix from . import trial_balance from . import partner_balance from . import open_invoices -#from . import account_report_profit_loss diff --git a/account_financial_report_webkit/report/profit_loss.py b/account_financial_report_webkit/report/profit_loss.py deleted file mode 100644 index d53362e0..00000000 --- a/account_financial_report_webkit/report/profit_loss.py +++ /dev/null @@ -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 . -# -############################################################################## - -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) diff --git a/account_financial_report_webkit/report/report.xml b/account_financial_report_webkit/report/report.xml index b540318a..a003e55f 100644 --- a/account_financial_report_webkit/report/report.xml +++ b/account_financial_report_webkit/report/report.xml @@ -111,19 +111,5 @@ - - - - - - - - - - - - - - diff --git a/account_financial_report_webkit/wizard/__init__.py b/account_financial_report_webkit/wizard/__init__.py index 9e184891..6d5a6f1b 100644 --- a/account_financial_report_webkit/wizard/__init__.py +++ b/account_financial_report_webkit/wizard/__init__.py @@ -24,4 +24,3 @@ from . import partners_ledger_wizard from . import trial_balance_wizard from . import partner_balance_wizard from . import open_invoices_wizard -#from . import account_report_profit_loss_wizard diff --git a/account_financial_report_webkit/wizard/balance_common_view.xml b/account_financial_report_webkit/wizard/balance_common_view.xml index dc3e4f04..b73ed8f4 100644 --- a/account_financial_report_webkit/wizard/balance_common_view.xml +++ b/account_financial_report_webkit/wizard/balance_common_view.xml @@ -4,7 +4,7 @@ diff --git a/account_financial_report_webkit/wizard/partner_balance_wizard_view.xml b/account_financial_report_webkit/wizard/partner_balance_wizard_view.xml index 24b5be02..7d3c0f0f 100644 --- a/account_financial_report_webkit/wizard/partner_balance_wizard_view.xml +++ b/account_financial_report_webkit/wizard/partner_balance_wizard_view.xml @@ -4,7 +4,7 @@ Partner Balance diff --git a/account_financial_report_webkit/wizard/profit_loss_wizard.py b/account_financial_report_webkit/wizard/profit_loss_wizard.py deleted file mode 100644 index 25d758d9..00000000 --- a/account_financial_report_webkit/wizard/profit_loss_wizard.py +++ /dev/null @@ -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() diff --git a/account_financial_report_webkit/wizard/profit_loss_wizard_view.xml b/account_financial_report_webkit/wizard/profit_loss_wizard_view.xml deleted file mode 100644 index 08aa06d2..00000000 --- a/account_financial_report_webkit/wizard/profit_loss_wizard_view.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - Profit and Loss Webkit - profit.loss.webkit - - - - - - - - 4 - - - - - - - - - - - - - - - - - - - - - True - - - - - - - Profit and Loss Webkit - ir.actions.act_window - profit.loss.webkit - form - form - - new - - - - - - - - - - - - - - - - - - - - - diff --git a/account_financial_report_webkit/wizard/trial_balance_wizard_view.xml b/account_financial_report_webkit/wizard/trial_balance_wizard_view.xml index fe91d25d..871f837a 100644 --- a/account_financial_report_webkit/wizard/trial_balance_wizard_view.xml +++ b/account_financial_report_webkit/wizard/trial_balance_wizard_view.xml @@ -4,7 +4,7 @@ Trial Balance