From f776cf02995b390c041af3497564ac0f790ad1c0 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Mon, 27 Jan 2014 15:32:33 +0100 Subject: [PATCH] [ADD] added xls versions of reports --- .../__init__.py | 24 + .../__openerp__.py | 50 ++ .../report/__init__.py | 29 + .../report/general_ledger_xls.py | 286 ++++++++ .../report/open_invoices_xls.py | 627 ++++++++++++++++++ .../report/partner_ledger_xls.py | 365 ++++++++++ .../report/partners_balance_xls.py | 328 +++++++++ .../report/trial_balance_xls.py | 258 +++++++ .../wizard/__init__.py | 27 + .../wizard/general_ledger_wizard.py | 43 ++ .../wizard/general_ledger_wizard_view.xml | 26 + .../wizard/open_invoices_wizard.py | 42 ++ .../wizard/open_invoices_wizard_view.xml | 26 + .../wizard/partners_balance_wizard.py | 43 ++ .../wizard/partners_balance_wizard_view.xml | 26 + .../wizard/partners_ledger_wizard.py | 42 ++ .../wizard/partners_ledger_wizard_view.xml | 26 + .../wizard/trial_balance_wizard.py | 43 ++ .../wizard/trial_balance_wizard_view.xml | 26 + account_journal_report_xls/__init__.py | 27 + account_journal_report_xls/__openerp__.py | 57 ++ account_journal_report_xls/account_journal.py | 84 +++ account_journal_report_xls/i18n/fr.po | 256 +++++++ account_journal_report_xls/i18n/nl.po | 256 +++++++ account_journal_report_xls/report/__init__.py | 26 + .../report/nov_account_journal.py | 291 ++++++++ .../report/nov_account_journal.rml | 286 ++++++++ .../report/nov_account_journal_xls.py | 317 +++++++++ .../static/src/img/icon.png | Bin 0 -> 15230 bytes account_journal_report_xls/wizard/__init__.py | 25 + .../wizard/print_journal_wizard.py | 172 +++++ .../wizard/print_journal_wizard.xml | 80 +++ account_move_line_report_xls/__init__.py | 24 + account_move_line_report_xls/__openerp__.py | 46 ++ .../account_move_line.py | 52 ++ account_move_line_report_xls/i18n/fr.po | 111 ++++ account_move_line_report_xls/i18n/nl.po | 111 ++++ .../report/__init__.py | 23 + .../report/move_line_list_xls.py | 240 +++++++ .../report/move_line_list_xls.xml | 22 + .../static/src/img/icon.png | Bin 0 -> 11645 bytes 41 files changed, 4843 insertions(+) create mode 100644 account_financial_report_webkit_xls/__init__.py create mode 100644 account_financial_report_webkit_xls/__openerp__.py create mode 100644 account_financial_report_webkit_xls/report/__init__.py create mode 100644 account_financial_report_webkit_xls/report/general_ledger_xls.py create mode 100644 account_financial_report_webkit_xls/report/open_invoices_xls.py create mode 100644 account_financial_report_webkit_xls/report/partner_ledger_xls.py create mode 100644 account_financial_report_webkit_xls/report/partners_balance_xls.py create mode 100644 account_financial_report_webkit_xls/report/trial_balance_xls.py create mode 100644 account_financial_report_webkit_xls/wizard/__init__.py create mode 100644 account_financial_report_webkit_xls/wizard/general_ledger_wizard.py create mode 100644 account_financial_report_webkit_xls/wizard/general_ledger_wizard_view.xml create mode 100644 account_financial_report_webkit_xls/wizard/open_invoices_wizard.py create mode 100644 account_financial_report_webkit_xls/wizard/open_invoices_wizard_view.xml create mode 100644 account_financial_report_webkit_xls/wizard/partners_balance_wizard.py create mode 100644 account_financial_report_webkit_xls/wizard/partners_balance_wizard_view.xml create mode 100644 account_financial_report_webkit_xls/wizard/partners_ledger_wizard.py create mode 100644 account_financial_report_webkit_xls/wizard/partners_ledger_wizard_view.xml create mode 100644 account_financial_report_webkit_xls/wizard/trial_balance_wizard.py create mode 100644 account_financial_report_webkit_xls/wizard/trial_balance_wizard_view.xml create mode 100644 account_journal_report_xls/__init__.py create mode 100644 account_journal_report_xls/__openerp__.py create mode 100644 account_journal_report_xls/account_journal.py create mode 100644 account_journal_report_xls/i18n/fr.po create mode 100644 account_journal_report_xls/i18n/nl.po create mode 100644 account_journal_report_xls/report/__init__.py create mode 100644 account_journal_report_xls/report/nov_account_journal.py create mode 100644 account_journal_report_xls/report/nov_account_journal.rml create mode 100644 account_journal_report_xls/report/nov_account_journal_xls.py create mode 100644 account_journal_report_xls/static/src/img/icon.png create mode 100644 account_journal_report_xls/wizard/__init__.py create mode 100644 account_journal_report_xls/wizard/print_journal_wizard.py create mode 100644 account_journal_report_xls/wizard/print_journal_wizard.xml create mode 100644 account_move_line_report_xls/__init__.py create mode 100644 account_move_line_report_xls/__openerp__.py create mode 100644 account_move_line_report_xls/account_move_line.py create mode 100644 account_move_line_report_xls/i18n/fr.po create mode 100644 account_move_line_report_xls/i18n/nl.po create mode 100644 account_move_line_report_xls/report/__init__.py create mode 100644 account_move_line_report_xls/report/move_line_list_xls.py create mode 100644 account_move_line_report_xls/report/move_line_list_xls.xml create mode 100644 account_move_line_report_xls/static/src/img/icon.png diff --git a/account_financial_report_webkit_xls/__init__.py b/account_financial_report_webkit_xls/__init__.py new file mode 100644 index 00000000..d96f4819 --- /dev/null +++ b/account_financial_report_webkit_xls/__init__.py @@ -0,0 +1,24 @@ +# -*- 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 . +# +############################################################################## + +from . import wizard +from . import report diff --git a/account_financial_report_webkit_xls/__openerp__.py b/account_financial_report_webkit_xls/__openerp__.py new file mode 100644 index 00000000..d589a8e1 --- /dev/null +++ b/account_financial_report_webkit_xls/__openerp__.py @@ -0,0 +1,50 @@ +# -*- 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 . +# +############################################################################## +{ + 'name': 'Add XLS export to accounting reports', + 'version': '0.4', + 'license': 'AGPL-3', + 'author': 'Noviat', + '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_xml': [], + 'init_xml': [], + 'update_xml' : [ + 'wizard/general_ledger_wizard_view.xml', + 'wizard/trial_balance_wizard_view.xml', + 'wizard/partners_ledger_wizard_view.xml', + 'wizard/partners_balance_wizard_view.xml', + 'wizard/open_invoices_wizard_view.xml', + ], + 'active': False, + 'installable': True, +} diff --git a/account_financial_report_webkit_xls/report/__init__.py b/account_financial_report_webkit_xls/report/__init__.py new file mode 100644 index 00000000..b42b033e --- /dev/null +++ b/account_financial_report_webkit_xls/report/__init__.py @@ -0,0 +1,29 @@ +# -*- 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 . +# +############################################################################## + +from . import general_ledger_xls +from . import trial_balance_xls +from . import partners_balance_xls +from . import partner_ledger_xls +from . import open_invoices_xls + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/account_financial_report_webkit_xls/report/general_ledger_xls.py b/account_financial_report_webkit_xls/report/general_ledger_xls.py new file mode 100644 index 00000000..967f3733 --- /dev/null +++ b/account_financial_report_webkit_xls/report/general_ledger_xls.py @@ -0,0 +1,286 @@ +# -*- 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 . +# +############################################################################## + +import xlwt +import time +from datetime import datetime +from openerp.report import report_sxw +from openerp.addons.report_xls.report_xls import report_xls +from openerp.addons.report_xls.utils import rowcol_to_cell +from openerp.addons.account_financial_report_webkit.report.general_ledger import GeneralLedgerWebkit +from openerp.tools.translate import _ +#import logging +#_logger = logging.getLogger(__name__) + +_column_sizes = [ + ('date', 12), + ('period', 12), + ('move', 20), + ('journal', 12), + ('account_code', 12), + ('partner', 30), + ('label', 45), + ('counterpart', 30), + ('debit', 15), + ('credit', 15), + ('cumul_bal', 15), + ('curr_bal', 15), + ('curr_code', 7), +] + +class general_ledger_xls(report_xls): + column_sizes = [x[1] for x in _column_sizes] + + def generate_xls_report(self, _p, _xs, data, objects, wb): + + ws = wb.add_sheet(_p.report_name[:31]) + ws.panes_frozen = True + ws.remove_splits = True + ws.portrait = 0 # Landscape + ws.fit_width_to_pages = 1 + row_pos = 0 + + # set print header/footer + ws.header_str = self.xls_headers['standard'] + ws.footer_str = self.xls_footers['standard'] + + # cf. account_report_general_ledger.mako + initial_balance_text = {'initial_balance': _('Computed'), 'opening_balance': _('Opening Entries'), False: _('No')} + + # Title + cell_style = xlwt.easyxf(_xs['xls_title']) + report_name = ' - '.join([_p.report_name.upper(), _p.company.partner_id.name, _p.company.currency_id.name]) + c_specs = [ + ('report_name', 1, 0, 'text', report_name), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style) + + # write empty row to define column sizes + c_sizes = self.column_sizes + c_specs = [('empty%s'%i, 1, c_sizes[i], 'text', None) for i in range(0,len(c_sizes))] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, set_column_size=True) + + # Header Table + cell_format = _xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] + cell_style = xlwt.easyxf(cell_format) + cell_style_center = xlwt.easyxf(cell_format + _xs['center']) + c_specs = [ + ('coa', 2, 0, 'text', _('Chart of Account')), + ('fy', 1, 0, 'text', _('Fiscal Year')), + ('df', 3, 0, 'text', _p.filter_form(data) == 'filter_date' and _('Dates Filter') or _('Periods Filter')), + ('af', 1, 0, 'text', _('Accounts Filter')), + ('tm', 2, 0, 'text', _('Target Moves')), + ('ib', 2, 0, 'text', _('Initial Balance')), + + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style_center) + + cell_format = _xs['borders_all'] + cell_style = xlwt.easyxf(cell_format) + cell_style_center = xlwt.easyxf(cell_format + _xs['center']) + c_specs = [ + ('coa', 2, 0, 'text', _p.chart_account.name), + ('fy', 1, 0, 'text', _p.fiscalyear.name if _p.fiscalyear else '-'), + ] + df = _('From') + ': ' + if _p.filter_form(data) == 'filter_date': + df += _p.start_date if _p.start_date else u'' + else: + df += _p.start_period.name if _p.start_period else u'' + df += ' ' + _('To') + ': ' + if _p.filter_form(data) == 'filter_date': + df += _p.stop_date if _p.stop_date else u'' + else: + df += _p.stop_period.name if _p.stop_period else u'' + c_specs += [ + ('df', 3, 0, 'text', df), + ('af', 1, 0, 'text', _p.accounts(data) and ', '.join([account.code for account in _p.accounts(data)]) or _('All')), + ('tm', 2, 0, 'text', _p.display_target_move(data)), + ('ib', 2, 0, 'text', initial_balance_text[_p.initial_balance_mode]), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style_center) + ws.set_horz_split_pos(row_pos) + row_pos += 1 + + # Column Title Row + cell_format = _xs['bold'] + c_title_cell_style = xlwt.easyxf(cell_format) + + # Column Header Row + cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all'] + c_hdr_cell_style = xlwt.easyxf(cell_format) + c_hdr_cell_style_right = xlwt.easyxf(cell_format + _xs['right']) + c_hdr_cell_style_center = xlwt.easyxf(cell_format + _xs['center']) + c_hdr_cell_style_decimal = xlwt.easyxf(cell_format + _xs['right'], num_format_str = report_xls.decimal_format) + + # Column Initial Balance Row + cell_format = _xs['italic'] + _xs['borders_all'] + c_init_cell_style = xlwt.easyxf(cell_format) + c_init_cell_style_right = xlwt.easyxf(cell_format + _xs['right']) + c_init_cell_style_center = xlwt.easyxf(cell_format + _xs['center']) + c_init_cell_style_decimal = xlwt.easyxf(cell_format + _xs['right'], num_format_str = report_xls.decimal_format) + + c_specs = [ + ('date', 1, 0, 'text', _('Date'), None, c_hdr_cell_style), + ('period', 1, 0, 'text', _('Period'), None, c_hdr_cell_style), + ('move', 1, 0, 'text', _('Entry'), None, c_hdr_cell_style), + ('journal', 1, 0, 'text', _('Journal'), None, c_hdr_cell_style), + ('account_code', 1, 0, 'text', _('Account'), None, c_hdr_cell_style), + ('partner', 1, 0, 'text', _('Partner'), None, c_hdr_cell_style), + ('label', 1, 0, 'text', _('Label'), None, c_hdr_cell_style), + ('counterpart', 1, 0, 'text', _('Counterpart'), None, c_hdr_cell_style), + ('debit', 1, 0, 'text', _('Debit'), None, c_hdr_cell_style_right), + ('credit', 1, 0, 'text', _('Credit'), None, c_hdr_cell_style_right), + ('cumul_bal', 1, 0, 'text', _('Cumul. Bal.'), None, c_hdr_cell_style_right), + ] + if _p.amount_currency(data): + c_specs += [ + ('curr_bal', 1, 0, 'text', _('Curr. Bal.'), None, c_hdr_cell_style_right), + ('curr_code', 1, 0, 'text', _('Curr.'), None, c_hdr_cell_style_center), + ] + c_hdr_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + + # cell styles for ledger lines + ll_cell_format = _xs['borders_all'] + ll_cell_style = xlwt.easyxf(ll_cell_format) + ll_cell_style_right = xlwt.easyxf(ll_cell_format + _xs['right']) + ll_cell_style_center = xlwt.easyxf(ll_cell_format + _xs['center']) + ll_cell_style_date = xlwt.easyxf(ll_cell_format + _xs['left'], num_format_str = report_xls.date_format) + ll_cell_style_decimal = xlwt.easyxf(ll_cell_format + _xs['right'], num_format_str = report_xls.decimal_format) + + cnt = 0 + for account in objects: + + display_initial_balance = account.init_balance and (account.init_balance.get('debit', 0.0) != 0.0 or account.init_balance.get('credit', 0.0) != 0.0) + display_ledger_lines = account.ledger_lines + + if _p.display_account_raw(data) == 'all' or (display_ledger_lines or display_initial_balance): + #TO DO : replace cumul amounts by xls formulas + cnt += 1 + cumul_debit = 0.0 + cumul_credit = 0.0 + cumul_balance = 0.0 + cumul_balance_curr = 0.0 + c_specs = [ + ('acc_title', 11, 0, 'text', ' - '.join([account.code, account.name])), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, c_title_cell_style) + row_pos = self.xls_write_row(ws, row_pos, c_hdr_data) + row_start = row_pos + + if display_initial_balance: + cumul_debit = account.init_balance.get('debit') or 0.0 + cumul_credit = account.init_balance.get('credit') or 0.0 + cumul_balance = account.init_balance.get('init_balance') or 0.0 + cumul_balance_curr = account.init_balance.get('init_balance_currency') or 0.0 + debit_cell = rowcol_to_cell(row_pos, 8) + credit_cell = rowcol_to_cell(row_pos, 9) + bal_formula = debit_cell + '-' + credit_cell + c_specs = [('empty%s' %x, 1, 0, 'text', None) for x in range(6)] + c_specs += [ + ('init_bal', 1, 0, 'text', _('Initial Balance')), + ('counterpart', 1, 0, 'text', None), + ('debit', 1, 0, 'number', cumul_debit, None, c_init_cell_style_decimal), + ('credit', 1, 0, 'number', cumul_credit, None, c_init_cell_style_decimal), + ('cumul_bal', 1, 0, 'number', cumul_balance, None, c_init_cell_style_decimal), + ] + if _p.amount_currency(data): + c_specs += [ + ('curr_bal', 1, 0, 'number', cumul_balance_curr, None, c_init_cell_style_decimal), + ('curr_code', 1, 0, 'text', None), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, c_init_cell_style) + + for line in account.ledger_lines: + + cumul_debit += line.get('debit') or 0.0 + cumul_credit += line.get('credit') or 0.0 + cumul_balance_curr += line.get('amount_currency') or 0.0 + cumul_balance += line.get('balance') or 0.0 + label_elements = [line.get('lname') or ''] + if line.get('invoice_number'): + label_elements.append("(%s)" % (line['invoice_number'],)) + label = ' '.join(label_elements) + + if line.get('ldate'): + c_specs = [ + ('ldate', 1, 0, 'date', datetime.strptime(line['ldate'],'%Y-%m-%d'), None, ll_cell_style_date), + ] + else: + c_specs = [ + ('ldate', 1, 0, 'text', None), + ] + c_specs += [ + ('period', 1, 0, 'text', line.get('period_code') or ''), + ('move', 1, 0, 'text', line.get('move_name') or ''), + ('journal', 1, 0, 'text', line.get('jcode') or ''), + ('account_code', 1, 0, 'text', account.code), + ('partner', 1, 0, 'text', line.get('partner_name') or ''), + ('label', 1, 0, 'text', label), + ('counterpart', 1, 0, 'text', line.get('counterparts') or ''), + ('debit', 1, 0, 'number', line.get('debit', 0.0), None, ll_cell_style_decimal), + ('credit', 1, 0, 'number', line.get('credit', 0.0), None, ll_cell_style_decimal), + ('cumul_bal', 1, 0, 'number', cumul_balance, None, ll_cell_style_decimal), + ] + if _p.amount_currency(data): + c_specs += [ + ('curr_bal', 1, 0, 'number', line.get('amount_currency') or 0.0, None, ll_cell_style_decimal), + ('curr_code', 1, 0, 'text', line.get('currency_code') or '', None, ll_cell_style_center), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, ll_cell_style) + + debit_start = rowcol_to_cell(row_start, 8) + debit_end = rowcol_to_cell(row_pos-1, 8) + debit_formula = 'SUM(' + debit_start + ':' + debit_end + ')' + credit_start = rowcol_to_cell(row_start, 9) + credit_end = rowcol_to_cell(row_pos-1, 9) + credit_formula = 'SUM(' + credit_start + ':' + credit_end + ')' + balance_debit = rowcol_to_cell(row_pos, 8) + balance_credit = rowcol_to_cell(row_pos, 9) + balance_formula = balance_debit + '-' + balance_credit + c_specs = [ + ('acc_title', 7, 0, 'text', ' - '.join([account.code, account.name])), + ('cum_bal', 1, 0, 'text', _('Cumulated Balance on Account'), None, c_hdr_cell_style_right), + ('debit', 1, 0, 'number', None, debit_formula, c_hdr_cell_style_decimal), + ('credit', 1, 0, 'number', None, credit_formula, c_hdr_cell_style_decimal), + ('balance', 1, 0, 'number', None, balance_formula, c_hdr_cell_style_decimal), + ] + if _p.amount_currency(data): + if account.currency_id: + c_specs += [('curr_bal', 1, 0, 'number', cumul_balance_curr, None, c_hdr_cell_style_decimal)] + else: + c_specs += [('curr_bal', 1, 0, 'text', None)] + c_specs += [('curr_code', 1, 0, 'text', None)] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, c_hdr_cell_style) + row_pos += 1 + +general_ledger_xls('report.account.account_report_general_ledger_xls', 'account.account', + parser=GeneralLedgerWebkit) +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_financial_report_webkit_xls/report/open_invoices_xls.py b/account_financial_report_webkit_xls/report/open_invoices_xls.py new file mode 100644 index 00000000..d88f314f --- /dev/null +++ b/account_financial_report_webkit_xls/report/open_invoices_xls.py @@ -0,0 +1,627 @@ +# -*- 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 . +# +############################################################################## + +import xlwt +import time +from datetime import datetime +from openerp.report import report_sxw +from openerp.addons.report_xls.report_xls import report_xls +from openerp.addons.report_xls.utils import rowcol_to_cell +from openerp.addons.account_financial_report_webkit.report.open_invoices import PartnersOpenInvoicesWebkit +from openerp.tools.translate import _ +#import logging +#_logger = logging.getLogger(__name__) + +class open_invoices_xls(report_xls): + column_sizes = [12,12,20,15,30,30,14,14,14,14,14,14,10] + + def global_initializations(self, wb, _p, xlwt, _xs, objects, data): + # this procedure will initialise variables and Excel cell styles and return them as global ones + global ws + ws = wb.add_sheet(_p.report_name[:31]) + ws.panes_frozen = True + ws.remove_splits = True + ws.portrait = 0 # Landscape + ws.fit_width_to_pages = 1 + ws.header_str = self.xls_headers['standard'] + ws.footer_str = self.xls_footers['standard'] + #------------------------------------------------------- + global nbr_columns #number of columns is 11 in case of normal report, 13 in case the option currency is selected and 12 in case of the regroup by currency option is checked + group_lines = False + for acc in objects: #search if the regroup option is selected by browsing the accounts defined in objects - see account_report_open_invoices.mako + if hasattr(acc, 'grouped_ledger_lines'): + group_lines = True + if group_lines: + nbr_columns = 12 + elif _p.amount_currency(data) and not group_lines: + nbr_columns = 13 + else: + nbr_columns = 11 + #------------------------------------------------------- + global style_font12 #cell style for report title + style_font12 = xlwt.easyxf(_xs['xls_title']) + #------------------------------------------------------- + global style_default + style_default = xlwt.easyxf(_xs['borders_all']) + #------------------------------------------------------- + global style_default_italic + style_default_italic = xlwt.easyxf(_xs['borders_all'] + _xs['italic']) + #------------------------------------------------------- + global style_bold + style_bold = xlwt.easyxf(_xs['bold'] + _xs['borders_all']) + #------------------------------------------------------- + global style_bold_center + style_bold_center = xlwt.easyxf(_xs['bold'] + _xs['borders_all'] + _xs['center']) + #------------------------------------------------------- + global style_bold_italic + style_bold_italic = xlwt.easyxf(_xs['bold'] + _xs['borders_all'] + _xs['italic']) + #------------------------------------------------------- + global style_bold_italic_decimal + style_bold_italic_decimal = xlwt.easyxf(_xs['bold'] + _xs['borders_all'] + _xs['italic'] + _xs['right'], num_format_str = report_xls.decimal_format) + #------------------------------------------------------- + global style_bold_blue + style_bold_blue = xlwt.easyxf(_xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] ) + #------------------------------------------------------- + global style_bold_blue_italic_decimal + style_bold_blue_italic_decimal = xlwt.easyxf(_xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] + _xs['italic'], num_format_str = report_xls.decimal_format) + #------------------------------------------------------- + global style_bold_blue_center #cell style for header titles: 'Chart of accounts' - 'Fiscal year' ... + style_bold_blue_center= xlwt.easyxf(_xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] + _xs['center']) + #------------------------------------------------------- + global style_center #cell style for header data: 'Chart of accounts' - 'Fiscal year' ... + style_center = xlwt.easyxf(_xs['borders_all'] + _xs['wrap'] + _xs['center']) + #------------------------------------------------------- + global style_yellow_bold #cell style for columns titles 'Date'- 'Period' - 'Entry'... + style_yellow_bold = xlwt.easyxf(_xs['bold'] + _xs['fill'] + _xs['borders_all']) + #------------------------------------------------------- + global style_yellow_bold_right #cell style for columns titles 'Date'- 'Period' - 'Entry'... + style_yellow_bold_right = xlwt.easyxf(_xs['bold'] + _xs['fill'] + _xs['borders_all'] + _xs['right']) + #------------------------------------------------------- + global style_right + style_right = xlwt.easyxf(_xs['borders_all'] + _xs['right']) + #------------------------------------------------------- + global style_right_italic + style_right_italic = xlwt.easyxf(_xs['borders_all'] + _xs['right'] + _xs['italic']) + #------------------------------------------------------- + global style_decimal + style_decimal = xlwt.easyxf(_xs['borders_all'] + _xs['right'], num_format_str = report_xls.decimal_format) + #------------------------------------------------------- + global style_decimal_italic + style_decimal_italic = xlwt.easyxf(_xs['borders_all'] + _xs['right'] + _xs['italic'], num_format_str = report_xls.decimal_format) + #------------------------------------------------------- + global style_date + style_date = xlwt.easyxf(_xs['borders_all'] + _xs['left'], num_format_str = report_xls.date_format) + #------------------------------------------------------- + global style_date_italic + style_date_italic = xlwt.easyxf(_xs['borders_all'] + _xs['left'] + _xs['italic'], num_format_str = report_xls.date_format) + #------------------------------------------------------- + global style_account_title, style_account_title_right, style_account_title_decimal + cell_format = _xs['xls_title'] + _xs['bold'] + _xs['fill'] + _xs['borders_all'] + style_account_title = xlwt.easyxf(cell_format) + style_account_title_right = xlwt.easyxf(cell_format + _xs['right']) + style_account_title_decimal = xlwt.easyxf(cell_format + _xs['right'], num_format_str = report_xls.decimal_format) + #------------------------------------------------------- + global style_partner_row + cell_format = _xs['bold'] + style_partner_row = xlwt.easyxf(cell_format) + #------------------------------------------------------- + global style_partner_cumul, style_partner_cumul_right, style_partner_cumul_center, style_partner_cumul_decimal + cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all'] + style_partner_cumul = xlwt.easyxf(cell_format) + style_partner_cumul_right = xlwt.easyxf(cell_format + _xs['right']) + style_partner_cumul_center = xlwt.easyxf(cell_format + _xs['center']) + style_partner_cumul_decimal = xlwt.easyxf(cell_format + _xs['right'], num_format_str = report_xls.decimal_format) + + def print_title(self, _p, row_position): # print the first line "OPEN INVOICE REPORT - db name - Currency + report_name = ' - '.join([_p.report_name.upper(), _p.company.partner_id.name, _p.company.currency_id.name]) + c_specs = [('report_name', nbr_columns, 0, 'text', report_name), ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, row_style=style_font12) + return row_position + + def print_empty_row(self, row_position): #send an empty row to the Excel document + c_sizes = self.column_sizes + c_specs = [('empty%s'%i, 1, c_sizes[i], 'text', None) for i in range(0,len(c_sizes))] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, set_column_size=True) + return row_position + + def print_header_titles(self, _p, data, row_position): #Fill in the titles of the header summary tables: Chart of account - Fiscal year - ... + c_specs = [ + ('coa', 2, 0, 'text', _('Chart of Account'), None, style_bold_blue_center), + ('fy', 2, 0, 'text', _('Fiscal Year'), None, style_bold_blue_center), + ('df', 2, 0, 'text', _p.filter_form(data) == 'filter_date' and _('Dates Filter') or _('Periods Filter'), None, style_bold_blue_center), + ('cd', 1 if nbr_columns == 11 else 2 , 0, 'text', _('Clearance Date'), None, style_bold_blue_center), + ('af', 2, 0, 'text', _('Accounts Filter'), None, style_bold_blue_center), + ('tm', 3 if nbr_columns == 13 else 2, 0, 'text', _('Target Moves'), None, style_bold_blue_center), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, row_style=style_bold_blue_center) + return row_position + + def print_header_data(self, _p, data, row_position): #Fill in the data of the header summary tables: Chart of account - Fiscal year - ... + c_specs = [ + ('coa', 2, 0, 'text', _p.chart_account.name, None, style_center), + ('fy', 2, 0, 'text', _p.fiscalyear.name if _p.fiscalyear else '-', None, style_center), + ] + df = _('From') + ': ' + if _p.filter_form(data) == 'filter_date': + df += _p.start_date if _p.start_date else u'' + else: + df += _p.start_period.name if _p.start_period else u'' + df += ' ' + _('To') + ': ' + if _p.filter_form(data) == 'filter_date': + df += _p.stop_date if _p.stop_date else u'' + else: + df += _p.stop_period.name if _p.stop_period else u'' + c_specs += [ + ('df', 2, 0, 'text', df, None, style_center), + ('cd', 1 if nbr_columns == 11 else 2, 0, 'text', _p.date_until, None, style_center), #clearance date + ('af', 2, 0, 'text', _('Custom Filter') if _p.partner_ids else _p.display_partner_account(data), None, style_center), + ('tm', 3 if nbr_columns == 13 else 2, 0, 'text', _p.display_target_move(data), None, style_center), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, row_style=style_center) + return row_position + + def print_columns_title(self, _p, row_position, data, group_lines=False): # Fill in a row with the titles of the columns for the invoice lines: Date - Period - Entry -... + c_specs = [ + ('date', 1, 0, 'text', _('Date'),None,style_yellow_bold), + ('period', 1, 0, 'text', _('Period'),None,style_yellow_bold), + ('entry', 1, 0, 'text', _('Entry'),None,style_yellow_bold), + ('journal', 1, 0, 'text', _('Journal'),None,style_yellow_bold), + ] + if not group_lines: + c_specs += [('partner', 1, 0, 'text', _('Partner'),None,style_yellow_bold),] + c_specs += [ + ('label', 1, 0, 'text', _('Label'),None,style_yellow_bold), + ('rec', 1, 0, 'text', _('Rec.'),None,style_yellow_bold), + ('due_date', 1, 0, 'text', _('Due Date'),None,style_yellow_bold), + ('debit', 1, 0, 'text', _('Debit'),None,style_yellow_bold_right), + ('credit', 1, 0, 'text', _('Credit'),None,style_yellow_bold_right), + ('cumul', 1, 0, 'text', _('Cumul. Bal.'),None,style_yellow_bold_right), + ] + if group_lines: + c_specs += [ + ('currbal', 1, 0, 'text', _('Curr. Balance'),None,style_yellow_bold_right), + ('curr', 1, 0, 'text', _('Curr.'),None,style_yellow_bold_right), + ] + else: + if _p.amount_currency(data): + c_specs += [ + ('currbal', 1, 0, 'text', _('Curr. Balance'),None,style_yellow_bold_right), + ('curr', 1, 0, 'text', _('Curr.'), None, style_yellow_bold_right), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, row_style=style_yellow_bold) + return row_position + + def print_row_code_account(self, regroupmode, account, row_position, partner_name): # Fill in a row with the code and the name of an account + the partner name in case of currency regrouping + if regroupmode == "regroup": + c_specs = [ ('acc_title', nbr_columns, 0, 'text', ' - '.join([account.code, account.name, partner_name or _('No partner')])), ] + else: + c_specs = [ ('acc_title', nbr_columns, 0, 'text', ' - '.join([account.code, account.name])), ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, style_account_title) + return row_position+1 + + def print_row_partner(self, row_position, partner_name): + c_specs = [ ('partner', nbr_columns, 0, 'text', partner_name or _('No partner')), ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, style_partner_row) + return row_position + + def print_group_currency(self, row_position, curr, _p): + c_specs = [ ('curr', nbr_columns, 0, 'text', curr or _p.company.currency_id.name), ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, style_bold) + return row_position + + def print_lines(self, row_position, account, line,_p, data, line_number): # Fill in rows of invoice line + + label_elements = [line.get('lname') or ''] + if line.get('invoice_number'): + label_elements.append("(%s)" % (line['invoice_number'],)) + label = ' '.join(label_elements) + + # Mako:
+ if line.get('is_from_previous_periods') or line.get('is_clearance_line'): + style_line_default = style_default_italic + style_line_right = style_right_italic + style_line_date = style_date_italic + style_line_decimal = style_decimal_italic + else: + style_line_default = style_default + style_line_right = style_right + style_line_date = style_date + style_line_decimal = style_decimal + if line.get('ldate'): + c_specs = [('date', 1, 0, 'date', datetime.strptime(line['ldate'],'%Y-%m-%d'), None, style_line_date)] + else: + c_specs = [('date', 1, 0, 'text', None)] + c_specs += [ + ('period_code', 1, 0, 'text', line.get('period_code') or '' ), + ('entry', 1, 0, 'text', line.get('move_name') or '' ), + ('journal', 1, 0, 'text', line.get('jcode') or '' ), + ('partner', 1, 0, 'text', line.get('partner_name') or '' ), + ('label', 1, 0, 'text', label ), + ('rec', 1, 0, 'text', line.get('rec_name') or '' ), + ] + if line.get('date_maturity'): + c_specs += [('datedue', 1, 0, 'date', datetime.strptime(line['date_maturity'],'%Y-%m-%d'), None, style_line_date)] + else: + c_specs += [('datedue', 1, 0, 'text', None)] + c_specs += [ + ('debit', 1, 0, 'number', line.get('debit') or 0.0 , None, style_line_decimal), + ('credit', 1, 0, 'number', line.get('credit') or 0.0 , None, style_line_decimal), + ] + + #determine the formula of the cumulated balance + debit_cell = rowcol_to_cell(row_position, 8) + credit_cell = rowcol_to_cell(row_position, 9) + previous_balance = rowcol_to_cell(row_position - 1, 10) + + if line_number == 1: #if it is the first line, the balance is only debit - credit + cumul_balance = debit_cell + '-' + credit_cell + else: # cumulate debit - credit and balance of previous line + cumul_balance = debit_cell + '-' + credit_cell + '+' + previous_balance + + c_specs += [('cumul', 1, 0, 'number', None, cumul_balance, style_line_decimal)] + + if _p.amount_currency(data): + if account.currency_id: + c_specs += [ + ('curramount', 1, 0, 'number', line.get('amount_currency') or 0.0, None, style_line_decimal), + ('currcode', 1, 0, 'text', line['currency_code'], None, style_line_right), + ] + else: + c_specs += [ + ('curramount', 1, 0, 'text', '-', None, style_line_right), + ('currcode', 1, 0, 'text', '', None, style_line_right), + ] + + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, style_line_default) + return row_position + + def print_group_lines(self, row_position, account, line,_p, line_number): # Fill in rows of invoice line when the option currency regroup is selected + + label_elements = [line.get('lname') or ''] + if line.get('invoice_number'): + label_elements.append("(%s)" % (line['invoice_number'],)) + label = ' '.join(label_elements) + # Mako:
+ if line.get('is_from_previous_periods') or line.get('is_clearance_line'): + style_line_default = style_default_italic + style_line_right = style_right_italic + style_line_date = style_date_italic + style_line_decimal = style_decimal_italic + else: + style_line_default = style_default + style_line_right = style_right + style_line_date = style_date + style_line_decimal = style_decimal + + debit_cell = rowcol_to_cell(row_position, 7) + credit_cell = rowcol_to_cell(row_position, 8) + previous_balance = rowcol_to_cell(row_position - 1, 9) + + if line_number == 1: #if it is the first line, the balance is only debit - credit + cumul_balance = debit_cell + '-' + credit_cell + else: # cumulate devit - credit and balance of previous line + cumul_balance = debit_cell + '-' + credit_cell + '+' + previous_balance + + if line.get('ldate'): + c_specs = [('date', 1, 0, 'date', datetime.strptime(line['ldate'],'%Y-%m-%d'), None, style_line_date)] + else: + c_specs = [('date', 1, 0, 'text', None)] + c_specs += [ + ('period_code', 1, 0, 'text', line.get('period_code') or '' ), + ('entry', 1, 0, 'text', line.get('move_name') or '' ), + ('journal', 1, 0, 'text', line.get('jcode') or '' ), + ('label', 1, 0, 'text', label), + ('rec', 1, 0, 'text', line.get('rec_name') or '' ), + ] + if line.get('date_maturity'): + c_specs += [('datedue', 1, 0, 'date', datetime.strptime(line['date_maturity'],'%Y-%m-%d'), None, style_line_date)] + else: + c_specs += [('datedue', 1, 0, 'text', None)] + c_specs += [ + ('debit', 1, 0, 'number', line.get('debit') or 0.0, None, style_line_decimal), + ('credit', 1, 0, 'number', line.get('credit') or 0.0, None, style_line_decimal), + ('cumul', 1, 0, 'number', None, cumul_balance, style_line_decimal), + ] + if account.currency_id: + c_specs += [ + ('curramount', 1, 0, 'number', line.get('amount_currency') or 0.0, None, style_line_decimal), + ('currcode', 1, 0, 'text', line.get('currency_code') or '', None, style_line_right), + ] + else: + c_specs += [ + ('curramount', 1, 0, 'text', '-', None, style_line_right), + ('currcode', 1, 0, 'text', '', None, style_line_right), + ] + + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, style_line_default) + return (row_position, cumul_balance) + + def print_cumul_partner(self, row_position, row_start_partner, account, _p, data): #print by partner the totals and cumulated balance (Excel formulas) + + start_col = 5 #the text "Cumulated Balance on Partner starts in column 4 when selecting the option regroup by currency, 5 in the other case + + debit_partner_start = rowcol_to_cell(row_start_partner, start_col + 3) + debit_partner_end = rowcol_to_cell(row_position-1, start_col + 3) + debit_partner_total = 'SUM(' + debit_partner_start + ':' + debit_partner_end + ')' + + credit_partner_start = rowcol_to_cell(row_start_partner, start_col + 4) + credit_partner_end = rowcol_to_cell(row_position-1, start_col + 4) + credit_partner_total = 'SUM(' + credit_partner_start + ':' + credit_partner_end + ')' + + bal_curr_start = rowcol_to_cell(row_start_partner, start_col + 6) + bal_curr_end = rowcol_to_cell(row_position-1, start_col + 6) + cumul_balance_curr = 'SUM(' + bal_curr_start + ':' + bal_curr_end + ')' + + + bal_partner_debit = rowcol_to_cell(row_position, start_col + 3) + bal_partner_credit = rowcol_to_cell(row_position, start_col + 4) + bal_partner_total = bal_partner_debit + '-' + bal_partner_credit + + c_specs = [('empty%s' %x, 1, 0, 'text', None) for x in range(start_col)] + + c_specs += [ + ('init_bal', 1, 0, 'text', _('Cumulated Balance on Partner')), + ('rec', 1, 0, 'text', None), + ('empty5', 1, 0, 'text', None), + ('debit', 1, 0, 'number', None, debit_partner_total, style_partner_cumul_decimal), + ('credit', 1, 0, 'number', None, credit_partner_total, style_partner_cumul_decimal), + ('cumul_bal', 1, 0, 'number', None, bal_partner_total, style_partner_cumul_decimal), + ] + if _p.amount_currency(data): + if account.currency_id: + c_specs += [('cumul_bal_curr', 1, 0, 'number', None, cumul_balance_curr, style_partner_cumul_decimal), + ('curr_name', 1, 0, 'text', account.currency_id.name, None, style_partner_cumul_right), + ] + else: + c_specs += [('cumul_bal_curr', 1, 0, 'text', '-', None, style_partner_cumul_right), + ('curr_name', 1, 0, 'text', '', None, style_partner_cumul_right) + ] + + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, style_partner_cumul) + return row_position+1 + + def print_group_cumul_partner(self,row_position, row_start_partner, account, _p, data): #print by partner the totals and cumulated balance (Excel formulas) when the option currency regroup is selected + + start_col = 4 #the text "Cumulated Balance on Partner starts in column 4 when selecting the option regroup by currency, 5 in the other case + + debit_partner_start = rowcol_to_cell(row_start_partner, start_col + 3) + debit_partner_end = rowcol_to_cell(row_position-1, start_col + 3) + debit_partner_total = 'SUM(' + debit_partner_start + ':' + debit_partner_end + ')' + + credit_partner_start = rowcol_to_cell(row_start_partner, start_col + 4) + credit_partner_end = rowcol_to_cell(row_position-1, start_col + 4) + credit_partner_total = 'SUM(' + credit_partner_start + ':' + credit_partner_end + ')' + + bal_curr_start = rowcol_to_cell(row_start_partner, start_col + 5) + bal_curr_end = rowcol_to_cell(row_position-1, start_col + 5) + cumul_balance_curr = 'SUM(' + bal_curr_start + ':' + bal_curr_end + ')' + + bal_partner_debit = rowcol_to_cell(row_position, start_col + 3) + bal_partner_credit = rowcol_to_cell(row_position, start_col + 4) + bal_partner_total = bal_partner_debit + '-' + bal_partner_credit + + c_specs = [('empty%s' %x, 1, 0, 'text', None) for x in range(start_col)] + + c_specs += [ + ('init_bal', 1, 0, 'text', _('Cumulated Balance on Partner')), #, style_bold_italic), + ('rec', 1, 0, 'text', None), + ('empty5', 1, 0, 'text', None), + ('debit', 1, 0, 'number', None, debit_partner_total, style_partner_cumul_decimal), + ('credit', 1, 0, 'number', None, credit_partner_total, style_partner_cumul_decimal), + ('cumul_bal', 1, 0, 'number', None, bal_partner_total, style_partner_cumul_decimal), + ] + if account.currency_id: + c_specs += [ + ('cumul_bal_curr', 1, 0, 'number', None, cumul_balance_curr, style_partner_cumul_decimal), + ('curr_name', 1, 0, 'text', account.currency_id.name, None, style_partner_cumul_right), + ] + else: + c_specs += [ + ('cumul_bal_curr', 1, 0, 'text', "-", None, style_partner_cumul_right), + ('curr_name', 1, 0, 'text', "", None, style_partner_cumul_right), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, style_partner_cumul) + return row_position+1 + + def print_cumul_account(self, row_position, row_start_account, account, _p, data): #print by account the totals of the credit and debit + balance calculation + + #This procedure will create an Excel sumif function that will check in the column "label" for the "Cumulated Balance.." string and make a sum of the debit & credit data + start_col = 5 #the text "Cumulated Balance on Partner starts in column 4 when selecting the option regroup by currency, 5 in the other case + + reference_start = rowcol_to_cell(row_start_account, start_col) #range in which we search for the text "Cumulated Balance on Partner" + reference_stop = rowcol_to_cell(row_position -1 , start_col) + + range_debit_start = rowcol_to_cell(row_start_account, start_col + 3) #range in which we make the sum of all the cumulated balance lines (debit) + range_debit_stop = rowcol_to_cell(row_position -1, start_col + 3) + + range_credit_start = rowcol_to_cell(row_start_account, start_col + 4) #range in which we make the sum of all the cumulated balance lines (crebit) + range_credit_stop = rowcol_to_cell(row_position -1, start_col + 4) + + search_key = _('Cumulated Balance on Partner') + total_debit_account = 'SUMIF(' + reference_start + ':' + reference_stop + ';"' + search_key + '";' + range_debit_start + ':' + range_debit_stop + ')' + total_credit_account = 'SUMIF(' + reference_start + ':' + reference_stop + ';"' + search_key + '";' + range_credit_start + ':' + range_credit_stop + ')' + + bal_account_debit = rowcol_to_cell(row_position, start_col + 3) + bal_account_credit = rowcol_to_cell(row_position, start_col + 4) + bal_account_total = bal_account_debit + '-' + bal_account_credit + + bal_curr_start = rowcol_to_cell(row_start_account, start_col + 6) + bal_curr_end = rowcol_to_cell(row_position-1, start_col + 6) + cumul_balance_curr = 'SUMIF(' + reference_start + ':' + reference_stop + ';"' + search_key + '";' + bal_curr_start + ':' + bal_curr_end + ')' + + c_specs = [ + ('acc_title', start_col, 0, 'text', ' - '.join([account.code, account.name])), + ('init_bal', 2, 0, 'text', _('Cumulated Balance on Account')), + ('empty2', 1, 0, 'text', None), + ('debit', 1, 0, 'number', None, total_debit_account, style_account_title_decimal), + ('credit', 1, 0, 'number', None, total_credit_account, style_account_title_decimal), + ('balance', 1, 0, 'number', None, bal_account_total, style_account_title_decimal), + ] + if _p.amount_currency(data): + if account.currency_id: + c_specs += [('cumul_bal_curr', 1, 0, 'number', None, cumul_balance_curr), + ('curr_name', 1, 0, 'text', account.currency_id.name, None, style_account_title_right), + ] + else: + c_specs += [('cumul_bal_curr', 1, 0, 'text', "-", None, style_account_title_right), + ('curr_name', 1, 0, 'text', "", None, style_account_title_right) + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, style_account_title) + return row_position+1 + + def print_group_cumul_account(self,row_position, row_start_account, account): #print by account the totals of the credit and debit + balance calculation + #This procedure will create an Excel sumif function that will check in the column "label" for the "Cumulated Balance.." string and make a sum of the debit & credit data + start_col = 4 #the text "Cumulated Balance on Partner starts in column 4 when selecting the option regroup by currency, 5 in the other case + + reference_start = rowcol_to_cell(row_start_account, start_col) #range in which we search for the text "Cumulated Balance on Partner" + reference_stop = rowcol_to_cell(row_position -1 , start_col) + + range_debit_start = rowcol_to_cell(row_start_account, start_col + 3) #range in which we make the sum of all the cumulated balance lines (debit) + range_debit_stop = rowcol_to_cell(row_position -1, start_col + 3) + + range_credit_start = rowcol_to_cell(row_start_account, start_col + 4) #range in which we make the sum of all the cumulated balance lines (crebit) + range_credit_stop = rowcol_to_cell(row_position -1, start_col + 4) + + search_key = _('Cumulated Balance on Partner') + total_debit_account = 'SUMIF(' + reference_start + ':' + reference_stop + ';"' + search_key + '";' + range_debit_start + ':' + range_debit_stop + ')' + total_credit_account = 'SUMIF(' + reference_start + ':' + reference_stop + ';"' + search_key + '";' + range_credit_start + ':' + range_credit_stop + ')' + + bal_account_debit = rowcol_to_cell(row_position, start_col + 3) + bal_account_credit = rowcol_to_cell(row_position, start_col + 4) + bal_account_total = bal_account_debit + '-' + bal_account_credit + + bal_curr_start = rowcol_to_cell(row_start_account, start_col + 6) + bal_curr_end = rowcol_to_cell(row_position-1, start_col + 6) + cumul_balance_curr = 'SUMIF(' + reference_start + ':' + reference_stop + ';"' + search_key + '";' + bal_curr_start + ':' + bal_curr_end + ')' + + c_specs = [ + ('acc_title', start_col, 0, 'text', ' - '.join([account.code, account.name])), + ('init_bal', 2, 0, 'text', _('Cumulated Balance on Account')), + ('empty2', 1, 0, 'text', None), + ('debit', 1, 0, 'number', None, total_debit_account, style_account_title_decimal), + ('credit', 1, 0, 'number', None, total_credit_account, style_account_title_decimal), + ('balance', 1, 0, 'number', None, bal_account_total, style_account_title_decimal), + ] + if account.currency_id: + c_specs += [('cumul_bal_curr', 1, 0, 'number', None, cumul_balance_curr, style_account_title_decimal), + ('curr_name', 1, 0, 'text', account.currency_id.name, None, style_account_title_decimal), + ] + else: + c_specs += [('cumul_bal_curr', 1, 0, 'text', "-", None, style_account_title_right), + ('curr_name', 1, 0, 'text', "", None, style_account_title_right) + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, style_account_title) + return row_position+1 + + def print_grouped_line_report(self, row_pos, account, _xs, xlwt, _p, data): # export the invoice AR/AP lines when the option currency regroup is selected + + if account.grouped_ledger_lines and account.partners_order: + row_start_account = row_pos + + for partner_name, p_id, p_ref, p_name in account.partners_order: + row_pos = self.print_row_code_account("regroup", account,row_pos, partner_name) + + for curr, grouped_lines in account.grouped_ledger_lines.get(p_id, []): + + row_pos = self.print_group_currency(row_pos, curr, _p) + # Print row: Titles "Date-Period-Entry-Journal..." + row_pos = self.print_columns_title(_p, row_pos, data, group_lines=True) + + row_pos_start = row_pos + line_number = 0 + for line in grouped_lines: + line_number += 1 + row_pos, cumul_balance = self.print_group_lines(row_pos, account, line, _p, line_number) + row_pos = self.print_group_cumul_partner(row_pos,row_pos_start, account, _p, data) + + row_pos = self.print_group_cumul_account(row_pos, row_start_account, account) + + return row_pos + + def print_ledger_lines(self, row_pos, account, _xs, xlwt, _p, data): # export the invoice AR/AP lines + + if account.ledger_lines and account.partners_order: + row_start_account = row_pos + + #Print account line: code - account + row_pos = self.print_row_code_account("noregroup",account,row_pos, "") + for partner_name, p_id, p_ref, p_name in account.partners_order: + + #Print partner row + row_pos = self.print_row_partner(row_pos, partner_name) + # Print row: Titles "Date-Period-Entry-Journal..." + row_pos = self.print_columns_title(_p, row_pos, data, group_lines=False) + + row_pos_start = row_pos + line_number = 0 + for line in account.ledger_lines.get(p_id, []): + line_number += 1 + # print ledger lines + row_pos = self.print_lines(row_pos, account, line, _p, data, line_number) + row_pos = self.print_cumul_partner(row_pos, row_pos_start, account, _p, data) + + row_pos = self.print_cumul_account(row_pos, row_start_account, account, _p, data) + + return row_pos + + def generate_xls_report(self, _p, _xs, data, objects, wb): # main function + + # Initializations + self.global_initializations(wb,_p, xlwt, _xs, objects, data) + row_pos = 0 + # Print Title + row_pos = self.print_title(_p, row_pos) + # Print empty row to define column sizes + row_pos = self.print_empty_row(row_pos) + # Print Header Table titles (Fiscal Year - Accounts Filter - Periods Filter...) + row_pos = self.print_header_titles(_p, data, row_pos) + # Print Header Table data + row_pos = self.print_header_data(_p, data, row_pos) + #Freeze the line + ws.set_horz_split_pos(row_pos) + # Print empty row + row_pos = self.print_empty_row(row_pos) + + for acc in objects: + if hasattr(acc, 'grouped_ledger_lines'): + # call xls equivalent of "grouped_by_curr_open_invoices_inclusion.mako.html" + row_pos = self.print_grouped_line_report(row_pos, acc, _xs, xlwt, _p, data) + else: + # call xls equivalent of "open_invoices_inclusion.mako.html" + row_pos = self.print_ledger_lines(row_pos, acc, _xs, xlwt, _p, data) + row_pos += 1 + +open_invoices_xls('report.account.account_report_open_invoices_xls', 'account.account', parser=PartnersOpenInvoicesWebkit) diff --git a/account_financial_report_webkit_xls/report/partner_ledger_xls.py b/account_financial_report_webkit_xls/report/partner_ledger_xls.py new file mode 100644 index 00000000..18d190c5 --- /dev/null +++ b/account_financial_report_webkit_xls/report/partner_ledger_xls.py @@ -0,0 +1,365 @@ +# -*- 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 . +# +############################################################################## + +import xlwt +import time +from datetime import datetime +from openerp.report import report_sxw +from openerp.addons.report_xls.report_xls import report_xls +from openerp.addons.report_xls.utils import rowcol_to_cell +from openerp.addons.account_financial_report_webkit.report.partners_ledger import PartnersLedgerWebkit +from openerp.tools.translate import _ +#import logging +#_logger = logging.getLogger(__name__) + +_column_sizes = [ + ('date', 12), + ('period', 12), + ('move', 20), + ('journal', 12), + ('partner', 30), + ('label', 58), + ('rec', 12), + ('debit', 15), + ('credit', 15), + ('cumul_bal', 15), + ('curr_bal', 15), + ('curr_code', 7), +] + +class partner_ledger_xls(report_xls): + column_sizes = [x[1] for x in _column_sizes] + + def generate_xls_report(self, _p, _xs, data, objects, wb): + + ws = wb.add_sheet(_p.report_name[:31]) + ws.panes_frozen = True + ws.remove_splits = True + ws.portrait = 0 # Landscape + ws.fit_width_to_pages = 1 + row_pos = 0 + + # set print header/footer + ws.header_str = self.xls_headers['standard'] + ws.footer_str = self.xls_footers['standard'] + + # cf. account_report_partner_ledger.mako + initial_balance_text = {'initial_balance': _('Computed'), 'opening_balance': _('Opening Entries'), False: _('No')} + + # Title + cell_style = xlwt.easyxf(_xs['xls_title']) + report_name = ' - '.join([_p.report_name.upper(), _p.company.partner_id.name, _p.company.currency_id.name]) + c_specs = [ + ('report_name', 1, 0, 'text', report_name), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style) + + # write empty row to define column sizes + c_sizes = self.column_sizes + c_specs = [('empty%s'%i, 1, c_sizes[i], 'text', None) for i in range(0,len(c_sizes))] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, set_column_size=True) + + # Header Table + nbr_columns = 10 + if _p.amount_currency(data): + nbr_columns = 12 + cell_format = _xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] + cell_style = xlwt.easyxf(cell_format) + cell_style_center = xlwt.easyxf(cell_format + _xs['center']) + c_specs = [ + ('coa', 2, 0, 'text', _('Chart of Account')), + ('fy', 1, 0, 'text', _('Fiscal Year')), + ('df', 2, 0, 'text', _p.filter_form(data) == 'filter_date' and _('Dates Filter') or _('Periods Filter')), + ('af', 1, 0, 'text', _('Accounts Filter')), + ('tm', 2, 0, 'text', _('Target Moves')), + ('ib', nbr_columns-8, 0, 'text', _('Initial Balance')), + + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style_center) + + cell_format = _xs['borders_all'] + cell_style = xlwt.easyxf(cell_format) + cell_style_center = xlwt.easyxf(cell_format + _xs['center']) + c_specs = [ + ('coa', 2, 0, 'text', _p.chart_account.name), + ('fy', 1, 0, 'text', _p.fiscalyear.name if _p.fiscalyear else '-'), + ] + df = _('From') + ': ' + if _p.filter_form(data) == 'filter_date': + df += _p.start_date if _p.start_date else u'' + else: + df += _p.start_period.name if _p.start_period else u'' + df += ' ' + _('To') + ': ' + if _p.filter_form(data) == 'filter_date': + df += _p.stop_date if _p.stop_date else u'' + else: + df += _p.stop_period.name if _p.stop_period else u'' + c_specs += [ + ('df', 2, 0, 'text', df), + ('af', 1, 0, 'text', _('Custom Filter') if _p.partner_ids else _p.display_partner_account(data)), + ('tm', 2, 0, 'text', _p.display_target_move(data)), + ('ib', nbr_columns-8, 0, 'text', initial_balance_text[_p.initial_balance_mode]), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style_center) + ws.set_horz_split_pos(row_pos) + row_pos += 1 + + # Account Title Row + cell_format = _xs['xls_title'] + _xs['bold'] + _xs['fill'] + _xs['borders_all'] + account_cell_style = xlwt.easyxf(cell_format) + account_cell_style_right = xlwt.easyxf(cell_format + _xs['right']) + account_cell_style_decimal = xlwt.easyxf(cell_format + _xs['right'], num_format_str = report_xls.decimal_format) + + # Column Title Row + cell_format = _xs['bold'] + c_title_cell_style = xlwt.easyxf(cell_format) + + # Column Header Row + cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all'] + c_hdr_cell_style = xlwt.easyxf(cell_format) + c_hdr_cell_style_right = xlwt.easyxf(cell_format + _xs['right']) + c_hdr_cell_style_center = xlwt.easyxf(cell_format + _xs['center']) + c_hdr_cell_style_decimal = xlwt.easyxf(cell_format + _xs['right'], num_format_str = report_xls.decimal_format) + + # Column Initial Balance Row + cell_format = _xs['italic'] + _xs['borders_all'] + c_init_cell_style = xlwt.easyxf(cell_format) + c_init_cell_style_right = xlwt.easyxf(cell_format + _xs['right']) + c_init_cell_style_center = xlwt.easyxf(cell_format + _xs['center']) + c_init_cell_style_decimal = xlwt.easyxf(cell_format + _xs['right'], num_format_str = report_xls.decimal_format) + + # Column Cumulated balance Row + cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all'] + c_cumul_cell_style = xlwt.easyxf(cell_format) + c_cumul_cell_style_right = xlwt.easyxf(cell_format + _xs['right']) + c_cumul_cell_style_center = xlwt.easyxf(cell_format + _xs['center']) + c_cumul_cell_style_decimal = xlwt.easyxf(cell_format + _xs['right'], num_format_str = report_xls.decimal_format) + + # Column Partner Row + cell_format = _xs['bold'] + c_part_cell_style = xlwt.easyxf(cell_format) + + c_specs = [ + ('date', 1, 0, 'text', _('Date'), None, c_hdr_cell_style), + ('period', 1, 0, 'text', _('Period'), None, c_hdr_cell_style), + ('move', 1, 0, 'text', _('Entry'), None, c_hdr_cell_style), + ('journal', 1, 0, 'text', _('Journal'), None, c_hdr_cell_style), + ('partner', 1, 0, 'text', _('Partner'), None, c_hdr_cell_style), + ('label', 1, 0, 'text', _('Label'), None, c_hdr_cell_style), + ('rec', 1, 0, 'text', _('Rec.'), None, c_hdr_cell_style), + ('debit', 1, 0, 'text', _('Debit'), None, c_hdr_cell_style_right), + ('credit', 1, 0, 'text', _('Credit'), None, c_hdr_cell_style_right), + ('cumul_bal', 1, 0, 'text', _('Cumul. Bal.'), None, c_hdr_cell_style_right), + ] + if _p.amount_currency(data): + c_specs += [ + ('curr_bal', 1, 0, 'text', _('Curr. Bal.'), None, c_hdr_cell_style_right), + ('curr_code', 1, 0, 'text', _('Curr.'), None, c_hdr_cell_style_center), + ] + c_hdr_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + + # cell styles for ledger lines + ll_cell_format = _xs['borders_all'] + ll_cell_style = xlwt.easyxf(ll_cell_format) + ll_cell_style_right = xlwt.easyxf(ll_cell_format + _xs['right']) + ll_cell_style_center = xlwt.easyxf(ll_cell_format + _xs['center']) + ll_cell_style_date = xlwt.easyxf(ll_cell_format + _xs['left'], num_format_str = report_xls.date_format) + ll_cell_style_decimal = xlwt.easyxf(ll_cell_format + _xs['right'], num_format_str = report_xls.decimal_format) + + cnt = 0 + for account in objects: + if account.ledger_lines or account.init_balance: + if not account.partners_order: + continue + cnt += 1 + account_total_debit = 0.0 + account_total_credit = 0.0 + account_balance_cumul = 0.0 + account_balance_cumul_curr = 0.0 + c_specs = [ + ('acc_title', nbr_columns, 0, 'text', ' - '.join([account.code, account.name]), None, account_cell_style), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, c_title_cell_style) + row_pos += 1 + row_start_account = row_pos + + for partner_name, p_id, p_ref, p_name in account.partners_order: + + total_debit = 0.0 + total_credit = 0.0 + cumul_balance = 0.0 + cumul_balance_curr = 0.0 + part_cumul_balance = 0.0 + part_cumul_balance_curr = 0.0 + c_specs = [ + ('partner_title', nbr_columns, 0, 'text', partner_name or _('No Partner'), None, c_part_cell_style), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, c_title_cell_style) + row_pos = self.xls_write_row(ws, row_pos, c_hdr_data) + row_start_partner = row_pos + + total_debit = account.init_balance.get(p_id, {}).get('debit') or 0.0 + total_credit = account.init_balance.get(p_id, {}).get('credit') or 0.0 + + init_line = False + if _p.initial_balance_mode and (total_debit or total_credit): + init_line = True + + part_cumul_balance = account.init_balance.get(p_id, {}).get('init_balance') or 0.0 + part_cumul_balance_curr = account.init_balance.get(p_id, {}).get('init_balance_currency') or 0.0 + balance_forward_currency = account.init_balance.get(p_id, {}).get('currency_name') or '' + + cumul_balance += part_cumul_balance + cumul_balance_curr += part_cumul_balance_curr + + debit_cell = rowcol_to_cell(row_pos, 7) + credit_cell = rowcol_to_cell(row_pos, 8) + init_bal_formula = debit_cell + '-' + credit_cell + + ################## Print row 'Initial Balance' by partner ################# + c_specs = [('empty%s' %x, 1, 0, 'text', None) for x in range(5)] + c_specs += [ + ('init_bal', 1, 0, 'text', _('Initial Balance')), + ('rec', 1, 0, 'text', None), + ('debit', 1, 0, 'number', total_debit, None, c_init_cell_style_decimal), + ('credit', 1, 0, 'number', total_credit, None, c_init_cell_style_decimal), + ('cumul_bal', 1, 0, 'number', None, init_bal_formula, c_init_cell_style_decimal), + ] + if _p.amount_currency(data): + c_specs += [ + ('curr_bal', 1, 0, 'number', part_cumul_balance_curr, None, c_init_cell_style_decimal), + ('curr_code', 1, 0, 'text', balance_forward_currency), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, c_init_cell_style) + + for line in account.ledger_lines.get(p_id, []): + + total_debit += line.get('debit') or 0.0 + total_credit += line.get('credit') or 0.0 + + label_elements = [line.get('lname') or ''] + if line.get('invoice_number'): + label_elements.append("(%s)" % (line['invoice_number'],)) + label = ' '.join(label_elements) + cumul_balance += line.get('balance') or 0.0 + + if init_line or row_pos > row_start_partner: + cumbal_formula = rowcol_to_cell(row_pos-1, 9) + '+' + else: + cumbal_formula = '' + debit_cell = rowcol_to_cell(row_pos, 7) + credit_cell = rowcol_to_cell(row_pos, 8) + cumbal_formula += debit_cell + '-' + credit_cell + ################## Print row ledger line data ################# + + if line.get('ldate'): + c_specs = [ + ('ldate', 1, 0, 'date', datetime.strptime(line['ldate'],'%Y-%m-%d'), None, ll_cell_style_date), + ] + else: + c_specs = [ + ('ldate', 1, 0, 'text', None), + ] + c_specs += [ + ('period', 1, 0, 'text', line.get('period_code') or ''), + ('move', 1, 0, 'text', line.get('move_name') or ''), + ('journal', 1, 0, 'text', line.get('jcode') or ''), + ('partner', 1, 0, 'text', line.get('partner_name') or ''), + ('label', 1, 0, 'text', label), + ('rec_name', 1, 0, 'text', line.get('rec_name') or ''), + ('debit', 1, 0, 'number', line.get('debit'), None, ll_cell_style_decimal), + ('credit', 1, 0, 'number', line.get('credit'), None, ll_cell_style_decimal), + ('cumul_bal', 1, 0, 'number', None, cumbal_formula, ll_cell_style_decimal), + ] + if _p.amount_currency(data): + c_specs += [ + ('curr_bal', 1, 0, 'number', line.get('amount_currency') or 0.0, None, ll_cell_style_decimal), + ('curr_code', 1, 0, 'text', line.get('currency_code') or '', None, ll_cell_style_center), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, ll_cell_style) + #end for line + + ################## Print row Cumulated Balance by partner ################# + debit_partner_start = rowcol_to_cell(row_start_partner, 7) + debit_partner_end = rowcol_to_cell(row_pos-1, 7) + debit_partner_total = 'SUM(' + debit_partner_start + ':' + debit_partner_end + ')' + + credit_partner_start = rowcol_to_cell(row_start_partner, 8) + credit_partner_end = rowcol_to_cell(row_pos-1, 8) + credit_partner_total = 'SUM(' + credit_partner_start + ':' + credit_partner_end + ')' + + bal_partner_debit = rowcol_to_cell(row_pos, 7) + bal_partner_credit = rowcol_to_cell(row_pos, 8) + bal_partner_total = bal_partner_debit + '-' + bal_partner_credit + + c_specs = [('empty%s' %x, 1, 0, 'text', None) for x in range(5)] + c_specs += [ + ('init_bal', 1, 0, 'text', _('Cumulated balance on Partner')), + ('rec', 1, 0, 'text', None), + ('debit', 1, 0, 'number', None, debit_partner_total, c_cumul_cell_style_decimal), + ('credit', 1, 0, 'number', None, credit_partner_total, c_cumul_cell_style_decimal), + ('cumul_bal', 1, 0, 'number', None, bal_partner_total, c_cumul_cell_style_decimal), + ] + if _p.amount_currency(data): + if account.currency_id: + c_specs += [('curr_bal', 1, 0, 'number', cumul_balance_curr or 0.0, None, c_cumul_cell_style_decimal)] + else: + c_specs += [('curr_bal', 1, 0, 'text', '-', None, c_cumul_cell_style_right)] + c_specs += [('curr_code', 1, 0, 'text', account.currency_id.name if account.currency_id else u'', None, c_cumul_cell_style_center)] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, c_cumul_cell_style) + row_pos += 1 + account_total_debit += total_debit + account_total_credit += total_credit + account_balance_cumul += cumul_balance + account_balance_cumul_curr += cumul_balance_curr + + ################## Print row Cumulated Balance by account ################# + c_specs = [('acc_title', 5, 0, 'text', ' - '.join([account.code, account.name])), ] + c_specs += [ + ('label', 1, 0, 'text', _('Cumulated balance on Account')), + ('rec', 1, 0, 'text', None), + ('debit', 1, 0, 'number', account_total_debit, None, account_cell_style_decimal), + ('credit', 1, 0, 'number', account_total_credit, None, account_cell_style_decimal), + ('cumul_bal', 1, 0, 'number', account_balance_cumul, None, account_cell_style_decimal), + ] + if _p.amount_currency(data): + if account.currency_id: + c_specs += [('curr_bal', 1, 0, 'number', account_balance_cumul_curr or 0.0, None, account_cell_style_decimal)] + else: + c_specs += [('curr_bal', 1, 0, 'text', '-', None, account_cell_style_right)] + c_specs += [('curr_code', 1, 0, 'text', account.currency_id.name if account.currency_id else u'', None, account_cell_style)] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, account_cell_style) + row_pos += 2 + +partner_ledger_xls('report.account.account_report_partner_ledger_xls', 'account.account', + parser=PartnersLedgerWebkit) +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_financial_report_webkit_xls/report/partners_balance_xls.py b/account_financial_report_webkit_xls/report/partners_balance_xls.py new file mode 100644 index 00000000..6cfd6f0c --- /dev/null +++ b/account_financial_report_webkit_xls/report/partners_balance_xls.py @@ -0,0 +1,328 @@ +# -*- 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 . +# +############################################################################## + +import xlwt +import time +from openerp.report import report_sxw +from openerp.addons.report_xls.report_xls import report_xls +from openerp.addons.report_xls.utils import rowcol_to_cell +from openerp.addons.account_financial_report_webkit.report.partner_balance import PartnerBalanceWebkit +from openerp.tools.translate import _ +#import logging +#_logger = logging.getLogger(__name__) + +def display_line(all_comparison_lines): + return any([line.get('balance') for line in all_comparison_lines]) + +class partners_balance_xls(report_xls): + column_sizes = [12,40,25,17,17,17,17,17] + + def print_title(self, ws, _p, row_position, xlwt,_xs): + cell_style = xlwt.easyxf(_xs['xls_title']) + report_name = ' - '.join([_p.report_name.upper(), _p.company.partner_id.name, _p.company.currency_id.name]) + c_specs = [ + ('report_name', 1, 0, 'text', report_name), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, row_style=cell_style) + return row_position + + def print_empty_row(self, ws, row_position): + c_sizes = self.column_sizes + c_specs = [('empty%s'%i, 1, c_sizes[i], 'text', None) for i in range(0,len(c_sizes))] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, set_column_size=True) + return row_position + + def print_header_titles(self, ws, _p, data, row_position, xlwt, _xs): + cell_format = _xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] + cell_style = xlwt.easyxf(cell_format) + cell_style_center = xlwt.easyxf(cell_format + _xs['center']) + + c_specs = [ + ('fy', 1, 0, 'text', _('Fiscal Year'), None, cell_style_center), + ('af', 1, 0, 'text', _('Accounts Filter'), None, cell_style_center), + ('df', 1, 0, 'text', _p.filter_form(data) == 'filter_date' and _('Dates Filter') or _('Periods Filter'), None, cell_style_center), + ('pf', 1, 0, 'text', _('Partners Filter'), None, cell_style_center), + ('tm', 1, 0, 'text', _('Target Moves'), None, cell_style_center), + ('ib', 1, 0, 'text', _('Initial Balance'), None, cell_style_center), + ('coa', 1, 0, 'text', _('Chart of Account'), None, cell_style_center), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, row_style=cell_style) + return row_position + + def print_header_data(self, ws, _p, data, row_position, xlwt, _xs, initial_balance_text): + cell_format = _xs['borders_all'] + _xs['wrap'] + _xs['top'] + cell_style = xlwt.easyxf(cell_format) + cell_style_center = xlwt.easyxf(cell_format + _xs['center']) + c_specs = [ + ('fy', 1, 0, 'text', _p.fiscalyear.name if _p.fiscalyear else '-', None, cell_style_center), + ('af', 1, 0, 'text', _p.accounts(data) and ', '.join([account.code for account in _p.accounts(data)]) or _('All'), None, cell_style_center), + ] + df = _('From') + ': ' + if _p.filter_form(data) == 'filter_date': + df += _p.start_date if _p.start_date else u'' + else: + df += _p.start_period.name if _p.start_period else u'' + df += ' ' + _('\nTo') + ': ' + if _p.filter_form(data) == 'filter_date': + df += _p.stop_date if _p.stop_date else u'' + else: + df += _p.stop_period.name if _p.stop_period else u'' + c_specs += [ + ('df', 1, 0, 'text', df, None, cell_style_center), + ('tm', 1, 0, 'text', _p.display_partner_account(data), None, cell_style_center), + ('pf', 1, 0, 'text', _p.display_target_move(data), None, cell_style_center), + ('ib', 1, 0, 'text', initial_balance_text[_p.initial_balance_mode], None, cell_style_center), + ('coa', 1, 0, 'text', _p.chart_account.name, None, cell_style_center), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, row_style=cell_style) + return row_position + + def print_comparison_header(self, _xs, xlwt, row_position, _p, ws, initial_balance_text ): + cell_format_ct = _xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] + cell_style_ct = xlwt.easyxf(cell_format_ct) + c_specs = [('ct', 7, 0, 'text', _('Comparisons'))] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, row_style=cell_style_ct) + cell_format = _xs['borders_all'] + _xs['wrap'] + _xs['top'] + cell_style_center = xlwt.easyxf(cell_format) + for index, params in enumerate(_p.comp_params): + c_specs = [('c', 2, 0, 'text', _('Comparison') + str(index + 1) + ' (C' + str(index + 1) + ')')] + if params['comparison_filter'] == 'filter_date': + c_specs += [('f', 2, 0, 'text', _('Dates Filter') + ': ' + _p.formatLang(params['start'], date=True) + ' - ' + _p.formatLang(params['stop'], date=True))] + elif params['comparison_filter'] == 'filter_period': + c_specs += [('f', 2, 0, 'text', _('Periods Filter') + ': ' + params['start'].name + ' - ' + params['stop'].name)] + else: + c_specs += [('f', 2, 0, 'text', _('Fiscal Year') + ': ' + params['fiscalyear'].name)] + c_specs += [('ib', 2, 0, 'text', _('Initial Balance') + ': ' + initial_balance_text[params['initial_balance_mode']])] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, row_style=cell_style_center) + return row_position + + def print_account_header(self, ws, _p, _xs, xlwt, row_position): + cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all'] + _xs['wrap'] + _xs['top'] + cell_style = xlwt.easyxf(cell_format) + cell_style_right = xlwt.easyxf(cell_format + _xs['right']) + cell_style_center = xlwt.easyxf(cell_format + _xs['center']) + if len(_p.comp_params) == 2: + account_span = 3 + else: + account_span = _p.initial_balance_mode and 2 or 3 + c_specs = [ + ('account', account_span, 0, 'text', _('Account / Partner Name')), + ('code', 1, 0, 'text', _('Code / Ref')), + ] + if _p.comparison_mode == 'no_comparison': + if _p.initial_balance_mode: + c_specs += [('init_bal', 1, 0, 'text', _('Initial Balance'), None, cell_style_right)] + c_specs += [ + ('debit', 1, 0, 'text', _('Debit'), None, cell_style_right), + ('credit', 1, 0, 'text', _('Credit'), None, cell_style_right), + ] + + if _p.comparison_mode == 'no_comparison' or not _p.fiscalyear: + c_specs += [('balance', 1, 0, 'text', _('Balance'), None, cell_style_right)] + else: + c_specs += [('balance_fy', 1, 0, 'text', _('Balance %s') % _p.fiscalyear.name, None, cell_style_right)] + if _p.comparison_mode in ('single', 'multiple'): + for index in range(_p.nb_comparison): + if _p.comp_params[index]['comparison_filter'] == 'filter_year' and _p.comp_params[index].get('fiscalyear', False): + c_specs += [('balance_%s' %index, 1, 0, 'text', _('Balance %s') % _p.comp_params[index]['fiscalyear'].name, None, cell_style_right)] + else: + c_specs += [('balance_%s' %index, 1, 0, 'text', _('Balance C%s') % (index + 1), None, cell_style_right)] + if _p.comparison_mode == 'single': + c_specs += [ + ('diff', 1, 0, 'text', _('Difference'), None, cell_style_right), + ('diff_percent', 1, 0, 'text', _('% Difference'), None, cell_style_center), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, row_style=cell_style) + return row_position + + def print_row_code_account(self, ws, current_account, row_position, _xs, xlwt): + cell_format = _xs['xls_title'] + _xs['bold'] + _xs['fill'] + _xs['borders_all'] + cell_style = xlwt.easyxf(cell_format) + c_specs = [ ('acc_title', 7, 0, 'text', ' - '.join([current_account.code, current_account.name])), ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, cell_style) + return row_position + + def print_account_totals(self, _xs, xlwt, ws, row_start_account, row_position, current_account,_p): + cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all'] + _xs['wrap'] + _xs['top'] + cell_style = xlwt.easyxf(cell_format) + cell_style_decimal = xlwt.easyxf(cell_format + _xs['right'], num_format_str = report_xls.decimal_format) + c_specs = [ + ('acc_title', 2, 0, 'text', current_account.name), + ('code', 1, 0, 'text', current_account.code), + ] + for column in range(3,7): + if (_p.comparison_mode == 'single' and column == 6): #in case of one single comparison, the column 6 will contain percentages + total_diff = rowcol_to_cell(row_position, column-1) + total_balance = rowcol_to_cell(row_position, column-2) + account_formula = 'Round('+ total_diff + '/' + total_balance + '*100;0)' + else: + account_start = rowcol_to_cell(row_start_account, column) + account_end = rowcol_to_cell(row_position -1, column) + account_formula = 'Round(SUM(' + account_start + ':' + account_end + ');2)' + c_specs += [('total%s' %column, 1, 0, 'text', None, account_formula, None, cell_style_decimal)] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_position = self.xls_write_row(ws, row_position, row_data, cell_style) + return row_position + 1 + + def generate_xls_report(self, _p, _xs, data, objects, wb): + + # Initialisations + ws = wb.add_sheet(_p.report_name[:31]) + ws.panes_frozen = True + ws.remove_splits = True + ws.portrait = 0 # Landscape + ws.fit_width_to_pages = 1 + row_pos = 0 + ws.header_str = self.xls_headers['standard'] + ws.footer_str = self.xls_footers['standard'] + + # Print Title + row_pos = self.print_title(ws, _p, row_pos, xlwt, _xs) + # Print empty row to define column sizes + row_pos = self.print_empty_row(ws, row_pos) + # Print Header Table titles (Fiscal Year - Accounts Filter - Periods Filter...) + row_pos = self.print_header_titles(ws, _p, data, row_pos, xlwt, _xs) + + initial_balance_text = {'initial_balance': _('Computed'), 'opening_balance': _('Opening Entries'), False: _('No')} # cf. account_report_partner_balance.mako + # Print Header Table data + row_pos = self.print_header_data(ws, _p, data, row_pos, xlwt, _xs, initial_balance_text) + # Print comparison header table + if _p.comparison_mode in ('single', 'multiple'): + row_pos += 1 + row_pos = self.print_comparison_header(_xs, xlwt, row_pos, _p, ws, initial_balance_text) + + # Freeze the line + ws.set_horz_split_pos(row_pos) + + # cell styles for account data + regular_cell_format = _xs['borders_all'] + regular_cell_style = xlwt.easyxf(regular_cell_format) + regular_cell_style_center = xlwt.easyxf(regular_cell_format + _xs['center']) + regular_cell_style_decimal = xlwt.easyxf(regular_cell_format + _xs['right'], num_format_str = report_xls.decimal_format) + regular_cell_style_pct = xlwt.easyxf(regular_cell_format + _xs['center'], num_format_str = '0') + + row_pos += 1 + for current_account in objects: + + partners_order = current_account.partners_order + + # do not display accounts without partners + if not partners_order: + continue + + comparisons = current_account.comparisons + + # in multiple columns mode, we do not want to print accounts without any rows + if _p.comparison_mode in ('single', 'multiple'): + all_comparison_lines = [comp['partners_amounts'][partner_id[1]] + for partner_id in partners_order + for comp in comparisons] + if not display_line(all_comparison_lines): + continue + + current_partner_amounts = current_account.partners_amounts + + if _p.comparison_mode in ('single', 'multiple'): + comparison_total = {} + for i, comp in enumerate(comparisons): + comparison_total[i] = {'balance': 0.0} + + # print row: Code - Account name + row_pos = self.print_row_code_account(ws, current_account, row_pos, _xs, xlwt) + row_account_start = row_pos + # Print row: Titles "Account/Partner Name-Code/ref-Initial Balance-Debit-Credit-Balance" or "Account/Partner Name-Code/ref-Balance Year-Balance Year2-Balance C2-Balance C3" + row_pos = self.print_account_header(ws, _p, _xs, xlwt, row_pos) + + for (partner_code_name, partner_id, partner_ref, partner_name) in partners_order: + partner = current_partner_amounts.get(partner_id, {}) + # in single mode, we have to display all the partners even if their balance is 0.0 because the initial balance should match with the previous year closings + # in multiple columns mode, we do not want to print partners which have a balance at 0.0 in each comparison column + if _p.comparison_mode in ('single', 'multiple'): + all_comparison_lines = [comp['partners_amounts'][partner_id] + for comp in comparisons + if comp['partners_amounts'].get(partner_id)] + if not display_line(all_comparison_lines): + continue + + # display data row + if len(_p.comp_params) == 2: + account_span = 3 + else: + account_span = _p.initial_balance_mode and 2 or 3 + + c_specs = [('acc_title', account_span, 0, 'text', partner_name if partner_name else _('Unallocated'))] + c_specs += [('partner_ref', 1, 0, 'text', partner_ref if partner_ref else '')] + if _p.comparison_mode == 'no_comparison': + bal_formula = '' + if _p.initial_balance_mode: + init_bal_cell = rowcol_to_cell(row_pos, 3) + bal_formula = init_bal_cell + '+' + debit_col = 4 + c_specs += [ + ('init_bal', 1, 0, 'number', partner.get('init_balance', 0.0), None, regular_cell_style_decimal), + ] + else: + debit_col = 3 + c_specs += [ + ('debit', 1, 0, 'number', partner.get('debit', 0.0), None, regular_cell_style_decimal), + ('credit', 1, 0, 'number', partner.get('credit', 0.0), None, regular_cell_style_decimal), + ] + debit_cell = rowcol_to_cell(row_pos, debit_col) + credit_cell = rowcol_to_cell(row_pos, debit_col+1) + bal_formula += debit_cell + '-' + credit_cell + c_specs += [('bal', 1, 0, 'number', None, bal_formula, regular_cell_style_decimal),] + else: + c_specs += [('bal', 1, 0, 'number', partner.get('balance', 0.0), None, regular_cell_style_decimal),] + + if _p.comparison_mode in ('single', 'multiple'): + for i, comp in enumerate(comparisons): + comp_partners = comp['partners_amounts'] + balance = diff = percent_diff = 0 + if comp_partners.get(partner_id): + balance = comp_partners[partner_id]['balance'] + diff = comp_partners[partner_id]['diff'] + percent_diff = comp_partners[partner_id]['percent_diff'] + comparison_total[i]['balance'] += balance + c_specs += [('balance_%s' %i, 1, 0, 'number', balance, None, regular_cell_style_decimal), ] + if _p.comparison_mode == 'single': ## no diff in multiple comparisons because it shows too much data + c_specs += [('balance_diff', 1, 0, 'number', diff, None, regular_cell_style_decimal), ] + if percent_diff is False: + c_specs += [('balance', 1, 0, 'number', diff, None, regular_cell_style_decimal), ] + else: + c_specs += [('perc_diff', 1, 0, 'number', int(round(percent_diff))), ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, regular_cell_style) + + row_pos = self.print_account_totals(_xs, xlwt, ws, row_account_start, row_pos, current_account,_p) + +partners_balance_xls('report.account.account_report_partner_balance_xls', 'account.account', + parser=PartnerBalanceWebkit) + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_financial_report_webkit_xls/report/trial_balance_xls.py b/account_financial_report_webkit_xls/report/trial_balance_xls.py new file mode 100644 index 00000000..d6b7e3bf --- /dev/null +++ b/account_financial_report_webkit_xls/report/trial_balance_xls.py @@ -0,0 +1,258 @@ +# -*- 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 . +# +############################################################################## + +import xlwt +import time +from openerp.report import report_sxw +from openerp.addons.report_xls.report_xls import report_xls +from openerp.addons.report_xls.utils import rowcol_to_cell +from openerp.addons.account_financial_report_webkit.report.trial_balance import TrialBalanceWebkit +from openerp.tools.translate import _ +#import logging +#_logger = logging.getLogger(__name__) + +class trial_balance_xls(report_xls): + column_sizes = [12,60,17,17,17,17,17,17] + + def generate_xls_report(self, _p, _xs, data, objects, wb): + + ws = wb.add_sheet(_p.report_name[:31]) + ws.panes_frozen = True + ws.remove_splits = True + ws.portrait = 0 # Landscape + ws.fit_width_to_pages = 1 + row_pos = 0 + + # set print header/footer + ws.header_str = self.xls_headers['standard'] + ws.footer_str = self.xls_footers['standard'] + + # cf. account_report_trial_balance.mako + initial_balance_text = {'initial_balance': _('Computed'), 'opening_balance': _('Opening Entries'), False: _('No')} + + # Title + cell_style = xlwt.easyxf(_xs['xls_title']) + report_name = ' - '.join([_p.report_name.upper(), _p.company.partner_id.name, _p.company.currency_id.name]) + c_specs = [ + ('report_name', 1, 0, 'text', report_name), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style) + + # write empty row to define column sizes + c_sizes = self.column_sizes + c_specs = [('empty%s'%i, 1, c_sizes[i], 'text', None) for i in range(0,len(c_sizes))] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, set_column_size=True) + + # Header Table + cell_format = _xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] + cell_style = xlwt.easyxf(cell_format) + cell_style_center = xlwt.easyxf(cell_format + _xs['center']) + c_specs = [ + ('fy', 1, 0, 'text', _('Fiscal Year')), + ('af', 2, 0, 'text', _('Accounts Filter')), + ('df', 1, 0, 'text', _p.filter_form(data) == 'filter_date' and _('Dates Filter') or _('Periods Filter')), + ('tm', 2, 0, 'text', _('Target Moves'), None, cell_style_center), + ('ib', 1, 0, 'text', _('Initial Balance'), None, cell_style_center), + ('coa', 1, 0, 'text', _('Chart of Account'), None, cell_style_center), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style) + + cell_format = _xs['borders_all'] + _xs['wrap'] + _xs['top'] + cell_style = xlwt.easyxf(cell_format) + cell_style_center = xlwt.easyxf(cell_format + _xs['center']) + c_specs = [ + ('fy', 1, 0, 'text', _p.fiscalyear.name if _p.fiscalyear else '-'), + ('af', 2, 0, 'text', _p.accounts(data) and ', '.join([account.code for account in _p.accounts(data)]) or _('All')), + ] + df = _('From') + ': ' + if _p.filter_form(data) == 'filter_date': + df += _p.start_date if _p.start_date else u'' + else: + df += _p.start_period.name if _p.start_period else u'' + df += ' ' + _('\nTo') + ': ' + if _p.filter_form(data) == 'filter_date': + df += _p.stop_date if _p.stop_date else u'' + else: + df += _p.stop_period.name if _p.stop_period else u'' + c_specs += [ + ('df', 1, 0, 'text', df), + ('tm', 2, 0, 'text', _p.display_target_move(data), None, cell_style_center), + ('ib', 1, 0, 'text', initial_balance_text[_p.initial_balance_mode], None, cell_style_center), + ('coa', 1, 0, 'text', _p.chart_account.name, None, cell_style_center), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style) + + # comparison header table + if _p.comparison_mode in ('single', 'multiple'): + row_pos += 1 + cell_format_ct = _xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] + cell_style_ct = xlwt.easyxf(cell_format_ct) + c_specs = [('ct', 8, 0, 'text', _('Comparisons'))] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style_ct) + cell_style_center = xlwt.easyxf(cell_format) + for index, params in enumerate(_p.comp_params): + c_specs = [('c', 3, 0, 'text', _('Comparison') + str(index + 1) + ' (C' + str(index + 1) + ')')] + if params['comparison_filter'] == 'filter_date': + c_specs += [('f', 3, 0, 'text', _('Dates Filter') + ': ' + _p.formatLang(params['start'], date=True) + ' - ' + _p.formatLang(params['stop'], date=True))] + elif params['comparison_filter'] == 'filter_period': + c_specs += [('f', 3, 0, 'text', _('Periods Filter') + ': ' + params['start'].name + ' - ' + params['stop'].name)] + else: + c_specs += [('f', 3, 0, 'text', _('Fiscal Year') + ': ' + params['fiscalyear'].name)] + c_specs += [('ib', 2, 0, 'text', _('Initial Balance') + ': ' + initial_balance_text[params['initial_balance_mode']])] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style_center) + + row_pos += 1 + + # Column Header Row + cell_format = _xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] + _xs['wrap'] + _xs['top'] + cell_style = xlwt.easyxf(cell_format) + cell_style_right = xlwt.easyxf(cell_format + _xs['right']) + cell_style_center = xlwt.easyxf(cell_format + _xs['center']) + if len(_p.comp_params) == 2: + account_span = 3 + else: + account_span = _p.initial_balance_mode and 2 or 3 + c_specs = [ + ('code', 1, 0, 'text', _('Code')), + ('account', account_span, 0, 'text', _('Account')), + ] + if _p.comparison_mode == 'no_comparison': + if _p.initial_balance_mode: + c_specs += [('init_bal', 1, 0, 'text', _('Initial Balance'), None, cell_style_right)] + c_specs += [ + ('debit', 1, 0, 'text', _('Debit'), None, cell_style_right), + ('credit', 1, 0, 'text', _('Credit'), None, cell_style_right), + ] + + if _p.comparison_mode == 'no_comparison' or not _p.fiscalyear: + c_specs += [('balance', 1, 0, 'text', _('Balance'), None, cell_style_right)] + else: + c_specs += [('balance_fy', 1, 0, 'text', _('Balance %s') % _p.fiscalyear.name, None, cell_style_right)] + if _p.comparison_mode in ('single', 'multiple'): + for index in range(_p.nb_comparison): + if _p.comp_params[index]['comparison_filter'] == 'filter_year' and _p.comp_params[index].get('fiscalyear', False): + c_specs += [('balance_%s' %index, 1, 0, 'text', _('Balance %s') % _p.comp_params[index]['fiscalyear'].name, None, cell_style_right)] + else: + c_specs += [('balance_%s' %index, 1, 0, 'text', _('Balance C%s') % (index + 1), None, cell_style_right)] + if _p.comparison_mode == 'single': + c_specs += [ + ('diff', 1, 0, 'text', _('Difference'), None, cell_style_right), + ('diff_percent', 1, 0, 'text', _('% Difference'), None, cell_style_center), + ] + c_specs += [('type', 1, 0, 'text', _('Type'), None, cell_style_center)] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style) + ws.set_horz_split_pos(row_pos) + + last_child_consol_ids = [] + last_level = False + + # cell styles for account data + view_cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all'] + view_cell_style = xlwt.easyxf(view_cell_format) + view_cell_style_center = xlwt.easyxf(view_cell_format + _xs['center']) + view_cell_style_decimal = xlwt.easyxf(view_cell_format + _xs['right'], num_format_str = report_xls.decimal_format) + view_cell_style_pct = xlwt.easyxf(view_cell_format + _xs['center'], num_format_str = '0') + regular_cell_format = _xs['borders_all'] + regular_cell_style = xlwt.easyxf(regular_cell_format) + regular_cell_style_center = xlwt.easyxf(regular_cell_format + _xs['center']) + regular_cell_style_decimal = xlwt.easyxf(regular_cell_format + _xs['right'], num_format_str = report_xls.decimal_format) + regular_cell_style_pct = xlwt.easyxf(regular_cell_format + _xs['center'], num_format_str = '0') + + for current_account in objects: + + if not current_account.to_display: + continue + + if current_account.type == 'view': + cell_style = view_cell_style + cell_style_center = view_cell_style_center + cell_style_decimal = view_cell_style_decimal + cell_style_pct = view_cell_style_pct + else: + cell_style = regular_cell_style + cell_style_center = regular_cell_style_center + cell_style_decimal = regular_cell_style_decimal + cell_style_pct = regular_cell_style_pct + + comparisons = current_account.comparisons + + if current_account.id in last_child_consol_ids: + # current account is a consolidation child of the last account: use the level of last account + level = last_level + level_class = 'account_level_consol' + else: + # current account is a not a consolidation child: use its own level + level = current_account.level or 0 + level_class = "account_level_%s" % (level,) + last_child_consol_ids = [child_consol_id.id for child_consol_id in current_account.child_consol_ids] + last_level = current_account.level + + c_specs = [ + ('code', 1, 0, 'text', current_account.code), + ('account', account_span, 0, 'text', current_account.name), + ] + if _p.comparison_mode == 'no_comparison': + + debit_cell = rowcol_to_cell(row_pos, 3) + credit_cell = rowcol_to_cell(row_pos, 4) + bal_formula = debit_cell + '-' + credit_cell + + if _p.initial_balance_mode: + init_cell = rowcol_to_cell(row_pos, 3) + debit_cell = rowcol_to_cell(row_pos, 4) + credit_cell = rowcol_to_cell(row_pos, 5) + bal_formula = init_cell + '+' + debit_cell + '-' + credit_cell + c_specs += [('init_bal', 1, 0, 'number', current_account.init_balance, None, cell_style_decimal)] + c_specs += [ + ('debit', 1, 0, 'number', current_account.debit, None, cell_style_decimal), + ('credit', 1, 0, 'number', current_account.credit, None, cell_style_decimal), + ] + c_specs += [('balance', 1, 0, 'number', None, bal_formula, cell_style_decimal)] + else: + c_specs += [('balance', 1, 0, 'number', current_account.balance, None, cell_style_decimal)] + + if _p.comparison_mode in ('single', 'multiple'): + c = 1 + for comp_account in comparisons: + c_specs += [('balance_%s' %c, 1, 0, 'number', comp_account['balance'], None, cell_style_decimal)] + c += 1 + if _p.comparison_mode == 'single': + c_specs += [ + ('diff', 1, 0, 'number', comp_account['diff'], None, cell_style_decimal), + ('diff_percent', 1, 0, 'number', comp_account['percent_diff'] and comp_account['percent_diff'] or 0, None, cell_style_pct), + ] + + c_specs += [('type', 1, 0, 'text', current_account.type, None, cell_style_center)] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style) + +trial_balance_xls('report.account.account_report_trial_balance_xls', 'account.account', + parser=TrialBalanceWebkit) + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_financial_report_webkit_xls/wizard/__init__.py b/account_financial_report_webkit_xls/wizard/__init__.py new file mode 100644 index 00000000..4efb87d5 --- /dev/null +++ b/account_financial_report_webkit_xls/wizard/__init__.py @@ -0,0 +1,27 @@ +# -*- 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 . +# +############################################################################## + +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 \ No newline at end of file diff --git a/account_financial_report_webkit_xls/wizard/general_ledger_wizard.py b/account_financial_report_webkit_xls/wizard/general_ledger_wizard.py new file mode 100644 index 00000000..30cc6a88 --- /dev/null +++ b/account_financial_report_webkit_xls/wizard/general_ledger_wizard.py @@ -0,0 +1,43 @@ +# -*- 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 . +# +############################################################################## + +from openerp.osv import orm +#import logging +#_logger = logging.getLogger(__name__) + +class general_ledger_webkit_wizard(orm.TransientModel): + _inherit = 'general.ledger.webkit' + + def xls_export(self, cr, uid, ids, context=None): + return self.check_report(cr, uid, ids, context=context) + + def _print_report(self, cr, uid, ids, data, context=None): + context = context or {} + if context.get('xls_export'): + # we update form with display account value + data = self.pre_print_report(cr, uid, ids, data, context=context) + return {'type': 'ir.actions.report.xml', + 'report_name': 'account.account_report_general_ledger_xls', + 'datas': data} + else: + return super(general_ledger_webkit_wizard, self)._print_report(cr, uid, ids, data, context=context) + 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 new file mode 100644 index 00000000..1ab4f6ca --- /dev/null +++ b/account_financial_report_webkit_xls/wizard/general_ledger_wizard_view.xml @@ -0,0 +1,26 @@ + + + + + + general.ledger.webkit.xls + general.ledger.webkit + form + + + + + + + 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 new file mode 100644 index 00000000..ff01ca8a --- /dev/null +++ b/account_financial_report_webkit_xls/wizard/open_invoices_wizard.py @@ -0,0 +1,42 @@ +# -*- 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 . +# +############################################################################## + +from openerp.osv import orm +#import logging +#_logger = logging.getLogger(__name__) + +class open_invoices_webkit_wizard(orm.TransientModel): + _inherit = 'open.invoices.webkit' + + def xls_export(self, cr, uid, ids, context=None): + return self.check_report(cr, uid, ids, context=context) + + def _print_report(self, cr, uid, ids, data, context=None): + context = context or {} + if context.get('xls_export'): + # we update form with display account value + data = self.pre_print_report(cr, uid, ids, data, context=context) + return {'type': 'ir.actions.report.xml', + 'report_name': 'account.account_report_open_invoices_xls', + 'datas': data} + else: + return super(open_invoices_webkit_wizard, self)._print_report(cr, uid, ids, data, context=context) 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 new file mode 100644 index 00000000..2d089239 --- /dev/null +++ b/account_financial_report_webkit_xls/wizard/open_invoices_wizard_view.xml @@ -0,0 +1,26 @@ + + + + + + open.invoices.webkit.xls + open.invoices.webkit + form + + + + + + + 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 new file mode 100644 index 00000000..2f574371 --- /dev/null +++ b/account_financial_report_webkit_xls/wizard/partners_balance_wizard.py @@ -0,0 +1,43 @@ +# -*- 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 . +# +############################################################################## + +from openerp.osv import orm +#import logging +#_logger = logging.getLogger(__name__) + +class partner_balance_wizard(orm.TransientModel): + _inherit = 'partner.balance.webkit' + + def xls_export(self, cr, uid, ids, context=None): + return self.check_report(cr, uid, ids, context=context) + + def _print_report(self, cr, uid, ids, data, context=None): + context = context or {} + if context.get('xls_export'): + # we update form with display account value + data = self.pre_print_report(cr, uid, ids, data, context=context) + return {'type': 'ir.actions.report.xml', + 'report_name': 'account.account_report_partner_balance_xls', + 'datas': data} + else: + return super(partner_balance_wizard, self)._print_report(cr, uid, ids, data, context=context) + 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 new file mode 100644 index 00000000..7dbd6cca --- /dev/null +++ b/account_financial_report_webkit_xls/wizard/partners_balance_wizard_view.xml @@ -0,0 +1,26 @@ + + + + + + partner.balance.webkit.xls + partner.balance.webkit + form + + + + + + + 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 new file mode 100644 index 00000000..7225f0cf --- /dev/null +++ b/account_financial_report_webkit_xls/wizard/partners_ledger_wizard.py @@ -0,0 +1,42 @@ +# -*- 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 . +# +############################################################################## + +from openerp.osv import orm +#import logging +#_logger = logging.getLogger(__name__) + +class partner_ledger_webkit_wizard(orm.TransientModel): + _inherit = 'partners.ledger.webkit' + + def xls_export(self, cr, uid, ids, context=None): + return self.check_report(cr, uid, ids, context=context) + + def _print_report(self, cr, uid, ids, data, context=None): + context = context or {} + if context.get('xls_export'): + # we update form with display account value + data = self.pre_print_report(cr, uid, ids, data, context=context) + return {'type': 'ir.actions.report.xml', + 'report_name': 'account.account_report_partner_ledger_xls', + 'datas': data} + else: + return super(partner_ledger_webkit_wizard, self)._print_report(cr, uid, ids, data, context=context) 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 new file mode 100644 index 00000000..3015eb82 --- /dev/null +++ b/account_financial_report_webkit_xls/wizard/partners_ledger_wizard_view.xml @@ -0,0 +1,26 @@ + + + + + + partners.ledger.webkit.xls + partners.ledger.webkit + form + + + + + + + 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 new file mode 100644 index 00000000..dafb0ee9 --- /dev/null +++ b/account_financial_report_webkit_xls/wizard/trial_balance_wizard.py @@ -0,0 +1,43 @@ +# -*- 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 . +# +############################################################################## + +from openerp.osv import orm +#import logging +#_logger = logging.getLogger(__name__) + +class trial_balance_wizard(orm.TransientModel): + _inherit = 'trial.balance.webkit' + + def xls_export(self, cr, uid, ids, context=None): + return self.check_report(cr, uid, ids, context=context) + + def _print_report(self, cr, uid, ids, data, context=None): + context = context or {} + if context.get('xls_export'): + # we update form with display account value + data = self.pre_print_report(cr, uid, ids, data, context=context) + return {'type': 'ir.actions.report.xml', + 'report_name': 'account.account_report_trial_balance_xls', + 'datas': data} + else: + return super(trial_balance_wizard, self)._print_report(cr, uid, ids, data, context=context) + 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 new file mode 100644 index 00000000..f7d16633 --- /dev/null +++ b/account_financial_report_webkit_xls/wizard/trial_balance_wizard_view.xml @@ -0,0 +1,26 @@ + + + + + + trial.balance.webkit.xls + trial.balance.webkit + form + + + + + + + 6 + + + + + + + + diff --git a/account_journal_report_xls/__init__.py b/account_journal_report_xls/__init__.py new file mode 100644 index 00000000..87345508 --- /dev/null +++ b/account_journal_report_xls/__init__.py @@ -0,0 +1,27 @@ +# -*- 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 . +# +############################################################################## + +from . import account_journal +from . import wizard +from . import report + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_journal_report_xls/__openerp__.py b/account_journal_report_xls/__openerp__.py new file mode 100644 index 00000000..6cd9f593 --- /dev/null +++ b/account_journal_report_xls/__openerp__.py @@ -0,0 +1,57 @@ +# -*- 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 . +# +############################################################################## + +{ + 'name': 'Financial Journal reports', + 'version': '0.1', + 'license': 'AGPL-3', + 'author': 'Noviat', + 'category': 'Accounting & Finance', + 'description': """ + +Journal Reports +=============== + +This module adds journal reports by period and by fiscal year with + - entries printed per move + - option to group entries with same general account & VAT case + - vat info per entry + - vat summary + +These reports are available in PDF and XLS format. + +This module depends upon the 'report_xls' module, +cf. https://launchpad.net/openerp-reporting-engines + + """, + 'depends': [ + 'account_voucher', + 'report_xls', + ], + 'demo_xml': [], + 'init_xml': [], + 'update_xml': [ + 'wizard/print_journal_wizard.xml', + ], +} + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_journal_report_xls/account_journal.py b/account_journal_report_xls/account_journal.py new file mode 100644 index 00000000..c1e3dbcf --- /dev/null +++ b/account_journal_report_xls/account_journal.py @@ -0,0 +1,84 @@ +# -*- 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 . +# +############################################################################## + +from openerp.osv import orm +from openerp.addons.report_xls.utils import rowcol_to_cell, _render +from openerp.tools.translate import _ + + +class account_journal(orm.Model): + _inherit = 'account.journal' + + # allow inherited modules to extend the query + def _report_xls_query_extra(self, cr, uid, context=None): + select_extra = "" + join_extra = "" + where_extra = "" + return (select_extra, join_extra, where_extra) + + # allow inherited modules to add document references + def _report_xls_document_extra(self, cr, uid, context): + return "''" + + # override list in inherited module to add/drop columns or change order + def _report_xls_fields(self, cr, uid, context=None): + res = [ + 'move_name', # account.move,name + 'move_date', # account.move,date + 'acc_code', # account.account,code + ] + if context.get('print_by') == 'fiscalyear': + res += [ + 'period', # account.period,code or name + ] + res += [ + 'partner_name', # res.partner,name + 'aml_name', # account.move.line,name + 'tax_code', # account.tax.code,code + 'tax_amount', # account.move.line,tax_amount + 'debit', # account.move.line,debit + 'credit', # account.move.line,credit + 'balance', # debit-credit + 'docname', # origin document if any + #'date_maturity', # account.move.line,date_maturity + #'reconcile', # account.move.line,reconcile_id.name + #'reconcile_partial', # account.move.line,reconcile_partial_id.name + #'partner_ref', # res.partner,ref + #'move_ref', # account.move,ref + #'move_id', # account.move,id + ] + return res + + # Change/Add Template entries + def _report_xls_template(self, cr, uid, context=None): + """ + Template updates, e.g. + + my_change = { + 'move_name':{ + 'header': [1, 20, 'text', _render("_('My Move Title')")], + 'lines': [1, 0, 'text', _render("l['move_name'] != '/' and l['move_name'] or ('*'+str(l['move_id']))")], + 'totals': [1, 0, 'text', None]}, + } + return my_change + """ + return {} diff --git a/account_journal_report_xls/i18n/fr.po b/account_journal_report_xls/i18n/fr.po new file mode 100644 index 00000000..eec93f28 --- /dev/null +++ b/account_journal_report_xls/i18n/fr.po @@ -0,0 +1,256 @@ +# French translation of OpenERP Server 6.1. +# This file contains the translation of the following modules: +# * account_journal_report_xls +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.1\n" +"Report-Msgid-Bugs-To: support@noviat.be\n" +"POT-Creation-Date: 2013-11-23 17:11:14.941000\n" +"PO-Revision-Date: 2013-11-23 17:11:14.941000\n" +"Last-Translator: Luc De Meyer (Noviat nv/sa)\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. module: account_journal_report_xls +#: model:ir.actions.act_window,name:account_journal_report_xls.action_print_journal_by_period_xls +msgid "Journal by Period" +msgstr "Journal détaillé par période" + +#. module: account_journal_report_xls +#: model:ir.actions.act_window,name:account_journal_report_xls.action_print_journal_by_fiscalyear_xls +msgid "Journal by Fiscal Year" +msgstr "Journal détaillé par exercice fiscal" + +#. module: account_journal_report_xls +#: model:ir.ui.menu,name:account_journal_report_xls.menu_print_journal_by_period_xls +msgid "Journal by Period" +msgstr "Journal détaillé par période" + +#. module: account_journal_report_xls +#: model:ir.ui.menu,name:account_journal_report_xls.menu_print_journal_by_fiscalyear_xls +msgid "Journal by Fiscal Year" +msgstr "Journal détaillé par exercice fiscal" + +#. module: account_journal_report_xls +#: field:account.print.journal.xls,chart_account_id:0 +msgid "Chart of Account" +msgstr "Plan comptable" + +#. module: account_journal_report_xls +#: field:account.print.journal.xls,fiscalyear_id:0 +msgid "Fiscal Year" +msgstr "Exercice fiscal" + +#. module: account_journal_report_xls +#: field:account.print.journal.xls,target_move:0 +msgid "Target Moves" +msgstr "Mouvements ciblés" + +#. module: account_journal_report_xls +#: selection:account.print.journal.xls,target_move:0 +msgid "All Posted Entries" +msgstr "Toutes les écritures passées" + +#. module: account_journal_report_xls +#: selection:account.print.journal.xls,target_move:0 +msgid "All Entries" +msgstr "Toutes les écritures" + +#. module: account_journal_report_xls +#: field:account.print.journal.xls,sort_selection:0 +msgid "Entries Sorted by" +msgstr "Écritures triées par" + +#. module: account_journal_report_xls +#: selection:account.print.journal.xls,sort_selection:0 +msgid "Journal Entry Number" +msgstr "N° écriture dans le journal" + +#. module: account_journal_report_xls +#: selection:account.print.journal.xls,sort_selection:0 +msgid "Date" +msgstr "Date" + +#. module: account_journal_report_xls +#: field:account.print.journal.xls,amount_currency:0 +msgid "With Currency" +msgstr "Avec devise" + +#. module: account_journal_report_xls +#: field:account.print.journal.xls,group_entries:0 +msgid "Group Entries" +msgstr "Group Entries" + +#. module: account_journal_report_xls +#: field:account.print.journal.xls,period_from:0 +msgid "Start Period" +msgstr "Première période" + +#. module: account_journal_report_xls +#: field:account.print.journal.xls,period_to:0 +msgid "End Period" +msgstr "Dernière période" + +#. module: account_journal_report_xls +#: code:addons/account_journal_report_xls/wizard/print_journal_wizard.py:10 +msgid "No records found for your selection!" +msgstr "Aucun enregistrement trouvé pour votre sélection!" + +#. module: account_journal_report_xls +#: code:addons/account_journal_report_xls/wizard/print_journal_wizard.py:11 +msgid "No Data Available" +msgstr "Aucune donnée disponible" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Period" +msgstr "Période" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Fiscal Year" +msgstr "Exercice fiscal" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Journal Overview" +msgstr "Journal détaillé" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Entry" +msgstr "Écriture" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Date" +msgstr "Date" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Account" +msgstr "Compte" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Description" +msgstr "Description" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Partner" +msgstr "Partenaire" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Partner Reference" +msgstr "Réf. Partenaire" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Maturity Date" +msgstr "Date d'échéance" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Debit" +msgstr "Débit" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Credit" +msgstr "Crédit" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Balance" +msgstr "Solde" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Rec." +msgstr "Let." + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Part. Rec." +msgstr "Let. Part." + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "VAT" +msgstr "TVA" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "VAT Amount" +msgstr "Montant TVA" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Amount" +msgstr "Montant" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Currency" +msgstr "Devise" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Am. Currency" +msgstr "Montant devise" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Curr." +msgstr "Dev." + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Document" +msgstr "Document" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Entry Reference" +msgstr "Écriture réf." + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Entry Id" +msgstr "Écriture id" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "VAT Declaration" +msgstr "Déclaration TVA" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Case" +msgstr "Case" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Invoice" +msgstr "Facture" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Voucher" +msgstr "Voucher" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Statement" +msgstr "Relevé" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Grouped Entries" +msgstr "Écritures groupées" + diff --git a/account_journal_report_xls/i18n/nl.po b/account_journal_report_xls/i18n/nl.po new file mode 100644 index 00000000..502febcf --- /dev/null +++ b/account_journal_report_xls/i18n/nl.po @@ -0,0 +1,256 @@ +# Dutch translation of OpenERP Server 6.1. +# This file contains the translation of the following modules: +# * account_journal_report_xls +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.1\n" +"Report-Msgid-Bugs-To: support@noviat.be\n" +"POT-Creation-Date: 2013-11-23 17:11:14.936000\n" +"PO-Revision-Date: 2013-11-23 17:11:14.936000\n" +"Last-Translator: Luc De Meyer (Noviat nv/sa)\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. module: account_journal_report_xls +#: model:ir.actions.act_window,name:account_journal_report_xls.action_print_journal_by_period_xls +msgid "Journal by Period" +msgstr "Dagboekoverzicht per periode" + +#. module: account_journal_report_xls +#: model:ir.actions.act_window,name:account_journal_report_xls.action_print_journal_by_fiscalyear_xls +msgid "Journal by Fiscal Year" +msgstr "Dagboekoverzicht per boekjaar" + +#. module: account_journal_report_xls +#: model:ir.ui.menu,name:account_journal_report_xls.menu_print_journal_by_period_xls +msgid "Journal by Period" +msgstr "Dagboekoverzicht per periode" + +#. module: account_journal_report_xls +#: model:ir.ui.menu,name:account_journal_report_xls.menu_print_journal_by_fiscalyear_xls +msgid "Journal by Fiscal Year" +msgstr "Dagboekoverzicht per boekjaar" + +#. module: account_journal_report_xls +#: field:account.print.journal.xls,chart_account_id:0 +msgid "Chart of Account" +msgstr "Rekeningschema" + +#. module: account_journal_report_xls +#: field:account.print.journal.xls,fiscalyear_id:0 +msgid "Fiscal Year" +msgstr "Boekjaar" + +#. module: account_journal_report_xls +#: field:account.print.journal.xls,target_move:0 +msgid "Target Moves" +msgstr "Boekingen" + +#. module: account_journal_report_xls +#: selection:account.print.journal.xls,target_move:0 +msgid "All Posted Entries" +msgstr "Alle goedgekeurde boekingen" + +#. module: account_journal_report_xls +#: selection:account.print.journal.xls,target_move:0 +msgid "All Entries" +msgstr "Alle boekingen" + +#. module: account_journal_report_xls +#: field:account.print.journal.xls,sort_selection:0 +msgid "Entries Sorted by" +msgstr "Boekingen gesorteerd op" + +#. module: account_journal_report_xls +#: selection:account.print.journal.xls,sort_selection:0 +msgid "Journal Entry Number" +msgstr "Nummer journaalpost" + +#. module: account_journal_report_xls +#: selection:account.print.journal.xls,sort_selection:0 +msgid "Date" +msgstr "Datum" + +#. module: account_journal_report_xls +#: field:account.print.journal.xls,amount_currency:0 +msgid "With Currency" +msgstr "Met valuta" + +#. module: account_journal_report_xls +#: field:account.print.journal.xls,group_entries:0 +msgid "Group Entries" +msgstr "Groepeer dagboekregels" + +#. module: account_journal_report_xls +#: field:account.print.journal.xls,period_from:0 +msgid "Start Period" +msgstr "Beginperiode" + +#. module: account_journal_report_xls +#: field:account.print.journal.xls,period_to:0 +msgid "End Period" +msgstr "Eindperiode" + +#. module: account_journal_report_xls +#: code:addons/account_journal_report_xls/wizard/print_journal_wizard.py:10 +msgid "No records found for your selection!" +msgstr "Geen records gevonden voor uw keuze!" + +#. module: account_journal_report_xls +#: code:addons/account_journal_report_xls/wizard/print_journal_wizard.py:11 +msgid "No Data Available" +msgstr "Geen gegevens beschikbaar" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Period" +msgstr "Periode" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Fiscal Year" +msgstr "Boekjaar" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Journal Overview" +msgstr "Dagboekoverzicht" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Entry" +msgstr "Boeking" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Date" +msgstr "Datum" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Account" +msgstr "Rekening" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Description" +msgstr "Omschrijving" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Partner" +msgstr "Partner" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Partner Reference" +msgstr "Ref. Partner" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Maturity Date" +msgstr "Vervaldatum" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Debit" +msgstr "Debet" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Credit" +msgstr "Credit" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Balance" +msgstr "Saldo" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Rec." +msgstr "Rec." + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Part. Rec." +msgstr "Rec. Part." + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "VAT" +msgstr "BTW" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "VAT Amount" +msgstr "Bedrag BTW" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Amount" +msgstr "Bedrag" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Currency" +msgstr "Valuta" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Am. Currency" +msgstr "Bedrag valuta" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Curr." +msgstr "Val." + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Document" +msgstr "Document" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Entry Reference" +msgstr "Boeking ref." + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Entry Id" +msgstr "Boeking id" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "VAT Declaration" +msgstr "BTW aangifte" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Case" +msgstr "Vak" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Invoice" +msgstr "Factuur" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Voucher" +msgstr "Voucher" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Statement" +msgstr "Uitreksel" + +#. module: account_journal_report_xls +#: report:nov.account.journal.print:0 +msgid "Grouped Entries" +msgstr "Gegroepeerde boekingsregels" + diff --git a/account_journal_report_xls/report/__init__.py b/account_journal_report_xls/report/__init__.py new file mode 100644 index 00000000..100df303 --- /dev/null +++ b/account_journal_report_xls/report/__init__.py @@ -0,0 +1,26 @@ +# -*- 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 . +# +############################################################################## + +import nov_account_journal +import nov_account_journal_xls + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_journal_report_xls/report/nov_account_journal.py b/account_journal_report_xls/report/nov_account_journal.py new file mode 100644 index 00000000..d46fb5d4 --- /dev/null +++ b/account_journal_report_xls/report/nov_account_journal.py @@ -0,0 +1,291 @@ +# -*- 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 . +# +############################################################################## + +import time +from openerp.report import report_sxw +from openerp.tools.translate import translate, _ +import logging +_logger = logging.getLogger(__name__) + +_ir_translation_name = 'nov.account.journal.print' + + +class nov_journal_print(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) + j_obj = self.pool.get('account.journal') + p_obj = self.pool.get('account.period') + fy_obj = self.pool.get('account.fiscalyear') + self.sort_selection = data['sort_selection'] + if data['target_move'] == 'posted': + self.move_states = ['posted'] + else: + self.move_states = ['draft', 'posted'] + self.display_currency = self.localcontext['display_currency'] = data['display_currency'] + self.group_entries = data['group_entries'] + self.print_by = data['print_by'] + self.report_type = report_type + if self.print_by == 'period': + journal_period_ids = data['journal_period_ids'] + objects = [] + for jp in journal_period_ids: + journal = j_obj.browse(self.cr, self.uid, jp[0], self.context) + periods = p_obj.browse(self.cr, self.uid, jp[1], self.context) + objects.extend([(journal, period) for period in periods]) + self.localcontext['objects'] = self.objects = objects + else: + journal_fy_ids = data['journal_fy_ids'] + objects = [] + for jf in journal_fy_ids: + journal = j_obj.browse(self.cr, self.uid, jf[0], self.context) + fiscalyear = fy_obj.browse(self.cr, self.uid, jf[1], self.context) + objects.append((journal, fiscalyear)) + self.localcontext['objects'] = self.objects = objects + + def __init__(self, cr, uid, name, context): + if context is None: + context = {} + super(nov_journal_print, self).__init__(cr, uid, name, context=context) + self.localcontext.update({ + 'time': time, + 'title': self._title, + 'amount_title': self._amount_title, + 'lines': self._lines, + 'sum1': self._sum1, + 'sum2': self._sum2, + 'tax_codes': self._tax_codes, + 'sum_vat': self._sum_vat, + '_': self._, + }) + self.context = context + + def _(self, src): + lang = self.context.get('lang', 'en_US') + return translate(self.cr, _ir_translation_name, 'report', lang, src) or src + + def _title(self, object): + return ((self.print_by == 'period' and self._('Period') or self._('Fiscal Year')) + ' ' + object[1].name, object[0].name) + + def _amount_title(self): + return self.display_currency and (self._('Amount'), self._('Currency')) or (self._('Debit'), self._('Credit')) + + def _lines(self, object): + j_obj = self.pool.get('account.journal') + _ = self._ + journal = object[0] + journal_id = journal.id + if self.print_by == 'period': + period = object[1] + period_id = period.id + period_ids = [period_id] + # update status period + ids_journal_period = self.pool.get('account.journal.period').search(self.cr, self.uid, + [('journal_id', '=', journal_id), ('period_id', '=', period_id)]) + if ids_journal_period: + self.cr.execute( + 'update account_journal_period set state=%s where journal_id=%s and period_id=%s and state=%s', + ('printed', journal_id, period_id, 'draft')) + else: + self.pool.get('account.journal.period').create(self.cr, self.uid, { + 'name': (journal.code or journal.name) + ':' + (period.name or ''), + 'journal_id': journal.id, + 'period_id': period.id, + 'state': 'printed', + }) + _logger.error("The Entry for Period '%s', Journal '%s' was missing in 'account.journal.period' and has been fixed now !", + period.name, journal.name) + else: + fiscalyear = object[1] + period_ids = [x.id for x in fiscalyear.period_ids] + + select_extra, join_extra, where_extra = j_obj._report_xls_query_extra(self.cr, self.uid, self.context) + + 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, am.date AS move_date, " + "aa.id AS account_id, aa.code AS acc_code, " + "coalesce(rp.name,'') AS partner_name, coalesce(rp.ref,'') AS partner_ref, rp.id AS partner_id, " + "coalesce(l.name,'') AS aml_name, " + "l.date_maturity AS date_maturity, " + "coalesce(ap.code, ap.name) AS period, " + "coalesce(atc.code,'') AS tax_code, atc.id AS tax_code_id, coalesce(l.tax_amount,0.0) AS tax_amount, " + "coalesce(l.debit,0.0) AS debit, coalesce(l.credit,0.0) AS credit, " + "coalesce(amr.name,'') AS reconcile, coalesce(amrp.name,'') AS reconcile_partial, " + "coalesce(l.amount_currency,0.0) AS amount_currency, " + "rc.id AS currency_id, rc.name AS currency_name, rc.symbol AS currency_symbol, " + "coalesce(ai.internal_number,'-') AS inv_number, coalesce(abs.name,'-') AS st_number, coalesce(av.number,'-') AS voucher_number " + + select_extra + + "FROM account_move_line l " + "INNER JOIN account_move am ON l.move_id = am.id " + "INNER JOIN account_account aa ON l.account_id = aa.id " + "INNER JOIN account_period ap ON l.period_id = ap.id " + "LEFT OUTER JOIN account_invoice ai ON ai.move_id = am.id " + "LEFT OUTER JOIN account_voucher av ON av.move_id = am.id " + "LEFT OUTER JOIN account_bank_statement abs ON l.statement_id = abs.id " + "LEFT OUTER JOIN res_partner rp ON l.partner_id = rp.id " + "LEFT OUTER JOIN account_tax_code atc ON l.tax_code_id = atc.id " + "LEFT OUTER JOIN account_move_reconcile amr ON l.reconcile_id = amr.id " + "LEFT OUTER JOIN account_move_reconcile amrp ON l.reconcile_partial_id = amrp.id " + "LEFT OUTER JOIN res_currency rc ON l.currency_id = rc.id " + + join_extra + + "WHERE l.period_id IN %s AND l.journal_id = %s " + "AND am.state IN %s " + + where_extra + + "ORDER BY " + self.sort_selection + ", move_date, move_id, acc_code", + (tuple(period_ids), journal_id, tuple(self.move_states))) + lines = self.cr.dictfetchall() + + # add reference of corresponding origin document + if journal.type in ('sale', 'sale_refund', 'purchase', 'purchase_refund'): + [x.update({'docname': (_('Invoice') + ': ' + x['inv_number']) or (_('Voucher') + ': ' + x['voucher_number']) or '-'}) for x in lines] + elif journal.type in ('bank', 'cash'): + [x.update({'docname': (_('Statement') + ': ' + x['st_number']) or (_('Voucher') + ': ' + x['voucher_number']) or '-'}) for x in lines] + else: + code_string = j_obj._report_xls_document_extra(self.cr, self.uid, self.context) + #_logger.warn('code_string= %s', code_string) + [x.update({'docname': eval(code_string) or '-'}) for x in lines] + + # format debit, credit, amount_currency for pdf report + if self.display_currency and self.report_type == 'pdf': + curr_obj = self.pool.get('res.currency') + [x.update({ + 'amount1': self.formatLang(x['debit'] - x['credit']), + 'amount2': self.formatLang(x['amount_currency'], monetary=True, currency_obj=curr_obj.browse(self.cr, self.uid, x['currency_id'])), + }) for x in lines] + else: + [x.update({'amount1': self.formatLang(x['debit']), 'amount2': self.formatLang(x['credit'])}) for x in lines] + + # group lines + if self.group_entries: + lines = self._group_lines(lines) + + # insert a flag in every move_line to indicate the end of a move + # this flag will be used to draw a full line between moves + for cnt in range(len(lines) - 1): + if lines[cnt]['move_id'] != lines[cnt + 1]['move_id']: + lines[cnt]['draw_line'] = 1 + else: + lines[cnt]['draw_line'] = 0 + lines[-1]['draw_line'] = 1 + + return lines + + def _group_lines(self, lines_in): + + _ = self._ + + def group_move(lines_in): + if len(lines_in) == 1: + return lines_in + lines_grouped = {} + for line in lines_in: + key = (line['account_id'], line['tax_code_id'], line['partner_id']) + if not key in lines_grouped: + lines_grouped[key] = line + else: + lines_grouped[key]['debit'] += line['debit'] + lines_grouped[key]['credit'] += line['credit'] + lines_grouped[key]['tax_amount'] += line['tax_amount'] + lines_grouped[key]['aml_name'] = _('Grouped Entries') + lines_out = lines_grouped.values() + lines_out.sort(key=lambda x: x['acc_code']) + return lines_out + + lines_out = [] + grouped_lines = [lines_in[0]] + move_id = lines_in[0]['move_id'] + line_cnt = len(lines_in) + for i in range(1,line_cnt): + line = lines_in[i] + if line['move_id'] == move_id: + grouped_lines.append(line) + if i == line_cnt - 1: + lines_out += group_move(grouped_lines) + else: + lines_out += group_move(grouped_lines) + grouped_lines = [line] + move_id = line['move_id'] + + return lines_out + + def _tax_codes(self, object): + journal_id = object[0].id + if self.print_by == 'period': + period_id = object[1].id + period_ids = [period_id] + else: + fiscalyear = object[1] + period_ids = [x.id for x in fiscalyear.period_ids] + self.cr.execute( + "SELECT distinct tax_code_id 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 l.tax_code_id IS NOT NULL AND am.state IN %s", + (tuple(period_ids), journal_id, tuple(self.move_states))) + ids = map(lambda x: x[0], self.cr.fetchall()) + if ids: + self.cr.execute('SELECT id FROM account_tax_code WHERE id IN %s ORDER BY code', (tuple(ids),)) + tax_code_ids = map(lambda x: x[0], self.cr.fetchall()) + else: + tax_code_ids = [] + tax_codes = self.pool.get('account.tax.code').browse(self.cr, self.uid, tax_code_ids, self.context) + return tax_codes + + def _totals(self, field, object, tax_code_id=None): + journal_id = object[0].id + if self.print_by == 'period': + period_id = object[1].id + period_ids = [period_id] + else: + fiscalyear = object[1] + period_ids = [x.id for x in fiscalyear.period_ids] + 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" + if field == 'tax_amount': + select += " AND tax_code_id=%s" % tax_code_id + self.cr.execute(select, (tuple(period_ids), journal_id, tuple(self.move_states))) + return self.cr.fetchone()[0] or 0.0 + + def _sum1(self, object): + return self._totals('debit', object) + + def _sum2(self, object): + if self.display_currency: + return '' + else: + return self._totals('credit', object) + + def _sum_vat(self, object, tax_code): + return self._totals('tax_amount', object, tax_code.id) + + def formatLang(self, value, digits=None, date=False, date_time=False, grouping=True, monetary=False, dp=False, currency_obj=False): + if isinstance(value, (float, int)) and not value: + return '' + else: + return super(nov_journal_print, self).formatLang(value, digits, date, date_time, grouping, monetary, dp, currency_obj) + +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) + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_journal_report_xls/report/nov_account_journal.rml b/account_journal_report_xls/report/nov_account_journal.rml new file mode 100644 index 00000000..48070b70 --- /dev/null +++ b/account_journal_report_xls/report/nov_account_journal.rml @@ -0,0 +1,286 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ [[ repeatIn(objects, 'o') ]] +
+ + [[ o!=objects[0] and ' ' or removeParentNode('section') ]] +
+ + + + [[ company.name ]] + + + [[ title(o)[0] ]] + + + [[ title(o)[1] ]] + + + Journal Overview [[ '- ' + company.currency_id.name ]] + + + + + + + + + + + + + + + + + + + + + [[ formatLang(sum1(o)) ]] + + + + + [[ formatLang(sum2(o)) ]] + + + + + + + + + + + + + + + + + Entry + + + Date + + + Account + + + Partner + + + Description + + + VAT + + + [[ amount_title()[0] ]] + + + [[ amount_title()[1] ]] + + + +
+ [[ repeatIn(lines(o), 'l') ]] + + + + [[ l['move_name'] != '/' and l['move_name'] or ('*'+str(l['move_id'])) ]] + + + [[ l['move_date'] ]] + + + [[ l['acc_code'] ]] + + + [[ l['partner_name'] ]] + + + [[ l['aml_name'] ]] + + + [[ l['tax_code'] and (l['tax_code'] + ':') ]] + + + [[ l['tax_code'] and formatLang(l['tax_amount']) ]] + + + [[ l['amount1'] ]] + + + [[ l['amount2'] ]] + + + + + + + [[ l['draw_line'] and removeParentNode('blockTable') ]] + + + + + + + [[ not l['draw_line'] and removeParentNode('blockTable') ]] + + + +
+ + + + + + + VAT Declaration + + + + + + +
+ [[ repeatIn(tax_codes(o), 't') ]] + + + + [[ t.code + ': ' ]] + + + [[ formatLang(sum_vat(o,t)) ]] + + + + + + + + [[ t.name ]] + + + +
+
+
+
+ diff --git a/account_journal_report_xls/report/nov_account_journal_xls.py b/account_journal_report_xls/report/nov_account_journal_xls.py new file mode 100644 index 00000000..34229a43 --- /dev/null +++ b/account_journal_report_xls/report/nov_account_journal_xls.py @@ -0,0 +1,317 @@ +# -*- 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 . +# +############################################################################## + +import xlwt +import time +from datetime import datetime +from openerp.osv import orm +from openerp.report import report_sxw +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 _ +import logging +_logger = logging.getLogger(__name__) + + +class account_journal_xls_parser(nov_journal_print): + + def __init__(self, cr, uid, name, context): + super(account_journal_xls_parser, 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) + template_changes = journal_obj._report_xls_template(cr, uid, context) + self.localcontext.update({ + 'datetime': datetime, + 'wanted_list': wanted_list, + 'template_changes': template_changes, + }) + + +class account_journal_xls(report_xls): + + def __init__(self, name, table, rml=False, parser=False, header=True, store=False): + super(account_journal_xls, self).__init__(name, table, rml, parser, header, store) + + # Cell Styles + _xs = self.xls_styles + # header + rh_cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all'] + self.rh_cell_style = xlwt.easyxf(rh_cell_format) + self.rh_cell_style_center = xlwt.easyxf(rh_cell_format + _xs['center']) + self.rh_cell_style_right = xlwt.easyxf(rh_cell_format + _xs['right']) + # lines + aml_cell_format = _xs['borders_all'] + self.aml_cell_style = xlwt.easyxf(aml_cell_format) + self.aml_cell_style_center = xlwt.easyxf(aml_cell_format + _xs['center']) + self.aml_cell_style_date = xlwt.easyxf(aml_cell_format + _xs['left'], num_format_str=report_xls.date_format) + self.aml_cell_style_decimal = xlwt.easyxf(aml_cell_format + _xs['right'], num_format_str=report_xls.decimal_format) + # totals + rt_cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all'] + self.rt_cell_style = xlwt.easyxf(rt_cell_format) + self.rt_cell_style_right = xlwt.easyxf(rt_cell_format + _xs['right']) + self.rt_cell_style_decimal = xlwt.easyxf(rt_cell_format + _xs['right'], num_format_str=report_xls.decimal_format) + + # XLS Template Journal Items + self.col_specs_lines_template = { + 'move_name': { + 'header': [1, 20, 'text', _render("_('Entry')")], + 'lines': [1, 0, 'text', _render("l['move_name'] != '/' and l['move_name'] or ('*'+str(l['move_id']))")], + 'totals': [1, 0, 'text', None]}, + 'move_date': { + 'header': [1, 13, 'text', _render("_('Date')")], + 'lines': [1, 0, 'date', _render("datetime.strptime(l['move_date'],'%Y-%m-%d')"), None, self.aml_cell_style_date], + 'totals': [1, 0, 'text', None]}, + 'acc_code': { + 'header': [1, 12, 'text', _render("_('Account')")], + 'lines': [1, 0, 'text', _render("l['acc_code']")], + 'totals': [1, 0, 'text', None]}, + 'aml_name': { + 'header': [1, 42, 'text', _render("_('Description')")], + 'lines': [1, 0, 'text', _render("l['aml_name']")], + 'totals': [1, 0, 'text', None]}, + 'period': { + 'header': [1, 12, 'text', _render("_('Period')")], + 'lines': [1, 0, 'text', _render("l['period']")], + 'totals': [1, 0, 'text', None]}, + 'partner_name': { + 'header': [1, 36, 'text', _render("_('Partner')")], + 'lines': [1, 0, 'text', _render("l['partner_name']")], + 'totals': [1, 0, 'text', None]}, + 'partner_ref': { + 'header': [1, 36, 'text', _render("_('Partner Reference')")], + 'lines': [1, 0, 'text', _render("l['partner_ref']")], + 'totals': [1, 0, 'text', None]}, + 'date_maturity': { + 'header': [1, 13, 'text', _render("_('Maturity Date')")], + 'lines': [1, 0, _render("l['date_maturity'] and 'date' or 'text'"), + _render("l['date_maturity'] and datetime.strptime(l['date_maturity'],'%Y-%m-%d') or None"), + None, self.aml_cell_style_date], + 'totals': [1, 0, 'text', None]}, + 'debit': { + 'header': [1, 18, 'text', _render("_('Debit')"), None, self.rh_cell_style_right], + 'lines': [1, 0, 'number', _render("l['debit']"), None, self.aml_cell_style_decimal], + 'totals': [1, 0, 'number', None, _render("debit_formula"), self.rt_cell_style_decimal]}, + 'credit': { + 'header': [1, 18, 'text', _render("_('Credit')"), None, self.rh_cell_style_right], + 'lines': [1, 0, 'number', _render("l['credit']"), None, self.aml_cell_style_decimal], + 'totals': [1, 0, 'number', None, _render("credit_formula"), self.rt_cell_style_decimal]}, + 'balance': { + 'header': [1, 18, 'text', _render("_('Balance')"), None, self.rh_cell_style_right], + 'lines': [1, 0, 'number', None, _render("bal_formula"), self.aml_cell_style_decimal], + 'totals': [1, 0, 'number', None, _render("bal_formula"), self.rt_cell_style_decimal]}, + 'reconcile': { + 'header': [1, 12, 'text', _render("_('Rec.')"), None, self.rh_cell_style_center], + 'lines': [1, 0, 'text', _render("l['reconcile']"), None, self.aml_cell_style_center], + 'totals': [1, 0, 'text', None]}, + 'reconcile_partial': { + 'header': [1, 12, 'text', _render("_('Part. Rec.')"), None, self.rh_cell_style_center], + 'lines': [1, 0, 'text', _render("l['reconcile_partial']"), None, self.aml_cell_style_center], + 'totals': [1, 0, 'text', None]}, + 'tax_code': { + 'header': [1, 6, 'text', _render("_('VAT')"), None, self.rh_cell_style_center], + 'lines': [1, 0, 'text', _render("l['tax_code']"), None, self.aml_cell_style_center], + 'totals': [1, 0, 'text', None]}, + 'tax_amount': { + 'header': [1, 18, 'text', _render("_('VAT Amount')"), None, self.rh_cell_style_right], + 'lines': [1, 0, 'number', _render("l['tax_amount']"), None, self.aml_cell_style_decimal], + 'totals': [1, 0, 'text', None]}, + 'amount_currency': { + 'header': [1, 18, 'text', _render("_('Am. Currency')"), None, self.rh_cell_style_right], + 'lines': [1, 0, _render("l['amount_currency'] and 'number' or 'text'"), + _render("l['amount_currency'] or None"), + None, self.aml_cell_style_decimal], + 'totals': [1, 0, 'text', None]}, + 'currency_name': { + 'header': [1, 6, 'text', _render("_('Curr.')"), None, self.rh_cell_style_center], + 'lines': [1, 0, 'text', _render("l['currency_name']"), None, self.aml_cell_style_center], + 'totals': [1, 0, 'text', None]}, + 'docname': { + 'header': [1, 35, 'text', _render("_('Document')")], + 'lines': [1, 0, 'text', _render("l['docname']")], + 'totals': [1, 0, 'text', None]}, + 'move_ref': { + 'header': [1, 25, 'text', _render("_('Entry Reference')")], + 'lines': [1, 0, 'text', _render("l['move_ref']")], + 'totals': [1, 0, 'text', None]}, + 'move_id': { + 'header': [1, 10, 'text', _render("_('Entry Id')")], + 'lines': [1, 0, 'text', _render("str(l['move_id'])")], + 'totals': [1, 0, 'text', None]}, + } + + # XLS Template VAT Summary + self.col_specs_vat_summary_template = { + 'tax_case_name': { + 'header': [1, 45, 'text', _render("_('Description')")], + 'tax_totals': [1, 0, 'text', _render("t.name")]}, + 'tax_code': { + 'header': [1, 6, 'text', _render("_('Case')")], + 'tax_totals': [1, 0, 'text', _render("t.code")]}, + 'tax_amount': { + 'header': [1, 18, 'text', _render("_('Amount')"), None, self.rh_cell_style_right], + 'tax_totals': [1, 0, 'number', _render("sum_vat(o,t)"), None, self.aml_cell_style_decimal]}, + } + + def _journal_title(self, o, ws, _p, row_pos, xlwt, _xs): + cell_style = xlwt.easyxf(_xs['xls_title']) + report_name = (10 * ' ').join([ + _p.company.name, + _p.title(o)[0], + _p.title(o)[1], + _p._("Journal Overview") + ' - ' + _p.company.currency_id.name, + ]) + c_specs = [ + ('report_name', 1, 0, 'text', report_name), + ] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style) + return row_pos + 1 + + def _journal_lines(self, o, ws, _p, row_pos, xlwt, _xs): + + wanted_list = self.wanted_list + debit_pos = self.debit_pos + credit_pos = self.credit_pos + + # Column headers + c_specs = map(lambda x: self.render(x, self.col_specs_lines_template, 'header', render_space={'_': _p._}), wanted_list) + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=self.rh_cell_style, set_column_size=True) + ws.set_horz_split_pos(row_pos) + + # account move lines + aml_start_pos = row_pos + aml_cnt = len(_p.lines(o)) + cnt = 0 + for l in _p.lines(o): + cnt += 1 + debit_cell = rowcol_to_cell(row_pos, debit_pos) + credit_cell = rowcol_to_cell(row_pos, credit_pos) + bal_formula = debit_cell + '-' + credit_cell + c_specs = map(lambda x: self.render(x, self.col_specs_lines_template, 'lines'), wanted_list) + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=self.aml_cell_style) + if l['draw_line'] and cnt != aml_cnt: + row_pos += 1 + + # Totals + debit_start = rowcol_to_cell(aml_start_pos, debit_pos) + debit_stop = rowcol_to_cell(row_pos - 1, debit_pos) + debit_formula = 'SUM(%s:%s)' % (debit_start, debit_stop) + credit_start = rowcol_to_cell(aml_start_pos, credit_pos) + credit_stop = rowcol_to_cell(row_pos - 1, credit_pos) + credit_formula = 'SUM(%s:%s)' % (credit_start, credit_stop) + debit_cell = rowcol_to_cell(row_pos, debit_pos) + credit_cell = rowcol_to_cell(row_pos, credit_pos) + bal_formula = debit_cell + '-' + credit_cell + c_specs = map(lambda x: self.render(x, self.col_specs_lines_template, 'totals'), wanted_list) + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=self.rt_cell_style_right) + return row_pos + 1 + + def _journal_vat_summary(self, o, ws, _p, row_pos, xlwt, _xs): + + if not _p.tax_codes(o): + return row_pos + + title_cell_style = xlwt.easyxf(_xs['bold']) + c_specs = [('summary_title', 1, 0, 'text', _p._("VAT Declaration"))] + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=title_cell_style) + 1 + + wanted_list = self.wanted_list + vat_summary_wanted_list = ['tax_case_name', 'tax_code', 'tax_amount'] + + # calculate col_span + 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(_('Programming Error!'), + _("vat_summary_cols_number should be < cols_number !")) + index = 0 + for i in range(vat_summary_cols_number): + col = vat_summary_wanted_list[i] + col_size = self.col_specs_lines_template[wanted_list[index]]['header'][1] + templ_col_size = self.col_specs_vat_summary_template[col]['header'][1] + #_logger.warn("col=%s, col_size=%s, templ_col_size=%s", col, col_size, templ_col_size) + col_span = 1 + if templ_col_size > col_size: + new_size = col_size + while templ_col_size > new_size: + col_span += 1 + index += 1 + new_size += self.col_specs_lines_template[wanted_list[index]]['header'][1] + self.col_specs_vat_summary_template[col]['header'][0] = col_span + self.col_specs_vat_summary_template[col]['tax_totals'][0] = col_span + index += 1 + + c_specs = map(lambda x: self.render(x, self.col_specs_vat_summary_template, 'header'), vat_summary_wanted_list) + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=self.rh_cell_style) + + for t in _p.tax_codes(o): + c_specs = map(lambda x: self.render(x, self.col_specs_vat_summary_template, 'tax_totals'), vat_summary_wanted_list) + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=self.aml_cell_style) + + return row_pos + + def generate_xls_report(self, _p, _xs, data, objects, wb): + + wanted_list = _p.wanted_list + if _p.display_currency: + wanted_list += ['amount_currency', 'currency_name'] + self.wanted_list = wanted_list + self.col_specs_lines_template.update(_p.template_changes) + + self.debit_pos = 'debit' in wanted_list and wanted_list.index('debit') + self.credit_pos = 'credit' in wanted_list and wanted_list.index('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 !")) + + for o in objects: + + sheet_name = ' - '.join([o[1].code, o[0].code])[:31].replace('/', '-') + sheet_name = sheet_name[:31].replace('/', '-') + ws = wb.add_sheet(sheet_name) + ws.panes_frozen = True + ws.remove_splits = True + ws.portrait = 0 # Landscape + ws.fit_width_to_pages = 1 + row_pos = 0 + + # set print header/footer + ws.header_str = self.xls_headers['standard'] + ws.footer_str = self.xls_footers['standard'] + + # Data + row_pos = self._journal_title(o, ws, _p, row_pos, xlwt, _xs) + row_pos = self._journal_lines(o, ws, _p, row_pos, xlwt, _xs) + row_pos = self._journal_vat_summary(o, ws, _p, row_pos, xlwt, _xs) + +account_journal_xls('report.nov.account.journal.xls', 'account.journal.period', + parser=account_journal_xls_parser) + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_journal_report_xls/static/src/img/icon.png b/account_journal_report_xls/static/src/img/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..272d0294347c7c2fda3bc37cf726a9079c3f6313 GIT binary patch literal 15230 zcmd^l=U-IM(q~U(V8}T$1d*JP3`5R>1O-8I&PfCWnHh3U5)=g#K|o0Yf`Twa5k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nTrhz zPa5N>Kjk&F?fzs^oZiHdPe;g$?(|wP*Y!ME9+%-BcDlj}3}e$5v7fJoO(~_Z3h=45 zA3MKQb;yU<`aB~od~D}$!v0L|ch$4^VmWV4>+8#C@-6}5i|YGlYB%o6!qTEj23Pzk z0KFO_LBea!Cd2CD)0EWCIVVp#AmXNj!=9c0NRl+R5egyFzaOizNhB!Rm6^wMjVV~N z**n!YG5|(&9C7~nGQJcA4_G-~>D>26gJoydUv0ljOLXY$dN$I|j^_PozrE<#i?NCyonDm!tK$QcZP%-Rt}6S89dHp* zMiJOGgrCx24W0=_=GDZ#>Hhv9l1OX9Ey2aT35p@Hpt=VnqqlN%@6j-7FJ6VzjXn6j zD)E$(V^-&NLK#&wLXtEQV@JQ{cJS$~D9nMBF&K~>DY;;Ol@W_+fFVT&?$hz}YG*`g z2h%z766Ga+;z?pb<4ff66sT(%MZ>L~;QYoB-^JWZIm{uf%;NC|2 z1I#?`+SNZ5`W`Dea4`6~5K?!yr(S7nUc*tUHrBbtpzdc4lIZk#BtIlJS)%v`vE>L-7kTr(&-0A5llt!6yYBod z(m#(NbJ+$G>zsf{t0$T>l)%m`?MD9|_xLsh7?wHQ^O=9LC4S-dS81Na#Z-WY<@E74 z+@4rnrvM^qC?-_)k2Ae?;SOC;2fx-pV&yE}-TH9x6JvAKvo9T-fDqT!IWsFe^acjr z81?DStH5z(kERUR{@Ousv&Op<_uw{kz;MZPVgHPbcCref7|EidCgf&=fff7vFw_`D z-fb#i#po>RBPMOLt`9^QgEbv*>cy1y2Gv40uce$ZIe@HR)YMS#uTXH_^tCT*)o3^n F{udP(AcX(` literal 0 HcmV?d00001 diff --git a/account_journal_report_xls/wizard/__init__.py b/account_journal_report_xls/wizard/__init__.py new file mode 100644 index 00000000..154d6a6e --- /dev/null +++ b/account_journal_report_xls/wizard/__init__.py @@ -0,0 +1,25 @@ +# -*- 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 . +# +############################################################################## + +from . import print_journal_wizard + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_journal_report_xls/wizard/print_journal_wizard.py b/account_journal_report_xls/wizard/print_journal_wizard.py new file mode 100644 index 00000000..75216164 --- /dev/null +++ b/account_journal_report_xls/wizard/print_journal_wizard.py @@ -0,0 +1,172 @@ +# -*- 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 . +# +############################################################################## + +from openerp.tools.translate import _ +from openerp.osv import orm, fields +from openerp.addons.account.wizard.account_report_common_journal import account_common_journal_report +import time +import logging +_logger = logging.getLogger(__name__) + + +class account_print_journal_xls(orm.TransientModel): + _inherit = 'account.print.journal' + _name = 'account.print.journal.xls' + _description = 'Print/Export Journal' + _columns = { + 'journal_ids': fields.many2many('account.journal', string='Journals', required=True), + 'group_entries': fields.boolean('Group Entries', help="Group entries with same General Account & Tax Code."), + } + _defaults = { + 'group_entries': True, + } + + def fields_get(self, cr, uid, fields=None, context=None): + res = super(account_print_journal_xls, self).fields_get(cr, uid, fields, context) + if context.get('print_by') == 'fiscalyear': + if 'fiscalyear_id' in res: + res['fiscalyear_id']['required'] = True + if 'period_from' in res: + res['period_from']['readonly'] = True + if 'period_to' in res: + res['period_to']['readonly'] = True + else: + if 'period_from' in res: + res['period_from']['required'] = True + if 'period_to' in res: + res['period_to']['required'] = True + return res + + def fy_period_ids(self, cr, uid, fiscalyear_id): + """ returns all periods from a fiscalyear sorted by date """ + fy_period_ids = [] + cr.execute('SELECT id, coalesce(special, False) AS special FROM account_period ' + 'WHERE fiscalyear_id=%s ORDER BY date_start, special DESC', + (fiscalyear_id,)) + res = cr.fetchall() + if res: + fy_period_ids = [x[0] for x in res] + return fy_period_ids + + def onchange_fiscalyear_id(self, cr, uid, ids, fiscalyear_id=False, context=None): + res = {'value': {}} + if context.get('print_by') == 'fiscalyear': + # get period_from/to with opening/close periods + fy_period_ids = self.fy_period_ids(cr, uid, fiscalyear_id) + if fy_period_ids: + res['value']['period_from'] = fy_period_ids[0] + res['value']['period_to'] = fy_period_ids[-1] + return res + + 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 (adds domain filter on journal type) """ + return super(account_common_journal_report, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu) + + def xls_export(self, cr, uid, ids, context=None): + return self.print_report(cr, uid, ids, context=context) + + def print_report(self, cr, uid, ids, context=None): + if context is None: + context = {} + move_obj = self.pool.get('account.move') + print_by = context.get('print_by') + wiz_form = self.browse(cr, uid, ids)[0] + fiscalyear_id = wiz_form.fiscalyear_id.id + company_id = wiz_form.company_id.id + + if print_by == 'fiscalyear': + wiz_period_ids = self.fy_period_ids(cr, uid, fiscalyear_id) + else: + period_from = wiz_form.period_from + period_to = wiz_form.period_to + cr.execute("SELECT id, coalesce(special, False) AS special FROM account_period ap " + "WHERE ap.date_start>=%s AND ap.date_stop<=%s AND company_id=%s " + "ORDER BY date_start, special DESC", + (period_from.date_start, period_to.date_stop, company_id)) + wiz_period_ids = map(lambda x: x[0], cr.fetchall()) + wiz_journal_ids = [j.id for j in wiz_form.journal_ids] + + # sort journals + cr.execute('SELECT id FROM account_journal ' + 'WHERE id IN %s ORDER BY type DESC', + (tuple(wiz_journal_ids),)) + wiz_journal_ids = map(lambda x: x[0], cr.fetchall()) + + datas = { + 'model': 'account.journal', + 'print_by': print_by, + 'sort_selection': wiz_form.sort_selection, + 'target_move': wiz_form.target_move, + 'display_currency': wiz_form.amount_currency, + 'group_entries': wiz_form.group_entries, + } + + if wiz_form.target_move == 'posted': + move_states = ['posted'] + else: + move_states = ['draft', 'posted'] + + if print_by == 'fiscalyear': + journal_fy_ids = [] + for journal_id in wiz_journal_ids: + aml_ids = move_obj.search(cr, uid, + [('journal_id', '=', journal_id), ('period_id', 'in', wiz_period_ids), ('state', 'in', move_states)], + limit=1) + if aml_ids: + journal_fy_ids.append((journal_id, fiscalyear_id)) + if not journal_fy_ids: + raise orm.except_orm(_('No Data Available'), _('No records found for your selection!')) + datas.update({ + 'ids': [x[0] for x in journal_fy_ids], + 'journal_fy_ids': journal_fy_ids, + }) + else: + # perform account.move.line query in stead of 'account.journal.period' since this table is not always reliable + journal_period_ids = [] + for journal_id in wiz_journal_ids: + period_ids = [] + for period_id in wiz_period_ids: + aml_ids = move_obj.search(cr, uid, + [('journal_id', '=', journal_id), ('period_id', '=', period_id), ('state', 'in', move_states)], + limit=1) + if aml_ids: + period_ids.append(period_id) + if period_ids: + journal_period_ids.append((journal_id, period_ids)) + if not journal_period_ids: + raise orm.except_orm(_('No Data Available'), _('No records found for your selection!')) + datas.update({ + 'ids': [x[0] for x in journal_period_ids], + 'journal_period_ids': journal_period_ids, + }) + + if context.get('xls_export'): + return {'type': 'ir.actions.report.xml', + 'report_name': 'nov.account.journal.xls', + 'datas': datas} + else: + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'nov.account.journal.print', + 'datas': datas} + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_journal_report_xls/wizard/print_journal_wizard.xml b/account_journal_report_xls/wizard/print_journal_wizard.xml new file mode 100644 index 00000000..cae4135c --- /dev/null +++ b/account_journal_report_xls/wizard/print_journal_wizard.xml @@ -0,0 +1,80 @@ + + + + + + Print/Export Journals + account.print.journal.xls + + + + + onchange_fiscalyear_id(fiscalyear_id, context) + + + + + + + + + + + + + + + + + + + + + + + + Journal by Period + ir.actions.act_window + account.print.journal.xls + form + form + {'print_by':'period'} + + new + + + + + Journal by Fiscal Year + ir.actions.act_window + account.print.journal.xls + form + form + {'print_by':'fiscalyear'} + + new + + + + + 3 + + + + diff --git a/account_move_line_report_xls/__init__.py b/account_move_line_report_xls/__init__.py new file mode 100644 index 00000000..728de535 --- /dev/null +++ b/account_move_line_report_xls/__init__.py @@ -0,0 +1,24 @@ +# -*- 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 . +# +############################################################################## + +from . import account_move_line +from . import report diff --git a/account_move_line_report_xls/__openerp__.py b/account_move_line_report_xls/__openerp__.py new file mode 100644 index 00000000..366a9238 --- /dev/null +++ b/account_move_line_report_xls/__openerp__.py @@ -0,0 +1,46 @@ +# -*- 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 . +# +############################################################################## + +{ + 'name': 'Account Move Line XLS export', + 'version': '0.5', + 'license': 'AGPL-3', + 'author': 'Noviat', + 'category' : 'Accounting & Finance', + 'description': """ + +Journal Items Excel Export +========================== + +This module adds a button on the journal items ('account.move.line') list view in order to export the selected lines. + +If you are installing this module manually, you need also the module 'report_xls', that is located in: +https://launchpad.net/openerp-reporting-engines" + + """, + 'depends': ['account', 'report_xls'], + 'demo_xml': [], + 'init_xml': [], + 'update_xml' : [ + 'report/move_line_list_xls.xml', + ], +} diff --git a/account_move_line_report_xls/account_move_line.py b/account_move_line_report_xls/account_move_line.py new file mode 100644 index 00000000..f63a833e --- /dev/null +++ b/account_move_line_report_xls/account_move_line.py @@ -0,0 +1,52 @@ +# -*- 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 . +# +############################################################################## + +from openerp.osv import orm +from openerp.addons.report_xls.utils import rowcol_to_cell, _render +from openerp.tools.translate import _ + +class account_move_line(orm.Model): + _inherit = 'account.move.line' + + # override list in custom module to add/drop columns or change order + def _report_xls_fields(self, cr, uid, context=None): + return [ + 'move', 'name', 'date', 'period', 'partner', 'account', + 'date_maturity', 'debit', 'credit', 'balance', 'reconcile', 'reconcile_partial', + #'amount_currency', 'currency_name', + ] + + # Change/Add Template entries + def _report_xls_template(self, cr, uid, context=None): + """ + Template updates, e.g. + + my_change = { + 'move':{ + 'header': [1, 20, 'text', _('My Move Title')], + 'lines': [1, 0, 'text', _render("line.move_id.name or ''")], + 'totals': [1, 0, 'text', None]}, + } + return my_change + """ + return {} + diff --git a/account_move_line_report_xls/i18n/fr.po b/account_move_line_report_xls/i18n/fr.po new file mode 100644 index 00000000..3e027d89 --- /dev/null +++ b/account_move_line_report_xls/i18n/fr.po @@ -0,0 +1,111 @@ +# French translation of OpenERP Server 6.1. +# This file contains the translation of the following modules: +# * account_move_line_report_xls +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.1\n" +"Report-Msgid-Bugs-To: support@noviat.be\n" +"POT-Creation-Date: 2013-11-23 16:11:12.706000\n" +"PO-Revision-Date: 2013-11-23 16:11:12.706000\n" +"Last-Translator: Luc De Meyer (Noviat nv/sa)\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Journal Items" +msgstr "Écritures comptables" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Entry" +msgstr "Écriture" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Name" +msgstr "Nom" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Reference" +msgstr "Référence" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Effective Date" +msgstr "Date" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Period" +msgstr "Période" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Partner" +msgstr "Partenaire" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Partner Reference" +msgstr "Réf. Partenaire" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Account" +msgstr "Compte" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Maturity Date" +msgstr "Date d'échéance" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Debit" +msgstr "Débit" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Credit" +msgstr "Crédit" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Balance" +msgstr "Solde" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Rec." +msgstr "Let." + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Part. Rec." +msgstr "Let. Part." + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Tax Code" +msgstr "Case TVA" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Tax/Base Amount" +msgstr "Montant TVA/Base" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Am. Currency" +msgstr "Montant devise" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Curr." +msgstr "Dev." + diff --git a/account_move_line_report_xls/i18n/nl.po b/account_move_line_report_xls/i18n/nl.po new file mode 100644 index 00000000..3b396580 --- /dev/null +++ b/account_move_line_report_xls/i18n/nl.po @@ -0,0 +1,111 @@ +# Dutch translation of OpenERP Server 6.1. +# This file contains the translation of the following modules: +# * account_move_line_report_xls +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.1\n" +"Report-Msgid-Bugs-To: support@noviat.be\n" +"POT-Creation-Date: 2013-11-23 16:11:12.702000\n" +"PO-Revision-Date: 2013-11-23 16:11:12.702000\n" +"Last-Translator: Luc De Meyer (Noviat nv/sa)\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Journal Items" +msgstr "Boekingsregels" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Entry" +msgstr "Boeking" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Name" +msgstr "Naam" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Reference" +msgstr "Referentie" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Effective Date" +msgstr "Datum" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Period" +msgstr "Periode" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Partner" +msgstr "Partner" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Partner Reference" +msgstr "Ref. Partner" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Account" +msgstr "Rekening" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Maturity Date" +msgstr "Vervaldatum" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Debit" +msgstr "Debet" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Credit" +msgstr "Credit" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Balance" +msgstr "Saldo" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Rec." +msgstr "Rec." + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Part. Rec." +msgstr "Rec. Part." + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Tax Code" +msgstr "BTW vak" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Tax/Base Amount" +msgstr "Bedrag BTW/Mvh" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Am. Currency" +msgstr "Bedrag valuta" + +#. module: account_move_line_report_xls +#: report:move.line.list.xls:0 +msgid "Curr." +msgstr "Val." + diff --git a/account_move_line_report_xls/report/__init__.py b/account_move_line_report_xls/report/__init__.py new file mode 100644 index 00000000..b4754155 --- /dev/null +++ b/account_move_line_report_xls/report/__init__.py @@ -0,0 +1,23 @@ +# -*- 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 . +# +############################################################################## + +from . import move_line_list_xls diff --git a/account_move_line_report_xls/report/move_line_list_xls.py b/account_move_line_report_xls/report/move_line_list_xls.py new file mode 100644 index 00000000..dbe3f340 --- /dev/null +++ b/account_move_line_report_xls/report/move_line_list_xls.py @@ -0,0 +1,240 @@ +# -*- 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 . +# +############################################################################## + +import xlwt +import time +from datetime import datetime +from openerp.osv import orm +from openerp.report import report_sxw +from openerp.addons.report_xls.report_xls import report_xls +from openerp.addons.report_xls.utils import rowcol_to_cell, _render +from openerp.tools.translate import translate, _ +from openerp import pooler +import logging +_logger = logging.getLogger(__name__) + +_ir_translation_name = 'move.line.list.xls' + +class move_line_xls_parser(report_sxw.rml_parse): + + def __init__(self, cr, uid, name, context): + super(move_line_xls_parser, self).__init__(cr, uid, name, context=context) + move_obj = self.pool.get('account.move.line') + self.context = context + wanted_list = move_obj._report_xls_fields(cr, uid, context) + template_changes = move_obj._report_xls_template(cr, uid, context) + self.localcontext.update({ + 'datetime': datetime, + 'wanted_list': wanted_list, + 'template_changes': template_changes, + '_': self._, + }) + + def _(self, src): + lang = self.context.get('lang', 'en_US') + return translate(self.cr, _ir_translation_name, 'report', lang, src) or src + +class move_line_xls(report_xls): + + def __init__(self, name, table, rml=False, parser=False, header=True, store=False): + super(move_line_xls, self).__init__(name, table, rml, parser, header, store) + + # Cell Styles + _xs = self.xls_styles + # header + rh_cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all'] + self.rh_cell_style = xlwt.easyxf(rh_cell_format) + self.rh_cell_style_center = xlwt.easyxf(rh_cell_format + _xs['center']) + self.rh_cell_style_right = xlwt.easyxf(rh_cell_format + _xs['right']) + # lines + aml_cell_format = _xs['borders_all'] + self.aml_cell_style = xlwt.easyxf(aml_cell_format) + self.aml_cell_style_center = xlwt.easyxf(aml_cell_format + _xs['center']) + self.aml_cell_style_date = xlwt.easyxf(aml_cell_format + _xs['left'], num_format_str = report_xls.date_format) + self.aml_cell_style_decimal = xlwt.easyxf(aml_cell_format + _xs['right'], num_format_str = report_xls.decimal_format) + # totals + rt_cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all'] + self.rt_cell_style = xlwt.easyxf(rt_cell_format) + self.rt_cell_style_right = xlwt.easyxf(rt_cell_format + _xs['right']) + self.rt_cell_style_decimal = xlwt.easyxf(rt_cell_format + _xs['right'], num_format_str = report_xls.decimal_format) + + # XLS Template + self.col_specs_template = { + 'move':{ + 'header': [1, 20, 'text', _render("_('Entry')")], + 'lines': [1, 0, 'text', _render("line.move_id.name or ''")], + 'totals': [1, 0, 'text', None]}, + 'name':{ + 'header': [1, 42, 'text', _render("_('Name')")], + 'lines': [1, 0, 'text', _render("line.name or ''")], + 'totals': [1, 0, 'text', None]}, + 'ref':{ + 'header': [1, 42, 'text', _render("_('Reference')")], + 'lines': [1, 0, 'text', _render("line.ref or ''")], + 'totals': [1, 0, 'text', None]}, + 'date':{ + 'header': [1, 13, 'text', _render("_('Effective Date')")], + 'lines': [1, 0, 'date', _render("datetime.strptime(line.date,'%Y-%m-%d')"), None, self.aml_cell_style_date], + 'totals': [1, 0, 'text', None]}, + 'period':{ + 'header': [1, 12, 'text', _render("_('Period')")], + 'lines': [1, 0, 'text', _render("line.period_id.code or line.period_id.name")], + 'totals': [1, 0, 'text', None]}, + 'partner':{ + 'header': [1, 36, 'text', _render("_('Partner')")], + 'lines': [1, 0, 'text', _render("line.partner_id and line.partner_id.name or ''")], + 'totals': [1, 0, 'text', None]}, + 'partner_ref':{ + 'header': [1, 36, 'text', _render("_('Partner Reference')")], + 'lines': [1, 0, 'text', _render("line.partner_id and line.partner_id.ref or ''")], + 'totals': [1, 0, 'text', None]}, + 'account':{ + 'header': [1, 12, 'text', _render("_('Account')")], + 'lines': [1, 0, 'text', _render("line.account_id.code")], + 'totals': [1, 0, 'text', None]}, + 'date_maturity':{ + 'header': [1, 13, 'text', _render("_('Maturity Date')")], + 'lines': [1, 0, _render("line.date_maturity.val and 'date' or 'text'"), + _render("line.date_maturity.val and datetime.strptime(line.date_maturity,'%Y-%m-%d') or None"), + None, self.aml_cell_style_date], + 'totals': [1, 0, 'text', None]}, + 'debit':{ + 'header': [1, 18, 'text', _render("_('Debit')"), None, self.rh_cell_style_right], + 'lines': [1, 0, 'number', _render("line.debit"), None, self.aml_cell_style_decimal], + 'totals': [1, 0, 'number', None, _render("debit_formula"), self.rt_cell_style_decimal]}, + 'credit':{ + 'header': [1, 18, 'text', _render("_('Credit')"), None, self.rh_cell_style_right], + 'lines': [1, 0, 'number', _render("line.credit"), None, self.aml_cell_style_decimal], + 'totals': [1, 0, 'number', None, _render("credit_formula"), self.rt_cell_style_decimal]}, + 'balance':{ + 'header': [1, 18, 'text', _render("_('Balance')"), None, self.rh_cell_style_right], + 'lines': [1, 0, 'number', None, _render("bal_formula"), self.aml_cell_style_decimal], + 'totals': [1, 0, 'number', None, _render("bal_formula"), self.rt_cell_style_decimal]}, + 'reconcile':{ + 'header': [1, 12, 'text', _render("_('Rec.')"), None, self.rh_cell_style_center], + 'lines': [1, 0, 'text', _render("line.reconcile_id.name or ''"), None, self.aml_cell_style_center], + 'totals': [1, 0, 'text', None]}, + 'reconcile_partial':{ + 'header': [1, 12, 'text', _render("_('Part. Rec.')"), None, self.rh_cell_style_center], + 'lines': [1, 0, 'text', _render("line.reconcile_partial_id.name or ''"), None, self.aml_cell_style_center], + 'totals': [1, 0, 'text', None]}, + 'tax_code':{ + 'header': [1, 12, 'text', _render("_('Tax Code')"), None, self.rh_cell_style_center], + 'lines': [1, 0, 'text', _render("line.tax_code_id.code or ''"), None, self.aml_cell_style_center], + 'totals': [1, 0, 'text', None]}, + 'tax_amount':{ + 'header': [1, 18, 'text', _render("_('Tax/Base Amount')"), None, self.rh_cell_style_right], + 'lines': [1, 0, 'number', _render("line.tax_amount"), None, self.aml_cell_style_decimal], + 'totals': [1, 0, 'text', None]}, + 'amount_currency':{ + 'header': [1, 18, 'text', _render("_('Am. Currency')"), None, self.rh_cell_style_right], + 'lines': [1, 0, _render("line.amount_currency and 'number' or 'text'"), + _render("line.amount_currency or None"), + None, self.aml_cell_style_decimal], + 'totals': [1, 0, 'text', None]}, + 'currency_name':{ + 'header': [1, 6, 'text', _render("_('Curr.')"), None, self.rh_cell_style_center], + 'lines': [1, 0, 'text', _render("line.currency_id and line.currency_id.name or ''"), None, self.aml_cell_style_center], + 'totals': [1, 0, 'text', None]}, + 'journal': { + 'header': [1, 6, 'text', _('Journal')], + 'lines': [1, 0, 'text', _render("line.journal_id.code or ''")], + 'totals': [1, 0, 'text', None]}, + 'company_currency': { + 'header': [1, 6, 'text', _('Company currency')], + 'lines': [1, 0, 'text', _render("line.company_id.currency_id.name or ''")], + 'totals': [1, 0, 'text', None]}, + 'analytic_account': { + 'header': [1, 6, 'text', _('Analytic Account')], + 'lines': [1, 0, 'text', _render("line.analytic_account_id.code or ''")], + 'totals': [1, 0, 'text', None]}, + } + + def generate_xls_report(self, _p, _xs, data, objects, wb): + + wanted_list = _p.wanted_list + self.col_specs_template.update(_p.template_changes) + _ = _p._ + + debit_pos = 'debit' in wanted_list and wanted_list.index('debit') + credit_pos = 'credit' in wanted_list and wanted_list.index('credit') + if not (credit_pos and 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 !")) + + #report_name = objects[0]._description or objects[0]._name + report_name = _("Journal Items") + ws = wb.add_sheet(report_name[:31]) + ws.panes_frozen = True + ws.remove_splits = True + ws.portrait = 0 # Landscape + ws.fit_width_to_pages = 1 + row_pos = 0 + + # set print header/footer + ws.header_str = self.xls_headers['standard'] + ws.footer_str = self.xls_footers['standard'] + + # Title + cell_style = xlwt.easyxf(_xs['xls_title']) + c_specs = [ + ('report_name', 1, 0, 'text', report_name), + ] + row_data = self.xls_row_template(c_specs, ['report_name']) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style) + row_pos += 1 + + # Column headers + c_specs = map(lambda x: self.render(x, self.col_specs_template, 'header', render_space={'_': _p._}), wanted_list) + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=self.rh_cell_style, set_column_size=True) + ws.set_horz_split_pos(row_pos) + + # account move lines + for line in objects: + debit_cell = rowcol_to_cell(row_pos, debit_pos) + credit_cell = rowcol_to_cell(row_pos, credit_pos) + bal_formula = debit_cell + '-' + credit_cell + c_specs = map(lambda x: self.render(x, self.col_specs_template, 'lines'), wanted_list) + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=self.aml_cell_style) + + # Totals + aml_cnt = len(objects) + debit_start = rowcol_to_cell(row_pos - aml_cnt, debit_pos) + debit_stop = rowcol_to_cell(row_pos - 1, debit_pos) + debit_formula = 'SUM(%s:%s)' %(debit_start, debit_stop) + credit_start = rowcol_to_cell(row_pos - aml_cnt, credit_pos) + credit_stop = rowcol_to_cell(row_pos - 1, credit_pos) + credit_formula = 'SUM(%s:%s)' %(credit_start, credit_stop) + debit_cell = rowcol_to_cell(row_pos, debit_pos) + credit_cell = rowcol_to_cell(row_pos, credit_pos) + bal_formula = debit_cell + '-' + credit_cell + c_specs = map(lambda x: self.render(x, self.col_specs_template, 'totals'), wanted_list) + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=self.rt_cell_style_right) + +move_line_xls('report.move.line.list.xls', + 'account.move.line', + parser=move_line_xls_parser) + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/account_move_line_report_xls/report/move_line_list_xls.xml b/account_move_line_report_xls/report/move_line_list_xls.xml new file mode 100644 index 00000000..fcd4f00a --- /dev/null +++ b/account_move_line_report_xls/report/move_line_list_xls.xml @@ -0,0 +1,22 @@ + + + + + + Export Selected Lines + account.move.line + ir.actions.report.xml + move.line.list.xls + xls + + + + + Export Selected Lines + client_action_multi + + account.move.line + + + + diff --git a/account_move_line_report_xls/static/src/img/icon.png b/account_move_line_report_xls/static/src/img/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..b8a2fcdff9d1ae795a22cc4608a55d3c290b6e0c GIT binary patch literal 11645 zcmV-@ErQaCP)C<(Ewy&_zRo_QU6!mF+ma>OGPaS8u~8CiBn}u1hBz_CkYEBFAYd@d z0mlSR90-sTAF{B8gA-#m8?dqLVA+yoOV&tZ&C+{UbyZh&SJkVx-h1=?_r9v>nVtm6 zI^j5PdaA3cU%hwlfB*mczkj*Kwbtywf%hb5$~+h52S>`7rof)% z%dPWI)W3MH^<*Pn@5QY&>u|>L5ve3yi!-ept+>6oQc5%Y(?T<$v^|ujyK(xfvu{Y; zo++g=moYEQfoDp&+PpRc&M)F*dWzs>FZaSzSu z6^+nmA?H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