Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][MIG] account_financial_report_number #131

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions account_financial_report_number/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.. 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

================================
Account Financial Reports Number
================================

* This module adds a filter to Journal Ledger report to filter by journal entry number


Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/nuobit/odoo-addons/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.

Credits
=======

Contributors
------------

* Eric Antones <eantones@nuobit.com>
* Christopher Ormaza <chris.ormaza@forgeflow.com>
6 changes: 6 additions & 0 deletions account_financial_report_number/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright NuoBiT Solutions, S.L. (<https://www.nuobit.com>)
# Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from . import report
from . import wizard
23 changes: 23 additions & 0 deletions account_financial_report_number/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright NuoBiT Solutions, S.L. (<https://www.nuobit.com>)
# Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

{
"name": "Account Financial Reports Number",
"summary": "This module adds a filter to Journal Ledger "
"report to filter by journal entry number",
"version": "14.0.1.0.0",
"category": "Reporting",
"author": "NuoBiT Solutions, S.L., Eric Antones",
"website": "https://github.com/nuobit/odoo-addons",
"license": "AGPL-3",
"depends": [
"account_financial_report",
],
"data": [
"wizard/journal_ledger_wizard_view.xml",
],
"installable": True,
"development_status": "Beta",
"maintainers": ["eantones"],
}
57 changes: 57 additions & 0 deletions account_financial_report_number/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_financial_report_number
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-12-25 00:22+0000\n"
"PO-Revision-Date: 2020-12-25 00:22+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_financial_report_number
#: code:addons/account_financial_report_number/report/journal_ledger.py:52
#: code:addons/account_financial_report_number/report/journal_ledger.py:73
#, python-format
msgid "At least from number should be entered"
msgstr "At least from number should be entered"

#. module: account_financial_report_number
#: model:ir.ui.view,arch_db:account_financial_report_number.journal_ledger_wizard
msgid "Entry number"
msgstr "Número de asiento"

#. module: account_financial_report_number
#: model:ir.model.fields,field_description:account_financial_report_number.field_journal_ledger_report_wizard_filter_by_number
#: model:ir.model.fields,field_description:account_financial_report_number.field_report_journal_ledger_filter_by_number
msgid "Filter by entry number"
msgstr "Filtar por número de asiento"

#. module: account_financial_report_number
#: model:ir.model.fields,field_description:account_financial_report_number.field_journal_ledger_report_wizard_number_from
#: model:ir.model.fields,field_description:account_financial_report_number.field_report_journal_ledger_number_from
msgid "From number"
msgstr "Desde número"

#. module: account_financial_report_number
#: model:ir.model,name:account_financial_report_number.model_journal_ledger_report_wizard
msgid "Journal Ledger Report Wizard"
msgstr "Asistente de informe de Libro Diario"

#. module: account_financial_report_number
#: model:ir.model.fields,field_description:account_financial_report_number.field_journal_ledger_report_wizard_number_to
#: model:ir.model.fields,field_description:account_financial_report_number.field_report_journal_ledger_number_to
msgid "To number"
msgstr "Hasta número"

#. module: account_financial_report_number
#: model:ir.model,name:account_financial_report_number.model_report_journal_ledger
msgid "report_journal_ledger"
msgstr "informe_libro_diario"

5 changes: 5 additions & 0 deletions account_financial_report_number/report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright NuoBiT Solutions, S.L. (<https://www.nuobit.com>)
# Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from . import journal_ledger
46 changes: 46 additions & 0 deletions account_financial_report_number/report/journal_ledger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright NuoBiT Solutions, S.L. (<https://www.nuobit.com>)
# Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import _, models
from odoo.exceptions import UserError


def _get_number_interval(wizard):
number_from = wizard.number_from
number_to = wizard.number_to
if wizard.number_from and not wizard.number_to:
number_to = wizard.number_from
elif not wizard.number_from and wizard.number_to:
number_from = wizard.number_to
elif not wizard.number_from and not wizard.number_to:
return None, None
return number_from, number_to


class JournalLedgerReport(models.AbstractModel):
_inherit = "report.account_financial_report.journal_ledger"

def _get_moves_domain(self, wizard, journal_ids):
domain = super(JournalLedgerReport, self)._get_moves_domain(wizard, journal_ids)
if wizard.filter_by_number:
number_from, number_to = _get_number_interval(wizard)
if not number_from and not number_to:
raise UserError(_("At least from number should be entered"))
if number_from:
domain += [
("name", ">=", number_from),
]
if number_to and number_from != number_to:
domain += [
("name", "<=", number_to),
]
new_domain = []
for criteria in domain:
if isinstance(criteria, (list, tuple)) and len(criteria) == 3:
if criteria[0] != "date":
new_domain.append(criteria)
else:
new_domain.append(criteria)
domain = new_domain
return domain
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions account_financial_report_number/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright NuoBiT Solutions, S.L. (<https://www.nuobit.com>)
# Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from . import journal_ledger_wizard
28 changes: 28 additions & 0 deletions account_financial_report_number/wizard/journal_ledger_wizard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright NuoBiT Solutions, S.L. (<https://www.nuobit.com>)
# Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import fields, models


class JournalLedgerReportWizard(models.TransientModel):
_inherit = "journal.ledger.report.wizard"

date_from = fields.Date(required=False)
date_to = fields.Date(required=False)

filter_by_number = fields.Boolean(string="Filter by entry number", default=False)

number_from = fields.Char(string="From number", required=False)
number_to = fields.Char(string="To number", required=False)

def _prepare_report_journal_ledger(self):
values = super(JournalLedgerReportWizard, self)._prepare_report_journal_ledger()
values.update(
{
"number_from": self.number_from,
"number_to": self.number_to,
"filter_by_number": self.filter_by_number,
}
)
return values
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright NuoBiT Solutions, S.L. (<https://www.nuobit.com>)
Eric Antones <eantones@nuobit.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) -->
<odoo>
<record id="journal_ledger_wizard" model="ir.ui.view">
<field name="name">Journal Ledger with number filter</field>
<field name="model">journal.ledger.report.wizard</field>
<field name="inherit_id" ref="account_financial_report.journal_ledger_wizard" />
<field name="arch" type="xml">
<xpath expr="//group[field[@name='company_id']]" position="after">
<group>
<field name="filter_by_number" />
</group>

<separator
string="Entry number"
attrs="{'invisible': [('filter_by_number', '!=', True)]}"
/>
<group attrs="{'invisible': [('filter_by_number', '!=', True)]}">
<group>
<field
name="number_from"
attrs="{'required': [('filter_by_number', '=', True)]}"
/>
<field name="number_to" />
</group>
</group>
</xpath>

<xpath
expr="//group[group[field[@name='date_range_id']]]/preceding-sibling::separator[1]"
position="attributes"
>
<attribute name="attrs">
{'invisible': [('filter_by_number', '=', True)]}
</attribute>
</xpath>

<xpath
expr="//group[group[field[@name='date_range_id']]]"
position="attributes"
>
<attribute name="attrs">
{'invisible': [('filter_by_number', '=', True)]}
</attribute>
</xpath>

<field name="date_from" position="attributes">
<attribute name="attrs">
{'required': [('filter_by_number', '!=', True)]}
</attribute>
</field>

<field name="date_to" position="attributes">
<attribute name="attrs">
{'required': [('filter_by_number', '!=', True)]}
</attribute>
</field>
</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions setup/account_financial_report_number/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)