Merge pull request #298 from Eficent/9.0-add-account_journal_report
[9.0][ADD] Account Journal Reportpull/333/head
commit
a27550539e
|
@ -0,0 +1,67 @@
|
|||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
|
||||
==============
|
||||
Journal Report
|
||||
==============
|
||||
|
||||
Adds the following report in PDF and XLSX format:
|
||||
|
||||
* Journal Ledger. It groups the moves by their entries.
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
Users willing to access to this report should have proper Accounting & Finance rights:
|
||||
|
||||
#. Go to *Settings / Users* and edit your user to add the corresponding access rights as follows.
|
||||
#. In *Application / Accounting & Finance*, select *Accountant* or *Adviser* options.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
To use this module, you need to:
|
||||
|
||||
#. Go to *Invoicing* or *Accounting* menu
|
||||
#. Press 'Reporting > PDF Reports > Journal Ledger'
|
||||
#. Press 'Print' to print in PDF or 'Export' to export in Excel.
|
||||
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/91/9.0
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues
|
||||
<https://github.com/OCA/account-financial-reporting/issues>`_. In case of trouble,
|
||||
please check there if your issue has already been reported. If you spotted it
|
||||
first, help us smash it by providing detailed and welcomed feedback.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Joaquin Gutierrez <joaquingpedrosa@gmail.com>
|
||||
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
|
||||
* RGB Consulting SL (http://www.rgbconsulting.com)
|
||||
* Miquel Raïch <miquel.raich@eficent.com>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
.. image:: http://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: https://odoo-community.org
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.
|
||||
|
||||
To contribute to this module, please visit https://odoo-community.org.
|
|
@ -0,0 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2013 Joaquin Gutierrez (http://www.gutierrezweb.es)
|
||||
# Copyright 2015 Tecnativa S.L. (http://www.tecnativa.com)
|
||||
# Pedro M. Baeza <pedro.baeza@tecnativa.com>
|
||||
# Copyright 2017 RGB Consulting S.L. (http://www.rgbconsulting.com)
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# Miquel Raich <miquel.raich@eficent.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import report
|
||||
from . import wizard
|
|
@ -0,0 +1,30 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2013 Joaquin Gutierrez (http://www.gutierrezweb.es)
|
||||
# Copyright 2015 Tecnativa - Pedro M. Baeza
|
||||
# Copyright 2017 RGB Consulting
|
||||
# Copyright 2017 Eficent - Miquel Raich
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': "Journal Report",
|
||||
'version': "9.0.1.0.0",
|
||||
'depends': [
|
||||
"account",
|
||||
"report_xlsx",
|
||||
],
|
||||
'license': "AGPL-3",
|
||||
'author': "J. Gutierrez, "
|
||||
"Tecnativa, "
|
||||
"RGB Consulting, "
|
||||
"Eficent, "
|
||||
"Odoo Community Association (OCA)",
|
||||
'website': "http://github.com/OCA/account-financial-reporting",
|
||||
'category': "Accounting",
|
||||
'summary': "Journal Report",
|
||||
'data': [
|
||||
"wizard/wizard_print_journal_ledger_view.xml",
|
||||
"report/reports.xml",
|
||||
"views/templates.xml",
|
||||
],
|
||||
"installable": True,
|
||||
}
|
|
@ -0,0 +1,259 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * account_journal_report
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 9.0c\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-05-02 14:48+0200\n"
|
||||
"PO-Revision-Date: 2017-05-02 14:48+0200\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Generator: Poedit 1.8.7.1\n"
|
||||
"Last-Translator: \n"
|
||||
"Language: es\n"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: code:addons/account_journal_report/report/journal_ledger_report_xlsx.py:74
|
||||
#, python-format
|
||||
msgid " to "
|
||||
msgstr " a "
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.ui.view,arch_db:account_journal_report.journal_ledger
|
||||
msgid "<em>Account name</em>"
|
||||
msgstr "<em>Nombre cuenta</em>"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.ui.view,arch_db:account_journal_report.journal_ledger
|
||||
msgid "<em>Account</em>"
|
||||
msgstr "<em>Cuenta</em>"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.ui.view,arch_db:account_journal_report.journal_ledger
|
||||
msgid "<em>Description</em>"
|
||||
msgstr "<em>Descripción</em>"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: code:addons/account_journal_report/report/journal_ledger_report_xlsx.py:95
|
||||
#, python-format
|
||||
msgid "Account"
|
||||
msgstr "Cuenta"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: code:addons/account_journal_report/report/journal_ledger_report_xlsx.py:98
|
||||
#, python-format
|
||||
msgid "Account name"
|
||||
msgstr "Nombre cuenta"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: selection:account.journal.entries.report,sort_selection:0
|
||||
msgid "By date"
|
||||
msgstr "Por fecha"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: selection:account.journal.entries.report,sort_selection:0
|
||||
msgid "By entry number"
|
||||
msgstr "Por nº de entrada"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: selection:account.journal.entries.report,sort_selection:0
|
||||
msgid "By reference number"
|
||||
msgstr "Por referencia"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.ui.view,arch_db:account_journal_report.account_journal_ledger_report_view
|
||||
msgid "Cancel"
|
||||
msgstr "Cancelar"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.model.fields,field_description:account_journal_report.field_account_journal_entries_report_create_uid
|
||||
msgid "Created by"
|
||||
msgstr "Creado por"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.model.fields,field_description:account_journal_report.field_account_journal_entries_report_create_date
|
||||
msgid "Created on"
|
||||
msgstr "Creado el"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: code:addons/account_journal_report/report/journal_ledger_report_xlsx.py:107
|
||||
#: model:ir.ui.view,arch_db:account_journal_report.journal_ledger
|
||||
#, python-format
|
||||
msgid "Credit"
|
||||
msgstr "Haber"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: code:addons/account_journal_report/report/journal_ledger_report_xlsx.py:92
|
||||
#: model:ir.ui.view,arch_db:account_journal_report.journal_ledger
|
||||
#, python-format
|
||||
msgid "Date"
|
||||
msgstr "Fecha"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.model.fields,field_description:account_journal_report.field_account_journal_entries_report_date_end
|
||||
msgid "Date end"
|
||||
msgstr "Fecha final"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.model.fields,field_description:account_journal_report.field_account_journal_entries_report_date_start
|
||||
msgid "Date start"
|
||||
msgstr "Fecha inicial"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: code:addons/account_journal_report/report/journal_ledger_report_xlsx.py:104
|
||||
#: model:ir.ui.view,arch_db:account_journal_report.journal_ledger
|
||||
#, python-format
|
||||
msgid "Debit"
|
||||
msgstr "Debe"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: code:addons/account_journal_report/report/journal_ledger_report_xlsx.py:101
|
||||
#, python-format
|
||||
msgid "Description"
|
||||
msgstr "Descripción"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.model.fields,field_description:account_journal_report.field_account_journal_entries_report_display_name
|
||||
#: model:ir.model.fields,field_description:account_journal_report.field_report_account_journal_report_journal_ledger_display_name
|
||||
msgid "Display Name"
|
||||
msgstr "Nombre mostrado"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.model.fields,field_description:account_journal_report.field_account_journal_entries_report_sort_selection
|
||||
msgid "Entries Sorted By"
|
||||
msgstr "Entradas ordenadas por"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: code:addons/account_journal_report/report/journal_ledger_report_xlsx.py:89
|
||||
#: model:ir.ui.view,arch_db:account_journal_report.journal_ledger
|
||||
#, python-format
|
||||
msgid "Entry"
|
||||
msgstr "Entrada"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.ui.view,arch_db:account_journal_report.account_journal_ledger_report_view
|
||||
msgid "Export"
|
||||
msgstr "Exportar"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.ui.view,arch_db:account_journal_report.journal_ledger
|
||||
msgid "From"
|
||||
msgstr "De"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: code:addons/account_journal_report/report/journal_ledger_report_xlsx.py:74
|
||||
#, python-format
|
||||
msgid "From "
|
||||
msgstr "De "
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.model.fields,field_description:account_journal_report.field_account_journal_entries_report_id
|
||||
#: model:ir.model.fields,field_description:account_journal_report.field_report_account_journal_report_journal_ledger_id
|
||||
msgid "ID"
|
||||
msgstr "ID"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: code:addons/account_journal_report/report/journal_ledger_report_xlsx.py:79
|
||||
#: model:ir.ui.view,arch_db:account_journal_report.journal_ledger
|
||||
#, python-format
|
||||
msgid "Journal"
|
||||
msgstr "Diario"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: code:addons/account_journal_report/report/journal_ledger_report_xlsx.py:180
|
||||
#: model:ir.actions.report.xml,name:account_journal_report.account_journal_ledger_report
|
||||
#: model:ir.actions.report.xml,name:account_journal_report.action_account_journal_ledger_xlsx
|
||||
#: model:ir.ui.menu,name:account_journal_report.menu_journal_ledger_report
|
||||
#, python-format
|
||||
msgid "Journal Ledger"
|
||||
msgstr "Libro Diario"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.ui.view,arch_db:account_journal_report.journal_ledger
|
||||
msgid "Journal Ledger -"
|
||||
msgstr "Libro Diario -"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.model.fields,field_description:account_journal_report.field_account_journal_entries_report_journal_ids
|
||||
msgid "Journals"
|
||||
msgstr "Diarios"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.model.fields,field_description:account_journal_report.field_account_journal_entries_report_landscape
|
||||
msgid "Landscape mode"
|
||||
msgstr "Modo apaisado"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.model.fields,field_description:account_journal_report.field_account_journal_entries_report___last_update
|
||||
#: model:ir.model.fields,field_description:account_journal_report.field_report_account_journal_report_journal_ledger___last_update
|
||||
msgid "Last Modified on"
|
||||
msgstr "Última modificación el"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.model.fields,field_description:account_journal_report.field_account_journal_entries_report_write_uid
|
||||
msgid "Last Updated by"
|
||||
msgstr "Última actualización por"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.model.fields,field_description:account_journal_report.field_account_journal_entries_report_write_date
|
||||
msgid "Last Updated on"
|
||||
msgstr "Última actualización el"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: code:addons/account_journal_report/wizard/wizard_print_journal_ledger.py:57
|
||||
#: code:addons/account_journal_report/wizard/wizard_print_journal_ledger.py:76
|
||||
#, python-format
|
||||
msgid "No data available"
|
||||
msgstr "No hay datos disponibles"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: code:addons/account_journal_report/wizard/wizard_print_journal_ledger.py:58
|
||||
#: code:addons/account_journal_report/wizard/wizard_print_journal_ledger.py:77
|
||||
#, python-format
|
||||
msgid "No records found for your selection!"
|
||||
msgstr "No se han encontrado registros para su selección"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: code:addons/account_journal_report/report/journal_ledger_report_xlsx.py:82
|
||||
#: model:ir.ui.view,arch_db:account_journal_report.journal_ledger
|
||||
#, python-format
|
||||
msgid "Partner"
|
||||
msgstr "Empresa"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.ui.view,arch_db:account_journal_report.account_journal_ledger_report_view
|
||||
msgid "Print"
|
||||
msgstr "Imprimir"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.actions.act_window,name:account_journal_report.wizard_account_journal_ledger_report_new
|
||||
#: model:ir.model,name:account_journal_report.model_account_journal_entries_report
|
||||
msgid "Print Journal Ledger"
|
||||
msgstr "Imprimir Libro Diario"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.ui.view,arch_db:account_journal_report.account_journal_ledger_report_view
|
||||
msgid "Print journal ledger"
|
||||
msgstr "Imprimir libro diario"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: code:addons/account_journal_report/report/journal_ledger_report_xlsx.py:85
|
||||
#: model:ir.ui.view,arch_db:account_journal_report.journal_ledger
|
||||
#, python-format
|
||||
msgid "Reference"
|
||||
msgstr "Referencia"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.ui.view,arch_db:account_journal_report.account_journal_ledger_report_view
|
||||
msgid "or"
|
||||
msgstr "o"
|
||||
|
||||
#. module: account_journal_report
|
||||
#: model:ir.ui.view,arch_db:account_journal_report.journal_ledger
|
||||
msgid "to"
|
||||
msgstr "a"
|
|
@ -0,0 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2013 Joaquin Gutierrez (http://www.gutierrezweb.es)
|
||||
# Copyright 2015 Tecnativa S.L. (http://www.tecnativa.com)
|
||||
# Pedro M. Baeza <pedro.baeza@tecnativa.com>
|
||||
# Copyright 2017 RGB Consulting S.L. (http://www.rgbconsulting.com)
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# Miquel Raich <miquel.raich@eficent.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import journal_ledger_report
|
||||
from . import journal_ledger_report_xlsx
|
|
@ -0,0 +1,50 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2013 Joaquin Gutierrez (http://www.gutierrezweb.es)
|
||||
# Copyright 2015 Tecnativa - Pedro M. Baeza
|
||||
# Copyright 2017 RGB Consulting
|
||||
# Copyright 2017 Eficent - Miquel Raich
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp import api, fields, models
|
||||
|
||||
|
||||
class JournalLedger(models.AbstractModel):
|
||||
_name = 'report.account_journal_report.journal_ledger'
|
||||
|
||||
def _format_date_to_lang(self, str_date):
|
||||
if 'lang' not in self._context:
|
||||
return str_date
|
||||
lang_code = self._context['lang']
|
||||
lang_id = self.env['res.lang']._lang_get(lang_code)
|
||||
lang = self.env['res.lang'].browse(lang_id)
|
||||
date = fields.Date.from_string(str_date)
|
||||
return date.strftime(lang.date_format)
|
||||
|
||||
@api.multi
|
||||
def render_html(self, data):
|
||||
account_move_obj = self.env['account.move']
|
||||
report_obj = self.env['report']
|
||||
|
||||
date_start = data.get('date_start')
|
||||
date_end = data.get('date_end')
|
||||
journal_ids = data.get('journal_ids', [])
|
||||
|
||||
move_ids = account_move_obj.search(
|
||||
[('date', '<=', date_end),
|
||||
('date', '>=', date_start),
|
||||
('journal_id', 'in', journal_ids),
|
||||
('state', '!=', 'draft')],
|
||||
order=data.get('sort_selection', 'date') + ', id')
|
||||
|
||||
report = report_obj._get_report_from_name(
|
||||
'account_journal_report.journal_ledger')
|
||||
docargs = {
|
||||
'doc_model': report.model,
|
||||
'docs': move_ids,
|
||||
'date_start': self._format_date_to_lang(
|
||||
date_start),
|
||||
'date_end': self._format_date_to_lang(
|
||||
date_end),
|
||||
}
|
||||
return report_obj.render(
|
||||
'account_journal_report.journal_ledger', docargs)
|
|
@ -0,0 +1,201 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 RGB Consulting S.L. (http://www.rgbconsulting.com)
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# Miquel Raich <miquel.raich@eficent.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
try:
|
||||
from openerp.addons.report_xlsx.report.report_xlsx import ReportXlsx
|
||||
except ImportError:
|
||||
ReportXlsx = object
|
||||
from openerp.report import report_sxw
|
||||
from openerp import _
|
||||
|
||||
|
||||
class JournalLedgerXlsx(ReportXlsx):
|
||||
def __init__(self, name, table, rml=False, parser=False, header=True,
|
||||
store=False):
|
||||
super(ReportXlsx, self).__init__(
|
||||
name, table, rml, parser, header, store)
|
||||
|
||||
self.sheet = None
|
||||
self.row_pos = None
|
||||
|
||||
self.format_title = None
|
||||
self.format_border_top = None
|
||||
|
||||
def _define_formats(self, workbook):
|
||||
""" Add cell formats to current workbook.
|
||||
Available formats:
|
||||
* format_title
|
||||
* format_header
|
||||
* format_header_right
|
||||
* format_header_italic
|
||||
* format_border_top
|
||||
"""
|
||||
self.format_title = workbook.add_format({
|
||||
'bold': True,
|
||||
'align': 'center',
|
||||
'bg_color': '#46C646',
|
||||
'border': True
|
||||
})
|
||||
self.format_header = workbook.add_format({
|
||||
'bold': True,
|
||||
'bg_color': '#FFFFCC',
|
||||
'border': True
|
||||
})
|
||||
self.format_header_right = workbook.add_format({
|
||||
'bold': True,
|
||||
'bg_color': '#FFFFCC',
|
||||
'border': True,
|
||||
'align': 'right'
|
||||
})
|
||||
self.format_header_italic = workbook.add_format({
|
||||
'bold': True,
|
||||
'bg_color': '#FFFFCC',
|
||||
'border': True,
|
||||
'italic': True
|
||||
})
|
||||
self.format_border_top = workbook.add_format({
|
||||
'top': 1,
|
||||
'bg_color': '#eeeeee'
|
||||
})
|
||||
|
||||
def _write_report_title(self, title):
|
||||
self.sheet.merge_range(
|
||||
self.row_pos, 0, self.row_pos, 6, title, self.format_title
|
||||
)
|
||||
self.row_pos += 1
|
||||
|
||||
def _write_report_range(self, date1, date2):
|
||||
self.sheet.merge_range(
|
||||
self.row_pos, 0, self.row_pos, 1,
|
||||
_('From ')+date1+_(' to ')+date2+_(':'))
|
||||
self.row_pos += 1
|
||||
|
||||
def _set_headers(self):
|
||||
# Journal
|
||||
self.sheet.write_string(self.row_pos, 2, _('Journal'),
|
||||
self.format_header)
|
||||
# Partner
|
||||
self.sheet.write_string(self.row_pos, 3, _('Partner'),
|
||||
self.format_header)
|
||||
# Reference
|
||||
self.sheet.write_string(self.row_pos, 4, _('Reference'),
|
||||
self.format_header)
|
||||
self.row_pos += 1
|
||||
# Entry
|
||||
self.sheet.write_string(self.row_pos, 0, _('Entry'),
|
||||
self.format_header)
|
||||
# Date
|
||||
self.sheet.write_string(self.row_pos, 1, _('Date'), self.format_header)
|
||||
|
||||
# Account
|
||||
self.sheet.write_string(self.row_pos, 2, _('Account'),
|
||||
self.format_header_italic)
|
||||
# Account name
|
||||
self.sheet.write_string(self.row_pos, 3, _('Account name'),
|
||||
self.format_header_italic)
|
||||
# Description
|
||||
self.sheet.write_string(self.row_pos, 4, _('Description'),
|
||||
self.format_header_italic)
|
||||
# Debit
|
||||
self.sheet.write_string(self.row_pos, 5, _('Debit'),
|
||||
self.format_header_right)
|
||||
# Credit
|
||||
self.sheet.write_string(self.row_pos, 6, _('Credit'),
|
||||
self.format_header_right)
|
||||
self.sheet.freeze_panes(4, 0)
|
||||
self.row_pos += 1
|
||||
|
||||
def _generate_report_content(self, report_data):
|
||||
for move in report_data:
|
||||
# Entry
|
||||
self.sheet.write_string(self.row_pos, 0, move.name or '',
|
||||
self.format_border_top)
|
||||
self.sheet.set_column(0, 0, 18)
|
||||
# Date
|
||||
self.sheet.write_string(self.row_pos, 1, move.date or '',
|
||||
self.format_border_top)
|
||||
self.sheet.set_column(1, 1, 12)
|
||||
# Journal
|
||||
self.sheet.write_string(self.row_pos, 2,
|
||||
move.journal_id.name or '',
|
||||
self.format_border_top)
|
||||
self.sheet.set_column(2, 2, 30)
|
||||
# Partner
|
||||
self.sheet.write_string(self.row_pos, 3,
|
||||
move.partner_id.name or '',
|
||||
self.format_border_top)
|
||||
self.sheet.set_column(3, 3, 40)
|
||||
# Reference
|
||||
self.sheet.write_string(self.row_pos, 4, move.ref or '',
|
||||
self.format_border_top)
|
||||
self.sheet.set_column(4, 4, 40)
|
||||
# Debit
|
||||
self.sheet.write_number(self.row_pos, 5, move.amount or 0,
|
||||
self.format_border_top)
|
||||
self.sheet.set_column(5, 5, 12)
|
||||
# Credit
|
||||
self.sheet.write_number(self.row_pos, 6, move.amount or 0,
|
||||
self.format_border_top)
|
||||
self.sheet.set_column(6, 6, 12)
|
||||
|
||||
self.row_pos += 1
|
||||
for line in move.line_ids:
|
||||
# Account code
|
||||
self.sheet.write_string(self.row_pos, 2,
|
||||
line.account_id.code or '')
|
||||
# Account name
|
||||
self.sheet.write_string(self.row_pos, 3,
|
||||
line.account_id.name or '')
|
||||
# Line description
|
||||
self.sheet.write_string(self.row_pos, 4, line.name or '')
|
||||
# Debit
|
||||
self.sheet.write_number(self.row_pos, 5, line.debit or 0)
|
||||
# Credit
|
||||
self.sheet.write_number(self.row_pos, 6, line.credit or 0)
|
||||
self.row_pos += 1
|
||||
|
||||
def generate_xlsx_report(self, workbook, data, objects):
|
||||
date_start = data.get('date_start')
|
||||
date_end = data.get('date_end')
|
||||
journal_ids = data.get('journal_ids', [])
|
||||
|
||||
report_data = self.env['account.move'].search(
|
||||
[('date', '<=', date_end),
|
||||
('date', '>=', date_start),
|
||||
('journal_id', 'in', journal_ids),
|
||||
('state', '!=', 'draft')],
|
||||
order=data.get('sort_selection', 'date') + ', id')
|
||||
|
||||
# Initial row
|
||||
self.row_pos = 0
|
||||
|
||||
# Load formats to workbook
|
||||
self._define_formats(workbook)
|
||||
|
||||
# Set report name
|
||||
report_name = _('Journal Ledger') + ' - ' + \
|
||||
self.env.user.company_id.name
|
||||
self.sheet = workbook.add_worksheet(report_name[:31])
|
||||
if data.get('landscape'):
|
||||
self.sheet.set_landscape()
|
||||
self.sheet.fit_to_pages(1, 0)
|
||||
self.sheet.set_zoom(80)
|
||||
self._write_report_title(report_name)
|
||||
self._write_report_range(date_start, date_end)
|
||||
|
||||
# Set headers
|
||||
self._set_headers()
|
||||
|
||||
# Generate data
|
||||
self._generate_report_content(report_data)
|
||||
|
||||
|
||||
if ReportXlsx != object:
|
||||
JournalLedgerXlsx(
|
||||
'report.account_journal_report.journal_ledger_xlsx',
|
||||
'account.journal', parser=report_sxw.rml_parse
|
||||
)
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
<!-- Account Journal Ledger Report -->
|
||||
<report id="account_journal_ledger_report"
|
||||
string="Journal Ledger"
|
||||
model="account.journal"
|
||||
report_type="qweb-pdf"
|
||||
name="account_journal_report.journal_ledger"
|
||||
file="account_journal_report.journal_ledger"/>
|
||||
|
||||
<record id="action_account_journal_ledger_xlsx" model="ir.actions.report.xml">
|
||||
<field name="name">Journal Ledger</field>
|
||||
<field name="model">account.journal</field>
|
||||
<field name="type">ir.actions.report.xml</field>
|
||||
<field name="report_name">account_journal_report.journal_ledger_xlsx</field>
|
||||
<field name="report_type">xlsx</field>
|
||||
<field name="auto" eval="False"/>
|
||||
</record>
|
||||
|
||||
<record id="account_journal_ledger_paperformat"
|
||||
model="report.paperformat">
|
||||
<field name="name">Account Journal Ledger</field>
|
||||
<field name="default" eval="False"/>
|
||||
<field name="format">A4</field>
|
||||
<field name="orientation"/>
|
||||
<field name="margin_top">10</field>
|
||||
<field name="margin_bottom">10</field>
|
||||
<field name="margin_left">7</field>
|
||||
<field name="margin_right">7</field>
|
||||
<field name="header_spacing">0</field>
|
||||
<field name="dpi">90</field>
|
||||
</record>
|
||||
|
||||
<record id="account_journal_ledger_report"
|
||||
model="ir.actions.report.xml">
|
||||
<field name="paperformat_id"
|
||||
ref="account_journal_ledger_paperformat"/>
|
||||
</record>
|
||||
|
||||
</odoo>
|
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
|
@ -0,0 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import test_account_journal_report
|
|
@ -0,0 +1,114 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
from openerp import fields
|
||||
from openerp.tests.common import SavepointCase
|
||||
|
||||
|
||||
class TestAccountJournalReport(SavepointCase):
|
||||
"""
|
||||
Tests for Account Journal Report.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestAccountJournalReport, self).setUp()
|
||||
|
||||
self.report_model = \
|
||||
self.env['report.account_journal_report.journal_ledger']
|
||||
self.wiz = self.env['account.journal.entries.report']
|
||||
self.report_name = 'account_journal_report.journal_ledger'
|
||||
self.action_name = 'account_journal_report.' \
|
||||
'account_journal_ledger_report'
|
||||
self.report_xlsx_name = 'account_journal_report.journal_ledger_xlsx'
|
||||
self.action_xlsx_name = 'account_journal_report.' \
|
||||
'action_account_journal_ledger_xlsx'
|
||||
self.report_title = 'Journal Ledger'
|
||||
|
||||
self.today = fields.Date.today()
|
||||
|
||||
self.account_type = self.env['account.account.type'].create({
|
||||
'name': 'Test account type',
|
||||
'type': 'other',
|
||||
})
|
||||
self.account = self.env['account.account'].create({
|
||||
'name': 'Test account',
|
||||
'code': 'TEST',
|
||||
'user_type_id': self.account_type.id,
|
||||
})
|
||||
self.journal = self.env['account.journal'].create({
|
||||
'name': 'Test journal',
|
||||
'code': 'TEST',
|
||||
'type': 'general',
|
||||
})
|
||||
self.move = self.env['account.move'].create({
|
||||
'journal_id': self.journal.id,
|
||||
'date': fields.Date.today(),
|
||||
'line_ids': [
|
||||
(0, 0, {
|
||||
'name': 'Debit line',
|
||||
'account_id': self.account.id,
|
||||
'debit': 100,
|
||||
}),
|
||||
(0, 0, {
|
||||
'name': 'Credit line',
|
||||
'account_id': self.account.id,
|
||||
'credit': 100,
|
||||
}),
|
||||
],
|
||||
})
|
||||
self.move.post()
|
||||
|
||||
def test_account_journal_report(self):
|
||||
|
||||
wiz_id = self.wiz.create({
|
||||
'journal_ids': [(6, 0, self.journal.ids)],
|
||||
'date_start': self.today,
|
||||
'date_end': self.today,
|
||||
})
|
||||
report = wiz_id.print_report()
|
||||
|
||||
self.assertDictContainsSubset(
|
||||
{
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': self.report_name,
|
||||
'report_type': 'qweb-pdf',
|
||||
},
|
||||
report,
|
||||
'There was an error and the PDF report was not generated.'
|
||||
)
|
||||
|
||||
data = wiz_id.read()[0]
|
||||
report = self.env.ref(self.action_name).\
|
||||
render_report(
|
||||
wiz_id.ids, self.report_name, data
|
||||
)
|
||||
self.assertGreaterEqual(len(report[0]), 1)
|
||||
self.assertEqual(report[1], 'html')
|
||||
|
||||
def test_account_journal_report_xlsx(self):
|
||||
|
||||
wiz_id = self.wiz.create({
|
||||
'journal_ids': [(6, 0, self.journal.ids)],
|
||||
'date_start': self.today,
|
||||
'date_end': self.today,
|
||||
})
|
||||
report = wiz_id.print_report_xlsx()
|
||||
|
||||
self.assertDictContainsSubset(
|
||||
{
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_type': 'xlsx',
|
||||
'report_name': self.report_xlsx_name,
|
||||
},
|
||||
report,
|
||||
'There was an error and the XLSX report was not generated.'
|
||||
)
|
||||
|
||||
data = wiz_id.read()[0]
|
||||
report_xlsx = self.env.ref(self.action_xlsx_name).\
|
||||
render_report(
|
||||
wiz_id.ids, self.report_xlsx_name, data
|
||||
)
|
||||
|
||||
self.assertGreaterEqual(len(report_xlsx[0]), 1)
|
||||
self.assertEqual(report_xlsx[1], 'xlsx')
|
|
@ -0,0 +1,85 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<!-- Account Journal Ledger Template -->
|
||||
<template id="journal_ledger">
|
||||
<t t-call="report.html_container">
|
||||
<div class="page">
|
||||
<h2 class="text-center">Journal Ledger -
|
||||
<t t-esc="res_company.name"/>
|
||||
</h2>
|
||||
From <span t-esc="date_start"/> to <span t-esc="date_end"/>:
|
||||
<table class="table table-condensed">
|
||||
<thead>
|
||||
<th>Entry</th>
|
||||
<th>Date</th>
|
||||
<th>
|
||||
<div>Journal</div>
|
||||
<em>Account</em>
|
||||
</th>
|
||||
<th>
|
||||
<div>Partner</div>
|
||||
<em>Account name</em>
|
||||
</th>
|
||||
<th>
|
||||
<div>Reference</div>
|
||||
<em>Description</em>
|
||||
</th>
|
||||
<th class="text-right">Debit</th>
|
||||
<th class="text-right">Credit</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<t t-foreach="docs" t-as="o">
|
||||
<tr style="border-top: 2px solid black;">
|
||||
<td>
|
||||
<span t-field="o.name"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-field="o.date"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-field="o.journal_id.code"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-field="o.partner_id.name"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-field="o.ref"/>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<span t-field="o.amount"
|
||||
t-field-options='{"widget": "monetary", "display_currency": "res_company.currency_id"}'/>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<span t-field="o.amount"
|
||||
t-field-options='{"widget": "monetary", "display_currency": "res_company.currency_id"}'/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr t-foreach="o.line_ids" t-as="l"
|
||||
style="border: 0;">
|
||||
<td/>
|
||||
<td/>
|
||||
<td>
|
||||
<span t-field="l.account_id.code"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-field="l.account_id.name"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-field="l.name"/>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<span t-field="l.debit"
|
||||
t-field-options='{"widget": "monetary", "display_currency": "res_company.currency_id"}'/>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<span t-field="l.credit"
|
||||
t-field-options='{"widget": "monetary", "display_currency": "res_company.currency_id"}'/>
|
||||
</td>
|
||||
</tr>
|
||||
</t>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
</odoo>
|
|
@ -0,0 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2013 Joaquin Gutierrez (http://www.gutierrezweb.es)
|
||||
# Copyright 2015 Tecnativa S.L. (http://www.tecnativa.com)
|
||||
# Pedro M. Baeza <pedro.baeza@tecnativa.com>
|
||||
# Copyright 2017 RGB Consulting S.L. (http://www.rgbconsulting.com)
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# Miquel Raich <miquel.raich@eficent.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import wizard_print_journal_ledger
|
|
@ -0,0 +1,86 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2013 Joaquin Gutierrez (http://www.gutierrezweb.es)
|
||||
# Copyright 2015 Tecnativa - Pedro M. Baeza
|
||||
# Copyright 2017 RGB Consulting
|
||||
# Copyright 2017 Eficent - Miquel Raich
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from datetime import date, timedelta
|
||||
from openerp import api, fields, models, exceptions, _
|
||||
|
||||
|
||||
class AccountJournalLedgerReport(models.TransientModel):
|
||||
_name = "account.journal.entries.report"
|
||||
_description = "Print Journal Ledger"
|
||||
|
||||
@api.model
|
||||
def _default_journal_ids(self):
|
||||
return self.env['account.journal'].search([])
|
||||
|
||||
journal_ids = fields.Many2many(
|
||||
comodel_name='account.journal',
|
||||
relation="account_journal_entries_report_journals_rel",
|
||||
string='Journals', required=True, default=_default_journal_ids,
|
||||
)
|
||||
date_start = fields.Date(required=True,
|
||||
default=fields.Date.to_string(
|
||||
date.today()-timedelta(days=90)))
|
||||
date_end = fields.Date(required=True,
|
||||
default=fields.Date.to_string(date.today()))
|
||||
sort_selection = fields.Selection(
|
||||
[('date', 'By date'),
|
||||
('name', 'By entry number'),
|
||||
('ref', 'By reference number')],
|
||||
string='Entries Sorted By', required=True, default='name',
|
||||
)
|
||||
landscape = fields.Boolean(string='Landscape mode', default=True)
|
||||
|
||||
@api.multi
|
||||
def _check_data(self):
|
||||
if not self.journal_ids:
|
||||
return False
|
||||
journal_obj = self.env['account.journal']
|
||||
for journal in self.journal_ids:
|
||||
ids_journal = journal_obj.search(
|
||||
[('id', '=', journal.id)])
|
||||
if ids_journal:
|
||||
return True
|
||||
return False
|
||||
|
||||
@api.multi
|
||||
def print_report(self):
|
||||
"""Print report PDF"""
|
||||
|
||||
# Check data
|
||||
if not self._check_data():
|
||||
raise exceptions.Warning(
|
||||
_('No data available'),
|
||||
_('No records found for your selection!'))
|
||||
|
||||
report_name = 'account_journal_report.journal_ledger'
|
||||
|
||||
# Call report
|
||||
data = self.read()[0]
|
||||
return self.env['report'].with_context(
|
||||
{'landscape': self.landscape}).get_action(self,
|
||||
report_name=report_name,
|
||||
data=data)
|
||||
|
||||
@api.multi
|
||||
def print_report_xlsx(self):
|
||||
"""Print report XLSX"""
|
||||
|
||||
# Check data
|
||||
if not self._check_data():
|
||||
raise exceptions.Warning(
|
||||
_('No data available'),
|
||||
_('No records found for your selection!'))
|
||||
|
||||
# Call report
|
||||
data = self.read()[0]
|
||||
report_name = 'account_journal_report.journal_ledger_xlsx'
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': report_name,
|
||||
'report_type': 'xlsx',
|
||||
'datas': data}
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
<record id="account_journal_ledger_report_view" model="ir.ui.view">
|
||||
<field name="name">Print journal ledger</field>
|
||||
<field name="model">account.journal.entries.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Print journal ledger">
|
||||
<group>
|
||||
<group>
|
||||
<field name="sort_selection"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="landscape"/>
|
||||
</group>
|
||||
</group>
|
||||
<group name="dates">
|
||||
<field name="date_start"/>
|
||||
<field name="date_end"/>
|
||||
</group>
|
||||
<group/>
|
||||
<label for="journal_ids"/>
|
||||
<field name="journal_ids" nolabel="1" options="{'no_create': True}"/>
|
||||
<group/>
|
||||
<footer>
|
||||
<button name="print_report" string="Print" type="object"
|
||||
default_focus="1" class="oe_highlight"/>
|
||||
or<button name="print_report_xlsx" string="Export"
|
||||
type="object"/>
|
||||
<button special="cancel" string="Cancel"
|
||||
class="oe_link"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="wizard_account_journal_ledger_report_new"
|
||||
model="ir.actions.act_window">
|
||||
<field name="name">Print Journal Ledger</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">account.journal.entries.report</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="account_journal_ledger_report_view"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<menuitem name="Journal Ledger"
|
||||
parent="account.menu_finance_legal_statement"
|
||||
action="wizard_account_journal_ledger_report_new"
|
||||
id="menu_journal_ledger_report"/>
|
||||
</odoo>
|
Loading…
Reference in New Issue