From daa1783dc5ff40351ba2c97be64f59cf34b41bb2 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 28 Sep 2017 14:59:32 +0200 Subject: [PATCH 1/8] [IMP] precompute last_rec_date [ADD] index last_rec_date --- account_financial_report_webkit/__init__.py | 2 ++ .../__openerp__.py | 1 + account_financial_report_webkit/hooks.py | 35 +++++++++++++++++++ .../models/account_move_line.py | 1 + 4 files changed, 39 insertions(+) create mode 100644 account_financial_report_webkit/hooks.py diff --git a/account_financial_report_webkit/__init__.py b/account_financial_report_webkit/__init__.py index 1eeb7fc5..bf51e89d 100644 --- a/account_financial_report_webkit/__init__.py +++ b/account_financial_report_webkit/__init__.py @@ -21,3 +21,5 @@ from . import models from . import wizard from . import report +from . import hooks +from .hooks import pre_init_hook diff --git a/account_financial_report_webkit/__openerp__.py b/account_financial_report_webkit/__openerp__.py index b0776563..98c42008 100644 --- a/account_financial_report_webkit/__openerp__.py +++ b/account_financial_report_webkit/__openerp__.py @@ -60,4 +60,5 @@ 'active': False, 'installable': True, 'application': True, + 'pre_init_hook': 'pre_init_hook', } diff --git a/account_financial_report_webkit/hooks.py b/account_financial_report_webkit/hooks.py new file mode 100644 index 00000000..18081b6c --- /dev/null +++ b/account_financial_report_webkit/hooks.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from .models.account_move_line import AccountMoveLine + + +def pre_init_hook(cr): + with cr.savepoint(): + # don't break if column exists + cr.execute( + 'alter table account_move_line add column last_rec_date date', + ) + cr.execute( + 'comment on column account_move_line.last_rec_date is %s', + (AccountMoveLine.last_rec_date.string,), + ) + cr.execute( + 'create index account_move_line_last_rec_date_index ' + 'on account_move_line (last_rec_date)', + ) + # but still do the initialization + cr.execute( + """update account_move_line + set last_rec_date=ml_fr.date + from account_move_line ml + left join account_move_reconcile fr on ml.reconcile_id=fr.id + join ( + select + coalesce(reconcile_id, reconcile_partial_id) as reconcile_id, + max(date) as date + from account_move_line + group by coalesce(reconcile_id, reconcile_partial_id) + ) ml_fr on ml_fr.reconcile_id=fr.id + where ml.id=account_move_line.id""" + ) diff --git a/account_financial_report_webkit/models/account_move_line.py b/account_financial_report_webkit/models/account_move_line.py index e95618c0..9a3a6cc7 100644 --- a/account_financial_report_webkit/models/account_move_line.py +++ b/account_financial_report_webkit/models/account_move_line.py @@ -18,6 +18,7 @@ class AccountMoveLine(models.Model): last_rec_date = fields.Date( compute='_compute_last_rec_date', store=True, + index=True, string='Last reconciliation date', help="The date of the last reconciliation (full or partial) " "account move line." From b170a15dfb61c89a06cbe37b4a5cf87141edadd0 Mon Sep 17 00:00:00 2001 From: luc-demeyer Date: Fri, 30 Dec 2016 18:30:36 +0100 Subject: [PATCH 2/8] [ADD] XLS report to Aged Partner Balance --- .../__init__.py | 23 +- .../__openerp__.py | 27 +- .../report/__init__.py | 1 + .../report/aged_partner_balance_xls.py | 280 +++++++++ .../report/trial_balance_xls.py | 28 +- .../static/description/icon.svg | 556 ------------------ .../wizard/__init__.py | 24 +- .../wizard/aged_partner_balance_wizard.py | 25 + .../wizard/aged_partner_balance_wizard.xml | 21 + .../wizard/general_ledger_wizard.py | 33 +- .../wizard/general_ledger_wizard_view.xml | 22 +- .../wizard/open_invoices_wizard.py | 33 +- .../wizard/open_invoices_wizard_view.xml | 22 +- .../wizard/partners_balance_wizard.py | 33 +- .../wizard/partners_balance_wizard_view.xml | 24 +- .../wizard/partners_ledger_wizard.py | 41 +- .../wizard/partners_ledger_wizard_view.xml | 22 +- .../wizard/trial_balance_wizard.py | 33 +- .../wizard/trial_balance_wizard_view.xml | 24 +- 19 files changed, 438 insertions(+), 834 deletions(-) create mode 100644 account_financial_report_webkit_xls/report/aged_partner_balance_xls.py delete mode 100644 account_financial_report_webkit_xls/static/description/icon.svg create mode 100644 account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.py create mode 100644 account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.xml diff --git a/account_financial_report_webkit_xls/__init__.py b/account_financial_report_webkit_xls/__init__.py index 49db08a9..5c3bc2f8 100644 --- a/account_financial_report_webkit_xls/__init__.py +++ b/account_financial_report_webkit_xls/__init__.py @@ -1,25 +1,4 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# -# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - +# -*- coding: utf-8 -*- try: from . import wizard from . import report diff --git a/account_financial_report_webkit_xls/__openerp__.py b/account_financial_report_webkit_xls/__openerp__.py index 024a2b31..ff8078d7 100644 --- a/account_financial_report_webkit_xls/__openerp__.py +++ b/account_financial_report_webkit_xls/__openerp__.py @@ -1,27 +1,9 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# -# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# Copyright 2009-2016 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Add XLS export to accounting reports', - 'version': '8.0.0.4.0', + 'version': '8.0.0.5.0', 'license': 'AGPL-3', 'author': "Noviat,Odoo Community Association (OCA)", 'category': 'Generic Modules/Accounting', @@ -43,6 +25,7 @@ 'wizard/partners_ledger_wizard_view.xml', 'wizard/partners_balance_wizard_view.xml', 'wizard/open_invoices_wizard_view.xml', + 'wizard/aged_partner_balance_wizard.xml', ], 'test': ['tests/general_ledger.yml', 'tests/partner_ledger.yml', diff --git a/account_financial_report_webkit_xls/report/__init__.py b/account_financial_report_webkit_xls/report/__init__.py index 2e7d18c6..302e50c7 100644 --- a/account_financial_report_webkit_xls/report/__init__.py +++ b/account_financial_report_webkit_xls/report/__init__.py @@ -4,3 +4,4 @@ from . import trial_balance_xls from . import partners_balance_xls from . import partner_ledger_xls from . import open_invoices_xls +from . import aged_partner_balance_xls diff --git a/account_financial_report_webkit_xls/report/aged_partner_balance_xls.py b/account_financial_report_webkit_xls/report/aged_partner_balance_xls.py new file mode 100644 index 00000000..a7d16006 --- /dev/null +++ b/account_financial_report_webkit_xls/report/aged_partner_balance_xls.py @@ -0,0 +1,280 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2016 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import xlwt +from openerp.addons.report_xls.report_xls import report_xls +from openerp.addons.report_xls.utils import rowcol_to_cell +from openerp.addons.account_financial_report_webkit.report \ + .aged_partner_balance import AccountAgedTrialBalanceWebkit +from openerp.tools.translate import _ +# import logging +# _logger = logging.getLogger(__name__) + + +class AccountAgedTrialBalanceWebkitXls(report_xls): + + def create(self, cr, uid, ids, data, context=None): + self._column_sizes = [ + 30, # Partner + 20, # Partner Code + 20, # Balance + 20, # Due + 20, # Overdue 0-30 + 20, # Overdue 30-60 + 20, # Overdue 60-90 + 20, # Overdue 90-120 + 20, # Overdue 120+ + ] + self._balance_pos = 2 + return super(AccountAgedTrialBalanceWebkitXls, self).create( + cr, uid, ids, data, context=context) + + def _cell_styles(self, _xs): + self._style_title = xlwt.easyxf(_xs['xls_title']) + self._style_bold_blue_center = xlwt.easyxf( + _xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] + + _xs['center']) + self._style_center = xlwt.easyxf( + _xs['borders_all'] + _xs['wrap'] + _xs['center']) + + format_yellow_bold = _xs['bold'] + _xs['fill'] + _xs['borders_all'] + self._style_account_title = xlwt.easyxf( + format_yellow_bold + _xs['xls_title']) + self._style_yellow_bold = xlwt.easyxf(format_yellow_bold) + self._style_yellow_bold_right = xlwt.easyxf( + format_yellow_bold + _xs['right']) + self._style_yellow_bold_decimal = xlwt.easyxf( + format_yellow_bold + _xs['right'], + num_format_str=report_xls.decimal_format) + + self._style_default = xlwt.easyxf(_xs['borders_all']) + self._style_decimal = xlwt.easyxf( + _xs['borders_all'] + _xs['right'], + num_format_str=report_xls.decimal_format) + self._style_percent = xlwt.easyxf( + _xs['borders_all'] + _xs['right'], + num_format_str='0.00%') + + def _setup_worksheet(self, _p, _xs, data, wb): + self.ws = wb.add_sheet(_p.report_name[:31]) + self.ws.panes_frozen = True + self.ws.remove_splits = True + self.ws.portrait = 0 # Landscape + self.ws.fit_width_to_pages = 1 + self.ws.header_str = self.xls_headers['standard'] + self.ws.footer_str = self.xls_footers['standard'] + + def _print_title(self, _p, _xs, data, row_pos): + report_name = ' - '.join( + [_p.report_name.upper(), + _p.company.partner_id.name, + _p.company.currency_id.name]) + c_specs = [ + ('report_name', 1, 0, 'text', report_name), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row( + self.ws, row_pos, row_data, row_style=self._style_title) + return row_pos + + def _print_empty_row(self, _p, _xs, data, row_pos): + """ + Print empty row to define column sizes + """ + c_specs = [('empty%s' % i, 1, self._column_sizes[i], 'text', None) + for i in range(len(self._column_sizes))] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row( + self.ws, row_pos, row_data, set_column_size=True) + return row_pos + + def _print_header_title(self, _p, _xs, data, row_pos): + c_specs = [ + ('coa', 1, 0, 'text', _('Chart of Account')), + ('fy', 1, 0, 'text', _('Fiscal Year')), + ('period_filter', 2, 0, 'text', _('Periods Filter')), + ('cd', 1, 0, 'text', _('Clearance Date')), + ('account_filter', 2, 0, 'text', _('Accounts Filter')), + ('partner_filter', 1, 0, 'text', _('Partners Filter')), + ('tm', 1, 0, 'text', _('Target Moves')), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row( + self.ws, row_pos, row_data, + row_style=self._style_bold_blue_center) + return row_pos + + def _print_header_data(self, _p, _xs, data, row_pos): + period_filter = _('From') + ': ' + period_filter += _p.start_period.name if _p.start_period else u'' + period_filter += ' ' + _('To') + ': ' + period_filter += _p.stop_period.name if _p.stop_period else u'' + c_specs = [ + ('coa', 1, 0, 'text', _p.chart_account.name), + ('fy', 1, 0, 'text', + _p.fiscalyear.name if _p.fiscalyear else '-'), + ('period_filter', 2, 0, 'text', period_filter), + ('cd', 1, 0, 'text', _p.date_until), + ('account_filter', 2, 0, 'text', + _p.display_partner_account(data)), + ('partner_filter', 1, 0, 'text', + _('Selected Partners') if _p.partner_ids else '-'), + ('tm', 1, 0, 'text', + _p.display_target_move(data)), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row( + self.ws, row_pos, row_data, row_style=self._style_center) + return row_pos + + def _print_header(self, _p, _xs, data, row_pos): + """ + Header Table: Chart of Account, Fiscal year, Filters, ... + """ + row_pos = self._print_header_title(_p, _xs, data, row_pos) + row_pos = self._print_header_data(_p, _xs, data, row_pos) + self.ws.set_horz_split_pos(row_pos) # freeze the line + return row_pos + 1 + + def _print_account_header(self, _p, _xs, data, row_pos, account): + """ + Fill in a row with the code and name of the account + """ + c_specs = [ + ('acc_title', len(self._column_sizes), 0, 'text', + ' - '.join([account.code, account.name])), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row( + self.ws, row_pos, row_data, self._style_account_title) + return row_pos + 1 + + def _print_partner_header(self, _p, _xs, data, row_pos): + """ + Partner header line + """ + c_specs = [ + ('partner_h', 1, 0, 'text', _('Partner'), + None, self._style_yellow_bold), + ('pcode_h', 1, 0, 'text', _('Code'), + None, self._style_yellow_bold), + ('balance_h', 1, 0, 'text', _('Balance')), + ('due_h', 1, 0, 'text', _('Due'))] + for days in [30, 60, 90, 120]: + entry = 'od_%s_h' % days + label = _("Overdue ≤ %s d.") % days + c_specs += [(entry, 1, 0, 'text', label)] + c_specs += [('older_h', 1, 0, 'text', _("Older"))] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row( + self.ws, row_pos, row_data, + row_style=self._style_yellow_bold_right) + return row_pos + + def _print_partner_line(self, _p, _xs, data, row_pos, partner, line): + """ + Partner data line + """ + partner_name, p_id, p_ref, p_name = partner + c_specs = [ + ('partner', 1, 0, 'text', p_name, + None, self._style_default), + ('pcode', 1, 0, 'text', p_ref, + None, self._style_default), + ('balance', 1, 0, 'number', line['balance'])] + for r in _p.ranges: + entry = 'od_%s' % r[0] + c_specs += [(entry, 1, 0, 'number', line['aged_lines'][r])] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row( + self.ws, row_pos, row_data, + row_style=self._style_decimal) + return row_pos + + def _print_partner_footer(self, _p, _xs, data, row_pos, + account, line_count): + """ + Partner header line + """ + # Totals + c_specs = [ + ('total', 1, 0, 'text', _('Total') + ' ' + account.code, + None, self._style_yellow_bold), + ('empty', 1, 0, 'text', None, + None, self._style_yellow_bold)] + row_start = row_pos - line_count + col_start = self._balance_pos + start = rowcol_to_cell(row_start, col_start) + stop = rowcol_to_cell(row_pos - 1, col_start) + formula = 'SUM(%s:%s)' % (start, stop) + c_specs += [('total_balance', 1, 0, 'number', None, formula)] + col_start += 1 + for i, r in enumerate(_p.ranges): + entry = 'total_%s' % i + start = rowcol_to_cell(row_start, col_start + i) + stop = rowcol_to_cell(row_pos - 1, col_start + i) + formula = 'SUM(%s:%s)' % (start, stop) + c_specs += [(entry, 1, 0, 'number', None, formula)] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row( + self.ws, row_pos, row_data, + row_style=self._style_yellow_bold_decimal) + + # percents + c_specs = [ + ('pct', 1, 0, 'text', _('Percentages') + ' ' + account.code, + None, self._style_default), + ('empty', 2, 0, 'text', None, + None, self._style_default)] + total_balance = rowcol_to_cell(row_pos - 1, self._balance_pos) + for i, r in enumerate(_p.ranges): + entry = 'pct_%s' % i + total_range = rowcol_to_cell(row_pos - 1, col_start + i) + formula = '%s/%s' % (total_range, total_balance) + c_specs += [(entry, 1, 0, 'number', None, formula)] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row( + self.ws, row_pos, row_data, + row_style=self._style_percent) + + return row_pos + + def _print_account_data(self, _p, _xs, data, row_pos, account): + if _p.agged_lines_accounts.get(account.id): + row_pos = self._print_account_header( + _p, _xs, data, row_pos, account) + lines = _p.agged_lines_accounts[account.id] + + row_pos = self._print_partner_header( + _p, _xs, data, row_pos) + row_pos_start = row_pos + for partner in _p.partners_order[account.id]: + partner_id = partner[1] + if partner_id in lines: + line = lines[partner_id] + row_pos = self._print_partner_line( + _p, _xs, data, row_pos, partner, line) + line_count = row_pos - row_pos_start + row_pos = self._print_partner_footer( + _p, _xs, data, row_pos, account, line_count) + return row_pos + 1 + + def generate_xls_report(self, _p, _xs, data, objects, wb): + + self._cell_styles(_xs) + self._setup_worksheet(_p, _xs, data, wb) + + row_pos = 0 + row_pos = self._print_title(_p, _xs, data, row_pos) + row_pos = self._print_empty_row(_p, _xs, data, row_pos) + row_pos = self._print_header(_p, _xs, data, row_pos) + + for account in objects: + row_pos = self._print_account_data( + _p, _xs, data, row_pos, account) + + +AccountAgedTrialBalanceWebkitXls( + 'report.account.account_report_aged_partner_balance_xls', + 'account.account', + parser=AccountAgedTrialBalanceWebkit) diff --git a/account_financial_report_webkit_xls/report/trial_balance_xls.py b/account_financial_report_webkit_xls/report/trial_balance_xls.py index 8cd5c3d5..fde93c06 100644 --- a/account_financial_report_webkit_xls/report/trial_balance_xls.py +++ b/account_financial_report_webkit_xls/report/trial_balance_xls.py @@ -11,8 +11,13 @@ from openerp.tools.translate import _ # _logger = logging.getLogger(__name__) -class trial_balance_xls(report_xls): - column_sizes = [12, 60, 17, 17, 17, 17, 17, 17] +class TrialBalanceXls(report_xls): + + def create(self, cr, uid, ids, data, context=None): + self._column_sizes = [12, 60, 17, 17, 17, 17, 17, 17] + self._debit_pos = 4 + return super(TrialBalanceXls, self).create( + cr, uid, ids, data, context=context) def generate_xls_report(self, _p, _xs, data, objects, wb): @@ -45,7 +50,7 @@ class trial_balance_xls(report_xls): ws, row_pos, row_data, row_style=cell_style) # write empty row to define column sizes - c_sizes = self.column_sizes + c_sizes = self._column_sizes c_specs = [('empty%s' % i, 1, c_sizes[i], 'text', None) for i in range(0, len(c_sizes))] row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) @@ -246,15 +251,14 @@ class trial_balance_xls(report_xls): ('account', account_span, 0, 'text', current_account.name), ] if _p.comparison_mode == 'no_comparison': - - debit_cell = rowcol_to_cell(row_pos, 4) - credit_cell = rowcol_to_cell(row_pos, 5) + debit_cell = rowcol_to_cell(row_pos, self._debit_pos) + credit_cell = rowcol_to_cell(row_pos, self._debit_pos + 1) bal_formula = debit_cell + '-' + credit_cell if _p.initial_balance_mode: - init_cell = rowcol_to_cell(row_pos, 3) - debit_cell = rowcol_to_cell(row_pos, 4) - credit_cell = rowcol_to_cell(row_pos, 5) + init_cell = rowcol_to_cell(row_pos, self._debit_pos - 1) + debit_cell = rowcol_to_cell(row_pos, self._debit_pos) + credit_cell = rowcol_to_cell(row_pos, self._debit_pos + 1) bal_formula = init_cell + '+' + \ debit_cell + '-' + credit_cell c_specs += [('init_bal', 1, 0, 'number', @@ -301,6 +305,6 @@ class trial_balance_xls(report_xls): ws, row_pos, row_data, row_style=cell_style) -trial_balance_xls('report.account.account_report_trial_balance_xls', - 'account.account', - parser=TrialBalanceWebkit) +TrialBalanceXls('report.account.account_report_trial_balance_xls', + 'account.account', + parser=TrialBalanceWebkit) diff --git a/account_financial_report_webkit_xls/static/description/icon.svg b/account_financial_report_webkit_xls/static/description/icon.svg deleted file mode 100644 index 1d087e94..00000000 --- a/account_financial_report_webkit_xls/static/description/icon.svg +++ /dev/null @@ -1,556 +0,0 @@ - - - - - - - - spain_provinces - - - - spain - geography - - - - - sherrera - - - - - sherrera - - - - - sherrera - - - - image/svg+xml - - - en - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/account_financial_report_webkit_xls/wizard/__init__.py b/account_financial_report_webkit_xls/wizard/__init__.py index 7de0a818..29f9b837 100644 --- a/account_financial_report_webkit_xls/wizard/__init__.py +++ b/account_financial_report_webkit_xls/wizard/__init__.py @@ -1,27 +1,7 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# -# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - +# -*- coding: utf-8 -*- from . import general_ledger_wizard from . import trial_balance_wizard from . import partners_balance_wizard from . import partners_ledger_wizard from . import open_invoices_wizard +from . import aged_partner_balance_wizard diff --git a/account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.py b/account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.py new file mode 100644 index 00000000..b70b23eb --- /dev/null +++ b/account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2016 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from openerp import models + + +class AccountAgedTrialBalance(models.TransientModel): + _inherit = 'account.aged.trial.balance.webkit' + + def xls_export(self, cr, uid, ids, context=None): + return self.check_report(cr, uid, ids, context=context) + + def _print_report(self, cr, uid, ids, data, context=None): + context = context or {} + if context.get('xls_export'): + # we update form with display account value + data = self.pre_print_report(cr, uid, ids, data, context=context) + return { + 'type': 'ir.actions.report.xml', + 'report_name': + 'account.account_report_aged_partner_balance_xls', + 'datas': data} + else: + return super(AccountAgedTrialBalance, self)._print_report( + cr, uid, ids, data, context=context) diff --git a/account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.xml b/account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.xml new file mode 100644 index 00000000..7d52859f --- /dev/null +++ b/account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.xml @@ -0,0 +1,21 @@ + + + + + + account.aged.trial.balance.webkit.xls + account.aged.trial.balance.webkit + form + + + + 6 + + + + + + + diff --git a/account_financial_report_webkit_xls/wizard/general_ledger_wizard.py b/account_financial_report_webkit_xls/wizard/general_ledger_wizard.py index 99ab9d07..d0d394cc 100644 --- a/account_financial_report_webkit_xls/wizard/general_ledger_wizard.py +++ b/account_financial_report_webkit_xls/wizard/general_ledger_wizard.py @@ -1,31 +1,10 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# -# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# Copyright 2009-2016 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from openerp import models -from openerp.osv import orm -# import logging -# _logger = logging.getLogger(__name__) - -class general_ledger_webkit_wizard(orm.TransientModel): +class AccountReportGeneralLedgerWizard(models.TransientModel): _inherit = 'general.ledger.webkit' def xls_export(self, cr, uid, ids, context=None): @@ -40,5 +19,5 @@ class general_ledger_webkit_wizard(orm.TransientModel): 'report_name': 'account.account_report_general_ledger_xls', 'datas': data} else: - return super(general_ledger_webkit_wizard, self)._print_report( + return super(AccountReportGeneralLedgerWizard, self)._print_report( cr, uid, ids, data, context=context) diff --git a/account_financial_report_webkit_xls/wizard/general_ledger_wizard_view.xml b/account_financial_report_webkit_xls/wizard/general_ledger_wizard_view.xml index 1ab4f6ca..8eb805db 100644 --- a/account_financial_report_webkit_xls/wizard/general_ledger_wizard_view.xml +++ b/account_financial_report_webkit_xls/wizard/general_ledger_wizard_view.xml @@ -2,23 +2,21 @@ - + general.ledger.webkit.xls general.ledger.webkit form - - - - - 6 - - - + + + + 6 + + diff --git a/account_financial_report_webkit_xls/wizard/open_invoices_wizard.py b/account_financial_report_webkit_xls/wizard/open_invoices_wizard.py index dcc339c4..5b4b4df6 100644 --- a/account_financial_report_webkit_xls/wizard/open_invoices_wizard.py +++ b/account_financial_report_webkit_xls/wizard/open_invoices_wizard.py @@ -1,31 +1,10 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# -# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# Copyright 2009-2016 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from openerp import models -from openerp.osv import orm -# import logging -# _logger = logging.getLogger(__name__) - -class open_invoices_webkit_wizard(orm.TransientModel): +class AccountReportOpenInvoicesWizard(models.TransientModel): _inherit = 'open.invoices.webkit' def xls_export(self, cr, uid, ids, context=None): @@ -40,5 +19,5 @@ class open_invoices_webkit_wizard(orm.TransientModel): 'report_name': 'account.account_report_open_invoices_xls', 'datas': data} else: - return super(open_invoices_webkit_wizard, self)._print_report( + return super(AccountReportOpenInvoicesWizard, self)._print_report( cr, uid, ids, data, context=context) diff --git a/account_financial_report_webkit_xls/wizard/open_invoices_wizard_view.xml b/account_financial_report_webkit_xls/wizard/open_invoices_wizard_view.xml index 2d089239..c73e1346 100644 --- a/account_financial_report_webkit_xls/wizard/open_invoices_wizard_view.xml +++ b/account_financial_report_webkit_xls/wizard/open_invoices_wizard_view.xml @@ -2,23 +2,21 @@ - + open.invoices.webkit.xls open.invoices.webkit form - - - - - 6 - - - + + + + 6 + + diff --git a/account_financial_report_webkit_xls/wizard/partners_balance_wizard.py b/account_financial_report_webkit_xls/wizard/partners_balance_wizard.py index 27fc1ae7..3c0d6faf 100644 --- a/account_financial_report_webkit_xls/wizard/partners_balance_wizard.py +++ b/account_financial_report_webkit_xls/wizard/partners_balance_wizard.py @@ -1,31 +1,10 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# -# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# Copyright 2009-2016 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from openerp import models -from openerp.osv import orm -# import logging -# _logger = logging.getLogger(__name__) - -class partner_balance_wizard(orm.TransientModel): +class AccountPartnerBalanceWizard(models.TransientModel): _inherit = 'partner.balance.webkit' def xls_export(self, cr, uid, ids, context=None): @@ -41,5 +20,5 @@ class partner_balance_wizard(orm.TransientModel): 'report_name': 'account.account_report_partner_balance_xls', 'datas': data} else: - return super(partner_balance_wizard, self)._print_report( + return super(AccountPartnerBalanceWizard, self)._print_report( cr, uid, ids, data, context=context) diff --git a/account_financial_report_webkit_xls/wizard/partners_balance_wizard_view.xml b/account_financial_report_webkit_xls/wizard/partners_balance_wizard_view.xml index 7dbd6cca..d6a00f98 100644 --- a/account_financial_report_webkit_xls/wizard/partners_balance_wizard_view.xml +++ b/account_financial_report_webkit_xls/wizard/partners_balance_wizard_view.xml @@ -1,24 +1,22 @@ - - + + partner.balance.webkit.xls partner.balance.webkit form - - - - - 6 - - - + + + + 6 + + diff --git a/account_financial_report_webkit_xls/wizard/partners_ledger_wizard.py b/account_financial_report_webkit_xls/wizard/partners_ledger_wizard.py index 27057c6d..450bbfab 100644 --- a/account_financial_report_webkit_xls/wizard/partners_ledger_wizard.py +++ b/account_financial_report_webkit_xls/wizard/partners_ledger_wizard.py @@ -1,31 +1,10 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# -# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# Copyright 2009-2016 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from openerp import models -from openerp.osv import orm -# import logging -# _logger = logging.getLogger(__name__) - -class partner_ledger_webkit_wizard(orm.TransientModel): +class AccountReportPartnersLedgerWizard(models.TransientModel): _inherit = 'partners.ledger.webkit' def xls_export(self, cr, uid, ids, context=None): @@ -36,9 +15,11 @@ class partner_ledger_webkit_wizard(orm.TransientModel): if context.get('xls_export'): # we update form with display account value data = self.pre_print_report(cr, uid, ids, data, context=context) - return {'type': 'ir.actions.report.xml', - 'report_name': 'account.account_report_partner_ledger_xls', - 'datas': data} + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'account.account_report_partner_ledger_xls', + 'datas': data} else: - return super(partner_ledger_webkit_wizard, self)._print_report( + return super( + AccountReportPartnersLedgerWizard, self)._print_report( cr, uid, ids, data, context=context) diff --git a/account_financial_report_webkit_xls/wizard/partners_ledger_wizard_view.xml b/account_financial_report_webkit_xls/wizard/partners_ledger_wizard_view.xml index 3015eb82..a1c2f18e 100644 --- a/account_financial_report_webkit_xls/wizard/partners_ledger_wizard_view.xml +++ b/account_financial_report_webkit_xls/wizard/partners_ledger_wizard_view.xml @@ -2,23 +2,21 @@ - + partners.ledger.webkit.xls partners.ledger.webkit form - - - - - 6 - - - + + + + 6 + + diff --git a/account_financial_report_webkit_xls/wizard/trial_balance_wizard.py b/account_financial_report_webkit_xls/wizard/trial_balance_wizard.py index 7f4ecd41..77965ba1 100644 --- a/account_financial_report_webkit_xls/wizard/trial_balance_wizard.py +++ b/account_financial_report_webkit_xls/wizard/trial_balance_wizard.py @@ -1,31 +1,10 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# -# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# Copyright 2009-2016 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from openerp import models -from openerp.osv import orm -# import logging -# _logger = logging.getLogger(__name__) - -class trial_balance_wizard(orm.TransientModel): +class AccountTrialBalanceWizard(models.TransientModel): _inherit = 'trial.balance.webkit' def xls_export(self, cr, uid, ids, context=None): @@ -40,5 +19,5 @@ class trial_balance_wizard(orm.TransientModel): 'report_name': 'account.account_report_trial_balance_xls', 'datas': data} else: - return super(trial_balance_wizard, self)._print_report( + return super(AccountTrialBalanceWizard, self)._print_report( cr, uid, ids, data, context=context) diff --git a/account_financial_report_webkit_xls/wizard/trial_balance_wizard_view.xml b/account_financial_report_webkit_xls/wizard/trial_balance_wizard_view.xml index f7d16633..cd0cd345 100644 --- a/account_financial_report_webkit_xls/wizard/trial_balance_wizard_view.xml +++ b/account_financial_report_webkit_xls/wizard/trial_balance_wizard_view.xml @@ -1,24 +1,22 @@ - - + + trial.balance.webkit.xls trial.balance.webkit form - - - - - 6 - - - + + + + 6 + + From 65a48d2106b21db43dbb8594c0aa95f420c83fec Mon Sep 17 00:00:00 2001 From: luc-demeyer Date: Sun, 1 Jan 2017 16:38:20 +0100 Subject: [PATCH 3/8] [ADD] tests, readme, fy fix --- account_financial_report_webkit/README.rst | 1 + .../__openerp__.py | 2 +- .../tests/__init__.py | 11 +- .../tests/test_aged_open_invoices.py | 24 ++++ .../tests/test_aged_partner_balance.py | 26 ++++ .../tests/test_common.py | 44 +++++++ .../tests/test_general_leger.py | 23 ++++ .../tests/test_journal.py | 27 ++++ .../tests/test_open_invoices.py | 24 ++++ .../tests/test_partner_balance.py | 23 ++++ .../tests/test_partner_ledger.py | 23 ++++ .../tests/test_trial_balance.py | 23 ++++ .../wizard/__init__.py | 26 +--- .../wizard/account_common_report_fix.py | 121 ++++++++++++++++++ .../wizard/aged_partner_balance_wizard.py | 37 +----- .../README.rst | 64 +++++++++ .../__openerp__.py | 24 +--- .../{tests => test}/general_ledger.yml | 0 .../{tests => test}/open_invoices.yml | 0 .../{tests => test}/partner_balance.yml | 0 .../{tests => test}/partner_ledger.yml | 0 .../{tests => test}/trial_balance.yml | 0 .../tests/__init__.py | 7 + .../tests/test_aged_partner_balance_xls.py | 31 +++++ .../tests/test_common_xls.py | 60 +++++++++ .../tests/test_general_leger_xls.py | 28 ++++ .../tests/test_open_invoices_xls.py | 29 +++++ .../tests/test_partner_balance_xls.py | 28 ++++ .../tests/test_partner_ledger_xls.py | 28 ++++ .../tests/test_trial_balance_xls.py | 28 ++++ account_journal_report_xls/wizard/__init__.py | 24 +--- .../wizard/account_common_report_fix.py | 65 ++++++++++ 32 files changed, 752 insertions(+), 99 deletions(-) create mode 100644 account_financial_report_webkit/tests/test_aged_open_invoices.py create mode 100644 account_financial_report_webkit/tests/test_aged_partner_balance.py create mode 100644 account_financial_report_webkit/tests/test_common.py create mode 100644 account_financial_report_webkit/tests/test_general_leger.py create mode 100644 account_financial_report_webkit/tests/test_journal.py create mode 100644 account_financial_report_webkit/tests/test_open_invoices.py create mode 100644 account_financial_report_webkit/tests/test_partner_balance.py create mode 100644 account_financial_report_webkit/tests/test_partner_ledger.py create mode 100644 account_financial_report_webkit/tests/test_trial_balance.py create mode 100644 account_financial_report_webkit/wizard/account_common_report_fix.py create mode 100644 account_financial_report_webkit_xls/README.rst rename account_financial_report_webkit_xls/{tests => test}/general_ledger.yml (100%) rename account_financial_report_webkit_xls/{tests => test}/open_invoices.yml (100%) rename account_financial_report_webkit_xls/{tests => test}/partner_balance.yml (100%) rename account_financial_report_webkit_xls/{tests => test}/partner_ledger.yml (100%) rename account_financial_report_webkit_xls/{tests => test}/trial_balance.yml (100%) create mode 100644 account_financial_report_webkit_xls/tests/__init__.py create mode 100644 account_financial_report_webkit_xls/tests/test_aged_partner_balance_xls.py create mode 100644 account_financial_report_webkit_xls/tests/test_common_xls.py create mode 100644 account_financial_report_webkit_xls/tests/test_general_leger_xls.py create mode 100644 account_financial_report_webkit_xls/tests/test_open_invoices_xls.py create mode 100644 account_financial_report_webkit_xls/tests/test_partner_balance_xls.py create mode 100644 account_financial_report_webkit_xls/tests/test_partner_ledger_xls.py create mode 100644 account_financial_report_webkit_xls/tests/test_trial_balance_xls.py create mode 100644 account_journal_report_xls/wizard/account_common_report_fix.py diff --git a/account_financial_report_webkit/README.rst b/account_financial_report_webkit/README.rst index f58645d7..caecc09d 100644 --- a/account_financial_report_webkit/README.rst +++ b/account_financial_report_webkit/README.rst @@ -165,6 +165,7 @@ Contributors * Nicolas Bessi * Guewen Baconnier * David Dufresne +* Luc De Meyer Maintainer ---------- diff --git a/account_financial_report_webkit/__openerp__.py b/account_financial_report_webkit/__openerp__.py index 98c42008..d77c80a5 100644 --- a/account_financial_report_webkit/__openerp__.py +++ b/account_financial_report_webkit/__openerp__.py @@ -20,7 +20,7 @@ ############################################################################## { 'name': 'Financial Reports - Webkit', - 'version': '8.0.1.2.0', + 'version': '8.0.1.2.1', 'author': ( "Camptocamp," "Savoir-faire Linux," diff --git a/account_financial_report_webkit/tests/__init__.py b/account_financial_report_webkit/tests/__init__.py index ccb19038..4bc79b53 100644 --- a/account_financial_report_webkit/tests/__init__.py +++ b/account_financial_report_webkit/tests/__init__.py @@ -1,5 +1,10 @@ # -*- coding: utf-8 -*- -# © 2016 Savoir-faire Linux -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - from . import test_account_move_line +from . import test_general_leger +from . import test_partner_ledger +from . import test_trial_balance +from . import test_partner_balance +from . import test_open_invoices +from . import test_aged_open_invoices +from . import test_aged_partner_balance +from . import test_journal diff --git a/account_financial_report_webkit/tests/test_aged_open_invoices.py b/account_financial_report_webkit/tests/test_aged_open_invoices.py new file mode 100644 index 00000000..359361fe --- /dev/null +++ b/account_financial_report_webkit/tests/test_aged_open_invoices.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2017 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from datetime import datetime +from .test_common import TestCommon + + +class TestOpenInvoices(TestCommon): + + def _getReportModel(self): + return 'aged.open.invoices.webkit' + + def _getReportName(self): + return 'account.account_aged_open_invoices_webkit' + + def _getBaseFilters(self): + return {'until_date': '%s-12-31' % (datetime.now().year)} + + def test_common(self): + common_tests = [ + x for x in dir(self) + if callable(getattr(self, x)) and x.startswith('common_test_')] + for test in common_tests: + getattr(self, test)() diff --git a/account_financial_report_webkit/tests/test_aged_partner_balance.py b/account_financial_report_webkit/tests/test_aged_partner_balance.py new file mode 100644 index 00000000..96eb7d52 --- /dev/null +++ b/account_financial_report_webkit/tests/test_aged_partner_balance.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2017 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from .test_common import TestCommon + + +class TestAgedPartnerBalance(TestCommon): + + def _getReportModel(self): + return 'account.aged.trial.balance.webkit' + + def _getReportName(self): + return 'account.account_aged_trial_balance_webkit' + + def _getBaseFilters(self): + fy_id = self.model._get_current_fiscalyear() + vals = self.model.onchange_fiscalyear(fiscalyear=fy_id)['value'] + vals.update({'fiscalyear_id': fy_id}) + return vals + + def test_common(self): + common_tests = [ + x for x in dir(self) + if callable(getattr(self, x)) and x.startswith('common_test_')] + for test in common_tests: + getattr(self, test)() diff --git a/account_financial_report_webkit/tests/test_common.py b/account_financial_report_webkit/tests/test_common.py new file mode 100644 index 00000000..f005fbd5 --- /dev/null +++ b/account_financial_report_webkit/tests/test_common.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2017 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from openerp.tests.common import TransactionCase + + +class TestCommon(TransactionCase): + """ Common tests for all reports """ + + def setUp(self): + super(TestCommon, self).setUp() + self.model = self.env[self._getReportModel()] + self.report_name = self._getReportName() + wiz_vals = {'chart_account_id': self.env.ref('account.chart0').id} + wiz_vals.update(self._getBaseFilters()) + self.report = self.model.create(wiz_vals) + + def common_test_01_generation_report(self): + """ Check if report is correctly generated """ + + # Check if returned report action is correct + report_action = self.report.check_report() + self.assertDictContainsSubset( + {'type': 'ir.actions.report.xml', + 'report_name': self.report_name}, + report_action) + + def _getReportModel(self): + """ + :return: the report model name + """ + raise NotImplementedError() + + def _getReportName(self): + """ + :return: the xls report name + """ + raise NotImplementedError() + + def _getBaseFilters(self): + """ + :return: the minimum required filters to generate report + """ + raise NotImplementedError() diff --git a/account_financial_report_webkit/tests/test_general_leger.py b/account_financial_report_webkit/tests/test_general_leger.py new file mode 100644 index 00000000..16f7a720 --- /dev/null +++ b/account_financial_report_webkit/tests/test_general_leger.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2017 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from .test_common import TestCommon + + +class TestGeneralLedger(TestCommon): + + def _getReportModel(self): + return 'general.ledger.webkit' + + def _getReportName(self): + return 'account.account_report_general_ledger_webkit' + + def _getBaseFilters(self): + return {} + + def test_common(self): + common_tests = [ + x for x in dir(self) + if callable(getattr(self, x)) and x.startswith('common_test_')] + for test in common_tests: + getattr(self, test)() diff --git a/account_financial_report_webkit/tests/test_journal.py b/account_financial_report_webkit/tests/test_journal.py new file mode 100644 index 00000000..931b161b --- /dev/null +++ b/account_financial_report_webkit/tests/test_journal.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2017 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from .test_common import TestCommon + + +class TestGeneralLedger(TestCommon): + + def _getReportModel(self): + return 'print.journal.webkit' + + def _getReportName(self): + return 'account.account_report_print_journal_webkit' + + def _getBaseFilters(self): + fy_id = self.model._get_fiscalyear() + vals = self.model.onchange_filter( + filter='filter_period', fiscalyear_id=fy_id)['value'] + vals.update({'fiscalyear_id': fy_id}) + return vals + + def test_common(self): + common_tests = [ + x for x in dir(self) + if callable(getattr(self, x)) and x.startswith('common_test_')] + for test in common_tests: + getattr(self, test)() diff --git a/account_financial_report_webkit/tests/test_open_invoices.py b/account_financial_report_webkit/tests/test_open_invoices.py new file mode 100644 index 00000000..527a2257 --- /dev/null +++ b/account_financial_report_webkit/tests/test_open_invoices.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2017 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from datetime import datetime +from .test_common import TestCommon + + +class TestOpenInvoices(TestCommon): + + def _getReportModel(self): + return 'open.invoices.webkit' + + def _getReportName(self): + return 'account.account_report_open_invoices_webkit' + + def _getBaseFilters(self): + return {'until_date': '%s-12-31' % (datetime.now().year)} + + def test_common(self): + common_tests = [ + x for x in dir(self) + if callable(getattr(self, x)) and x.startswith('common_test_')] + for test in common_tests: + getattr(self, test)() diff --git a/account_financial_report_webkit/tests/test_partner_balance.py b/account_financial_report_webkit/tests/test_partner_balance.py new file mode 100644 index 00000000..1864de41 --- /dev/null +++ b/account_financial_report_webkit/tests/test_partner_balance.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2017 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from .test_common import TestCommon + + +class TestPartnerBalance(TestCommon): + + def _getReportModel(self): + return 'partner.balance.webkit' + + def _getReportName(self): + return 'account.account_report_partner_balance_webkit' + + def _getBaseFilters(self): + return {} + + def test_common(self): + common_tests = [ + x for x in dir(self) + if callable(getattr(self, x)) and x.startswith('common_test_')] + for test in common_tests: + getattr(self, test)() diff --git a/account_financial_report_webkit/tests/test_partner_ledger.py b/account_financial_report_webkit/tests/test_partner_ledger.py new file mode 100644 index 00000000..97a050b7 --- /dev/null +++ b/account_financial_report_webkit/tests/test_partner_ledger.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2017 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from .test_common import TestCommon + + +class TestPartnerLedger(TestCommon): + + def _getReportModel(self): + return 'partners.ledger.webkit' + + def _getReportName(self): + return 'account.account_report_partners_ledger_webkit' + + def _getBaseFilters(self): + return {} + + def test_common(self): + common_tests = [ + x for x in dir(self) + if callable(getattr(self, x)) and x.startswith('common_test_')] + for test in common_tests: + getattr(self, test)() diff --git a/account_financial_report_webkit/tests/test_trial_balance.py b/account_financial_report_webkit/tests/test_trial_balance.py new file mode 100644 index 00000000..19546acb --- /dev/null +++ b/account_financial_report_webkit/tests/test_trial_balance.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2017 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from .test_common import TestCommon + + +class TestTrialBalance(TestCommon): + + def _getReportModel(self): + return 'trial.balance.webkit' + + def _getReportName(self): + return 'account.account_report_trial_balance_webkit' + + def _getBaseFilters(self): + return {} + + def test_common(self): + common_tests = [ + x for x in dir(self) + if callable(getattr(self, x)) and x.startswith('common_test_')] + for test in common_tests: + getattr(self, test)() diff --git a/account_financial_report_webkit/wizard/__init__.py b/account_financial_report_webkit/wizard/__init__.py index 341da9a8..cf2b2645 100644 --- a/account_financial_report_webkit/wizard/__init__.py +++ b/account_financial_report_webkit/wizard/__init__.py @@ -1,25 +1,4 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Author: Nicolas Bessi. Copyright Camptocamp SA -# Copyright (C) 2012 SYLEAM Info Services () -# Sebastien LANGE -# -# 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 . -# -############################################################################## - +# -*- coding: utf-8 -*- from . import balance_common from . import general_ledger_wizard from . import partners_ledger_wizard @@ -29,3 +8,6 @@ from . import open_invoices_wizard from . import aged_open_invoices_wizard from . import print_journal from . import aged_partner_balance_wizard +# uncomment import infra when running Odoo without +# PR https://github.com/odoo/odoo/pull/14891 +# from . import account_common_report_fix diff --git a/account_financial_report_webkit/wizard/account_common_report_fix.py b/account_financial_report_webkit/wizard/account_common_report_fix.py new file mode 100644 index 00000000..285faabe --- /dev/null +++ b/account_financial_report_webkit/wizard/account_common_report_fix.py @@ -0,0 +1,121 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2017 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +""" +Bypass of bug in Odoo: +The financial reports do not work on first and last day of the Fiscal Year. +This fix can be removed after merge of +PR https://github.com/odoo/odoo/pull/14891. +""" +import logging +import time +from openerp import api, fields, models +_logger = logging.getLogger(__name__) + + +class AccountCommonReportFix(object): + + @api.model + def _default_fiscalyear_id(self): + _logger.debug( + '%s, fix cf. PR https://github.com/odoo/odoo/pull/14891', + self._name) + fy_id = super(AccountCommonReportFix, self)._get_fiscalyear() + if fy_id: + return self.env['account.fiscalyear'].browse(fy_id) + + now = time.strftime('%Y-%m-%d') + ids = self._context.get('active_ids', []) + if ids and self._context.get('active_model') == 'account.account': + company = self.env['account.account'].browse(ids[0]) + else: # use current company id + company = self.env.user.company_id + domain = [('company_id', '=', company.id), + ('date_start', '<=', now), ('date_stop', '>=', now)] + return self.env['account.fiscalyear'].search(domain, limit=1) + + def onchange_chart_id(self, cr, uid, ids, + chart_account_id=False, context=None): + _logger.debug( + '%s, fix cf. PR https://github.com/odoo/odoo/pull/14891', + self._name) + res = super(AccountCommonReportFix, self).onchange_chart_id( + cr, uid, ids, chart_account_id=chart_account_id, context=context) + if not res.get('fiscalyear_id'): + if chart_account_id: + company_id = self.pool['account.account'].browse( + cr, uid, chart_account_id, context=context).company_id.id + now = time.strftime('%Y-%m-%d') + domain = [('company_id', '=', company_id), + ('date_start', '<=', now), ('date_stop', '>=', now)] + fiscalyears = self.pool['account.fiscalyear'].search( + cr, uid, domain, limit=1) + res['value'] = { + 'company_id': company_id, + 'fiscalyear_id': fiscalyears and fiscalyears[0] or False, + } + return res + + +class AccountReportGeneralLedgerWizard(AccountCommonReportFix, + models.TransientModel): + _inherit = 'general.ledger.webkit' + + fiscalyear_id = fields.Many2one( + default=lambda self: self._default_fiscalyear_id()) + + +class AgedOpenInvoice(AccountCommonReportFix, + models.TransientModel): + _inherit = 'aged.open.invoices.webkit' + + fiscalyear_id = fields.Many2one( + default=lambda self: self._default_fiscalyear_id()) + + +class AccountAgedTrialBalance(AccountCommonReportFix, + models.TransientModel): + _inherit = 'account.aged.trial.balance.webkit' + + # no fiscalyear_id in this one since the module has + # its own method for this. + + +class AccountReportOpenInvoicesWizard(AccountCommonReportFix, + models.TransientModel): + _inherit = 'open.invoices.webkit' + + fiscalyear_id = fields.Many2one( + default=lambda self: self._default_fiscalyear_id()) + + +class AccountPartnerBalanceWizard(AccountCommonReportFix, + models.TransientModel): + _inherit = 'partner.balance.webkit' + + fiscalyear_id = fields.Many2one( + default=lambda self: self._default_fiscalyear_id()) + + +class AccountReportPartnersLedgerWizard(AccountCommonReportFix, + models.TransientModel): + _inherit = 'partners.ledger.webkit' + + fiscalyear_id = fields.Many2one( + default=lambda self: self._default_fiscalyear_id()) + + +class AccountReportPrintJournalWizard(AccountCommonReportFix, + models.TransientModel): + _inherit = 'print.journal.webkit' + + fiscalyear_id = fields.Many2one( + default=lambda self: self._default_fiscalyear_id()) + + +class AccountTrialBalanceWizard(AccountCommonReportFix, + models.TransientModel): + _inherit = 'trial.balance.webkit' + + fiscalyear_id = fields.Many2one( + default=lambda self: self._default_fiscalyear_id()) diff --git a/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py b/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py index 2275b950..3bce5792 100644 --- a/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py +++ b/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py @@ -1,26 +1,7 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Author: Nicolas Bessi -# Copyright 2014 Camptocamp SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## -from datetime import date +# Copyright 2014 Camptocamp SA, Nicolas Bessi. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from openerp.osv import orm, fields -from openerp.tools import DEFAULT_SERVER_DATE_FORMAT as DATE_FORMAT class AccountAgedTrialBalance(orm.TransientModel): @@ -34,19 +15,7 @@ class AccountAgedTrialBalance(orm.TransientModel): _description = "Aged partner balanced" def _get_current_fiscalyear(self, cr, uid, context=None): - user_obj = self.pool['res.users'] - company = user_obj.browse(cr, uid, uid, context=context).company_id - fyear_obj = self.pool['account.period'] - today = date.today().strftime(DATE_FORMAT) - fyear_ids = fyear_obj.search( - cr, uid, - [('date_start', '>=', today), - ('date_stop', '<=', today), - ('company_id', '=', company.id)], - limit=1, - context=context) - if fyear_ids: - return fyear_ids[0] + return self.pool['account.fiscalyear'].find(cr, uid, context=context) _columns = { 'filter': fields.selection( diff --git a/account_financial_report_webkit_xls/README.rst b/account_financial_report_webkit_xls/README.rst new file mode 100644 index 00000000..deec2ae8 --- /dev/null +++ b/account_financial_report_webkit_xls/README.rst @@ -0,0 +1,64 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============================== +Financial Reports - XLS Export +============================== + +This module adds XLS export to the following accounting reports: + - General Ledger + - Trial Balance + - Partner Ledger + - Partner Balance + - Aged Partner Balance + - Open Invoices + +Installation +============ + +To install this module, you need also the **report_xls** +module located in: + +https://github.com/OCA/reporting-engine + +Usage +===== + +Use the 'Export' button on the financial report wizards to export the +data in Excel format. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/91/8.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smash it by providing detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ + +* Noviat + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/account_financial_report_webkit_xls/__openerp__.py b/account_financial_report_webkit_xls/__openerp__.py index ff8078d7..292e17f0 100644 --- a/account_financial_report_webkit_xls/__openerp__.py +++ b/account_financial_report_webkit_xls/__openerp__.py @@ -1,22 +1,12 @@ # -*- coding: utf-8 -*- -# Copyright 2009-2016 Noviat. +# Copyright 2009-2017 Noviat. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Add XLS export to accounting reports', - 'version': '8.0.0.5.0', + 'version': '8.0.1.0.0', 'license': 'AGPL-3', 'author': "Noviat,Odoo Community Association (OCA)", 'category': 'Generic Modules/Accounting', - 'description': """ - - This module adds XLS export to the following accounting reports: - - general ledger - - trial balance - - partner ledger - - partner balance - - open invoices - - """, 'depends': ['report_xls', 'account_financial_report_webkit'], 'demo': [], 'data': [ @@ -27,11 +17,11 @@ 'wizard/open_invoices_wizard_view.xml', 'wizard/aged_partner_balance_wizard.xml', ], - 'test': ['tests/general_ledger.yml', - 'tests/partner_ledger.yml', - 'tests/trial_balance.yml', - 'tests/partner_balance.yml', - 'tests/open_invoices.yml'], + 'test': ['test/general_ledger.yml', + 'test/partner_ledger.yml', + 'test/trial_balance.yml', + 'test/partner_balance.yml', + 'test/open_invoices.yml'], 'active': False, 'installable': True, } diff --git a/account_financial_report_webkit_xls/tests/general_ledger.yml b/account_financial_report_webkit_xls/test/general_ledger.yml similarity index 100% rename from account_financial_report_webkit_xls/tests/general_ledger.yml rename to account_financial_report_webkit_xls/test/general_ledger.yml diff --git a/account_financial_report_webkit_xls/tests/open_invoices.yml b/account_financial_report_webkit_xls/test/open_invoices.yml similarity index 100% rename from account_financial_report_webkit_xls/tests/open_invoices.yml rename to account_financial_report_webkit_xls/test/open_invoices.yml diff --git a/account_financial_report_webkit_xls/tests/partner_balance.yml b/account_financial_report_webkit_xls/test/partner_balance.yml similarity index 100% rename from account_financial_report_webkit_xls/tests/partner_balance.yml rename to account_financial_report_webkit_xls/test/partner_balance.yml diff --git a/account_financial_report_webkit_xls/tests/partner_ledger.yml b/account_financial_report_webkit_xls/test/partner_ledger.yml similarity index 100% rename from account_financial_report_webkit_xls/tests/partner_ledger.yml rename to account_financial_report_webkit_xls/test/partner_ledger.yml diff --git a/account_financial_report_webkit_xls/tests/trial_balance.yml b/account_financial_report_webkit_xls/test/trial_balance.yml similarity index 100% rename from account_financial_report_webkit_xls/tests/trial_balance.yml rename to account_financial_report_webkit_xls/test/trial_balance.yml diff --git a/account_financial_report_webkit_xls/tests/__init__.py b/account_financial_report_webkit_xls/tests/__init__.py new file mode 100644 index 00000000..7ebf9166 --- /dev/null +++ b/account_financial_report_webkit_xls/tests/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +from . import test_general_leger_xls +from . import test_partner_ledger_xls +from . import test_trial_balance_xls +from . import test_partner_balance_xls +from . import test_open_invoices_xls +from . import test_aged_partner_balance_xls diff --git a/account_financial_report_webkit_xls/tests/test_aged_partner_balance_xls.py b/account_financial_report_webkit_xls/tests/test_aged_partner_balance_xls.py new file mode 100644 index 00000000..d05a125f --- /dev/null +++ b/account_financial_report_webkit_xls/tests/test_aged_partner_balance_xls.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2017 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from .test_common_xls import TestCommonXls + + +class TestAgedPartnerBalanceXls(TestCommonXls): + + def _getReportModel(self): + return 'account.aged.trial.balance.webkit' + + def _getXlsReportName(self): + return 'account.account_report_aged_partner_balance_xls' + + def _getXlsReportActionName(self): + module = 'account_financial_report_webkit' + action = 'account_report_aged_trial_blanance_webkit' + return '%s.%s' % (module, action) + + def _getBaseFilters(self): + fy_id = self.model._get_current_fiscalyear() + vals = self.model.onchange_fiscalyear(fiscalyear=fy_id)['value'] + vals.update({'fiscalyear_id': fy_id}) + return vals + + def test_common(self): + common_tests = [ + x for x in dir(self) + if callable(getattr(self, x)) and x.startswith('common_test_')] + for test in common_tests: + getattr(self, test)() diff --git a/account_financial_report_webkit_xls/tests/test_common_xls.py b/account_financial_report_webkit_xls/tests/test_common_xls.py new file mode 100644 index 00000000..d8e88004 --- /dev/null +++ b/account_financial_report_webkit_xls/tests/test_common_xls.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2017 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from openerp.tests.common import TransactionCase + + +class TestCommonXls(TransactionCase): + """ Common tests for all XLS Exports """ + + def setUp(self): + super(TestCommonXls, self).setUp() + self.model = self.env[self._getReportModel()] + self.xls_report_name = self._getXlsReportName() + ctx = {'xls_export': 1} + self.xls_action_name = self._getXlsReportActionName() + self.xls_action = self.env.ref(self.xls_action_name).with_context(ctx) + wiz_vals = {'chart_account_id': self.env.ref('account.chart0').id} + wiz_vals.update(self._getBaseFilters()) + self.report = self.model.with_context(ctx).create(wiz_vals) + + def common_test_01_action_xls(self): + """ Check if report XLS action is correct """ + report_action = self.report.xls_export() + self.assertDictContainsSubset( + {'type': 'ir.actions.report.xml', + 'report_name': self.xls_report_name}, + report_action) + self.render_dict = report_action['datas'] + + def common_test_02_render_xls(self): + report_xls = self.xls_action.render_report( + self.report.ids, + self.xls_report_name, + self.render_dict) + self.assertGreaterEqual(len(report_xls[0]), 1) + self.assertEqual(report_xls[1], 'xls') + + def _getReportModel(self): + """ + :return: the report model name + """ + raise NotImplementedError() + + def _getXlsReportName(self): + """ + :return: the xls report name + """ + raise NotImplementedError() + + def _getXlsReportActionName(self): + """ + :return: the xls report action name + """ + raise NotImplementedError() + + def _getBaseFilters(self): + """ + :return: the minimum required filters to generate report + """ + raise NotImplementedError() diff --git a/account_financial_report_webkit_xls/tests/test_general_leger_xls.py b/account_financial_report_webkit_xls/tests/test_general_leger_xls.py new file mode 100644 index 00000000..af12a4c6 --- /dev/null +++ b/account_financial_report_webkit_xls/tests/test_general_leger_xls.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2017 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from .test_common_xls import TestCommonXls + + +class TestGeneralLedgerXls(TestCommonXls): + + def _getReportModel(self): + return 'general.ledger.webkit' + + def _getXlsReportName(self): + return 'account.account_report_general_ledger_xls' + + def _getXlsReportActionName(self): + module = 'account_financial_report_webkit' + action = 'account_report_general_ledger_webkit' + return '%s.%s' % (module, action) + + def _getBaseFilters(self): + return {} + + def test_common(self): + common_tests = [ + x for x in dir(self) + if callable(getattr(self, x)) and x.startswith('common_test_')] + for test in common_tests: + getattr(self, test)() diff --git a/account_financial_report_webkit_xls/tests/test_open_invoices_xls.py b/account_financial_report_webkit_xls/tests/test_open_invoices_xls.py new file mode 100644 index 00000000..d14bbfd7 --- /dev/null +++ b/account_financial_report_webkit_xls/tests/test_open_invoices_xls.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2017 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from datetime import datetime +from .test_common_xls import TestCommonXls + + +class TestOpenInvoicesXls(TestCommonXls): + + def _getReportModel(self): + return 'open.invoices.webkit' + + def _getXlsReportName(self): + return 'account.account_report_open_invoices_xls' + + def _getXlsReportActionName(self): + module = 'account_financial_report_webkit' + action = 'account_report_open_invoices_webkit' + return '%s.%s' % (module, action) + + def _getBaseFilters(self): + return {'until_date': '%s-12-31' % (datetime.now().year)} + + def test_common(self): + common_tests = [ + x for x in dir(self) + if callable(getattr(self, x)) and x.startswith('common_test_')] + for test in common_tests: + getattr(self, test)() diff --git a/account_financial_report_webkit_xls/tests/test_partner_balance_xls.py b/account_financial_report_webkit_xls/tests/test_partner_balance_xls.py new file mode 100644 index 00000000..d4e2f807 --- /dev/null +++ b/account_financial_report_webkit_xls/tests/test_partner_balance_xls.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2017 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from .test_common_xls import TestCommonXls + + +class TestPartnerBalanceXls(TestCommonXls): + + def _getReportModel(self): + return 'partner.balance.webkit' + + def _getXlsReportName(self): + return 'account.account_report_partner_balance_xls' + + def _getXlsReportActionName(self): + module = 'account_financial_report_webkit' + action = 'account_report_partner_balance_webkit' + return '%s.%s' % (module, action) + + def _getBaseFilters(self): + return {} + + def test_common(self): + common_tests = [ + x for x in dir(self) + if callable(getattr(self, x)) and x.startswith('common_test_')] + for test in common_tests: + getattr(self, test)() diff --git a/account_financial_report_webkit_xls/tests/test_partner_ledger_xls.py b/account_financial_report_webkit_xls/tests/test_partner_ledger_xls.py new file mode 100644 index 00000000..fbd0d568 --- /dev/null +++ b/account_financial_report_webkit_xls/tests/test_partner_ledger_xls.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2017 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from .test_common_xls import TestCommonXls + + +class TestPartnerLedgerXls(TestCommonXls): + + def _getReportModel(self): + return 'partners.ledger.webkit' + + def _getXlsReportName(self): + return 'account.account_report_partner_ledger_xls' + + def _getXlsReportActionName(self): + module = 'account_financial_report_webkit' + action = 'account_report_partners_ledger_webkit' + return '%s.%s' % (module, action) + + def _getBaseFilters(self): + return {} + + def test_common(self): + common_tests = [ + x for x in dir(self) + if callable(getattr(self, x)) and x.startswith('common_test_')] + for test in common_tests: + getattr(self, test)() diff --git a/account_financial_report_webkit_xls/tests/test_trial_balance_xls.py b/account_financial_report_webkit_xls/tests/test_trial_balance_xls.py new file mode 100644 index 00000000..1b989783 --- /dev/null +++ b/account_financial_report_webkit_xls/tests/test_trial_balance_xls.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2017 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from .test_common_xls import TestCommonXls + + +class TestTrialBalanceXls(TestCommonXls): + + def _getReportModel(self): + return 'trial.balance.webkit' + + def _getXlsReportName(self): + return 'account.account_report_trial_balance_xls' + + def _getXlsReportActionName(self): + module = 'account_financial_report_webkit' + action = 'account_report_trial_balance_webkit' + return '%s.%s' % (module, action) + + def _getBaseFilters(self): + return {} + + def test_common(self): + common_tests = [ + x for x in dir(self) + if callable(getattr(self, x)) and x.startswith('common_test_')] + for test in common_tests: + getattr(self, test)() diff --git a/account_journal_report_xls/wizard/__init__.py b/account_journal_report_xls/wizard/__init__.py index 406a7a8f..347f6753 100644 --- a/account_journal_report_xls/wizard/__init__.py +++ b/account_journal_report_xls/wizard/__init__.py @@ -1,23 +1,3 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# -# Copyright (c) 2014 Noviat nv/sa (www.noviat.com). All rights reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - +# -*- coding: utf-8 -*- from . import print_journal_wizard +from . import account_common_report_fix diff --git a/account_journal_report_xls/wizard/account_common_report_fix.py b/account_journal_report_xls/wizard/account_common_report_fix.py new file mode 100644 index 00000000..e777061d --- /dev/null +++ b/account_journal_report_xls/wizard/account_common_report_fix.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2017 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +""" +Bypass of bug in Odoo: +The financial reports do not work on first and last day of the Fiscal Year. +This fix can be removed after merge of +PR https://github.com/odoo/odoo/pull/14891. +""" +import logging +import time +from openerp import api, fields, models +_logger = logging.getLogger(__name__) + + +class AccountCommonReportFix(object): + + @api.model + def _default_fiscalyear_id(self): + _logger.debug( + '%s, fix cf. PR https://github.com/odoo/odoo/pull/14891', + self._name) + fy_id = super(AccountCommonReportFix, self)._get_fiscalyear() + if fy_id: + return self.env['account.fiscalyear'].browse(fy_id) + + now = time.strftime('%Y-%m-%d') + ids = self._context.get('active_ids', []) + if ids and self._context.get('active_model') == 'account.account': + company = self.env['account.account'].browse(ids[0]) + else: # use current company id + company = self.env.user.company_id + domain = [('company_id', '=', company.id), + ('date_start', '<=', now), ('date_stop', '>=', now)] + return self.env['account.fiscalyear'].search(domain, limit=1) + + def onchange_chart_id(self, cr, uid, ids, + chart_account_id=False, context=None): + _logger.debug( + '%s, fix cf. PR https://github.com/odoo/odoo/pull/14891', + self._name) + res = super(AccountCommonReportFix, self).onchange_chart_id( + cr, uid, ids, chart_account_id=chart_account_id, context=context) + if not res.get('fiscalyear_id'): + if chart_account_id: + company_id = self.pool['account.account'].browse( + cr, uid, chart_account_id, context=context).company_id.id + now = time.strftime('%Y-%m-%d') + domain = [('company_id', '=', company_id), + ('date_start', '<=', now), ('date_stop', '>=', now)] + fiscalyears = self.pool['account.fiscalyear'].search( + cr, uid, domain, limit=1) + res['value'] = { + 'company_id': company_id, + 'fiscalyear_id': fiscalyears and fiscalyears[0] or False, + } + return res + + +class AccountPrintJournalXls(AccountCommonReportFix, + models.TransientModel): + _inherit = 'account.print.journal.xls' + + fiscalyear_id = fields.Many2one( + default=lambda self: self._default_fiscalyear_id()) From 472b8d83ff0676d054c4025de5cbb44c42ab4750 Mon Sep 17 00:00:00 2001 From: luc-demeyer Date: Sun, 12 Mar 2017 08:28:27 +0100 Subject: [PATCH 4/8] [DEL] fy fix since merged upstream --- .../wizard/__init__.py | 3 - .../wizard/account_common_report_fix.py | 121 ------------------ account_journal_report_xls/wizard/__init__.py | 1 - .../wizard/account_common_report_fix.py | 65 ---------- 4 files changed, 190 deletions(-) delete mode 100644 account_financial_report_webkit/wizard/account_common_report_fix.py delete mode 100644 account_journal_report_xls/wizard/account_common_report_fix.py diff --git a/account_financial_report_webkit/wizard/__init__.py b/account_financial_report_webkit/wizard/__init__.py index cf2b2645..2fd101b2 100644 --- a/account_financial_report_webkit/wizard/__init__.py +++ b/account_financial_report_webkit/wizard/__init__.py @@ -8,6 +8,3 @@ from . import open_invoices_wizard from . import aged_open_invoices_wizard from . import print_journal from . import aged_partner_balance_wizard -# uncomment import infra when running Odoo without -# PR https://github.com/odoo/odoo/pull/14891 -# from . import account_common_report_fix diff --git a/account_financial_report_webkit/wizard/account_common_report_fix.py b/account_financial_report_webkit/wizard/account_common_report_fix.py deleted file mode 100644 index 285faabe..00000000 --- a/account_financial_report_webkit/wizard/account_common_report_fix.py +++ /dev/null @@ -1,121 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2009-2017 Noviat. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -""" -Bypass of bug in Odoo: -The financial reports do not work on first and last day of the Fiscal Year. -This fix can be removed after merge of -PR https://github.com/odoo/odoo/pull/14891. -""" -import logging -import time -from openerp import api, fields, models -_logger = logging.getLogger(__name__) - - -class AccountCommonReportFix(object): - - @api.model - def _default_fiscalyear_id(self): - _logger.debug( - '%s, fix cf. PR https://github.com/odoo/odoo/pull/14891', - self._name) - fy_id = super(AccountCommonReportFix, self)._get_fiscalyear() - if fy_id: - return self.env['account.fiscalyear'].browse(fy_id) - - now = time.strftime('%Y-%m-%d') - ids = self._context.get('active_ids', []) - if ids and self._context.get('active_model') == 'account.account': - company = self.env['account.account'].browse(ids[0]) - else: # use current company id - company = self.env.user.company_id - domain = [('company_id', '=', company.id), - ('date_start', '<=', now), ('date_stop', '>=', now)] - return self.env['account.fiscalyear'].search(domain, limit=1) - - def onchange_chart_id(self, cr, uid, ids, - chart_account_id=False, context=None): - _logger.debug( - '%s, fix cf. PR https://github.com/odoo/odoo/pull/14891', - self._name) - res = super(AccountCommonReportFix, self).onchange_chart_id( - cr, uid, ids, chart_account_id=chart_account_id, context=context) - if not res.get('fiscalyear_id'): - if chart_account_id: - company_id = self.pool['account.account'].browse( - cr, uid, chart_account_id, context=context).company_id.id - now = time.strftime('%Y-%m-%d') - domain = [('company_id', '=', company_id), - ('date_start', '<=', now), ('date_stop', '>=', now)] - fiscalyears = self.pool['account.fiscalyear'].search( - cr, uid, domain, limit=1) - res['value'] = { - 'company_id': company_id, - 'fiscalyear_id': fiscalyears and fiscalyears[0] or False, - } - return res - - -class AccountReportGeneralLedgerWizard(AccountCommonReportFix, - models.TransientModel): - _inherit = 'general.ledger.webkit' - - fiscalyear_id = fields.Many2one( - default=lambda self: self._default_fiscalyear_id()) - - -class AgedOpenInvoice(AccountCommonReportFix, - models.TransientModel): - _inherit = 'aged.open.invoices.webkit' - - fiscalyear_id = fields.Many2one( - default=lambda self: self._default_fiscalyear_id()) - - -class AccountAgedTrialBalance(AccountCommonReportFix, - models.TransientModel): - _inherit = 'account.aged.trial.balance.webkit' - - # no fiscalyear_id in this one since the module has - # its own method for this. - - -class AccountReportOpenInvoicesWizard(AccountCommonReportFix, - models.TransientModel): - _inherit = 'open.invoices.webkit' - - fiscalyear_id = fields.Many2one( - default=lambda self: self._default_fiscalyear_id()) - - -class AccountPartnerBalanceWizard(AccountCommonReportFix, - models.TransientModel): - _inherit = 'partner.balance.webkit' - - fiscalyear_id = fields.Many2one( - default=lambda self: self._default_fiscalyear_id()) - - -class AccountReportPartnersLedgerWizard(AccountCommonReportFix, - models.TransientModel): - _inherit = 'partners.ledger.webkit' - - fiscalyear_id = fields.Many2one( - default=lambda self: self._default_fiscalyear_id()) - - -class AccountReportPrintJournalWizard(AccountCommonReportFix, - models.TransientModel): - _inherit = 'print.journal.webkit' - - fiscalyear_id = fields.Many2one( - default=lambda self: self._default_fiscalyear_id()) - - -class AccountTrialBalanceWizard(AccountCommonReportFix, - models.TransientModel): - _inherit = 'trial.balance.webkit' - - fiscalyear_id = fields.Many2one( - default=lambda self: self._default_fiscalyear_id()) diff --git a/account_journal_report_xls/wizard/__init__.py b/account_journal_report_xls/wizard/__init__.py index 347f6753..29d7eb8a 100644 --- a/account_journal_report_xls/wizard/__init__.py +++ b/account_journal_report_xls/wizard/__init__.py @@ -1,3 +1,2 @@ # -*- coding: utf-8 -*- from . import print_journal_wizard -from . import account_common_report_fix diff --git a/account_journal_report_xls/wizard/account_common_report_fix.py b/account_journal_report_xls/wizard/account_common_report_fix.py deleted file mode 100644 index e777061d..00000000 --- a/account_journal_report_xls/wizard/account_common_report_fix.py +++ /dev/null @@ -1,65 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2009-2017 Noviat. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -""" -Bypass of bug in Odoo: -The financial reports do not work on first and last day of the Fiscal Year. -This fix can be removed after merge of -PR https://github.com/odoo/odoo/pull/14891. -""" -import logging -import time -from openerp import api, fields, models -_logger = logging.getLogger(__name__) - - -class AccountCommonReportFix(object): - - @api.model - def _default_fiscalyear_id(self): - _logger.debug( - '%s, fix cf. PR https://github.com/odoo/odoo/pull/14891', - self._name) - fy_id = super(AccountCommonReportFix, self)._get_fiscalyear() - if fy_id: - return self.env['account.fiscalyear'].browse(fy_id) - - now = time.strftime('%Y-%m-%d') - ids = self._context.get('active_ids', []) - if ids and self._context.get('active_model') == 'account.account': - company = self.env['account.account'].browse(ids[0]) - else: # use current company id - company = self.env.user.company_id - domain = [('company_id', '=', company.id), - ('date_start', '<=', now), ('date_stop', '>=', now)] - return self.env['account.fiscalyear'].search(domain, limit=1) - - def onchange_chart_id(self, cr, uid, ids, - chart_account_id=False, context=None): - _logger.debug( - '%s, fix cf. PR https://github.com/odoo/odoo/pull/14891', - self._name) - res = super(AccountCommonReportFix, self).onchange_chart_id( - cr, uid, ids, chart_account_id=chart_account_id, context=context) - if not res.get('fiscalyear_id'): - if chart_account_id: - company_id = self.pool['account.account'].browse( - cr, uid, chart_account_id, context=context).company_id.id - now = time.strftime('%Y-%m-%d') - domain = [('company_id', '=', company_id), - ('date_start', '<=', now), ('date_stop', '>=', now)] - fiscalyears = self.pool['account.fiscalyear'].search( - cr, uid, domain, limit=1) - res['value'] = { - 'company_id': company_id, - 'fiscalyear_id': fiscalyears and fiscalyears[0] or False, - } - return res - - -class AccountPrintJournalXls(AccountCommonReportFix, - models.TransientModel): - _inherit = 'account.print.journal.xls' - - fiscalyear_id = fields.Many2one( - default=lambda self: self._default_fiscalyear_id()) From 21ed5b95675d9c6e8225357032f6d04c132e5c63 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 28 Sep 2017 15:33:18 +0200 Subject: [PATCH 5/8] [DEL] nonworking view adaptions --- .../wizard/aged_partner_balance_wizard.xml | 3 --- .../wizard/general_ledger_wizard_view.xml | 3 --- .../wizard/open_invoices_wizard_view.xml | 3 --- .../wizard/partners_balance_wizard_view.xml | 6 ------ .../wizard/partners_ledger_wizard_view.xml | 3 --- .../wizard/trial_balance_wizard_view.xml | 3 --- 6 files changed, 21 deletions(-) diff --git a/account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.xml b/account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.xml index 7d52859f..f4965a7c 100644 --- a/account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.xml +++ b/account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.xml @@ -8,9 +8,6 @@ form - - 6 - diff --git a/account_financial_report_webkit_xls/wizard/general_ledger_wizard_view.xml b/account_financial_report_webkit_xls/wizard/general_ledger_wizard_view.xml index 8eb805db..dd6a53a7 100644 --- a/account_financial_report_webkit_xls/wizard/general_ledger_wizard_view.xml +++ b/account_financial_report_webkit_xls/wizard/general_ledger_wizard_view.xml @@ -11,9 +11,6 @@ - - 6 - diff --git a/account_financial_report_webkit_xls/wizard/open_invoices_wizard_view.xml b/account_financial_report_webkit_xls/wizard/open_invoices_wizard_view.xml index c73e1346..1430e727 100644 --- a/account_financial_report_webkit_xls/wizard/open_invoices_wizard_view.xml +++ b/account_financial_report_webkit_xls/wizard/open_invoices_wizard_view.xml @@ -11,9 +11,6 @@ - - 6 - diff --git a/account_financial_report_webkit_xls/wizard/partners_balance_wizard_view.xml b/account_financial_report_webkit_xls/wizard/partners_balance_wizard_view.xml index d6a00f98..163d9c1f 100644 --- a/account_financial_report_webkit_xls/wizard/partners_balance_wizard_view.xml +++ b/account_financial_report_webkit_xls/wizard/partners_balance_wizard_view.xml @@ -8,12 +8,6 @@ form - - - - 6 - diff --git a/account_financial_report_webkit_xls/wizard/partners_ledger_wizard_view.xml b/account_financial_report_webkit_xls/wizard/partners_ledger_wizard_view.xml index a1c2f18e..86201acf 100644 --- a/account_financial_report_webkit_xls/wizard/partners_ledger_wizard_view.xml +++ b/account_financial_report_webkit_xls/wizard/partners_ledger_wizard_view.xml @@ -11,9 +11,6 @@ - - 6 - diff --git a/account_financial_report_webkit_xls/wizard/trial_balance_wizard_view.xml b/account_financial_report_webkit_xls/wizard/trial_balance_wizard_view.xml index cd0cd345..e2828c71 100644 --- a/account_financial_report_webkit_xls/wizard/trial_balance_wizard_view.xml +++ b/account_financial_report_webkit_xls/wizard/trial_balance_wizard_view.xml @@ -11,9 +11,6 @@ - - 6 - From e49aa0cedd983e5966dbdac42dad67373a81e983 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 14 Dec 2017 14:06:14 +0100 Subject: [PATCH 6/8] [ADD] aged open invoices --- .../__openerp__.py | 1 + .../report/__init__.py | 1 + .../report/aged_open_invoices_xls.py | 280 ++++++++++++++++++ .../tests/__init__.py | 1 + .../tests/test_aged_open_invoices_xls.py | 33 +++ .../wizard/__init__.py | 1 + .../wizard/aged_open_invoices_wizard.py | 25 ++ .../wizard/aged_open_invoices_wizard.xml | 17 ++ 8 files changed, 359 insertions(+) create mode 100644 account_financial_report_webkit_xls/report/aged_open_invoices_xls.py create mode 100644 account_financial_report_webkit_xls/tests/test_aged_open_invoices_xls.py create mode 100644 account_financial_report_webkit_xls/wizard/aged_open_invoices_wizard.py create mode 100644 account_financial_report_webkit_xls/wizard/aged_open_invoices_wizard.xml diff --git a/account_financial_report_webkit_xls/__openerp__.py b/account_financial_report_webkit_xls/__openerp__.py index 292e17f0..eebbd67c 100644 --- a/account_financial_report_webkit_xls/__openerp__.py +++ b/account_financial_report_webkit_xls/__openerp__.py @@ -16,6 +16,7 @@ 'wizard/partners_balance_wizard_view.xml', 'wizard/open_invoices_wizard_view.xml', 'wizard/aged_partner_balance_wizard.xml', + 'wizard/aged_open_invoices_wizard.xml', ], 'test': ['test/general_ledger.yml', 'test/partner_ledger.yml', diff --git a/account_financial_report_webkit_xls/report/__init__.py b/account_financial_report_webkit_xls/report/__init__.py index 302e50c7..4b766662 100644 --- a/account_financial_report_webkit_xls/report/__init__.py +++ b/account_financial_report_webkit_xls/report/__init__.py @@ -5,3 +5,4 @@ from . import partners_balance_xls from . import partner_ledger_xls from . import open_invoices_xls from . import aged_partner_balance_xls +from . import aged_open_invoices_xls diff --git a/account_financial_report_webkit_xls/report/aged_open_invoices_xls.py b/account_financial_report_webkit_xls/report/aged_open_invoices_xls.py new file mode 100644 index 00000000..dfc7f402 --- /dev/null +++ b/account_financial_report_webkit_xls/report/aged_open_invoices_xls.py @@ -0,0 +1,280 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2016 Noviat. +# Copyright 2017 Therp BV. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import xlwt +from openerp.addons.report_xls.report_xls import report_xls +from openerp.addons.report_xls.utils import rowcol_to_cell +from openerp.addons.account_financial_report_webkit.report \ + .aged_open_invoices import AccountAgedOpenInvoicesWebkit +from openerp.tools.translate import _ +# import logging +# _logger = logging.getLogger(__name__) + + +class AccountAgedOpenInvoicesWebkitXls(report_xls): + + def create(self, cr, uid, ids, data, context=None): + self._column_sizes = [ + 30, # Partner + 20, # Partner Code + 20, # Balance + 20, # Due + 20, # Overdue 0-30 + 20, # Overdue 30-60 + 20, # Overdue 60-90 + 20, # Overdue 90-120 + 20, # Overdue 120+ + ] + self._balance_pos = 2 + return super(AccountAgedOpenInvoicesWebkitXls, self).create( + cr, uid, ids, data, context=context) + + def _cell_styles(self, _xs): + self._style_title = xlwt.easyxf(_xs['xls_title']) + self._style_bold_blue_center = xlwt.easyxf( + _xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] + + _xs['center']) + self._style_center = xlwt.easyxf( + _xs['borders_all'] + _xs['wrap'] + _xs['center']) + + format_yellow_bold = _xs['bold'] + _xs['fill'] + _xs['borders_all'] + self._style_account_title = xlwt.easyxf( + format_yellow_bold + _xs['xls_title']) + self._style_yellow_bold = xlwt.easyxf(format_yellow_bold) + self._style_yellow_bold_right = xlwt.easyxf( + format_yellow_bold + _xs['right']) + self._style_yellow_bold_decimal = xlwt.easyxf( + format_yellow_bold + _xs['right'], + num_format_str=report_xls.decimal_format) + + self._style_default = xlwt.easyxf(_xs['borders_all']) + self._style_decimal = xlwt.easyxf( + _xs['borders_all'] + _xs['right'], + num_format_str=report_xls.decimal_format) + self._style_percent = xlwt.easyxf( + _xs['borders_all'] + _xs['right'], + num_format_str='0.00%') + + def _setup_worksheet(self, _p, _xs, data, wb): + self.ws = wb.add_sheet(_p.report_name[:31]) + self.ws.panes_frozen = True + self.ws.remove_splits = True + self.ws.portrait = 0 # Landscape + self.ws.fit_width_to_pages = 1 + self.ws.header_str = self.xls_headers['standard'] + self.ws.footer_str = self.xls_footers['standard'] + + def _print_title(self, _p, _xs, data, row_pos): + report_name = ' - '.join( + [_p.report_name.upper(), + _p.company.partner_id.name, + _p.company.currency_id.name]) + c_specs = [ + ('report_name', 1, 0, 'text', report_name), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row( + self.ws, row_pos, row_data, row_style=self._style_title) + return row_pos + + def _print_empty_row(self, _p, _xs, data, row_pos): + """ + Print empty row to define column sizes + """ + c_specs = [('empty%s' % i, 1, self._column_sizes[i], 'text', None) + for i in range(len(self._column_sizes))] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row( + self.ws, row_pos, row_data, set_column_size=True) + return row_pos + + def _print_header_title(self, _p, _xs, data, row_pos): + c_specs = [ + ('coa', 1, 0, 'text', _('Chart of Account')), + ('fy', 1, 0, 'text', _('Fiscal Year')), + ('period_filter', 2, 0, 'text', _('Periods Filter')), + ('cd', 1, 0, 'text', _('Clearance Date')), + ('account_filter', 2, 0, 'text', _('Accounts Filter')), + ('partner_filter', 1, 0, 'text', _('Partners Filter')), + ('tm', 1, 0, 'text', _('Target Moves')), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row( + self.ws, row_pos, row_data, + row_style=self._style_bold_blue_center) + return row_pos + + def _print_header_data(self, _p, _xs, data, row_pos): + period_filter = _('From') + ': ' + period_filter += _p.start_period.name if _p.start_period else u'' + period_filter += ' ' + _('To') + ': ' + period_filter += _p.stop_period.name if _p.stop_period else u'' + c_specs = [ + ('coa', 1, 0, 'text', _p.chart_account.name), + ('fy', 1, 0, 'text', + _p.fiscalyear.name if _p.fiscalyear else '-'), + ('period_filter', 2, 0, 'text', period_filter), + ('cd', 1, 0, 'text', _p.date_until), + ('account_filter', 2, 0, 'text', + _p.display_partner_account(data)), + ('partner_filter', 1, 0, 'text', + _('Selected Partners') if _p.partner_ids else '-'), + ('tm', 1, 0, 'text', + _p.display_target_move(data)), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row( + self.ws, row_pos, row_data, row_style=self._style_center) + return row_pos + + def _print_header(self, _p, _xs, data, row_pos): + """ + Header Table: Chart of Account, Fiscal year, Filters, ... + """ + row_pos = self._print_header_title(_p, _xs, data, row_pos) + row_pos = self._print_header_data(_p, _xs, data, row_pos) + self.ws.set_horz_split_pos(row_pos) # freeze the line + return row_pos + 1 + + def _print_account_header(self, _p, _xs, data, row_pos, account): + """ + Fill in a row with the code and name of the account + """ + c_specs = [ + ('acc_title', len(self._column_sizes), 0, 'text', + ' - '.join([account.code, account.name])), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row( + self.ws, row_pos, row_data, self._style_account_title) + return row_pos + 1 + + def _print_partner_header(self, _p, _xs, data, row_pos): + """ + Partner header line + """ + c_specs = [ + ('partner_h', 1, 0, 'text', _('Partner'), + None, self._style_yellow_bold), + ('pcode_h', 1, 0, 'text', _('Code'), + None, self._style_yellow_bold), + ('balance_h', 1, 0, 'text', _('Balance')), + ('due_h', 1, 0, 'text', _('Due'))] + for days in [30, 60, 90, 120]: + entry = 'od_%s_h' % days + label = _("Overdue ≤ %s d.") % days + c_specs += [(entry, 1, 0, 'text', label)] + c_specs += [('older_h', 1, 0, 'text', _("Older"))] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row( + self.ws, row_pos, row_data, + row_style=self._style_yellow_bold_right) + return row_pos + + def _print_partner_line(self, _p, _xs, data, row_pos, partner, line): + """ + Partner data line + """ + partner_name, p_id, p_ref, p_name = partner + c_specs = [ + ('partner', 1, 0, 'text', p_name, + None, self._style_default), + ('pcode', 1, 0, 'text', p_ref, + None, self._style_default), + ('balance', 1, 0, 'number', line['balance'])] + for r in _p.ranges: + entry = 'od_%s' % r[0] + c_specs += [(entry, 1, 0, 'number', line[r])] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row( + self.ws, row_pos, row_data, + row_style=self._style_decimal) + return row_pos + + def _print_partner_footer(self, _p, _xs, data, row_pos, + account, line_count): + """ + Partner header line + """ + # Totals + c_specs = [ + ('total', 1, 0, 'text', _('Total') + ' ' + account.code, + None, self._style_yellow_bold), + ('empty', 1, 0, 'text', None, + None, self._style_yellow_bold)] + row_start = row_pos - line_count + col_start = self._balance_pos + start = rowcol_to_cell(row_start, col_start) + stop = rowcol_to_cell(row_pos - 1, col_start) + formula = 'SUM(%s:%s)' % (start, stop) + c_specs += [('total_balance', 1, 0, 'number', None, formula)] + col_start += 1 + for i, r in enumerate(_p.ranges): + entry = 'total_%s' % i + start = rowcol_to_cell(row_start, col_start + i) + stop = rowcol_to_cell(row_pos - 1, col_start + i) + formula = 'SUM(%s:%s)' % (start, stop) + c_specs += [(entry, 1, 0, 'number', None, formula)] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row( + self.ws, row_pos, row_data, + row_style=self._style_yellow_bold_decimal) + + # percents + c_specs = [ + ('pct', 1, 0, 'text', _('Percentages') + ' ' + account.code, + None, self._style_default), + ('empty', 2, 0, 'text', None, + None, self._style_default)] + total_balance = rowcol_to_cell(row_pos - 1, self._balance_pos) + for i, r in enumerate(_p.ranges): + entry = 'pct_%s' % i + total_range = rowcol_to_cell(row_pos - 1, col_start + i) + formula = '%s/%s' % (total_range, total_balance) + c_specs += [(entry, 1, 0, 'number', None, formula)] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row( + self.ws, row_pos, row_data, + row_style=self._style_percent) + + return row_pos + + def _print_account_data(self, _p, _xs, data, row_pos, account): + if _p.aged_open_inv[account.id]: + row_pos = self._print_account_header( + _p, _xs, data, row_pos, account) + lines = _p.aged_open_inv[account.id] + + row_pos = self._print_partner_header( + _p, _xs, data, row_pos) + row_pos_start = row_pos + for partner in _p.partners_order[account.id]: + partner_id = partner[1] + if partner_id in lines: + line = lines[partner_id] + row_pos = self._print_partner_line( + _p, _xs, data, row_pos, partner, line) + line_count = row_pos - row_pos_start + row_pos = self._print_partner_footer( + _p, _xs, data, row_pos, account, line_count) + return row_pos + 1 + + def generate_xls_report(self, _p, _xs, data, objects, wb): + self._cell_styles(_xs) + self._setup_worksheet(_p, _xs, data, wb) + + row_pos = 0 + row_pos = self._print_title(_p, _xs, data, row_pos) + row_pos = self._print_empty_row(_p, _xs, data, row_pos) + row_pos = self._print_header(_p, _xs, data, row_pos) + + for account in objects: + row_pos = self._print_account_data( + _p, _xs, data, row_pos, account) + + +AccountAgedOpenInvoicesWebkitXls( + 'report.account.aged_open_invoices_xls', + 'account.account', + parser=AccountAgedOpenInvoicesWebkit) diff --git a/account_financial_report_webkit_xls/tests/__init__.py b/account_financial_report_webkit_xls/tests/__init__.py index 7ebf9166..c94d1b81 100644 --- a/account_financial_report_webkit_xls/tests/__init__.py +++ b/account_financial_report_webkit_xls/tests/__init__.py @@ -5,3 +5,4 @@ from . import test_trial_balance_xls from . import test_partner_balance_xls from . import test_open_invoices_xls from . import test_aged_partner_balance_xls +from . import test_aged_open_invoices_xls diff --git a/account_financial_report_webkit_xls/tests/test_aged_open_invoices_xls.py b/account_financial_report_webkit_xls/tests/test_aged_open_invoices_xls.py new file mode 100644 index 00000000..021e0921 --- /dev/null +++ b/account_financial_report_webkit_xls/tests/test_aged_open_invoices_xls.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2017 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from datetime import datetime +from .test_common_xls import TestCommonXls + + +class TestAgedOpenInvoicesXls(TestCommonXls): + + def _getReportModel(self): + return 'aged.open.invoices.webkit' + + def _getXlsReportName(self): + return 'account.aged_open_invoices_xls' + + def _getXlsReportActionName(self): + module = 'account_financial_report_webkit' + action = 'account_report_open_invoices_webkit' + return '%s.%s' % (module, action) + + def _getBaseFilters(self): + return { + 'date_from': '%s-01-01' % (datetime.now().year), + 'date_to': '%s-12-31' % (datetime.now().year), + 'until_date': '%s-12-31' % (datetime.now().year), + } + + def test_common(self): + common_tests = [ + x for x in dir(self) + if callable(getattr(self, x)) and x.startswith('common_test_')] + for test in common_tests: + getattr(self, test)() diff --git a/account_financial_report_webkit_xls/wizard/__init__.py b/account_financial_report_webkit_xls/wizard/__init__.py index 29f9b837..3bf8a709 100644 --- a/account_financial_report_webkit_xls/wizard/__init__.py +++ b/account_financial_report_webkit_xls/wizard/__init__.py @@ -5,3 +5,4 @@ from . import partners_balance_wizard from . import partners_ledger_wizard from . import open_invoices_wizard from . import aged_partner_balance_wizard +from . import aged_open_invoices_wizard diff --git a/account_financial_report_webkit_xls/wizard/aged_open_invoices_wizard.py b/account_financial_report_webkit_xls/wizard/aged_open_invoices_wizard.py new file mode 100644 index 00000000..563e1d37 --- /dev/null +++ b/account_financial_report_webkit_xls/wizard/aged_open_invoices_wizard.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2016 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from openerp import models + + +class AgedOpenInvoice(models.TransientModel): + _inherit = 'aged.open.invoices.webkit' + + def xls_export(self, cr, uid, ids, context=None): + return self.check_report(cr, uid, ids, context=context) + + def _print_report(self, cr, uid, ids, data, context=None): + context = context or {} + if context.get('xls_export'): + # we update form with display account value + data = self.pre_print_report(cr, uid, ids, data, context=context) + return { + 'type': 'ir.actions.report.xml', + 'report_name': + 'account.aged_open_invoices_xls', + 'datas': data} + else: + return super(AgedOpenInvoice, self)._print_report( + cr, uid, ids, data, context=context) diff --git a/account_financial_report_webkit_xls/wizard/aged_open_invoices_wizard.xml b/account_financial_report_webkit_xls/wizard/aged_open_invoices_wizard.xml new file mode 100644 index 00000000..b44ba625 --- /dev/null +++ b/account_financial_report_webkit_xls/wizard/aged_open_invoices_wizard.xml @@ -0,0 +1,17 @@ + + + + + + aged.open.invoices.webkit + form + + + + + + + + From 13fa85ae5e5cf6f8f33e553d52e90bb00787ef49 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 14 Dec 2017 15:37:54 +0100 Subject: [PATCH 7/8] [FIX] lints --- account_financial_report/report/parser.py | 69 ++++++++-------- account_financial_report/wizard/wizard.py | 32 ++++---- .../__openerp__.py | 3 +- .../data/financial_webkit_header.xml | 2 +- .../models/account.py | 22 ++---- .../report/aged_open_invoices.py | 1 + .../report/aged_partner_balance.py | 1 + .../report/common_balance_reports.py | 2 +- .../report/common_partner_balance_reports.py | 2 +- .../report/common_partner_reports.py | 2 +- .../report/common_reports.py | 12 +-- .../report/general_ledger.py | 3 +- .../report/open_invoices.py | 14 ++-- .../report/partner_balance.py | 4 +- .../report/partners_ledger.py | 7 +- .../report/print_journal.py | 3 +- .../report/trial_balance.py | 3 +- .../report/webkit_parser_header_fix.py | 3 +- .../wizard/aged_open_invoices_wizard.py | 12 +-- .../wizard/aged_open_invoices_wizard.xml | 1 + .../wizard/aged_partner_balance_wizard.py | 35 ++++----- .../wizard/aged_partner_balance_wizard.xml | 1 + .../wizard/balance_common.py | 78 ++++++++++--------- .../wizard/general_ledger_wizard.py | 54 ++++++------- .../wizard/general_ledger_wizard_view.xml | 1 + .../wizard/open_invoices_wizard.py | 28 ++++--- .../wizard/open_invoices_wizard_view.xml | 1 + .../wizard/partner_balance_wizard.py | 1 + .../wizard/partner_balance_wizard_view.xml | 1 + .../wizard/partners_ledger_wizard.py | 48 ++++++------ .../wizard/partners_ledger_wizard_view.xml | 1 + .../wizard/print_journal.py | 24 +++--- .../wizard/print_journal_view.xml | 1 + .../wizard/trial_balance_wizard.py | 8 +- .../wizard/trial_balance_wizard_view.xml | 1 + .../__openerp__.py | 1 - .../report/aged_open_invoices_xls.py | 1 + .../report/aged_partner_balance_xls.py | 1 + .../report/general_ledger_xls.py | 8 +- .../report/open_invoices_xls.py | 6 +- .../report/partner_ledger_xls.py | 8 +- .../report/partners_balance_xls.py | 8 +- .../report/trial_balance_xls.py | 1 + .../wizard/aged_open_invoices_wizard.py | 2 + .../wizard/aged_partner_balance_wizard.py | 2 + .../wizard/general_ledger_wizard.py | 2 + .../wizard/general_ledger_wizard_view.xml | 1 + .../wizard/open_invoices_wizard.py | 2 + .../wizard/open_invoices_wizard_view.xml | 1 + .../wizard/partners_balance_wizard.py | 2 + .../wizard/partners_ledger_wizard.py | 2 + .../wizard/partners_ledger_wizard_view.xml | 1 + .../wizard/trial_balance_wizard.py | 2 + .../wizard/trial_balance_wizard_view.xml | 1 + account_journal_report_xls/__openerp__.py | 2 +- account_journal_report_xls/account_journal.py | 11 ++- .../report/nov_account_journal.py | 16 ++-- .../report/nov_account_journal_xls.py | 32 ++++---- .../wizard/print_journal_wizard.py | 48 ++++++------ .../wizard/print_journal_wizard.xml | 10 +-- 60 files changed, 350 insertions(+), 302 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index e92f9f10..b99d0d64 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -165,10 +165,11 @@ class account_balance(report_sxw.rml_parse): def exchange_name(self, form): self.from_currency_id = self.\ - get_company_currency(form['company_id'] - and type(form['company_id']) in (list, tuple) - and form['company_id'][0] - or form['company_id']) + get_company_currency( + form['company_id'] and + type(form['company_id']) in (list, tuple) and + form['company_id'][0] or form['company_id'] + ) if not form['currency_id']: self.to_currency_id = self.from_currency_id else: @@ -543,17 +544,18 @@ class account_balance(report_sxw.rml_parse): self.context['state'] = form['target_move'] or 'posted' self.from_currency_id = self.\ - get_company_currency(form['company_id'] - and type(form['company_id']) in (list, tuple) - and form['company_id'][0] - or form['company_id']) + get_company_currency( + form['company_id'] and + type(form['company_id']) in (list, tuple) and + form['company_id'][0] or form['company_id'] + ) if not form['currency_id']: self.to_currency_id = self.from_currency_id else: - self.to_currency_id = form['currency_id'] \ - and type(form['currency_id']) in (list, tuple) \ - and form['currency_id'][0] \ - or form['currency_id'] + self.to_currency_id = form['currency_id'] and\ + type(form['currency_id']) in (list, tuple) and\ + form['currency_id'][0] or\ + form['currency_id'] if 'account_list' in form and form['account_list']: account_ids = form['account_list'] @@ -561,16 +563,18 @@ class account_balance(report_sxw.rml_parse): del form['account_list'] credit_account_ids = self.\ - get_company_accounts(form['company_id'] - and type(form['company_id']) in (list, tuple) - and form['company_id'][0] - or form['company_id'], 'credit') + get_company_accounts( + form['company_id'] and + type(form['company_id']) in (list, tuple) and + form['company_id'][0] or form['company_id'], 'credit' + ) debit_account_ids = self.\ - get_company_accounts(form['company_id'] - and type(form['company_id']) in (list, tuple) - and form['company_id'][0] - or form['company_id'], 'debit') + get_company_accounts( + form['company_id'] and + type(form['company_id']) in (list, tuple) and + form['company_id'][0] or form['company_id'], 'debit' + ) if form.get('fiscalyear'): if type(form.get('fiscalyear')) in (list, tuple): @@ -587,9 +591,8 @@ class account_balance(report_sxw.rml_parse): account_ids = _get_children_and_consol( self.cr, self.uid, account_ids, - form['display_account_level'] - and form['display_account_level'] - or 100, self.context) + form['display_account_level'] and form['display_account_level'] or + 100, self.context) credit_account_ids = _get_children_and_consol( self.cr, self.uid, credit_account_ids, 100, self.context, @@ -622,16 +625,16 @@ class account_balance(report_sxw.rml_parse): ('special', '=', False)], order='date_start asc') a = 0 - l = [] + l1 = [] p = [] for x in period_ids: a += 1 if a < 3: - l.append(x) + l1.append(x) else: - l.append(x) - p.append(l) - l = [] + l1.append(x) + p.append(l1) + l1 = [] a = 0 tot_bal1 = 0.0 tot_bal2 = 0.0 @@ -845,15 +848,14 @@ class account_balance(report_sxw.rml_parse): 'id': id, 'type': aa_id[3].type, 'code': aa_id[3].code, - 'name': (aa_id[2] and not aa_id[1]) - and 'TOTAL %s' % (aa_id[3].name.upper()) - or aa_id[3].name, + 'name': (aa_id[2] and not aa_id[1]) and + 'TOTAL %s' % (aa_id[3].name.upper()) or aa_id[3].name, 'parent_id': aa_id[3].parent_id and aa_id[3].parent_id.id, 'level': aa_id[3].level, 'label': aa_id[1], 'total': aa_id[2], - 'change_sign': credit_account_ids - and (id in credit_account_ids and -1 or 1) or 1 + 'change_sign': credit_account_ids and + (id in credit_account_ids and -1 or 1) or 1 } if form['columns'] == 'qtr': @@ -1174,6 +1176,7 @@ class account_balance(report_sxw.rml_parse): result_acc.append(res2) return result_acc + report_sxw.report_sxw( 'report.afr.1cols', 'wizard.report', diff --git a/account_financial_report/wizard/wizard.py b/account_financial_report/wizard/wizard.py index 717300a9..82e51690 100644 --- a/account_financial_report/wizard/wizard.py +++ b/account_financial_report/wizard/wizard.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ########################################################################### # Module Writen to OpenERP, Open Source Management Solution # Copyright (C) OpenERP Venezuela (). @@ -25,13 +25,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . ############################################################################## - -from openerp.osv import osv, fields +from openerp import _, fields, models import time -from openerp.tools.translate import _ -class wizard_report(osv.osv_memory): +class WizardReport(models.TransientModel): _name = "wizard.report" _columns = { @@ -208,20 +206,20 @@ class wizard_report(osv.osv_memory): return res afr_brw = self.pool.get('afr').browse(cr, uid, afr_id, context=context) res['value'].update({ - 'currency_id': afr_brw.currency_id - and afr_brw.currency_id.id - or afr_brw.company_id.currency_id.id}) + 'currency_id': afr_brw.currency_id and afr_brw.currency_id.id or + afr_brw.company_id.currency_id.id, + }) res['value'].update({'inf_type': afr_brw.inf_type or 'BS'}) res['value'].update({'columns': afr_brw.columns or 'five'}) res['value'].update({ - 'display_account': afr_brw.display_account - or 'bal_mov'}) + 'display_account': afr_brw.display_account or 'bal_mov', + }) res['value'].update({ - 'display_account_level': afr_brw. - display_account_level or 0}) + 'display_account_level': afr_brw.display_account_level or 0 + }) res['value'].update({ - 'fiscalyear': afr_brw.fiscalyear_id - and afr_brw.fiscalyear_id.id}) + 'fiscalyear': afr_brw.fiscalyear_id and afr_brw.fiscalyear_id.id + }) res['value'].update({'account_list': [ acc.id for acc in afr_brw.account_ids]}) res['value'].update({'periods': [p.id for p in afr_brw.period_ids]}) @@ -270,8 +268,8 @@ class wizard_report(osv.osv_memory): res = cr.dictfetchall() if res: - if (data['form']['date_to'] > res[0]['date_stop'] - or data['form']['date_from'] < res[0]['date_start']): + if data['form']['date_to'] > res[0]['date_stop'] or\ + data['form']['date_from'] < res[0]['date_start']): raise osv.except_osv(_('UserError'), 'Las fechas deben estar entre %s y %s' % (res[0]['date_start'], @@ -369,5 +367,3 @@ class wizard_report(osv.osv_memory): return {'type': 'ir.actions.report.xml', 'report_name': name, 'datas': data} - -wizard_report() diff --git a/account_financial_report_webkit/__openerp__.py b/account_financial_report_webkit/__openerp__.py index d77c80a5..5ec2018c 100644 --- a/account_financial_report_webkit/__openerp__.py +++ b/account_financial_report_webkit/__openerp__.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Authors: Nicolas Bessi, Guewen Baconnier @@ -57,7 +57,6 @@ 'test/open_invoices.yml', 'test/aged_trial_balance.yml'], # 'tests/account_move_line.yml' - 'active': False, 'installable': True, 'application': True, 'pre_init_hook': 'pre_init_hook', diff --git a/account_financial_report_webkit/data/financial_webkit_header.xml b/account_financial_report_webkit/data/financial_webkit_header.xml index a4d6d618..063690a5 100644 --- a/account_financial_report_webkit/data/financial_webkit_header.xml +++ b/account_financial_report_webkit/data/financial_webkit_header.xml @@ -394,7 +394,7 @@ act_as_colgroup { .account_level_consol { font-weight: normal; - font-style: italic; + font-style: italic; } .overflow_ellipsis { diff --git a/account_financial_report_webkit/models/account.py b/account_financial_report_webkit/models/account.py index 4e1118ee..177f41d4 100644 --- a/account_financial_report_webkit/models/account.py +++ b/account_financial_report_webkit/models/account.py @@ -27,21 +27,15 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################## +from openerp import models, fields -from openerp.osv import fields, orm - -class AccountAccount(orm.Model): +class AccountAccount(models.Model): _inherit = 'account.account' - _columns = { - 'centralized': fields.boolean( - 'Centralized', - help="If flagged, no details will be displayed in " - "the General Ledger report (the webkit one only), " - "only centralized amounts per period."), - } - - _defaults = { - 'centralized': False, - } + centralized = fields.Boolean( + 'Centralized', default=False, + help="If flagged, no details will be displayed in " + "the General Ledger report (the webkit one only), " + "only centralized amounts per period." + ) diff --git a/account_financial_report_webkit/report/aged_open_invoices.py b/account_financial_report_webkit/report/aged_open_invoices.py index 96c78374..f8fb8df6 100644 --- a/account_financial_report_webkit/report/aged_open_invoices.py +++ b/account_financial_report_webkit/report/aged_open_invoices.py @@ -71,6 +71,7 @@ class AccountAgedOpenInvoicesWebkit(PartnersOpenInvoicesWebkit): """Compute Aged Open Invoices based on result of Open Invoices""" + # pylint: disable=old-api7-method-defined def __init__(self, cursor, uid, name, context=None): """Constructor, refer to :class:`openerp.report.report_sxw.rml_parse`""" diff --git a/account_financial_report_webkit/report/aged_partner_balance.py b/account_financial_report_webkit/report/aged_partner_balance.py index a9de9ca9..54c59c7d 100644 --- a/account_financial_report_webkit/report/aged_partner_balance.py +++ b/account_financial_report_webkit/report/aged_partner_balance.py @@ -69,6 +69,7 @@ class AccountAgedTrialBalanceWebkit(PartnersOpenInvoicesWebkit): """Compute Aged Partner Balance based on result of Open Invoices""" + # pylint: disable=old-api7-method-defined def __init__(self, cursor, uid, name, context=None): """Constructor, refer to :class:`openerp.report.report_sxw.rml_parse`""" diff --git a/account_financial_report_webkit/report/common_balance_reports.py b/account_financial_report_webkit/report/common_balance_reports.py index 2e09e6d3..0515c094 100644 --- a/account_financial_report_webkit/report/common_balance_reports.py +++ b/account_financial_report_webkit/report/common_balance_reports.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Author: Guewen Baconnier diff --git a/account_financial_report_webkit/report/common_partner_balance_reports.py b/account_financial_report_webkit/report/common_partner_balance_reports.py index 5139ad5e..f64ff9fc 100644 --- a/account_financial_report_webkit/report/common_partner_balance_reports.py +++ b/account_financial_report_webkit/report/common_partner_balance_reports.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Author: Guewen Baconnier diff --git a/account_financial_report_webkit/report/common_partner_reports.py b/account_financial_report_webkit/report/common_partner_reports.py index 55ce8efd..ced7cf22 100644 --- a/account_financial_report_webkit/report/common_partner_reports.py +++ b/account_financial_report_webkit/report/common_partner_reports.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Author: Nicolas Bessi, Guewen Baconnier diff --git a/account_financial_report_webkit/report/common_reports.py b/account_financial_report_webkit/report/common_reports.py index 7bbefe3d..45a15229 100644 --- a/account_financial_report_webkit/report/common_reports.py +++ b/account_financial_report_webkit/report/common_reports.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Author: Nicolas Bessi, Guewen Baconnier @@ -24,7 +24,7 @@ import logging -from openerp.osv import osv +from openerp.exceptions import except_orm from openerp.tools.translate import _ from openerp.addons.account.report.common_report_header \ import common_report_header @@ -361,7 +361,7 @@ class CommonReportHeaderWebkit(common_report_header): limit=1, order='date_start %s' % (order,)) if not p_id: - raise osv.except_osv(_('No period found'), '') + raise except_orm(_('No period found'), '') return period_obj.browse(self.cursor, self.uid, p_id[0]) ############################### @@ -404,7 +404,7 @@ class CommonReportHeaderWebkit(common_report_header): opening_period_selected = self.get_included_opening_period( start_period) if not opening_period_selected: - raise osv.except_osv( + raise except_orm( _('Error'), _('No opening period found to compute the opening balances.\n' 'You have to configure a period on the first of January' @@ -490,7 +490,7 @@ class CommonReportHeaderWebkit(common_report_header): target_move, mode='include_opening'): """Get account move lines base on form data""" if mode not in ('include_opening', 'exclude_opening'): - raise osv.except_osv( + raise except_orm( _('Invalid query mode'), _('Must be in include_opening, exclude_opening')) @@ -502,7 +502,7 @@ class CommonReportHeaderWebkit(common_report_header): return self._get_move_ids_from_dates(account_id, start, stop, target_move) else: - raise osv.except_osv( + raise except_orm( _('No valid filter'), _('Please set a valid time filter')) def _get_move_line_datas(self, move_line_ids, diff --git a/account_financial_report_webkit/report/general_ledger.py b/account_financial_report_webkit/report/general_ledger.py index b91273c8..dcebd263 100644 --- a/account_financial_report_webkit/report/general_ledger.py +++ b/account_financial_report_webkit/report/general_ledger.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Author: Nicolas Bessi, Guewen Baconnier @@ -32,6 +32,7 @@ from .webkit_parser_header_fix import HeaderFooterTextWebKitParser class GeneralLedgerWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit): + # pylint: disable=old-api7-method-defined def __init__(self, cursor, uid, name, context): super(GeneralLedgerWebkit, self).__init__( cursor, uid, name, context=context) diff --git a/account_financial_report_webkit/report/open_invoices.py b/account_financial_report_webkit/report/open_invoices.py index 07fd92e7..5e04f986 100644 --- a/account_financial_report_webkit/report/open_invoices.py +++ b/account_financial_report_webkit/report/open_invoices.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Author: Nicolas Bessi, Guewen Baconnier @@ -27,7 +27,7 @@ from mako.template import Template from openerp.modules.registry import RegistryManager -from openerp.osv import osv +from openerp.exceptions import except_orm from openerp.report import report_sxw from openerp.tools.translate import _ from openerp.addons.report_webkit import report_helper @@ -46,7 +46,7 @@ report_helper.WebKitHelper.get_mako_template = get_mako_template class PartnersOpenInvoicesWebkit(report_sxw.rml_parse, CommonPartnersReportHeaderWebkit): - + # pylint: disable=old-api7-method-defined def __init__(self, cursor, uid, name, context): super(PartnersOpenInvoicesWebkit, self).__init__( cursor, uid, name, context=context) @@ -134,7 +134,7 @@ class PartnersOpenInvoicesWebkit(report_sxw.rml_parse, new_ids, exclude_type=['view'], only_type=filter_type) if not account_ids: - raise osv.except_osv(_('Error'), _('No accounts to print.')) + raise except_orm(_('Error'), _('No accounts to print.')) # computation of ledeger lines if main_filter == 'filter_date': @@ -210,9 +210,9 @@ class PartnersOpenInvoicesWebkit(report_sxw.rml_parse, date_until_match = (stop == date_until) else: - raise osv.except_osv(_('Unsuported filter'), - _('Filter has to be in filter date, period, \ - or none')) + raise except_orm( + _('Unsuported filter'), + _('Filter has to be in filter date, period, or none')) initial_move_lines_per_account = {} if main_filter in ('filter_period', 'filter_no'): diff --git a/account_financial_report_webkit/report/partner_balance.py b/account_financial_report_webkit/report/partner_balance.py index 95a2787d..eb304ca3 100644 --- a/account_financial_report_webkit/report/partner_balance.py +++ b/account_financial_report_webkit/report/partner_balance.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Author: Guewen Baconnier @@ -32,7 +32,7 @@ from .webkit_parser_header_fix import HeaderFooterTextWebKitParser class PartnerBalanceWebkit(report_sxw.rml_parse, CommonPartnerBalanceReportHeaderWebkit): - + # pylint: disable=old-api7-method-defined def __init__(self, cursor, uid, name, context): super(PartnerBalanceWebkit, self).__init__( cursor, uid, name, context=context) diff --git a/account_financial_report_webkit/report/partners_ledger.py b/account_financial_report_webkit/report/partners_ledger.py index 7ddca6b5..190ee519 100644 --- a/account_financial_report_webkit/report/partners_ledger.py +++ b/account_financial_report_webkit/report/partners_ledger.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Author: Nicolas Bessi, Guewen Baconnier @@ -23,7 +23,7 @@ from collections import defaultdict from datetime import datetime from openerp.modules.registry import RegistryManager -from openerp.osv import osv +from openerp.exceptions import except_orm from openerp.report import report_sxw from openerp.tools.translate import _ from .common_partner_reports import CommonPartnersReportHeaderWebkit @@ -33,6 +33,7 @@ from .webkit_parser_header_fix import HeaderFooterTextWebKitParser class PartnersLedgerWebkit(report_sxw.rml_parse, CommonPartnersReportHeaderWebkit): + # pylint: disable=old-api7-method-defined def __init__(self, cursor, uid, name, context): super(PartnersLedgerWebkit, self).__init__( cursor, uid, name, context=context) @@ -116,7 +117,7 @@ class PartnersLedgerWebkit(report_sxw.rml_parse, only_type=filter_type) if not accounts: - raise osv.except_osv(_('Error'), _('No accounts to print.')) + raise except_orm(_('Error'), _('No accounts to print.')) if main_filter == 'filter_date': start = start_date diff --git a/account_financial_report_webkit/report/print_journal.py b/account_financial_report_webkit/report/print_journal.py index 3ef7d439..3876091e 100755 --- a/account_financial_report_webkit/report/print_journal.py +++ b/account_financial_report_webkit/report/print_journal.py @@ -34,6 +34,7 @@ from .webkit_parser_header_fix import HeaderFooterTextWebKitParser class PrintJournalWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit): + # pylint: disable=old-api7-method-defined def __init__(self, cursor, uid, name, context): super(PrintJournalWebkit, self).__init__(cursor, uid, name, context=context) @@ -165,5 +166,3 @@ HeaderFooterTextWebKitParser( 'addons/account_financial_report_webkit/report/templates/\ account_report_print_journal.mako', parser=PrintJournalWebkit) - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_financial_report_webkit/report/trial_balance.py b/account_financial_report_webkit/report/trial_balance.py index 8c86659d..92f94d22 100644 --- a/account_financial_report_webkit/report/trial_balance.py +++ b/account_financial_report_webkit/report/trial_balance.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Author: Guewen Baconnier @@ -36,6 +36,7 @@ def sign(number): class TrialBalanceWebkit(report_sxw.rml_parse, CommonBalanceReportHeaderWebkit): + # pylint: disable=old-api7-method-defined def __init__(self, cursor, uid, name, context): super(TrialBalanceWebkit, self).__init__(cursor, uid, name, context=context) diff --git a/account_financial_report_webkit/report/webkit_parser_header_fix.py b/account_financial_report_webkit/report/webkit_parser_header_fix.py index e2a45941..2766580d 100644 --- a/account_financial_report_webkit/report/webkit_parser_header_fix.py +++ b/account_financial_report_webkit/report/webkit_parser_header_fix.py @@ -38,7 +38,7 @@ from functools import partial from mako import exceptions -from openerp.osv.orm import except_orm +from openerp.exceptions import except_orm from openerp.tools.translate import _ from openerp.modules.registry import RegistryManager from openerp import tools @@ -182,6 +182,7 @@ class HeaderFooterTextWebKitParser(webkit_report.WebKitParser): return pdf # override needed to keep the attachments' storing procedure + # pylint: disable=old-api7-method-defined def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None): """generate the PDF""" diff --git a/account_financial_report_webkit/wizard/aged_open_invoices_wizard.py b/account_financial_report_webkit/wizard/aged_open_invoices_wizard.py index 3eb9f2fc..47cb38ed 100644 --- a/account_financial_report_webkit/wizard/aged_open_invoices_wizard.py +++ b/account_financial_report_webkit/wizard/aged_open_invoices_wizard.py @@ -19,24 +19,23 @@ # along with this program. If not, see . # ############################################################################## +from openerp import models, fields -from openerp.osv import orm - -class AgedOpenInvoice(orm.TransientModel): +class AgedOpenInvoice(models.TransientModel): """Will launch age partner balance report. This report is based on Open Invoice Report and share a lot of knowledge with him """ + # pylint: disable=consider-merging-classes-inherited _inherit = "open.invoices.webkit" _name = "aged.open.invoices.webkit" _description = "Aged open invoices" - _defaults = { - 'filter': 'filter_date', - } + filter = fields.Selection(default='filter_date') + # pylint: disable=old-api7-method-defined def onchange_fiscalyear(self, cr, uid, ids, fiscalyear=False, period_id=False, date_to=False, until_date=False, context=None): @@ -53,6 +52,7 @@ class AgedOpenInvoice(orm.TransientModel): }) return res + # pylint: disable=old-api7-method-defined def _print_report(self, cr, uid, ids, data, context=None): # we update form with display account value data = self.pre_print_report(cr, uid, ids, data, context=context) diff --git a/account_financial_report_webkit/wizard/aged_open_invoices_wizard.xml b/account_financial_report_webkit/wizard/aged_open_invoices_wizard.xml index 7f9b2f16..720bc975 100644 --- a/account_financial_report_webkit/wizard/aged_open_invoices_wizard.xml +++ b/account_financial_report_webkit/wizard/aged_open_invoices_wizard.xml @@ -5,6 +5,7 @@ Aged Open Invoice Report aged.open.invoices.webkit + 99 diff --git a/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py b/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py index 3bce5792..471812e8 100644 --- a/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py +++ b/account_financial_report_webkit/wizard/aged_partner_balance_wizard.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- # Copyright 2014 Camptocamp SA, Nicolas Bessi. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp.osv import orm, fields +from openerp import models, fields -class AccountAgedTrialBalance(orm.TransientModel): +class AccountAgedTrialBalance(models.TransientModel): """Will launch age partner balance report. This report is based on Open Invoice Report and share a lot of knowledge with him @@ -14,27 +14,21 @@ class AccountAgedTrialBalance(orm.TransientModel): _name = "account.aged.trial.balance.webkit" _description = "Aged partner balanced" + # pylint: disable=old-api7-method-defined def _get_current_fiscalyear(self, cr, uid, context=None): return self.pool['account.fiscalyear'].find(cr, uid, context=context) - _columns = { - 'filter': fields.selection( - [('filter_period', 'Periods')], - "Filter by", - required=True), - 'fiscalyear_id': fields.many2one( - 'account.fiscalyear', - 'Fiscal Year', - required=True), - 'period_to': fields.many2one('account.period', 'End Period', - required=True), - } - - _defaults = { - 'filter': 'filter_period', - 'fiscalyear_id': _get_current_fiscalyear, - } - + filter = fields.Selection( + [('filter_period', 'Periods')], "Filter by", required=True, + default='filter_period' + ) + fiscalyear_id = fields.Many2one( + 'account.fiscalyear', 'Fiscal Year', required=True, + default=lambda self: self._get_current_fiscalyear() + ) + period_to = fields.Many2one('account.period', 'End Period', required=True) + + # pylint: disable=old-api7-method-defined def onchange_fiscalyear(self, cr, uid, ids, fiscalyear=False, period_id=False, date_to=False, until_date=False, context=None): @@ -51,6 +45,7 @@ class AccountAgedTrialBalance(orm.TransientModel): }) return res + # pylint: disable=old-api7-method-defined def _print_report(self, cr, uid, ids, data, context=None): # we update form with display account value data = self.pre_print_report(cr, uid, ids, data, context=context) diff --git a/account_financial_report_webkit/wizard/aged_partner_balance_wizard.xml b/account_financial_report_webkit/wizard/aged_partner_balance_wizard.xml index 7d19e28c..32dc6825 100644 --- a/account_financial_report_webkit/wizard/aged_partner_balance_wizard.xml +++ b/account_financial_report_webkit/wizard/aged_partner_balance_wizard.xml @@ -5,6 +5,7 @@ Aged Partner Balance Report account.aged.trial.balance.webkit + 99 diff --git a/account_financial_report_webkit/wizard/balance_common.py b/account_financial_report_webkit/wizard/balance_common.py index 591c8799..39dc638f 100644 --- a/account_financial_report_webkit/wizard/balance_common.py +++ b/account_financial_report_webkit/wizard/balance_common.py @@ -32,8 +32,10 @@ import time from lxml import etree from datetime import datetime -from openerp.osv import fields, orm +from openerp import fields, models from openerp.tools.translate import _ +# pylint: disable=deprecated-module +from openerp.osv.orm import setup_modifiers def previous_year_date(date, nb_prev=1): @@ -46,10 +48,11 @@ def previous_year_date(date, nb_prev=1): return previous_date -class AccountBalanceCommonWizard(orm.TransientModel): +class AccountBalanceCommonWizard(models.TransientModel): """Will launch trial balance report and pass required args""" + # pylint: disable=consider-merging-classes-inherited _inherit = "account.common.account.report" _name = "account.common.balance.report" _description = "Common Balance Report" @@ -74,6 +77,7 @@ class AccountBalanceCommonWizard(orm.TransientModel): for index in range(COMPARISON_LEVEL)] DYNAMIC_FIELDS = M2O_DYNAMIC_FIELDS + SIMPLE_DYNAMIC_FIELDS + # pylint: disable=old-api7-method-defined def _get_account_ids(self, cr, uid, context=None): res = False if context.get('active_model', False) == 'account.account' \ @@ -81,48 +85,47 @@ class AccountBalanceCommonWizard(orm.TransientModel): res = context['active_ids'] return res - _columns = { - 'account_ids': fields.many2many( - 'account.account', string='Filter on accounts', - help="Only selected accounts will be printed. Leave empty to \ - print all accounts."), - 'filter': fields.selection( - [('filter_no', 'No Filters'), - ('filter_date', 'Date'), - ('filter_period', 'Periods'), - ('filter_opening', 'Opening Only')], - "Filter by", - required=True, - help='Filter by date: no opening balance will be displayed. ' - '(opening balance can only be computed based on period to be \ - correct).'), - # Set statically because of the impossibility of changing the selection - # field when changing chart_account_id - 'account_level': fields.selection( - [('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), - ('6', '6')], string="Account level"), - } - + account_ids = fields.Many2many( + 'account.account', string='Filter on accounts', + help="Only selected accounts will be printed. Leave empty to \ + print all accounts.", default=lambda self: self._get_account_ids(), + ) + filter = fields.Selection( + [('filter_no', 'No Filters'), + ('filter_date', 'Date'), + ('filter_period', 'Periods'), + ('filter_opening', 'Opening Only')], + "Filter by", required=True, + help='Filter by date: no opening balance will be displayed. ' + '(opening balance can only be computed based on period to be \ + correct).' + ) + # Set statically because of the impossibility of changing the selection + # field when changing chart_account_id + account_level = fields.Selection( + [('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), + ('6', '6')], string="Account level" + ) + + # pylint: disable=attribute-deprecated + _columns = {} for index in range(COMPARISON_LEVEL): _columns.update( {"comp%s_filter" % index: - fields.selection( + fields.fields.selection( COMPARE_SELECTION, string='Compare By', required=True), "comp%s_fiscalyear_id" % index: - fields.many2one('account.fiscalyear', 'Fiscal Year'), + fields.fields.many2one('account.fiscalyear', 'Fiscal Year'), "comp%s_period_from" % index: - fields.many2one('account.period', 'Start Period'), + fields.fields.many2one('account.period', 'Start Period'), "comp%s_period_to" % index: - fields.many2one('account.period', 'End Period'), + fields.fields.many2one('account.period', 'End Period'), "comp%s_date_from" % index: - fields.date("Start Date"), + fields.fields.date("Start Date"), "comp%s_date_to" % index: - fields.date("End Date")}) - - _defaults = { - 'account_ids': _get_account_ids, - } + fields.fields.date("End Date")}) + # pylint: disable=old-api7-method-defined def _check_fiscalyear(self, cr, uid, ids, context=None): obj = self.read( cr, uid, ids[0], ['fiscalyear_id', 'filter'], context=context) @@ -136,6 +139,7 @@ class AccountBalanceCommonWizard(orm.TransientModel): periods or by date.', ['filter']), ] + # pylint: disable=old-api7-method-defined def default_get(self, cr, uid, fields, context=None): """ To get default values for the object. @@ -157,6 +161,7 @@ class AccountBalanceCommonWizard(orm.TransientModel): res[field] = 'filter_no' return res + # pylint: disable=old-api7-method-defined def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): res = super(AccountBalanceCommonWizard, self).fields_view_get( @@ -180,7 +185,7 @@ class AccountBalanceCommonWizard(orm.TransientModel): page.append(group) def modifiers_and_append(elem): - orm.setup_modifiers(elem) + setup_modifiers(elem) group.append(elem) modifiers_and_append(etree.Element( @@ -244,6 +249,7 @@ class AccountBalanceCommonWizard(orm.TransientModel): res['arch'] = etree.tostring(eview) return res + # pylint: disable=old-api7-method-defined def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None): res = {} @@ -296,6 +302,7 @@ class AccountBalanceCommonWizard(orm.TransientModel): end_period, 'date_from': False, 'date_to': False} return res + # pylint: disable=old-api7-method-defined def onchange_comp_filter(self, cr, uid, ids, index, main_filter='filter_no', comp_filter='filter_no', fiscalyear_id=False, start_date=False, @@ -390,6 +397,7 @@ class AccountBalanceCommonWizard(orm.TransientModel): date_to_field: False} return res + # pylint: disable=old-api7-method-defined def pre_print_report(self, cr, uid, ids, data, context=None): data = super(AccountBalanceCommonWizard, self).pre_print_report( cr, uid, ids, data, context=context) diff --git a/account_financial_report_webkit/wizard/general_ledger_wizard.py b/account_financial_report_webkit/wizard/general_ledger_wizard.py index b820a9ad..25fe206c 100644 --- a/account_financial_report_webkit/wizard/general_ledger_wizard.py +++ b/account_financial_report_webkit/wizard/general_ledger_wizard.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Author: Nicolas Bessi, Guewen Baconnier @@ -20,11 +20,10 @@ ############################################################################## import time +from openerp import models, fields -from openerp.osv import fields, orm - -class AccountReportGeneralLedgerWizard(orm.TransientModel): +class AccountReportGeneralLedgerWizard(models.TransientModel): """Will launch general ledger report and pass required args""" @@ -32,6 +31,7 @@ class AccountReportGeneralLedgerWizard(orm.TransientModel): _name = "general.ledger.webkit" _description = "General Ledger Report" + # pylint: disable=old-api7-method-defined def _get_account_ids(self, cr, uid, context=None): res = False if context.get('active_model', False) == 'account.account' \ @@ -39,30 +39,27 @@ class AccountReportGeneralLedgerWizard(orm.TransientModel): res = context['active_ids'] return res - _columns = { - 'amount_currency': fields.boolean("With Currency", - help="It adds the currency column"), - - 'display_account': fields.selection( - [('bal_all', 'All'), - ('bal_mix', 'With transactions or non zero balance')], - 'Display accounts', - required=True), - 'account_ids': fields.many2many( - 'account.account', string='Filter on accounts', - help="""Only selected accounts will be printed. Leave empty to - print all accounts."""), - 'centralize': fields.boolean( - 'Activate Centralization', - help='Uncheck to display all the details of centralized accounts.') - } - _defaults = { - 'amount_currency': False, - 'display_account': 'bal_mix', - 'account_ids': _get_account_ids, - 'centralize': True, - } + amount_currency = fields.Boolean( + "With Currency", help="It adds the currency column", default=False, + ) + display_account = fields.Selection( + [ + ('bal_all', 'All'), + ('bal_mix', 'With transactions or non zero balance') + ], + 'Display accounts', required=True, default='bal_mix', + ) + account_ids = fields.Many2many( + 'account.account', string='Filter on accounts', + help="Only selected accounts will be printed. Leave empty to " + "print all accounts.", default=lambda self: self._get_account_ids(), + ) + centralize = fields.Boolean( + 'Activate Centralization', default=True, + help='Uncheck to display all the details of centralized accounts.', + ) + # pylint: disable=old-api7-method-defined def _check_fiscalyear(self, cr, uid, ids, context=None): obj = self.read( cr, uid, ids[0], ['fiscalyear_id', 'filter'], context=context) @@ -76,6 +73,7 @@ class AccountReportGeneralLedgerWizard(orm.TransientModel): periods or by date.', ['filter']), ] + # pylint: disable=old-api7-method-defined def pre_print_report(self, cr, uid, ids, data, context=None): data = super(AccountReportGeneralLedgerWizard, self).pre_print_report( cr, uid, ids, data, context=context) @@ -90,6 +88,7 @@ class AccountReportGeneralLedgerWizard(orm.TransientModel): data['form'].update(vals) return data + # pylint: disable=old-api7-method-defined def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None): res = {} @@ -148,6 +147,7 @@ class AccountReportGeneralLedgerWizard(orm.TransientModel): end_period, 'date_from': False, 'date_to': False} return res + # pylint: disable=old-api7-method-defined def _print_report(self, cursor, uid, ids, data, context=None): # we update form with display account value data = self.pre_print_report(cursor, uid, ids, data, context=context) diff --git a/account_financial_report_webkit/wizard/general_ledger_wizard_view.xml b/account_financial_report_webkit/wizard/general_ledger_wizard_view.xml index 982de98c..dc861bca 100644 --- a/account_financial_report_webkit/wizard/general_ledger_wizard_view.xml +++ b/account_financial_report_webkit/wizard/general_ledger_wizard_view.xml @@ -5,6 +5,7 @@ General Ledger general.ledger.webkit + 99 diff --git a/account_financial_report_webkit/wizard/open_invoices_wizard.py b/account_financial_report_webkit/wizard/open_invoices_wizard.py index 5ba70cc8..b19abce2 100644 --- a/account_financial_report_webkit/wizard/open_invoices_wizard.py +++ b/account_financial_report_webkit/wizard/open_invoices_wizard.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Author: Guewen Baconnier @@ -18,10 +18,10 @@ # along with this program. If not, see . # ############################################################################## -from openerp.osv import fields, orm +from openerp import models, fields -class AccountReportOpenInvoicesWizard(orm.TransientModel): +class AccountReportOpenInvoicesWizard(models.TransientModel): """Will launch partner ledger report and pass required args""" @@ -29,13 +29,11 @@ class AccountReportOpenInvoicesWizard(orm.TransientModel): _name = "open.invoices.webkit" _description = "Open Invoices Report" - _columns = { - 'group_by_currency': fields.boolean('Group Partner by currency'), - 'until_date': fields.date( - "Clearance date", - required=True, - help="""The clearance date is essentially a tool used for debtors - provisionning calculation. + group_by_currency = fields.Boolean('Group Partner by currency') + until_date = fields.Date( + "Clearance date", required=True, + help="""The clearance date is essentially a tool used for debtors +provisionning calculation. By default, this date is equal to the the end date (ie: 31/12/2011 if you select fy 2011). @@ -43,8 +41,9 @@ select fy 2011). By amending the clearance date, you will be, for instance, able to answer the question : 'based on my last year end debtors open invoices, which invoices are still unpaid today (today is my clearance date)?' -""")} +""") + # pylint: disable=old-api7-method-defined def _check_until_date(self, cr, uid, ids, context=None): def get_key_id(obj, field): return obj.get(field) and obj[field][0] or False @@ -66,6 +65,7 @@ are still unpaid today (today is my clearance date)?' last period or later.', ['until_date']), ] + # pylint: disable=old-api7-method-defined def default_until_date(self, cr, uid, ids, fiscalyear_id=False, period_id=False, date_to=False, context=None): res_date = False @@ -82,6 +82,7 @@ are still unpaid today (today is my clearance date)?' context=context)['date_stop'] return res_date + # pylint: disable=old-api7-method-defined def onchange_fiscalyear(self, cr, uid, ids, fiscalyear=False, period_id=False, date_to=False, until_date=False, context=None): @@ -94,6 +95,7 @@ are still unpaid today (today is my clearance date)?' context=context) return res + # pylint: disable=old-api7-method-defined def onchange_date_to(self, cr, uid, ids, fiscalyear=False, period_id=False, date_to=False, until_date=False, context=None): res = {'value': {}} @@ -105,6 +107,7 @@ are still unpaid today (today is my clearance date)?' context=context) return res + # pylint: disable=old-api7-method-defined def onchange_period_to(self, cr, uid, ids, fiscalyear=False, period_id=False, date_to=False, until_date=False, context=None): @@ -117,6 +120,7 @@ are still unpaid today (today is my clearance date)?' context=context) return res + # pylint: disable=old-api7-method-defined def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None): res = super(AccountReportOpenInvoicesWizard, self).onchange_filter( @@ -131,6 +135,7 @@ are still unpaid today (today is my clearance date)?' context=context) return res + # pylint: disable=old-api7-method-defined def pre_print_report(self, cr, uid, ids, data, context=None): data = super(AccountReportOpenInvoicesWizard, self).pre_print_report( cr, uid, ids, data, context=context) @@ -140,6 +145,7 @@ are still unpaid today (today is my clearance date)?' data['form'].update(vals) return data + # pylint: disable=old-api7-method-defined def _print_report(self, cr, uid, ids, data, context=None): # we update form with display account value data = self.pre_print_report(cr, uid, ids, data, context=context) diff --git a/account_financial_report_webkit/wizard/open_invoices_wizard_view.xml b/account_financial_report_webkit/wizard/open_invoices_wizard_view.xml index 9989a8f0..d36fa64c 100644 --- a/account_financial_report_webkit/wizard/open_invoices_wizard_view.xml +++ b/account_financial_report_webkit/wizard/open_invoices_wizard_view.xml @@ -5,6 +5,7 @@ Open Invoices Report open.invoices.webkit + 99 diff --git a/account_financial_report_webkit/wizard/partner_balance_wizard.py b/account_financial_report_webkit/wizard/partner_balance_wizard.py index cec955b8..a36a8e22 100644 --- a/account_financial_report_webkit/wizard/partner_balance_wizard.py +++ b/account_financial_report_webkit/wizard/partner_balance_wizard.py @@ -9,6 +9,7 @@ class AccountPartnerBalanceWizard(models.TransientModel): """Will launch partner balance report and pass required args""" + # pylint: disable=consider-merging-classes-inherited _inherit = "account.common.balance.report" _name = "partner.balance.webkit" _description = "Partner Balance Report" 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 e7b9e2b0..49431b53 100644 --- a/account_financial_report_webkit/wizard/partner_balance_wizard_view.xml +++ b/account_financial_report_webkit/wizard/partner_balance_wizard_view.xml @@ -9,6 +9,7 @@ Partner Balance partner.balance.webkit + 99 diff --git a/account_financial_report_webkit/wizard/partners_ledger_wizard.py b/account_financial_report_webkit/wizard/partners_ledger_wizard.py index d384b6b0..e92f2f32 100644 --- a/account_financial_report_webkit/wizard/partners_ledger_wizard.py +++ b/account_financial_report_webkit/wizard/partners_ledger_wizard.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Author: Nicolas Bessi, Guewen Baconnier @@ -19,11 +19,10 @@ # ############################################################################## import time +from openerp import models, fields -from openerp.osv import fields, orm - -class AccountReportPartnersLedgerWizard(orm.TransientModel): +class AccountReportPartnersLedgerWizard(models.TransientModel): """Will launch partner ledger report and pass required args""" @@ -31,27 +30,25 @@ class AccountReportPartnersLedgerWizard(orm.TransientModel): _name = "partners.ledger.webkit" _description = "Partner Ledger Report" - _columns = { - 'amount_currency': fields.boolean("With Currency", - help="It adds the currency column"), - 'partner_ids': fields.many2many( - 'res.partner', - string='Filter on partner', - help="Only selected partners will be printed. " - "Leave empty to print all partners."), - 'filter': fields.selection( - [('filter_no', 'No Filters'), - ('filter_date', 'Date'), - ('filter_period', 'Periods')], "Filter by", required=True, - help='Filter by date: no opening balance will be displayed. ' - '(opening balance can only be computed based on period to be \ - correct).'), - } - _defaults = { - 'amount_currency': False, - 'result_selection': 'customer_supplier', - } + amount_currency = fields.Boolean( + "With Currency", help="It adds the currency column", default=False, + ) + partner_ids = fields.Many2many( + 'res.partner', string='Filter on partner', + help="Only selected partners will be printed. Leave empty to print " + "all partners." + ) + filter = fields.Selection( + [('filter_no', 'No Filters'), + ('filter_date', 'Date'), + ('filter_period', 'Periods')], "Filter by", required=True, + help='Filter by date: no opening balance will be displayed. ' + '(opening balance can only be computed based on period to be ' + 'correct).', + ) + result_selection = fields.Selection(default='customer_supplier') + # pylint: disable=old-api7-method-defined def _check_fiscalyear(self, cr, uid, ids, context=None): obj = self.read( cr, uid, ids[0], ['fiscalyear_id', 'filter'], context=context) @@ -66,6 +63,7 @@ class AccountReportPartnersLedgerWizard(orm.TransientModel): ['filter']), ] + # pylint: disable=old-api7-method-defined def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None): res = {} @@ -119,6 +117,7 @@ class AccountReportPartnersLedgerWizard(orm.TransientModel): end_period, 'date_from': False, 'date_to': False} return res + # pylint: disable=old-api7-method-defined def pre_print_report(self, cr, uid, ids, data, context=None): data = super(AccountReportPartnersLedgerWizard, self).pre_print_report( cr, uid, ids, data, context=context) @@ -132,6 +131,7 @@ class AccountReportPartnersLedgerWizard(orm.TransientModel): data['form'].update(vals) return data + # pylint: disable=old-api7-method-defined def _print_report(self, cursor, uid, ids, data, context=None): # we update form with display account value data = self.pre_print_report(cursor, uid, ids, data, context=context) diff --git a/account_financial_report_webkit/wizard/partners_ledger_wizard_view.xml b/account_financial_report_webkit/wizard/partners_ledger_wizard_view.xml index 102926b6..38af6acb 100644 --- a/account_financial_report_webkit/wizard/partners_ledger_wizard_view.xml +++ b/account_financial_report_webkit/wizard/partners_ledger_wizard_view.xml @@ -5,6 +5,7 @@ Partner Ledger partners.ledger.webkit + 99 diff --git a/account_financial_report_webkit/wizard/print_journal.py b/account_financial_report_webkit/wizard/print_journal.py index 1f23fb8e..07c1540d 100644 --- a/account_financial_report_webkit/wizard/print_journal.py +++ b/account_financial_report_webkit/wizard/print_journal.py @@ -21,30 +21,25 @@ # along with this program. If not, see . # ############################################################################## - -from openerp.osv import fields, orm +from openerp import models, fields import time -class AccountReportPrintJournalWizard(orm.TransientModel): +class AccountReportPrintJournalWizard(models.TransientModel): """Will launch print journal report and pass requiered args""" + # pylint: disable=consider-merging-classes-inherited _inherit = "account.common.account.report" _name = "print.journal.webkit" _description = "Journals Report" - _columns = { - 'amount_currency': fields.boolean("With Currency", - help="It adds the currency column"), - } - - _defaults = { - 'amount_currency': False, - 'journal_ids': False, - 'filter': 'filter_period', - } + amount_currency = fields.Boolean( + "With Currency", default=False, help="It adds the currency column", + ) + filter = fields.Selection(default='filter_period') + # pylint: disable=old-api7-method-defined def _check_fiscalyear(self, cr, uid, ids, context=None): obj = self.read(cr, uid, ids[0], ['fiscalyear_id', 'filter'], context=context) @@ -57,6 +52,7 @@ class AccountReportPrintJournalWizard(orm.TransientModel): to filter by periods or by date.', ['filter']), ] + # pylint: disable=old-api7-method-defined def pre_print_report(self, cr, uid, ids, data, context=None): data = super(AccountReportPrintJournalWizard, self).\ pre_print_report(cr, uid, ids, data, context=context) @@ -70,6 +66,7 @@ class AccountReportPrintJournalWizard(orm.TransientModel): data['form'].update(vals) return data + # pylint: disable=old-api7-method-defined def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None): res = {} @@ -122,6 +119,7 @@ class AccountReportPrintJournalWizard(orm.TransientModel): end_period, 'date_from': False, 'date_to': False} return res + # pylint: disable=old-api7-method-defined def _print_report(self, cursor, uid, ids, data, context=None): context = context or {} # we update form with display account value diff --git a/account_financial_report_webkit/wizard/print_journal_view.xml b/account_financial_report_webkit/wizard/print_journal_view.xml index 2482927e..33e56207 100644 --- a/account_financial_report_webkit/wizard/print_journal_view.xml +++ b/account_financial_report_webkit/wizard/print_journal_view.xml @@ -28,6 +28,7 @@ Journals print.journal.webkit form + 99 diff --git a/account_financial_report_webkit/wizard/trial_balance_wizard.py b/account_financial_report_webkit/wizard/trial_balance_wizard.py index b34ce6c5..635d9623 100644 --- a/account_financial_report_webkit/wizard/trial_balance_wizard.py +++ b/account_financial_report_webkit/wizard/trial_balance_wizard.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Author: Guewen Baconnier @@ -18,17 +18,17 @@ # along with this program. If not, see . # ############################################################################## +from openerp import models -from openerp.osv import orm - -class AccountTrialBalanceWizard(orm.TransientModel): +class AccountTrialBalanceWizard(models.TransientModel): """Will launch trial balance report and pass required args""" _inherit = "account.common.balance.report" _name = "trial.balance.webkit" _description = "Trial Balance Report" + # pylint: disable=old-api7-method-defined def _print_report(self, cursor, uid, ids, data, context=None): context = context or {} # we update form with display account value 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 19d56efe..55a97c0c 100644 --- a/account_financial_report_webkit/wizard/trial_balance_wizard_view.xml +++ b/account_financial_report_webkit/wizard/trial_balance_wizard_view.xml @@ -9,6 +9,7 @@ Trial Balance trial.balance.webkit + 99 diff --git a/account_financial_report_webkit_xls/__openerp__.py b/account_financial_report_webkit_xls/__openerp__.py index eebbd67c..9fba30ce 100644 --- a/account_financial_report_webkit_xls/__openerp__.py +++ b/account_financial_report_webkit_xls/__openerp__.py @@ -23,6 +23,5 @@ 'test/trial_balance.yml', 'test/partner_balance.yml', 'test/open_invoices.yml'], - 'active': False, 'installable': True, } diff --git a/account_financial_report_webkit_xls/report/aged_open_invoices_xls.py b/account_financial_report_webkit_xls/report/aged_open_invoices_xls.py index dfc7f402..4b38556a 100644 --- a/account_financial_report_webkit_xls/report/aged_open_invoices_xls.py +++ b/account_financial_report_webkit_xls/report/aged_open_invoices_xls.py @@ -14,6 +14,7 @@ from openerp.tools.translate import _ class AccountAgedOpenInvoicesWebkitXls(report_xls): + # pylint: disable=old-api7-method-defined def create(self, cr, uid, ids, data, context=None): self._column_sizes = [ 30, # Partner diff --git a/account_financial_report_webkit_xls/report/aged_partner_balance_xls.py b/account_financial_report_webkit_xls/report/aged_partner_balance_xls.py index a7d16006..95a72312 100644 --- a/account_financial_report_webkit_xls/report/aged_partner_balance_xls.py +++ b/account_financial_report_webkit_xls/report/aged_partner_balance_xls.py @@ -13,6 +13,7 @@ from openerp.tools.translate import _ class AccountAgedTrialBalanceWebkitXls(report_xls): + # pylint: disable=old-api7-method-defined def create(self, cr, uid, ids, data, context=None): self._column_sizes = [ 30, # Partner diff --git a/account_financial_report_webkit_xls/report/general_ledger_xls.py b/account_financial_report_webkit_xls/report/general_ledger_xls.py index caebd35a..f8932735 100644 --- a/account_financial_report_webkit_xls/report/general_ledger_xls.py +++ b/account_financial_report_webkit_xls/report/general_ledger_xls.py @@ -29,7 +29,7 @@ _column_sizes = [ ] -class general_ledger_xls(report_xls): +class GeneralLedgerXls(report_xls): column_sizes = [x[1] for x in _column_sizes] def generate_xls_report(self, _p, _xs, data, objects, wb): @@ -327,6 +327,6 @@ class general_ledger_xls(report_xls): row_pos += 1 -general_ledger_xls('report.account.account_report_general_ledger_xls', - 'account.account', - parser=GeneralLedgerWebkit) +GeneralLedgerXls('report.account.account_report_general_ledger_xls', + 'account.account', + parser=GeneralLedgerWebkit) diff --git a/account_financial_report_webkit_xls/report/open_invoices_xls.py b/account_financial_report_webkit_xls/report/open_invoices_xls.py index c9aa9f36..2412bb30 100644 --- a/account_financial_report_webkit_xls/report/open_invoices_xls.py +++ b/account_financial_report_webkit_xls/report/open_invoices_xls.py @@ -12,7 +12,7 @@ from openerp.tools.translate import _ # _logger = logging.getLogger(__name__) -class open_invoices_xls(report_xls): +class OpenInvoicesXls(report_xls): column_sizes = [12, 12, 20, 15, 30, 30, 14, 14, 14, 14, 14, 14, 10] def global_initializations(self, wb, _p, xlwt, _xs, objects, data): @@ -806,5 +806,5 @@ class open_invoices_xls(report_xls): row_pos += 1 -open_invoices_xls('report.account.account_report_open_invoices_xls', - 'account.account', parser=PartnersOpenInvoicesWebkit) +OpenInvoicesXls('report.account.account_report_open_invoices_xls', + 'account.account', parser=PartnersOpenInvoicesWebkit) diff --git a/account_financial_report_webkit_xls/report/partner_ledger_xls.py b/account_financial_report_webkit_xls/report/partner_ledger_xls.py index 504fe2d0..5071a000 100644 --- a/account_financial_report_webkit_xls/report/partner_ledger_xls.py +++ b/account_financial_report_webkit_xls/report/partner_ledger_xls.py @@ -27,7 +27,7 @@ _column_sizes = [ ] -class partner_ledger_xls(report_xls): +class PartnerLedgerXls(report_xls): column_sizes = [x[1] for x in _column_sizes] def generate_xls_report(self, _p, _xs, data, objects, wb): @@ -438,6 +438,6 @@ class partner_ledger_xls(report_xls): row_pos += 2 -partner_ledger_xls('report.account.account_report_partner_ledger_xls', - 'account.account', - parser=PartnersLedgerWebkit) +PartnerLedgerXls('report.account.account_report_partner_ledger_xls', + 'account.account', + parser=PartnersLedgerWebkit) diff --git a/account_financial_report_webkit_xls/report/partners_balance_xls.py b/account_financial_report_webkit_xls/report/partners_balance_xls.py index b282b69b..2c0b1db3 100644 --- a/account_financial_report_webkit_xls/report/partners_balance_xls.py +++ b/account_financial_report_webkit_xls/report/partners_balance_xls.py @@ -15,7 +15,7 @@ def display_line(all_comparison_lines): return any([line.get('balance') for line in all_comparison_lines]) -class partners_balance_xls(report_xls): +class PartnersBalanceXls(report_xls): column_sizes = [12, 40, 25, 17, 17, 17, 17, 17] def print_title(self, ws, _p, row_position, xlwt, _xs): @@ -409,6 +409,6 @@ class partners_balance_xls(report_xls): _xs, xlwt, ws, row_account_start, row_pos, current_account, _p) -partners_balance_xls('report.account.account_report_partner_balance_xls', - 'account.account', - parser=PartnerBalanceWebkit) +PartnersBalanceXls('report.account.account_report_partner_balance_xls', + 'account.account', + parser=PartnerBalanceWebkit) diff --git a/account_financial_report_webkit_xls/report/trial_balance_xls.py b/account_financial_report_webkit_xls/report/trial_balance_xls.py index fde93c06..c6460382 100644 --- a/account_financial_report_webkit_xls/report/trial_balance_xls.py +++ b/account_financial_report_webkit_xls/report/trial_balance_xls.py @@ -13,6 +13,7 @@ from openerp.tools.translate import _ class TrialBalanceXls(report_xls): + # pylint: disable=old-api7-method-defined def create(self, cr, uid, ids, data, context=None): self._column_sizes = [12, 60, 17, 17, 17, 17, 17, 17] self._debit_pos = 4 diff --git a/account_financial_report_webkit_xls/wizard/aged_open_invoices_wizard.py b/account_financial_report_webkit_xls/wizard/aged_open_invoices_wizard.py index 563e1d37..5a2f675d 100644 --- a/account_financial_report_webkit_xls/wizard/aged_open_invoices_wizard.py +++ b/account_financial_report_webkit_xls/wizard/aged_open_invoices_wizard.py @@ -7,9 +7,11 @@ from openerp import models class AgedOpenInvoice(models.TransientModel): _inherit = 'aged.open.invoices.webkit' + # pylint: disable=old-api7-method-defined def xls_export(self, cr, uid, ids, context=None): return self.check_report(cr, uid, ids, context=context) + # pylint: disable=old-api7-method-defined def _print_report(self, cr, uid, ids, data, context=None): context = context or {} if context.get('xls_export'): diff --git a/account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.py b/account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.py index b70b23eb..63de571d 100644 --- a/account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.py +++ b/account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.py @@ -7,9 +7,11 @@ from openerp import models class AccountAgedTrialBalance(models.TransientModel): _inherit = 'account.aged.trial.balance.webkit' + # pylint: disable=old-api7-method-defined def xls_export(self, cr, uid, ids, context=None): return self.check_report(cr, uid, ids, context=context) + # pylint: disable=old-api7-method-defined def _print_report(self, cr, uid, ids, data, context=None): context = context or {} if context.get('xls_export'): diff --git a/account_financial_report_webkit_xls/wizard/general_ledger_wizard.py b/account_financial_report_webkit_xls/wizard/general_ledger_wizard.py index d0d394cc..a3766aa3 100644 --- a/account_financial_report_webkit_xls/wizard/general_ledger_wizard.py +++ b/account_financial_report_webkit_xls/wizard/general_ledger_wizard.py @@ -7,9 +7,11 @@ from openerp import models class AccountReportGeneralLedgerWizard(models.TransientModel): _inherit = 'general.ledger.webkit' + # pylint: disable=old-api7-method-defined def xls_export(self, cr, uid, ids, context=None): return self.check_report(cr, uid, ids, context=context) + # pylint: disable=old-api7-method-defined def _print_report(self, cr, uid, ids, data, context=None): context = context or {} if context.get('xls_export'): diff --git a/account_financial_report_webkit_xls/wizard/general_ledger_wizard_view.xml b/account_financial_report_webkit_xls/wizard/general_ledger_wizard_view.xml index dd6a53a7..1bffd05f 100644 --- a/account_financial_report_webkit_xls/wizard/general_ledger_wizard_view.xml +++ b/account_financial_report_webkit_xls/wizard/general_ledger_wizard_view.xml @@ -5,6 +5,7 @@ general.ledger.webkit.xls general.ledger.webkit + 99 form diff --git a/account_financial_report_webkit_xls/wizard/open_invoices_wizard.py b/account_financial_report_webkit_xls/wizard/open_invoices_wizard.py index 5b4b4df6..32dfd592 100644 --- a/account_financial_report_webkit_xls/wizard/open_invoices_wizard.py +++ b/account_financial_report_webkit_xls/wizard/open_invoices_wizard.py @@ -7,9 +7,11 @@ from openerp import models class AccountReportOpenInvoicesWizard(models.TransientModel): _inherit = 'open.invoices.webkit' + # pylint: disable=old-api7-method-defined def xls_export(self, cr, uid, ids, context=None): return self.check_report(cr, uid, ids, context=context) + # pylint: disable=old-api7-method-defined def _print_report(self, cr, uid, ids, data, context=None): context = context or {} if context.get('xls_export'): diff --git a/account_financial_report_webkit_xls/wizard/open_invoices_wizard_view.xml b/account_financial_report_webkit_xls/wizard/open_invoices_wizard_view.xml index 1430e727..e1b0e3ec 100644 --- a/account_financial_report_webkit_xls/wizard/open_invoices_wizard_view.xml +++ b/account_financial_report_webkit_xls/wizard/open_invoices_wizard_view.xml @@ -5,6 +5,7 @@ open.invoices.webkit.xls open.invoices.webkit + 99 form diff --git a/account_financial_report_webkit_xls/wizard/partners_balance_wizard.py b/account_financial_report_webkit_xls/wizard/partners_balance_wizard.py index 3c0d6faf..62a3a65e 100644 --- a/account_financial_report_webkit_xls/wizard/partners_balance_wizard.py +++ b/account_financial_report_webkit_xls/wizard/partners_balance_wizard.py @@ -7,9 +7,11 @@ from openerp import models class AccountPartnerBalanceWizard(models.TransientModel): _inherit = 'partner.balance.webkit' + # pylint: disable=old-api7-method-defined def xls_export(self, cr, uid, ids, context=None): return self.check_report(cr, uid, ids, context=context) + # pylint: disable=old-api7-method-defined def _print_report(self, cr, uid, ids, data, context=None): context = context or {} if context.get('xls_export'): diff --git a/account_financial_report_webkit_xls/wizard/partners_ledger_wizard.py b/account_financial_report_webkit_xls/wizard/partners_ledger_wizard.py index 450bbfab..8d514fcb 100644 --- a/account_financial_report_webkit_xls/wizard/partners_ledger_wizard.py +++ b/account_financial_report_webkit_xls/wizard/partners_ledger_wizard.py @@ -7,9 +7,11 @@ from openerp import models class AccountReportPartnersLedgerWizard(models.TransientModel): _inherit = 'partners.ledger.webkit' + # pylint: disable=old-api7-method-defined def xls_export(self, cr, uid, ids, context=None): return self.check_report(cr, uid, ids, context=context) + # pylint: disable=old-api7-method-defined def _print_report(self, cr, uid, ids, data, context=None): context = context or {} if context.get('xls_export'): diff --git a/account_financial_report_webkit_xls/wizard/partners_ledger_wizard_view.xml b/account_financial_report_webkit_xls/wizard/partners_ledger_wizard_view.xml index 86201acf..8f9976cc 100644 --- a/account_financial_report_webkit_xls/wizard/partners_ledger_wizard_view.xml +++ b/account_financial_report_webkit_xls/wizard/partners_ledger_wizard_view.xml @@ -5,6 +5,7 @@ partners.ledger.webkit.xls partners.ledger.webkit + 99 form diff --git a/account_financial_report_webkit_xls/wizard/trial_balance_wizard.py b/account_financial_report_webkit_xls/wizard/trial_balance_wizard.py index 77965ba1..5d6b1bd6 100644 --- a/account_financial_report_webkit_xls/wizard/trial_balance_wizard.py +++ b/account_financial_report_webkit_xls/wizard/trial_balance_wizard.py @@ -7,9 +7,11 @@ from openerp import models class AccountTrialBalanceWizard(models.TransientModel): _inherit = 'trial.balance.webkit' + # pylint: disable=old-api7-method-defined def xls_export(self, cr, uid, ids, context=None): return self.check_report(cr, uid, ids, context=context) + # pylint: disable=old-api7-method-defined def _print_report(self, cr, uid, ids, data, context=None): context = context or {} if context.get('xls_export'): diff --git a/account_financial_report_webkit_xls/wizard/trial_balance_wizard_view.xml b/account_financial_report_webkit_xls/wizard/trial_balance_wizard_view.xml index e2828c71..2fb2bd62 100644 --- a/account_financial_report_webkit_xls/wizard/trial_balance_wizard_view.xml +++ b/account_financial_report_webkit_xls/wizard/trial_balance_wizard_view.xml @@ -5,6 +5,7 @@ trial.balance.webkit.xls trial.balance.webkit + 99 form diff --git a/account_journal_report_xls/__openerp__.py b/account_journal_report_xls/__openerp__.py index 36057789..6666d83b 100644 --- a/account_journal_report_xls/__openerp__.py +++ b/account_journal_report_xls/__openerp__.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution diff --git a/account_journal_report_xls/account_journal.py b/account_journal_report_xls/account_journal.py index e426ec9d..bbb204ed 100644 --- a/account_journal_report_xls/account_journal.py +++ b/account_journal_report_xls/account_journal.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution @@ -19,14 +19,14 @@ # along with this program. If not, see . # ############################################################################## +from openerp import models -from openerp.osv import orm - -class account_journal(orm.Model): +class AccountJournal(models.Model): _inherit = 'account.journal' # allow inherited modules to extend the query + # pylint: disable=old-api7-method-defined def _report_xls_query_extra(self, cr, uid, context=None): select_extra = "" join_extra = "" @@ -34,10 +34,12 @@ class account_journal(orm.Model): return (select_extra, join_extra, where_extra) # allow inherited modules to add document references + # pylint: disable=old-api7-method-defined def _report_xls_document_extra(self, cr, uid, context): return "''" # override list in inherited module to add/drop columns or change order + # pylint: disable=old-api7-method-defined def _report_xls_fields(self, cr, uid, context=None): res = [ 'move_name', # account.move,name @@ -73,6 +75,7 @@ class account_journal(orm.Model): return res # Change/Add Template entries + # pylint: disable=old-api7-method-defined def _report_xls_template(self, cr, uid, context=None): """ Template updates, e.g. diff --git a/account_journal_report_xls/report/nov_account_journal.py b/account_journal_report_xls/report/nov_account_journal.py index bb8ed135..0ac14258 100644 --- a/account_journal_report_xls/report/nov_account_journal.py +++ b/account_journal_report_xls/report/nov_account_journal.py @@ -11,12 +11,12 @@ _logger = logging.getLogger(__name__) _ir_translation_name = 'nov.account.journal.print' -class nov_journal_print(report_sxw.rml_parse): +class NovJournalPrint(report_sxw.rml_parse): def set_context(self, objects, data, ids, report_type=None): # _logger.warn('set_context, objects = %s, data = %s, # ids = %s', objects, data, ids) - super(nov_journal_print, self).set_context(objects, data, ids) + super(NovJournalPrint, self).set_context(objects, data, ids) j_obj = self.pool.get('account.journal') p_obj = self.pool.get('account.period') fy_obj = self.pool.get('account.fiscalyear') @@ -48,10 +48,11 @@ class nov_journal_print(report_sxw.rml_parse): objects.append((journal, fiscalyear)) self.localcontext['objects'] = self.objects = objects + # pylint: disable=old-api7-method-defined def __init__(self, cr, uid, name, context): if context is None: context = {} - super(nov_journal_print, self).__init__(cr, uid, name, context=context) + super(NovJournalPrint, self).__init__(cr, uid, name, context=context) self.localcontext.update({ 'time': time, 'title': self._title, @@ -121,6 +122,7 @@ class nov_journal_print(report_sxw.rml_parse): # field value translations. # If performance is no issue, you can adapt the _report_xls_template in # an inherited module to add field value translations. + # pylint: disable=sql-injection self.cr.execute("SELECT l.move_id AS move_id, l.id AS aml_id, " "am.name AS move_name, " "coalesce(am.ref,'') AS move_ref, " @@ -197,8 +199,9 @@ class nov_journal_print(report_sxw.rml_parse): code_string = j_obj._report_xls_document_extra( self.cr, self.uid, self.context) # _logger.warn('code_string= %s', code_string) - # disable=W0123, safe_eval doesn't apply here since + # W0123, safe_eval doesn't apply here since # code_string comes from python module + # pylint: disable=eval-referenced [x.update( {'docname': eval(code_string) or '-'}) # pylint: disable=W0123 for x in lines] @@ -307,6 +310,7 @@ class nov_journal_print(report_sxw.rml_parse): else: fiscalyear = object[1] period_ids = [x.id for x in fiscalyear.period_ids] + # pylint: disable=sql-injection select = "SELECT sum(" + field + ") FROM account_move_line l " \ "INNER JOIN account_move am ON l.move_id = am.id " \ "WHERE l.period_id IN %s AND l.journal_id=%s AND am.state IN %s" @@ -334,7 +338,7 @@ class nov_journal_print(report_sxw.rml_parse): if isinstance(value, (float, int)) and not value: return '' else: - return super(nov_journal_print, self).formatLang( + return super(NovJournalPrint, self).formatLang( value, digits, date, date_time, grouping, monetary, dp, currency_obj) @@ -342,4 +346,4 @@ class nov_journal_print(report_sxw.rml_parse): report_sxw.report_sxw( 'report.nov.account.journal.print', 'account.journal', 'addons/account_journal_report_xls/report/nov_account_journal.rml', - parser=nov_journal_print, header=False) + parser=NovJournalPrint, header=False) diff --git a/account_journal_report_xls/report/nov_account_journal_xls.py b/account_journal_report_xls/report/nov_account_journal_xls.py index eab96259..c816ca76 100644 --- a/account_journal_report_xls/report/nov_account_journal_xls.py +++ b/account_journal_report_xls/report/nov_account_journal_xls.py @@ -4,20 +4,21 @@ import xlwt from datetime import datetime -from openerp.osv import orm from openerp.addons.report_xls.report_xls import report_xls from openerp.addons.report_xls.utils import rowcol_to_cell, _render from .nov_account_journal import nov_journal_print from openerp.tools.translate import _ +from openerp.exceptions import except_orm import logging _logger = logging.getLogger(__name__) -class account_journal_xls_parser(nov_journal_print): +class AccountJournalXlsParser(nov_journal_print): + # pylint: disable=old-api7-method-defined def __init__(self, cr, uid, name, context): - super(account_journal_xls_parser, self).__init__(cr, uid, name, - context=context) + super(AccountJournalXlsParser, self).__init__( + cr, uid, name, context=context) journal_obj = self.pool.get('account.journal') self.context = context wanted_list = journal_obj._report_xls_fields(cr, uid, context) @@ -29,11 +30,12 @@ class account_journal_xls_parser(nov_journal_print): }) -class account_journal_xls(report_xls): +class AccountJournalXls(report_xls): + # pylint: disable=old-api7-method-defined def __init__(self, name, table, rml=False, parser=False, header=True, store=False): - super(account_journal_xls, self).__init__( + super(AccountJournalXls, self).__init__( name, table, rml, parser, header, store) # Cell Styles @@ -305,7 +307,7 @@ class account_journal_xls(report_xls): cols_number = len(wanted_list) vat_summary_cols_number = len(vat_summary_wanted_list) if vat_summary_cols_number > cols_number: - raise orm.except_orm( + raise except_orm( _('Programming Error!'), _("vat_summary_cols_number should be < cols_number !")) index = 0 @@ -360,10 +362,12 @@ class account_journal_xls(report_xls): 'credit') if not (self.credit_pos and self.debit_pos) and 'balance' \ in wanted_list: - raise orm.except_orm(_('Customisation Error!'), - _("The 'Balance' field is a calculated XLS \ - field requiring the presence of the \ - 'Debit' and 'Credit' fields !")) + raise except_orm( + _('Customisation Error!'), + _("The 'Balance' field is a calculated XLS \ + field requiring the presence of the \ + 'Debit' and 'Credit' fields !") + ) for o in objects: @@ -387,5 +391,7 @@ class account_journal_xls(report_xls): row_pos = self._journal_vat_summary(o, ws, _p, row_pos, _xs) -account_journal_xls('report.nov.account.journal.xls', 'account.journal.period', - parser=account_journal_xls_parser) +AccountJournalXls( + 'report.nov.account.journal.xls', 'account.journal.period', + parser=AccountJournalXlsParser, +) diff --git a/account_journal_report_xls/wizard/print_journal_wizard.py b/account_journal_report_xls/wizard/print_journal_wizard.py index cc2ab4a2..e1390b22 100644 --- a/account_journal_report_xls/wizard/print_journal_wizard.py +++ b/account_journal_report_xls/wizard/print_journal_wizard.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution @@ -19,37 +19,34 @@ # along with this program. If not, see . # ############################################################################## - -from openerp.tools.translate import _ -from openerp.osv import orm, fields +from openerp import _, exceptions, models, fields from openerp.addons.account.wizard.account_report_common_journal \ import account_common_journal_report import logging _logger = logging.getLogger(__name__) -class account_print_journal_xls(orm.TransientModel): +class AccountPrintJournalXls(models.TransientModel): _inherit = 'account.print.journal' _name = 'account.print.journal.xls' _description = 'Print/Export Journal' - _columns = { - 'journal_ids': fields.many2many( - 'account.journal', - 'account_print_journal_xls_journal_rel', - 'journal_xls_id', - 'journal_id', - string='Journals', - required=True), - 'group_entries': fields.boolean( - 'Group Entries', - help="Group entries with same General Account & Tax Code."), - } - _defaults = { - 'group_entries': True, - } + journal_ids = fields.Many2many( + 'account.journal', + 'account_print_journal_xls_journal_rel', + 'journal_xls_id', + 'journal_id', + string='Journals', + required=True + ) + group_entries = fields.Boolean( + 'Group Entries', default=True, + help="Group entries with same General Account & Tax Code." + ) + + # pylint: disable=old-api7-method-defined def fields_get(self, cr, uid, fields=None, context=None): - res = super(account_print_journal_xls, self).fields_get( + res = super(AccountPrintJournalXls, self).fields_get( cr, uid, fields, context) if context.get('print_by') == 'fiscalyear': if 'fiscalyear_id' in res: @@ -65,6 +62,7 @@ class account_print_journal_xls(orm.TransientModel): res['period_to']['required'] = True return res + # pylint: disable=old-api7-method-defined def fy_period_ids(self, cr, uid, fiscalyear_id): """ returns all periods from a fiscalyear sorted by date """ fy_period_ids = [] @@ -78,6 +76,7 @@ class account_print_journal_xls(orm.TransientModel): fy_period_ids = [x[0] for x in res] return fy_period_ids + # pylint: disable=old-api7-method-defined def onchange_fiscalyear_id(self, cr, uid, ids, fiscalyear_id=False, context=None): res = {'value': {}} @@ -89,6 +88,7 @@ class account_print_journal_xls(orm.TransientModel): res['value']['period_to'] = fy_period_ids[-1] return res + # pylint: disable=old-api7-method-defined def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): """ skip account.common.journal.report,fields_view_get @@ -97,9 +97,11 @@ class account_print_journal_xls(orm.TransientModel): fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu) + # pylint: disable=old-api7-method-defined def xls_export(self, cr, uid, ids, context=None): return self.print_report(cr, uid, ids, context=context) + # pylint: disable=old-api7-method-defined def print_report(self, cr, uid, ids, context=None): if context is None: context = {} @@ -156,7 +158,7 @@ class account_print_journal_xls(orm.TransientModel): if aml_ids: journal_fy_ids.append((journal_id, fiscalyear_id)) if not journal_fy_ids: - raise orm.except_orm( + raise exceptions.except_orm( _('No Data Available'), _('No records found for your selection!')) datas.update({ @@ -180,7 +182,7 @@ class account_print_journal_xls(orm.TransientModel): if period_ids: journal_period_ids.append((journal_id, period_ids)) if not journal_period_ids: - raise orm.except_orm( + raise exceptions.except_orm( _('No Data Available'), _('No records found for your selection!')) datas.update({ diff --git a/account_journal_report_xls/wizard/print_journal_wizard.xml b/account_journal_report_xls/wizard/print_journal_wizard.xml index 6c3496e0..5ff82d11 100644 --- a/account_journal_report_xls/wizard/print_journal_wizard.xml +++ b/account_journal_report_xls/wizard/print_journal_wizard.xml @@ -1,10 +1,10 @@ - Print/Export Journals account.print.journal.xls + 99 @@ -19,7 +19,7 @@ - + @@ -53,7 +53,7 @@ action="action_print_journal_by_period_xls" id="menu_print_journal_by_period_xls" icon="STOCK_PRINT"/> - + Journal by Fiscal Year ir.actions.act_window @@ -75,6 +75,6 @@ 3 - + - \ No newline at end of file + From b6e6b6e5450e4802db2b76003c7351d3a7eb5ef3 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 20 Feb 2018 07:55:56 +0100 Subject: [PATCH 8/8] [FIX] imports of account_journal_report_xls --- account_journal_report_xls/__init__.py | 2 +- account_journal_report_xls/report/nov_account_journal_xls.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/account_journal_report_xls/__init__.py b/account_journal_report_xls/__init__.py index 6368e57d..c477732d 100644 --- a/account_journal_report_xls/__init__.py +++ b/account_journal_report_xls/__init__.py @@ -27,4 +27,4 @@ try: except ImportError: import logging logging.getLogger('openerp.module').warning('''report_xls not available in - addons path. account_financial_report_webkit_xls will not be usable''') + addons path. account_journal_report_xls will not be usable''') diff --git a/account_journal_report_xls/report/nov_account_journal_xls.py b/account_journal_report_xls/report/nov_account_journal_xls.py index c816ca76..e966e03f 100644 --- a/account_journal_report_xls/report/nov_account_journal_xls.py +++ b/account_journal_report_xls/report/nov_account_journal_xls.py @@ -6,14 +6,14 @@ import xlwt from datetime import datetime from openerp.addons.report_xls.report_xls import report_xls from openerp.addons.report_xls.utils import rowcol_to_cell, _render -from .nov_account_journal import nov_journal_print +from .nov_account_journal import NovJournalPrint from openerp.tools.translate import _ from openerp.exceptions import except_orm import logging _logger = logging.getLogger(__name__) -class AccountJournalXlsParser(nov_journal_print): +class AccountJournalXlsParser(NovJournalPrint): # pylint: disable=old-api7-method-defined def __init__(self, cr, uid, name, context):