From 8d2b7752c6eed28e7cfdac73a4919be83876ddde Mon Sep 17 00:00:00 2001 From: Ernesto Tejeda Date: Mon, 23 Mar 2020 11:15:55 -0400 Subject: [PATCH] [MIG] account_financial_report: Migration to 13.0 --- account_financial_report/README.rst | 28 +++- account_financial_report/__manifest__.py | 5 +- .../models/account_group.py | 5 +- .../models/account_move_line.py | 3 +- .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 2 +- account_financial_report/readme/ROADMAP.rst | 7 + .../report/abstract_report_xlsx.py | 26 +-- .../report/aged_partner_balance.py | 14 +- .../report/aged_partner_balance_xlsx.py | 1 + .../report/general_ledger.py | 7 +- .../report/general_ledger_xlsx.py | 18 +- .../report/journal_ledger.py | 80 ++++----- .../report/journal_ledger_xlsx.py | 7 +- account_financial_report/report/open_items.py | 29 ++-- .../report/open_items_xlsx.py | 1 + .../report/trial_balance.py | 17 +- .../report/trial_balance_xlsx.py | 1 + account_financial_report/report/vat_report.py | 20 ++- .../report/vat_report_xlsx.py | 1 + .../static/description/index.html | 62 ++++--- .../tests/test_general_ledger.py | 10 +- .../tests/test_journal_ledger.py | 156 ++++++++++-------- .../tests/test_trial_balance.py | 59 +------ .../tests/test_vat_report.py | 156 +++++++++++------- .../view/report_vat_report.xml | 0 .../wizard/aged_partner_balance_wizard.py | 12 +- .../aged_partner_balance_wizard_view.xml | 1 - .../wizard/general_ledger_wizard.py | 38 ++--- .../wizard/general_ledger_wizard_view.xml | 4 +- .../wizard/journal_ledger_wizard.py | 23 +-- .../wizard/journal_ledger_wizard_view.xml | 1 - .../wizard/open_items_wizard.py | 6 +- .../wizard/open_items_wizard_view.xml | 4 +- .../wizard/trial_balance_wizard.py | 27 ++- .../wizard/trial_balance_wizard_view.xml | 1 - .../wizard/vat_report_wizard.py | 7 +- .../wizard/vat_report_wizard_view.xml | 1 - oca_dependencies.txt | 1 + 39 files changed, 404 insertions(+), 438 deletions(-) create mode 100644 account_financial_report/readme/ROADMAP.rst mode change 100755 => 100644 account_financial_report/view/report_vat_report.xml mode change 100755 => 100644 account_financial_report/wizard/vat_report_wizard_view.xml diff --git a/account_financial_report/README.rst b/account_financial_report/README.rst index c67fc13e..66d43a59 100644 --- a/account_financial_report/README.rst +++ b/account_financial_report/README.rst @@ -14,19 +14,19 @@ Account Financial Reports :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github - :target: https://github.com/OCA/account-financial-reporting/tree/12.0/account_financial_report + :target: https://github.com/OCA/account-financial-reporting/tree/13.0/account_financial_report :alt: OCA/account-financial-reporting .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/account-financial-reporting-12-0/account-financial-reporting-12-0-account_financial_report + :target: https://translation.odoo-community.org/projects/account-financial-reporting-13-0/account-financial-reporting-13-0-account_financial_report :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/91/12.0 + :target: https://runbot.odoo-community.org/runbot/91/13.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| This module adds a set of financial reports. They are accessible under -Accounting / Reporting / OCA Reports. +Invoicing / Reporting / OCA accounting reports. - General ledger - Trial Balance @@ -47,6 +47,14 @@ currency balances are not available. .. contents:: :local: +Known issues / Roadmap +====================== + +* 'VAT Report' is valid only for cases where it's met that for each + Tax defined: all the "Account tags" of all the + 'Repartition for Invoices' or 'Repartition for Credit Notes' + are different. + Changelog ========= @@ -76,7 +84,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -89,12 +97,12 @@ Authors * Camptocamp SA * initOS GmbH * redCOR AG -* Eficent +* ForgeFlow Contributors ~~~~~~~~~~~~ -* Jordi Ballester +* Jordi Ballester * Yannick Vaucher * Simone Orsi * Leonardo Pistone @@ -110,11 +118,13 @@ Contributors * Akim Juillerat * Alexis de Lattre * Mihai Fekete -* Miquel Raïch +* Miquel Raïch +* Joan Sisquella * `Tecnativa `__: * Pedro M. Baeza * Sergio Teruel + * Ernesto Tejeda Much of the work in this module was done at a sprint in Sorrento, Italy in April 2016. @@ -132,6 +142,6 @@ 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. -This module is part of the `OCA/account-financial-reporting `_ project on GitHub. +This module is part of the `OCA/account-financial-reporting `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_financial_report/__manifest__.py b/account_financial_report/__manifest__.py index 664696d2..f091b15c 100644 --- a/account_financial_report/__manifest__.py +++ b/account_financial_report/__manifest__.py @@ -5,7 +5,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Account Financial Reports", - "version": "12.0.2.0.0", + "version": "13.0.1.0.0", "category": "Reporting", "summary": "OCA Financial Reports", "author": "Camptocamp SA," @@ -14,7 +14,7 @@ "ForgeFlow," "Odoo Community Association (OCA)", "website": "https://odoo-community.org/", - "depends": ["account", "date_range", "report_xlsx",], + "depends": ["account", "date_range", "report_xlsx"], "data": [ "wizard/aged_partner_balance_wizard_view.xml", "wizard/general_ledger_wizard_view.xml", @@ -40,7 +40,6 @@ "view/report_aged_partner_balance.xml", "view/report_vat_report.xml", ], - "external_dependencies": {"python": ["natsort", "pandas",],}, "installable": True, "application": True, "auto_install": False, diff --git a/account_financial_report/models/account_group.py b/account_financial_report/models/account_group.py index 69f8b67d..f1d237f0 100644 --- a/account_financial_report/models/account_group.py +++ b/account_financial_report/models/account_group.py @@ -36,13 +36,11 @@ class AccountGroup(models.Model): """ Forms complete code of location from parent location to child location. """ if self.parent_id.complete_code: self.complete_code = "{}/{}".format( - self.parent_id.complete_code, - self.code_prefix, + self.parent_id.complete_code, self.code_prefix ) else: self.complete_code = self.code_prefix - @api.multi @api.depends("parent_id", "parent_id.level") def _compute_level(self): for group in self: @@ -51,7 +49,6 @@ class AccountGroup(models.Model): else: group.level = group.parent_id.level + 1 - @api.multi @api.depends( "code_prefix", "account_ids", diff --git a/account_financial_report/models/account_move_line.py b/account_financial_report/models/account_move_line.py index 72fd9e26..4558a323 100644 --- a/account_financial_report/models/account_move_line.py +++ b/account_financial_report/models/account_move_line.py @@ -1,12 +1,11 @@ # Copyright 2019 ACSONE SA/NV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).- -from odoo import api, models +from odoo import models class AccountMoveLine(models.Model): _inherit = "account.move.line" - @api.model_cr def init(self): """ The join between accounts_partners subquery and account_move_line diff --git a/account_financial_report/readme/CONTRIBUTORS.rst b/account_financial_report/readme/CONTRIBUTORS.rst index ba511343..484bb7fb 100644 --- a/account_financial_report/readme/CONTRIBUTORS.rst +++ b/account_financial_report/readme/CONTRIBUTORS.rst @@ -20,6 +20,7 @@ * Pedro M. Baeza * Sergio Teruel + * Ernesto Tejeda Much of the work in this module was done at a sprint in Sorrento, Italy in April 2016. diff --git a/account_financial_report/readme/DESCRIPTION.rst b/account_financial_report/readme/DESCRIPTION.rst index 6dab949f..f638de8b 100644 --- a/account_financial_report/readme/DESCRIPTION.rst +++ b/account_financial_report/readme/DESCRIPTION.rst @@ -1,5 +1,5 @@ This module adds a set of financial reports. They are accessible under -Accounting / Reporting / OCA Reports. +Invoicing / Reporting / OCA accounting reports. - General ledger - Trial Balance diff --git a/account_financial_report/readme/ROADMAP.rst b/account_financial_report/readme/ROADMAP.rst new file mode 100644 index 00000000..46ff6c43 --- /dev/null +++ b/account_financial_report/readme/ROADMAP.rst @@ -0,0 +1,7 @@ +* 'VAT Report' is valid only for cases where it's met that for each + Tax defined: all the "Account tags" of all the + 'Repartition for Invoices' or 'Repartition for Credit Notes' + are different. +* It would be nice to have in reports a column indicating the + state of the entries when the option "All Entries" is selected + in "Target Moves" field in a wizard diff --git a/account_financial_report/report/abstract_report_xlsx.py b/account_financial_report/report/abstract_report_xlsx.py index 31fe6eec..ce972dde 100644 --- a/account_financial_report/report/abstract_report_xlsx.py +++ b/account_financial_report/report/abstract_report_xlsx.py @@ -6,6 +6,7 @@ from odoo import models class AbstractReportXslx(models.AbstractModel): _name = "report.account_financial_report.abstract_report_xlsx" + _description = "Abstract XLSX Account Financial Report" _inherit = "report.report_xlsx.abstract" def __init__(self, pool, cr): @@ -255,7 +256,7 @@ class AbstractReportXslx(models.AbstractModel): and not isinstance(value, bool) and not isinstance(value, int) ): - value = value.strftime("%d/%m/%Y") + value = value and value.strftime("%d/%m/%Y") self.sheet.write_string(self.row_pos, col_pos, value or "") elif cell_type == "amount": if ( @@ -444,10 +445,10 @@ class AbstractReportXslx(models.AbstractModel): def _get_currency_amt_format(self, line_object): """ Return amount format specific for each currency. """ if hasattr(line_object, "account_group_id") and line_object.account_group_id: - format_amt = getattr(self, "format_amount_bold") + format_amt = self.format_amount_bold field_prefix = "format_amount_bold" else: - format_amt = getattr(self, "format_amount") + format_amt = self.format_amount field_prefix = "format_amount" if line_object.currency_id: field_name = "{}_{}".format(field_prefix, line_object.currency_id.name) @@ -455,7 +456,7 @@ class AbstractReportXslx(models.AbstractModel): format_amt = getattr(self, field_name) else: format_amt = self.workbook.add_format() - setattr(self, "field_name", format_amt) + self.field_name = format_amt format_amount = "#,##0." + ( "0" * line_object.currency_id.decimal_places ) @@ -465,10 +466,10 @@ class AbstractReportXslx(models.AbstractModel): def _get_currency_amt_format_dict(self, line_dict): """ Return amount format specific for each currency. """ if line_dict.get("account_group_id", False) and line_dict["account_group_id"]: - format_amt = getattr(self, "format_amount_bold") + format_amt = self.format_amount_bold field_prefix = "format_amount_bold" else: - format_amt = getattr(self, "format_amount") + format_amt = self.format_amount field_prefix = "format_amount" if line_dict.get("currency_id", False) and line_dict["currency_id"]: currency = self.env["res.currency"].browse([line_dict["currency_id"]]) @@ -477,14 +478,14 @@ class AbstractReportXslx(models.AbstractModel): format_amt = getattr(self, field_name) else: format_amt = self.workbook.add_format() - setattr(self, "field_name", format_amt) + self.field_name = format_amt format_amount = "#,##0." + ("0" * currency.decimal_places) format_amt.set_num_format(format_amount) return format_amt def _get_currency_amt_header_format(self, line_object): """ Return amount header format for each currency. """ - format_amt = getattr(self, "format_header_amount") + format_amt = self.format_header_amount if line_object.currency_id: field_name = "format_header_amount_%s" % line_object.currency_id.name if hasattr(self, field_name): @@ -493,7 +494,7 @@ class AbstractReportXslx(models.AbstractModel): format_amt = self.workbook.add_format( {"bold": True, "border": True, "bg_color": "#FFFFCC"} ) - setattr(self, "field_name", format_amt) + self.field_name = format_amt format_amount = "#,##0." + ( "0" * line_object.currency_id.decimal_places ) @@ -502,7 +503,7 @@ class AbstractReportXslx(models.AbstractModel): def _get_currency_amt_header_format_dict(self, line_object): """ Return amount header format for each currency. """ - format_amt = getattr(self, "format_header_amount") + format_amt = self.format_header_amount if line_object["currency_id"]: field_name = "format_header_amount_%s" % line_object["currency_name"] if hasattr(self, field_name): @@ -511,7 +512,7 @@ class AbstractReportXslx(models.AbstractModel): format_amt = self.workbook.add_format( {"bold": True, "border": True, "bg_color": "#FFFFCC"} ) - setattr(self, "field_name", format_amt) + self.field_name = format_amt format_amount = "#,##0." + ( "0" * line_object["currency_id"].decimal_places ) @@ -527,8 +528,7 @@ class AbstractReportXslx(models.AbstractModel): def _get_report_complete_name(self, report, prefix, data=None): if report.company_id: suffix = " - {} - {}".format( - report.company_id.name, - report.company_id.currency_id.name, + report.company_id.name, report.company_id.currency_id.name ) return prefix + suffix return prefix diff --git a/account_financial_report/report/aged_partner_balance.py b/account_financial_report/report/aged_partner_balance.py index ec83165c..e67d25ee 100644 --- a/account_financial_report/report/aged_partner_balance.py +++ b/account_financial_report/report/aged_partner_balance.py @@ -4,14 +4,13 @@ from datetime import date, datetime, timedelta -import pandas as pd - from odoo import api, models from odoo.tools import float_is_zero class AgedPartnerBalanceReport(models.AbstractModel): _name = "report.account_financial_report.aged_partner_balance" + _description = "Aged Partner Balance Report" @api.model def _initialize_account(self, ag_pb_data, acc_id): @@ -122,7 +121,7 @@ class AgedPartnerBalanceReport(models.AbstractModel): credit_amount[credit_move_id] = 0.0 credit_amount[credit_move_id] += account_partial_reconcile_data["amount"] account_partial_reconcile_data.update( - {"debit_move_id": debit_move_id, "credit_move_id": credit_move_id,} + {"debit_move_id": debit_move_id, "credit_move_id": credit_move_id} ) return accounts_partial_reconcile, debit_amount, credit_amount @@ -215,7 +214,6 @@ class AgedPartnerBalanceReport(models.AbstractModel): move_lines = self.env["account.move.line"].search_read( domain=domain, fields=ml_fields ) - ml_ids = set(pd.DataFrame(move_lines).id.to_list()) journals_ids = set() partners_ids = set() partners_data = {} @@ -227,9 +225,9 @@ class AgedPartnerBalanceReport(models.AbstractModel): credit_amount, ) = self._get_account_partial_reconciled(company_id, date_at_object) if acc_partial_rec: - acc_partial_rec_data = pd.DataFrame(acc_partial_rec) - debit_ids = set(acc_partial_rec_data.debit_move_id.to_list()) - credit_ids = set(acc_partial_rec_data.credit_move_id.to_list()) + ml_ids = map(lambda r: r["id"], move_lines) + debit_ids = map(lambda r: r["debit_move_id"], acc_partial_rec) + credit_ids = map(lambda r: r["credit_move_id"], acc_partial_rec) move_lines = self._recalculate_move_lines( move_lines, debit_ids, @@ -414,7 +412,6 @@ class AgedPartnerBalanceReport(models.AbstractModel): ) return aged_partner_data - @api.multi def _get_report_values(self, docids, data): wizard_id = data["wizard_id"] company = self.env["res.company"].browse(data["company_id"]) @@ -423,6 +420,7 @@ class AgedPartnerBalanceReport(models.AbstractModel): partner_ids = data["partner_ids"] date_at = data["date_at"] date_at_object = datetime.strptime(date_at, "%Y-%m-%d").date() + only_posted_moves = data["only_posted_moves"] show_move_line_details = data["show_move_line_details"] ( diff --git a/account_financial_report/report/aged_partner_balance_xlsx.py b/account_financial_report/report/aged_partner_balance_xlsx.py index 29dab602..ea2c1084 100644 --- a/account_financial_report/report/aged_partner_balance_xlsx.py +++ b/account_financial_report/report/aged_partner_balance_xlsx.py @@ -7,6 +7,7 @@ from odoo import _, models class AgedPartnerBalanceXslx(models.AbstractModel): _name = "report.a_f_r.report_aged_partner_balance_xlsx" + _description = "Aged Partner Balance XLSL Report" _inherit = "report.account_financial_report.abstract_report_xlsx" def _get_report_name(self, report, data=False): diff --git a/account_financial_report/report/general_ledger.py b/account_financial_report/report/general_ledger.py index b872062f..b427bb8c 100644 --- a/account_financial_report/report/general_ledger.py +++ b/account_financial_report/report/general_ledger.py @@ -4,15 +4,13 @@ import calendar import datetime -from operator import itemgetter - -from natsort import natsorted from odoo import api, models class GeneralLedgerReport(models.AbstractModel): _name = "report.account_financial_report.general_ledger" + _description = "General Ledger Report" def _get_accounts_data(self, account_ids): accounts = self.env["account.account"].browse(account_ids) @@ -601,7 +599,6 @@ class GeneralLedgerReport(models.AbstractModel): list_centralized_ml += list(centralized_ml[jnl_id].values()) return list_centralized_ml - @api.multi def _get_report_values(self, docids, data): wizard_id = data["wizard_id"] company = self.env["res.company"].browse(data["company_id"]) @@ -669,7 +666,7 @@ class GeneralLedgerReport(models.AbstractModel): account["move_lines"] = centralized_ml account["partners"] = False del account["list_partner"] - general_ledger = natsorted(general_ledger, key=itemgetter("code")) + general_ledger = sorted(general_ledger, key=lambda k: k["code"]) return { "doc_ids": [wizard_id], "doc_model": "general.ledger.report.wizard", diff --git a/account_financial_report/report/general_ledger_xlsx.py b/account_financial_report/report/general_ledger_xlsx.py index 2ef805d1..bfe8c112 100644 --- a/account_financial_report/report/general_ledger_xlsx.py +++ b/account_financial_report/report/general_ledger_xlsx.py @@ -8,6 +8,7 @@ from odoo import _, models class GeneralLedgerXslx(models.AbstractModel): _name = "report.a_f_r.report_general_ledger_xlsx" + _description = "General Ledger XLSL Report" _inherit = "report.account_financial_report.abstract_report_xlsx" def _get_report_name(self, report, data=False): @@ -93,7 +94,7 @@ class GeneralLedgerXslx(models.AbstractModel): _("Account balance at 0 filter"), _("Hide") if report.hide_account_at_0 else _("Show"), ], - [_("Centralize filter"), _("Yes") if report.centralize else _("No"),], + [_("Centralize filter"), _("Yes") if report.centralize else _("No")], [ _("Show analytic tags"), _("Yes") if report.show_analytic_tags else _("No"), @@ -119,6 +120,7 @@ class GeneralLedgerXslx(models.AbstractModel): def _get_col_pos_final_balance_label(self): return 5 + # flake8: noqa: C901 def _generate_report_content(self, workbook, report, data): res_data = self.env[ "report.account_financial_report.general_ledger" @@ -152,7 +154,7 @@ class GeneralLedgerXslx(models.AbstractModel): ) if foreign_currency: account.update( - {"initial_bal_curr": account["init_bal"]["bal_curr"],} + {"initial_bal_curr": account["init_bal"]["bal_curr"]} ) self.write_initial_balance_from_dict(account) @@ -184,7 +186,7 @@ class GeneralLedgerXslx(models.AbstractModel): for tag_id in line["tag_ids"]: tags += tags_data[tag_id]["name"] + " " line.update( - {"taxes_description": taxes_description, "tags": tags,} + {"taxes_description": taxes_description, "tags": tags} ) self.write_line_from_dict(line) @@ -210,7 +212,7 @@ class GeneralLedgerXslx(models.AbstractModel): ) if foreign_currency: partner.update( - {"initial_bal_culrr": partner["init_bal"]["bal_curr"],} + {"initial_bal_culrr": partner["init_bal"]["bal_curr"]} ) self.write_initial_balance_from_dict(partner) @@ -235,7 +237,7 @@ class GeneralLedgerXslx(models.AbstractModel): for tag_id in line["tag_ids"]: tags += tags_data[tag_id]["name"] + " " line.update( - {"taxes_description": taxes_description, "tags": tags,} + {"taxes_description": taxes_description, "tags": tags} ) self.write_line_from_dict(line) @@ -249,7 +251,7 @@ class GeneralLedgerXslx(models.AbstractModel): ) if foreign_currency: partner.update( - {"final_bal_curr": partner["fin_bal"]["bal_curr"],} + {"final_bal_curr": partner["fin_bal"]["bal_curr"]} ) self.write_ending_balance_from_dict(partner) @@ -266,9 +268,7 @@ class GeneralLedgerXslx(models.AbstractModel): } ) if foreign_currency: - account.update( - {"final_bal_curr": account["fin_bal"]["bal_curr"],} - ) + account.update({"final_bal_curr": account["fin_bal"]["bal_curr"]}) self.write_ending_balance_from_dict(account) # 2 lines break diff --git a/account_financial_report/report/journal_ledger.py b/account_financial_report/report/journal_ledger.py index 2693c312..6ee75ccd 100644 --- a/account_financial_report/report/journal_ledger.py +++ b/account_financial_report/report/journal_ledger.py @@ -4,11 +4,12 @@ import itertools import operator -from odoo import api, models +from odoo import models class JournalLedgerReport(models.AbstractModel): _name = "report.account_financial_report.journal_ledger" + _description = "Journal Ledger Report" def _get_journal_ledger_data(self, journal): return { @@ -79,9 +80,7 @@ class JournalLedgerReport(models.AbstractModel): def _get_move_lines_domain(self, move_ids, wizard, journal_ids): - return [ - ("move_id", "in", move_ids), - ] + return [("move_id", "in", move_ids)] def _get_move_lines_order(self, move_ids, wizard, journal_ids): return "" @@ -140,9 +139,7 @@ class JournalLedgerReport(models.AbstractModel): return data def _get_partner_id_data(self, partner): - return { - "name": partner.name, - } + return {"name": partner.name} def _get_currency_data(self, currencies): data = {} @@ -151,9 +148,7 @@ class JournalLedgerReport(models.AbstractModel): return data def _get_currency_id_data(self, currency): - return { - "name": currency.name, - } + return {"name": currency.name} def _get_tax_line_data(self, taxes): data = {} @@ -162,10 +157,7 @@ class JournalLedgerReport(models.AbstractModel): return data def _get_tax_line_id_data(self, tax): - return { - "name": tax.name, - "description": tax.description, - } + return {"name": tax.name, "description": tax.description} def _get_query_taxes(self): return """ @@ -178,33 +170,32 @@ class JournalLedgerReport(models.AbstractModel): """ def _get_query_taxes_params(self, move_lines): - return { - "move_line_ids": tuple(move_lines.ids), - } + return {"move_line_ids": tuple(move_lines.ids)} def _get_move_lines(self, move_ids, wizard, journal_ids): move_lines = self.env["account.move.line"].search( self._get_move_lines_domain(move_ids, wizard, journal_ids), order=self._get_move_lines_order(move_ids, wizard, journal_ids), ) - # Get the taxes ids for the move lines - query_taxes_params = self._get_query_taxes_params(move_lines) - query_taxes = self._get_query_taxes() move_line_ids_taxes_data = {} - self.env.cr.execute(query_taxes, query_taxes_params) - # Fetch the taxes associated to the move line - for ( - move_line_id, - account_tax_id, - tax_description, - tax_name, - ) in self.env.cr.fetchall(): - if move_line_id not in move_line_ids_taxes_data.keys(): - move_line_ids_taxes_data[move_line_id] = {} - move_line_ids_taxes_data[move_line_id][account_tax_id] = { - "name": tax_name, - "description": tax_description, - } + if move_lines: + # Get the taxes ids for the move lines + query_taxes_params = self._get_query_taxes_params(move_lines) + query_taxes = self._get_query_taxes() + self.env.cr.execute(query_taxes, query_taxes_params) + # Fetch the taxes associated to the move line + for ( + move_line_id, + account_tax_id, + tax_description, + tax_name, + ) in self.env.cr.fetchall(): + if move_line_id not in move_line_ids_taxes_data.keys(): + move_line_ids_taxes_data[move_line_id] = {} + move_line_ids_taxes_data[move_line_id][account_tax_id] = { + "name": tax_name, + "description": tax_description, + } Move_Lines = {} accounts = self.env["account.account"] partners = self.env["res.partner"] @@ -292,7 +283,6 @@ class JournalLedgerReport(models.AbstractModel): ] return journals_taxes_data_2 - @api.multi def _get_report_values(self, docids, data): wizard_id = data["wizard_id"] wizard = self.env["journal.ledger.report.wizard"].browse(wizard_id) @@ -313,15 +303,12 @@ class JournalLedgerReport(models.AbstractModel): partner_ids_data ) = currency_ids_data = tax_line_ids_data = move_line_ids_taxes_data = {} if move_ids: - ( - move_line_ids, - move_lines_data, - account_ids_data, - partner_ids_data, - currency_ids_data, - tax_line_ids_data, - move_line_ids_taxes_data, - ) = self._get_move_lines(move_ids, wizard, journal_ids) + move_lines = self._get_move_lines(move_ids, wizard, journal_ids) + move_lines_data = move_lines[1] + account_ids_data = move_lines[2] + partner_ids_data = move_lines[3] + currency_ids_data = move_lines[4] + tax_line_ids_data = move_lines[5] for move_data in moves_data: move_id = move_data["move_id"] move_data["report_move_lines"] = [] @@ -338,10 +325,7 @@ class JournalLedgerReport(models.AbstractModel): for move_line_data in move_lines_data[move_id]: journal_id = move_line_data["journal_id"] if journal_id not in journal_totals.keys(): - journal_totals[journal_id] = { - "debit": 0.0, - "credit": 0.0, - } + journal_totals[journal_id] = {"debit": 0.0, "credit": 0.0} for item in ["debit", "credit"]: journal_totals[journal_id][item] += move_line_data[item] for journal_ledger_data in journal_ledgers_data: diff --git a/account_financial_report/report/journal_ledger_xlsx.py b/account_financial_report/report/journal_ledger_xlsx.py index 5728e97a..104c531e 100644 --- a/account_financial_report/report/journal_ledger_xlsx.py +++ b/account_financial_report/report/journal_ledger_xlsx.py @@ -8,6 +8,7 @@ from odoo import _, models class JournalLedgerXslx(models.AbstractModel): _name = "report.a_f_r.report_journal_ledger_xlsx" + _description = "Journal Ledger XLSX Report" _inherit = "report.account_financial_report.abstract_report_xlsx" def _get_report_name(self, report, data=False): @@ -35,7 +36,7 @@ class JournalLedgerXslx(models.AbstractModel): {"header": _("Partner"), "field": "partner", "width": 25}, {"header": _("Ref - Label"), "field": "label", "width": 40}, {"header": _("Taxes"), "field": "taxes_description", "width": 11}, - {"header": _("Debit"), "field": "debit", "type": "amount", "width": 14,}, + {"header": _("Debit"), "field": "debit", "type": "amount", "width": 14}, {"header": _("Credit"), "field": "credit", "type": "amount", "width": 14}, ] @@ -188,7 +189,9 @@ class JournalLedgerXslx(models.AbstractModel): and journal.currency_id.name or journal.company_id.currency_id.name ) - sheet_name = "Tax - {} ({}) - {}".format(journal.code, currency_name, journal.name) + sheet_name = "Tax - {} ({}) - {}".format( + journal.code, currency_name, journal.name + ) self._generate_taxes_summary(workbook, sheet_name, ledger["tax_lines"]) def _generate_moves_content(self, workbook, sheet_name, report, res_data, moves): diff --git a/account_financial_report/report/open_items.py b/account_financial_report/report/open_items.py index 7750bbee..f9f5143f 100644 --- a/account_financial_report/report/open_items.py +++ b/account_financial_report/report/open_items.py @@ -4,8 +4,6 @@ from datetime import date, datetime -import pandas as pd - from odoo import api, models from odoo.osv import expression from odoo.tools import float_is_zero @@ -13,6 +11,7 @@ from odoo.tools import float_is_zero class OpenItemsReport(models.AbstractModel): _name = "report.account_financial_report.open_items" + _description = "Open Items Report" @api.model def get_html(self, given_context=None): @@ -63,7 +62,7 @@ class OpenItemsReport(models.AbstractModel): credit_move_id ] += account_partial_reconcile_data["amount"] account_partial_reconcile_data.update( - {"debit_move_id": debit_move_id, "credit_move_id": credit_move_id,} + {"debit_move_id": debit_move_id, "credit_move_id": credit_move_id} ) return ( accounts_partial_reconcile, @@ -188,6 +187,7 @@ class OpenItemsReport(models.AbstractModel): journals_data.update({journal.id: {"id": journal.id, "code": journal.code}}) return journals_data + # flake8: noqa: C901 def _get_data( self, account_ids, @@ -201,12 +201,11 @@ class OpenItemsReport(models.AbstractModel): account_ids, partner_ids, date_at_object, target_move, company_id, date_from ) self._cr.execute(query) - move_lines_data = pd.DataFrame(self._cr.dictfetchall()) - account_ids = set(move_lines_data.account_id.to_list()) + move_lines_data = self._cr.dictfetchall() + account_ids = map(lambda r: r["account_id"], move_lines_data) accounts_data = self._get_accounts_data(list(account_ids)) - journal_ids = set(move_lines_data.journal_id.to_list()) + journal_ids = map(lambda r: r["journal_id"], move_lines_data) journals_data = self._get_journals_data(list(journal_ids)) - move_lines_data = move_lines_data.fillna(0).to_dict(orient="records") if date_at_object < date.today(): ( @@ -215,12 +214,11 @@ class OpenItemsReport(models.AbstractModel): credit_accounts_partial_amount, ) = self._get_account_partial_reconciled(move_lines_data, date_at_object) if accounts_partial_reconcile: - accounts_partial_reconcile_data = pd.DataFrame( - accounts_partial_reconcile + debit_ids = map( + operator.itemgetter("debit_move_id"), accounts_partial_reconcile ) - debit_ids = set(accounts_partial_reconcile_data.debit_move_id.to_list()) - credit_ids = set( - accounts_partial_reconcile_data.credit_move_id.to_list() + credit_ids = map( + operator.itemgetter("credit_move_id"), accounts_partial_reconcile ) for move_line in move_lines_data: if move_line["id"] in debit_ids: @@ -245,7 +243,7 @@ class OpenItemsReport(models.AbstractModel): for move_line in move_lines_data: no_partner = True # Partners data - if move_line["partner_id"] and not pd.isna(move_line["partner_id"]): + if move_line["partner_id"]: no_partner = False partners_data.update( { @@ -270,11 +268,11 @@ class OpenItemsReport(models.AbstractModel): original = move_line["credit"] * (-1) if not float_is_zero(move_line["debit"], precision_digits=2): original = move_line["debit"] - move_line.update( { "date": move_line["date"].strftime("%d/%m/%Y"), - "date_maturity": move_line["date_maturity"].strftime("%d/%m/%Y"), + "date_maturity": move_line["date_maturity"] + and move_line["date_maturity"].strftime("%d/%m/%Y"), "original": original, "partner_id": 0 if no_partner else move_line["partner_id"], "partner_name": "" if no_partner else move_line["partner_name"], @@ -325,7 +323,6 @@ class OpenItemsReport(models.AbstractModel): total_amount[account_id]["residual"] += move_line["amount_residual"] return total_amount - @api.multi def _get_report_values(self, docids, data): wizard_id = data["wizard_id"] company = self.env["res.company"].browse(data["company_id"]) diff --git a/account_financial_report/report/open_items_xlsx.py b/account_financial_report/report/open_items_xlsx.py index 781a46f1..36f8677a 100644 --- a/account_financial_report/report/open_items_xlsx.py +++ b/account_financial_report/report/open_items_xlsx.py @@ -7,6 +7,7 @@ from odoo import _, models class OpenItemsXslx(models.AbstractModel): _name = "report.a_f_r.report_open_items_xlsx" + _description = "Open Items XLSX Report" _inherit = "report.account_financial_report.abstract_report_xlsx" def _get_report_name(self, report, data=False): diff --git a/account_financial_report/report/trial_balance.py b/account_financial_report/report/trial_balance.py index 3e8b4977..f5c9853a 100644 --- a/account_financial_report/report/trial_balance.py +++ b/account_financial_report/report/trial_balance.py @@ -5,13 +5,12 @@ from operator import itemgetter -from natsort import natsorted - from odoo import api, models class TrialBalanceReport(models.AbstractModel): _name = "report.account_financial_report.trial_balance" + _description = "Trial Balance Report" @api.model def get_html(self, given_context=None): @@ -203,6 +202,7 @@ class TrialBalanceReport(models.AbstractModel): pl_initial_currency_balance += initial_balance["amount_currency"] return pl_initial_balance, pl_initial_currency_balance + # flake8: noqa: C901 def _get_data( self, account_ids, @@ -343,7 +343,7 @@ class TrialBalanceReport(models.AbstractModel): prt_id = tb["partner_id"][0] if tb["partner_id"] not in partners_ids: partners_data.update( - {prt_id: {"id": prt_id, "name": tb["partner_id"][1],}} + {prt_id: {"id": prt_id, "name": tb["partner_id"][1]}} ) total_amount[acc_id][prt_id] = {} total_amount[acc_id][prt_id]["credit"] = tb["credit"] @@ -363,7 +363,7 @@ class TrialBalanceReport(models.AbstractModel): prt_id = tb["partner_id"][0] if tb["partner_id"] not in partners_ids: partners_data.update( - {prt_id: {"id": prt_id, "name": tb["partner_id"][1],}} + {prt_id: {"id": prt_id, "name": tb["partner_id"][1]}} ) if acc_id not in total_amount.keys(): total_amount[acc_id][prt_id] = {} @@ -620,7 +620,6 @@ class TrialBalanceReport(models.AbstractModel): ] += total_amount[acc_id]["ending_currency_balance"] return groups_data - @api.multi def _get_report_values(self, docids, data): show_partner_details = data["show_partner_details"] wizard_id = data["wizard_id"] @@ -682,9 +681,7 @@ class TrialBalanceReport(models.AbstractModel): ) trial_balance = list(groups_data.values()) trial_balance += list(accounts_data.values()) - trial_balance = natsorted( - trial_balance, key=itemgetter("complete_code", "code") - ) + trial_balance = sorted(trial_balance, key=lambda k: k["complete_code"]) for trial in trial_balance: counter = trial["complete_code"].count("/") trial["level"] = counter @@ -694,10 +691,10 @@ class TrialBalanceReport(models.AbstractModel): ) trial_balance = list(groups_data.values()) trial_balance += list(accounts_data.values()) - trial_balance = natsorted(trial_balance, key=itemgetter("code")) + trial_balance = sorted(trial_balance, key=lambda k: k["code"]) if hierarchy_on == "none": trial_balance = list(accounts_data.values()) - trial_balance = natsorted(trial_balance, key=itemgetter("code")) + trial_balance = sorted(trial_balance, key=lambda k: k["code"]) else: if foreign_currency: for account_id in accounts_data.keys(): diff --git a/account_financial_report/report/trial_balance_xlsx.py b/account_financial_report/report/trial_balance_xlsx.py index 31c02ed8..dc34af9c 100644 --- a/account_financial_report/report/trial_balance_xlsx.py +++ b/account_financial_report/report/trial_balance_xlsx.py @@ -8,6 +8,7 @@ from odoo import _, models class TrialBalanceXslx(models.AbstractModel): _name = "report.a_f_r.report_trial_balance_xlsx" + _description = "Trial Balance XLSX Report" _inherit = "report.account_financial_report.abstract_report_xlsx" def _get_report_name(self, report, data=False): diff --git a/account_financial_report/report/vat_report.py b/account_financial_report/report/vat_report.py index 5a0a123a..7789a917 100644 --- a/account_financial_report/report/vat_report.py +++ b/account_financial_report/report/vat_report.py @@ -7,6 +7,7 @@ from odoo import api, models class VATReport(models.AbstractModel): _name = "report.account_financial_report.vat_report" + _description = "Vat Report Report" def _get_tax_data(self, tax_ids): taxes = self.env["account.tax"].browse(tax_ids) @@ -18,7 +19,6 @@ class VATReport(models.AbstractModel): "id": tax.id, "name": tax.name, "tax_group_id": tax.tax_group_id.id, - "tags_ids": tax.tag_ids.ids, } } ) @@ -42,15 +42,19 @@ class VATReport(models.AbstractModel): "tax_base_amount", "balance", "tax_line_id", + "tax_repartition_line_id", "analytic_tag_ids", ] tax_move_lines = self.env["account.move.line"].search_read( - domain=domain, fields=ml_fields, + domain=domain, fields=ml_fields ) vat_data = {} tax_ids = set() for tax_move_line in tax_move_lines: tax_ml_id = tax_move_line["id"] + repartition = self.env["account.tax.repartition.line"].browse( + tax_move_line["tax_repartition_line_id"][0] + ) vat_data[tax_ml_id] = {} vat_data[tax_ml_id].update( { @@ -60,6 +64,7 @@ class VATReport(models.AbstractModel): if tax_move_line["balance"] > 0 else (-1) * tax_move_line["balance"], "tax_line_id": tax_move_line["tax_line_id"], + "tags_ids": repartition.tag_ids.ids, } ) tax_ids.add(tax_move_line["tax_line_id"][0]) @@ -90,11 +95,11 @@ class VATReport(models.AbstractModel): vat_report[tax_group_id] = {} vat_report[tax_group_id]["net"] = 0.0 vat_report[tax_group_id]["tax"] = 0.0 - vat_report[tax_group_id][tax_id] = tax_data[tax_id] + vat_report[tax_group_id][tax_id] = dict(tax_data[tax_id]) vat_report[tax_group_id][tax_id].update({"net": 0.0, "tax": 0.0}) else: if tax_id not in vat_report[tax_group_id].keys(): - vat_report[tax_group_id][tax_id] = tax_data[tax_id] + vat_report[tax_group_id][tax_id] = dict(tax_data[tax_id]) vat_report[tax_group_id][tax_id].update({"net": 0.0, "tax": 0.0}) vat_report[tax_group_id]["net"] += tax_move_line["net"] vat_report[tax_group_id]["tax"] += tax_move_line["tax"] @@ -126,18 +131,18 @@ class VATReport(models.AbstractModel): vat_report = {} for tax_move_line in vat_report_data.values(): tax_id = tax_move_line["tax_line_id"][0] - tags_ids = tax_data[tax_id]["tags_ids"] + tags_ids = tax_move_line["tags_ids"] if tags_ids: for tag_id in tags_ids: if tag_id not in vat_report.keys(): vat_report[tag_id] = {} vat_report[tag_id]["net"] = 0.0 vat_report[tag_id]["tax"] = 0.0 - vat_report[tag_id][tax_id] = tax_data[tax_id] + vat_report[tag_id][tax_id] = dict(tax_data[tax_id]) vat_report[tag_id][tax_id].update({"net": 0.0, "tax": 0.0}) else: if tax_id not in vat_report[tag_id].keys(): - vat_report[tag_id][tax_id] = tax_data[tax_id] + vat_report[tag_id][tax_id] = dict(tax_data[tax_id]) vat_report[tag_id][tax_id].update({"net": 0.0, "tax": 0.0}) vat_report[tag_id][tax_id]["net"] += tax_move_line["net"] vat_report[tag_id][tax_id]["tax"] += tax_move_line["tax"] @@ -156,7 +161,6 @@ class VATReport(models.AbstractModel): vat_report_list.append(vat_report[tag_id]) return vat_report_list - @api.multi def _get_report_values(self, docids, data): wizard_id = data["wizard_id"] company = self.env["res.company"].browse(data["company_id"]) diff --git a/account_financial_report/report/vat_report_xlsx.py b/account_financial_report/report/vat_report_xlsx.py index b5c73e30..75f2f30c 100644 --- a/account_financial_report/report/vat_report_xlsx.py +++ b/account_financial_report/report/vat_report_xlsx.py @@ -6,6 +6,7 @@ from odoo import _, models class VATReportXslx(models.AbstractModel): _name = "report.a_f_r.report_vat_report_xlsx" + _description = "Vat Report XLSX Report" _inherit = "report.account_financial_report.abstract_report_xlsx" def _get_report_name(self, report, data): diff --git a/account_financial_report/static/description/index.html b/account_financial_report/static/description/index.html index 8f939aa2..b5a3d408 100644 --- a/account_financial_report/static/description/index.html +++ b/account_financial_report/static/description/index.html @@ -367,9 +367,9 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/account-financial-reporting Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/account-financial-reporting Translate me on Weblate Try me on Runbot

This module adds a set of financial reports. They are accessible under -Accounting / Reporting / OCA Reports.

+Invoicing / Reporting / OCA accounting reports.

  • General ledger
  • Trial Balance
  • @@ -386,31 +386,41 @@ currency balances are not available.

    Table of contents

    +
    +

    Known issues / Roadmap

    +
      +
    • ‘VAT Report’ is valid only for cases where it’s met that for each +Tax defined: all the “Account tags” of all the +‘Repartition for Invoices’ or ‘Repartition for Credit Notes’ +are different.
    • +
    +
    -

    Changelog

    +

    Changelog

    -

    11.0.2.5.0 (2019-04-26)

    +

    11.0.2.5.0 (2019-04-26)

    • In the Trial Balance you have an option to hide parent hierarchy levels
    -

    11.0.2.4.1 (2019-01-08)

    +

    11.0.2.4.1 (2019-01-08)

    • Handle better multicompany behaviour
    • Improve how title appears in the reports
    • @@ -418,7 +428,7 @@ currency balances are not available.

    -

    11.0.2.3.1 (2018-11-29)

    +

    11.0.2.3.1 (2018-11-29)

    • In the Trial Balance you can apply a filter by hierarchy levels
    • In the General Ledger you can apply a filter by Analytic Tag
    • @@ -427,28 +437,28 @@ currency balances are not available.

    -

    Bug Tracker

    +

    Bug Tracker

    Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

    +feedback.

    Do not contact contributors directly about support or help with technical issues.

    -

    Credits

    +

    Credits

    -

    Authors

    +

    Authors

    • Camptocamp SA
    • initOS GmbH
    • redCOR AG
    • -
    • Eficent
    • +
    • ForgeFlow
    -

    Contributors

    +

    Contributors

    @@ -475,13 +487,13 @@ If you spotted it first, help us smashing it by providing a detailed and welcome April 2016.

    -

    Maintainers

    +

    Maintainers

    This module is maintained by the OCA.

    Odoo Community Association

    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.

    -

    This module is part of the OCA/account-financial-reporting project on GitHub.

    +

    This module is part of the OCA/account-financial-reporting project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/account_financial_report/tests/test_general_ledger.py b/account_financial_report/tests/test_general_ledger.py index d90a85ab..54e0cca9 100644 --- a/account_financial_report/tests/test_general_ledger.py +++ b/account_financial_report/tests/test_general_ledger.py @@ -18,6 +18,7 @@ class TestGeneralLedgerReport(common.TransactionCase): self.previous_fy_date_end = fields.Date.from_string("2015-12-31") self.fy_date_start = fields.Date.from_string("2016-01-01") self.fy_date_end = fields.Date.from_string("2016-12-31") + self.receivable_account = self.env["account.account"].search( [("user_type_id.name", "=", "Receivable")], limit=1 ) @@ -46,19 +47,16 @@ class TestGeneralLedgerReport(common.TransactionCase): unaffected_debit=0, unaffected_credit=0, ): - move_name = "expense accrual" journal = self.env["account.journal"].search([], limit=1) partner = self.env.ref("base.res_partner_12") move_vals = { "journal_id": journal.id, - "name": move_name, "date": date, "line_ids": [ ( 0, 0, { - "name": move_name, "debit": receivable_debit, "credit": receivable_credit, "account_id": self.receivable_account.id, @@ -69,7 +67,6 @@ class TestGeneralLedgerReport(common.TransactionCase): 0, 0, { - "name": move_name, "debit": income_debit, "credit": income_credit, "account_id": self.income_account.id, @@ -80,7 +77,6 @@ class TestGeneralLedgerReport(common.TransactionCase): 0, 0, { - "name": move_name, "debit": unaffected_debit, "credit": unaffected_credit, "account_id": self.unaffected_account.id, @@ -678,9 +674,7 @@ class TestGeneralLedgerReport(common.TransactionCase): def test_validate_date(self): company_id = self.env.ref("base.main_company") - company_id.write( - {"fiscalyear_last_day": 31, "fiscalyear_last_month": 12,} - ) + company_id.write({"fiscalyear_last_day": 31, "fiscalyear_last_month": "12"}) user = self.env.ref("base.user_root").with_context(company_id=company_id.id) wizard = self.env["general.ledger.report.wizard"].with_context(user=user.id) self.assertEqual(wizard._init_date_from(), time.strftime("%Y") + "-01-01") diff --git a/account_financial_report/tests/test_journal_ledger.py b/account_financial_report/tests/test_journal_ledger.py index 6a07186e..ba83a70a 100644 --- a/account_financial_report/tests/test_journal_ledger.py +++ b/account_financial_report/tests/test_journal_ledger.py @@ -7,14 +7,14 @@ from datetime import datetime from dateutil.relativedelta import relativedelta from odoo.fields import Date -from odoo.tests.common import TransactionCase +from odoo.tests.common import Form, TransactionCase class TestJournalReport(TransactionCase): def setUp(self): super(TestJournalReport, self).setUp() self.AccountObj = self.env["account.account"] - self.InvoiceObj = self.env["account.invoice"] + self.InvoiceObj = self.env["account.move"] self.JournalObj = self.env["account.journal"] self.MoveObj = self.env["account.move"] self.TaxObj = self.env["account.tax"] @@ -24,6 +24,8 @@ class TestJournalReport(TransactionCase): "report.account_financial_report.journal_ledger" ] self.company = self.env.ref("base.main_company") + self.company.account_sale_tax_id = False + self.company.account_purchase_tax_id = False today = datetime.today() last_year = today - relativedelta(years=1) @@ -39,6 +41,9 @@ class TestJournalReport(TransactionCase): self.income_account = self.AccountObj.search( [("user_type_id.name", "=", "Income")], limit=1 ) + self.expense_account = self.AccountObj.search( + [("user_type_id.name", "=", "Expenses")], limit=1 + ) self.payable_account = self.AccountObj.search( [("user_type_id.name", "=", "Payable")], limit=1 ) @@ -55,7 +60,7 @@ class TestJournalReport(TransactionCase): { "name": "Test journal purchase", "code": "TST-JRNL-P", - "type": "sale", + "type": "purchase", "company_id": self.company.id, } ) @@ -194,6 +199,7 @@ class TestJournalReport(TransactionCase): "date_to": self.fy_date_end, "company_id": self.company.id, "journal_ids": [(6, 0, self.journal_sale.ids)], + "move_target": "all", } ) data = wiz._prepare_report_journal_ledger() @@ -227,39 +233,26 @@ class TestJournalReport(TransactionCase): self.check_report_journal_debit_credit(res_data, 300, 300) def test_02_test_taxes_out_invoice(self): - invoice_values = { - "journal_id": self.journal_sale.id, - "partner_id": self.partner_2.id, - "type": "out_invoice", - "invoice_line_ids": [ - ( - 0, - 0, - { - "quantity": 1.0, - "price_unit": 100, - "account_id": self.receivable_account.id, - "name": "Test", - "invoice_line_tax_ids": [(6, 0, [self.tax_15_s.id])], - }, - ), - ( - 0, - 0, - { - "quantity": 1.0, - "price_unit": 100, - "account_id": self.receivable_account.id, - "name": "Test", - "invoice_line_tax_ids": [ - (6, 0, [self.tax_15_s.id, self.tax_20_s.id]) - ], - }, - ), - ], - } - invoice = self.InvoiceObj.create(invoice_values) - invoice.action_invoice_open() + move_form = Form( + self.env["account.move"].with_context(default_type="out_invoice") + ) + move_form.partner_id = self.partner_2 + move_form.journal_id = self.journal_sale + with move_form.invoice_line_ids.new() as line_form: + line_form.name = "test" + line_form.quantity = 1.0 + line_form.price_unit = 100 + line_form.account_id = self.income_account + line_form.tax_ids.add(self.tax_15_s) + with move_form.invoice_line_ids.new() as line_form: + line_form.name = "test" + line_form.quantity = 1.0 + line_form.price_unit = 100 + line_form.account_id = self.income_account + line_form.tax_ids.add(self.tax_15_s) + line_form.tax_ids.add(self.tax_20_s) + invoice = move_form.save() + invoice.post() wiz = self.JournalLedgerReportWizard.create( { @@ -267,6 +260,7 @@ class TestJournalReport(TransactionCase): "date_to": self.fy_date_end, "company_id": self.company.id, "journal_ids": [(6, 0, self.journal_sale.ids)], + "move_target": "all", } ) data = wiz._prepare_report_journal_ledger() @@ -275,46 +269,68 @@ class TestJournalReport(TransactionCase): self.check_report_journal_debit_credit_taxes(res_data, 0, 300, 0, 50) def test_03_test_taxes_in_invoice(self): - invoice_values = { - "journal_id": self.journal_sale.id, - "partner_id": self.partner_2.id, - "type": "in_invoice", - "invoice_line_ids": [ - ( - 0, - 0, - { - "quantity": 1.0, - "price_unit": 100, - "account_id": self.payable_account.id, - "name": "Test", - "invoice_line_tax_ids": [(6, 0, [self.tax_15_p.id])], - }, - ), - ( - 0, - 0, - { - "quantity": 1.0, - "price_unit": 100, - "account_id": self.payable_account.id, - "name": "Test", - "invoice_line_tax_ids": [ - (6, 0, [self.tax_15_p.id, self.tax_20_p.id]) - ], - }, - ), - ], - } - invoice = self.InvoiceObj.create(invoice_values) - invoice.action_invoice_open() + # invoice_values = { + # "journal_id": self.journal_purchase.id, + # "partner_id": self.partner_2.id, + # "type": "in_invoice", + # "invoice_line_ids": [ + # ( + # 0, + # 0, + # { + # "quantity": 1.0, + # "price_unit": 100, + # "account_id": self.payable_account.id, + # "name": "Test", + # "tax_ids": [(6, 0, [self.tax_15_p.id])], + # }, + # ), + # ( + # 0, + # 0, + # { + # "quantity": 1.0, + # "price_unit": 100, + # "account_id": self.payable_account.id, + # "name": "Test", + # "tax_ids": [ + # (6, 0, [self.tax_15_p.id, self.tax_20_p.id]) + # ], + # }, + # ), + # ], + # } + # invoice = self.InvoiceObj.create(invoice_values) + # invoice.post() + + move_form = Form( + self.env["account.move"].with_context(default_type="in_invoice") + ) + move_form.partner_id = self.partner_2 + move_form.journal_id = self.journal_purchase + with move_form.invoice_line_ids.new() as line_form: + line_form.name = "test" + line_form.quantity = 1.0 + line_form.price_unit = 100 + line_form.account_id = self.expense_account + line_form.tax_ids.add(self.tax_15_p) + with move_form.invoice_line_ids.new() as line_form: + line_form.name = "test" + line_form.quantity = 1.0 + line_form.price_unit = 100 + line_form.account_id = self.expense_account + line_form.tax_ids.add(self.tax_15_p) + line_form.tax_ids.add(self.tax_20_p) + invoice = move_form.save() + invoice.post() wiz = self.JournalLedgerReportWizard.create( { "date_from": self.fy_date_start, "date_to": self.fy_date_end, "company_id": self.company.id, - "journal_ids": [(6, 0, self.journal_sale.ids)], + "journal_ids": [(6, 0, self.journal_purchase.ids)], + "move_target": "all", } ) data = wiz._prepare_report_journal_ledger() diff --git a/account_financial_report/tests/test_trial_balance.py b/account_financial_report/tests/test_trial_balance.py index ef00c935..57d132ac 100644 --- a/account_financial_report/tests/test_trial_balance.py +++ b/account_financial_report/tests/test_trial_balance.py @@ -92,19 +92,16 @@ class TestTrialBalanceReport(common.TransactionCase): unaffected_debit=0, unaffected_credit=0, ): - move_name = "expense accrual" journal = self.env["account.journal"].search([], limit=1) partner = self.env.ref("base.res_partner_12") move_vals = { "journal_id": journal.id, - "name": move_name, "date": date, "line_ids": [ ( 0, 0, { - "name": move_name, "debit": receivable_debit, "credit": receivable_credit, "partner_id": partner.id, @@ -115,7 +112,6 @@ class TestTrialBalanceReport(common.TransactionCase): 0, 0, { - "name": move_name, "debit": income_debit, "credit": income_credit, "partner_id": partner.id, @@ -126,7 +122,6 @@ class TestTrialBalanceReport(common.TransactionCase): 0, 0, { - "name": move_name, "debit": unaffected_debit, "credit": unaffected_credit, "partner_id": partner.id, @@ -137,7 +132,6 @@ class TestTrialBalanceReport(common.TransactionCase): 0, 0, { - "name": move_name, "debit": receivable_debit, "credit": receivable_credit, "partner_id": partner.id, @@ -148,7 +142,6 @@ class TestTrialBalanceReport(common.TransactionCase): 0, 0, { - "name": move_name, "debit": receivable_credit, "credit": receivable_debit, "partner_id": partner.id, @@ -240,8 +233,8 @@ class TestTrialBalanceReport(common.TransactionCase): return total def test_00_account_group(self): - self.assertGreaterEqual(len(self.group1.compute_account_ids), 19) - self.assertGreaterEqual(len(self.group2.compute_account_ids), 9) + self.assertTrue(self.account100 in self.group1.compute_account_ids) + self.assertTrue(self.account200 in self.group2.compute_account_ids) def test_01_account_balance_computed(self): # Make sure there's no account of type "Current Year Earnings" in the @@ -660,32 +653,20 @@ class TestTrialBalanceReport(common.TransactionCase): def test_04_undistributed_pl(self): # Add a P&L Move in the previous FY - move_name = "current year pl move" journal = self.env["account.journal"].search([], limit=1) move_vals = { "journal_id": journal.id, - "name": move_name, "date": self.previous_fy_date_end, "line_ids": [ ( 0, 0, - { - "name": move_name, - "debit": 0.0, - "credit": 1000.0, - "account_id": self.account300.id, - }, + {"debit": 0.0, "credit": 1000.0, "account_id": self.account300.id}, ), ( 0, 0, - { - "name": move_name, - "debit": 1000.0, - "credit": 0.0, - "account_id": self.account100.id, - }, + {"debit": 1000.0, "credit": 0.0, "account_id": self.account100.id}, ), ], } @@ -724,32 +705,20 @@ class TestTrialBalanceReport(common.TransactionCase): self.assertEqual(unaffected_lines["credit"], 0) self.assertEqual(unaffected_lines["final_balance"], -1000) # Add a P&L Move to the current FY - move_name = "current year pl move" journal = self.env["account.journal"].search([], limit=1) move_vals = { "journal_id": journal.id, - "name": move_name, "date": self.date_start, "line_ids": [ ( 0, 0, - { - "name": move_name, - "debit": 0.0, - "credit": 1000.0, - "account_id": self.account300.id, - }, + {"debit": 0.0, "credit": 1000.0, "account_id": self.account300.id}, ), ( 0, 0, - { - "name": move_name, - "debit": 1000.0, - "credit": 0.0, - "account_id": self.account100.id, - }, + {"debit": 1000.0, "credit": 0.0, "account_id": self.account100.id}, ), ], } @@ -788,32 +757,20 @@ class TestTrialBalanceReport(common.TransactionCase): self.assertEqual(unaffected_lines["credit"], 0) self.assertEqual(unaffected_lines["final_balance"], -1000) # Add a Move including Unaffected Earnings to the current FY - move_name = "current year unaffected earnings move" journal = self.env["account.journal"].search([], limit=1) move_vals = { "journal_id": journal.id, - "name": move_name, "date": self.date_start, "line_ids": [ ( 0, 0, - { - "name": move_name, - "debit": 0.0, - "credit": 1000.0, - "account_id": self.account110.id, - }, + {"debit": 0.0, "credit": 1000.0, "account_id": self.account110.id}, ), ( 0, 0, - { - "name": move_name, - "debit": 1000.0, - "credit": 0.0, - "account_id": self.account100.id, - }, + {"debit": 1000.0, "credit": 0.0, "account_id": self.account100.id}, ), ], } diff --git a/account_financial_report/tests/test_vat_report.py b/account_financial_report/tests/test_vat_report.py index 593f4cd0..49952b33 100644 --- a/account_financial_report/tests/test_vat_report.py +++ b/account_financial_report/tests/test_vat_report.py @@ -45,13 +45,25 @@ class TestVATReport(common.TransactionCase): [("type", "=", "bank"), ("company_id", "=", self.company.id)], limit=1 ) self.tax_tag_01 = self.env["account.account.tag"].create( - {"name": "Tag 01", "applicability": "taxes"} + { + "name": "Tag 01", + "applicability": "taxes", + "country_id": self.company.country_id.id, + } ) self.tax_tag_02 = self.env["account.account.tag"].create( - {"name": "Tag 02", "applicability": "taxes"} + { + "name": "Tag 02", + "applicability": "taxes", + "country_id": self.company.country_id.id, + } ) self.tax_tag_03 = self.env["account.account.tag"].create( - {"name": "Tag 03", "applicability": "taxes"} + { + "name": "Tag 03", + "applicability": "taxes", + "country_id": self.company.country_id.id, + } ) self.tax_group_10 = self.env["account.tax.group"].create( {"name": "Tax 10%", "sequence": 1} @@ -65,11 +77,35 @@ class TestVATReport(common.TransactionCase): "amount": 10.0, "amount_type": "percent", "type_tax_use": "sale", - "account_id": self.tax_account.id, "company_id": self.company.id, - "refund_account_id": self.tax_account.id, "tax_group_id": self.tax_group_10.id, - "tag_ids": [(6, 0, [self.tax_tag_01.id, self.tax_tag_02.id])], + "invoice_repartition_line_ids": [ + (0, 0, {"factor_percent": 100, "repartition_type": "base"}), + ( + 0, + 0, + { + "factor_percent": 100, + "repartition_type": "tax", + "account_id": self.tax_account.id, + "tag_ids": [ + (6, 0, [self.tax_tag_01.id, self.tax_tag_02.id]) + ], + }, + ), + ], + "refund_repartition_line_ids": [ + (0, 0, {"factor_percent": 100, "repartition_type": "base"}), + ( + 0, + 0, + { + "factor_percent": 100, + "repartition_type": "tax", + "account_id": self.tax_account.id, + }, + ), + ], } ) self.tax_20 = self.env["account.tax"].create( @@ -79,67 +115,65 @@ class TestVATReport(common.TransactionCase): "amount": 20.0, "amount_type": "percent", "type_tax_use": "sale", - "tax_exigibility": "on_payment", - "account_id": self.tax_account.id, "company_id": self.company.id, - "refund_account_id": self.tax_account.id, - "cash_basis_account_id": self.tax_account.id, + "cash_basis_transition_account_id": self.tax_account.id, "tax_group_id": self.tax_group_20.id, - "tag_ids": [(6, 0, [self.tax_tag_02.id, self.tax_tag_03.id])], - } - ) - - invoice = self.env["account.invoice"].create( - { - "partner_id": self.env.ref("base.res_partner_2").id, - "account_id": self.receivable_account.id, - "company_id": self.company.id, - "date_invoice": time.strftime("%Y-%m-03"), - "type": "out_invoice", - } - ) - - self.env["account.invoice.line"].create( - { - "product_id": self.env.ref("product.product_product_4").id, - "quantity": 1.0, - "price_unit": 100.0, - "invoice_id": invoice.id, - "name": "product", - "account_id": self.income_account.id, - "invoice_line_tax_ids": [(6, 0, [self.tax_10.id])], - } - ) - invoice.compute_taxes() - invoice.action_invoice_open() - - self.cbinvoice = self.env["account.invoice"].create( - { - "partner_id": self.env.ref("base.res_partner_2").id, - "account_id": self.receivable_account.id, - "company_id": self.company.id, - "date_invoice": time.strftime("%Y-%m-05"), - "type": "out_invoice", + "invoice_repartition_line_ids": [ + (0, 0, {"factor_percent": 100, "repartition_type": "base"}), + ( + 0, + 0, + { + "factor_percent": 100, + "repartition_type": "tax", + "account_id": self.tax_account.id, + "tag_ids": [ + (6, 0, [self.tax_tag_02.id, self.tax_tag_03.id]) + ], + }, + ), + ], + "refund_repartition_line_ids": [ + (0, 0, {"factor_percent": 100, "repartition_type": "base"}), + ( + 0, + 0, + { + "factor_percent": 100, + "repartition_type": "tax", + "account_id": self.tax_account.id, + }, + ), + ], } ) - self.env["account.invoice.line"].create( - { - "product_id": self.env.ref("product.product_product_4").id, - "quantity": 1.0, - "price_unit": 500.0, - "invoice_id": self.cbinvoice.id, - "name": "product", - "account_id": self.income_account.id, - "invoice_line_tax_ids": [(6, 0, [self.tax_20.id])], - } - ) - self.cbinvoice.compute_taxes() - self.cbinvoice.action_invoice_open() + move_form = common.Form( + self.env["account.move"].with_context(default_type="out_invoice") + ) + move_form.partner_id = self.env.ref("base.res_partner_2") + move_form.invoice_date = time.strftime("%Y-%m-03") + with move_form.invoice_line_ids.new() as line_form: + line_form.product_id = self.env.ref("product.product_product_4") + line_form.quantity = 1.0 + line_form.price_unit = 100.0 + line_form.account_id = self.income_account + line_form.tax_ids.add(self.tax_10) + invoice = move_form.save() + invoice.post() - self.cbinvoice.pay_and_reconcile( - self.bank_journal.id, 300, date(date.today().year, date.today().month, 10) - ) + move_form = common.Form( + self.env["account.move"].with_context(default_type="out_invoice") + ) + move_form.partner_id = self.env.ref("base.res_partner_2") + with move_form.invoice_line_ids.new() as line_form: + line_form.product_id = self.env.ref("product.product_product_4") + line_form.quantity = 1.0 + line_form.price_unit = 250.0 + line_form.account_id = self.income_account + line_form.tax_ids.add(self.tax_20) + self.cbinvoice = move_form.save() + self.cbinvoice.post() def _get_report_lines(self, taxgroups=False): based_on = "taxtags" diff --git a/account_financial_report/view/report_vat_report.xml b/account_financial_report/view/report_vat_report.xml old mode 100755 new mode 100644 diff --git a/account_financial_report/wizard/aged_partner_balance_wizard.py b/account_financial_report/wizard/aged_partner_balance_wizard.py index bc022172..e1eb65c7 100644 --- a/account_financial_report/wizard/aged_partner_balance_wizard.py +++ b/account_financial_report/wizard/aged_partner_balance_wizard.py @@ -24,16 +24,14 @@ class AgedPartnerBalanceWizard(models.TransientModel): [("posted", "All Posted Entries"), ("all", "All Entries")], string="Target Moves", required=True, - default="all", + default="posted", ) account_ids = fields.Many2many( - comodel_name="account.account", string="Filter accounts", + comodel_name="account.account", string="Filter accounts" ) receivable_accounts_only = fields.Boolean() payable_accounts_only = fields.Boolean() - partner_ids = fields.Many2many( - comodel_name="res.partner", string="Filter partners", - ) + partner_ids = fields.Many2many(comodel_name="res.partner", string="Filter partners") show_move_line_details = fields.Boolean() @api.onchange("company_id") @@ -73,7 +71,6 @@ class AgedPartnerBalanceWizard(models.TransientModel): domain += [("reconcile", "=", True)] self.account_ids = self.env["account.account"].search(domain) - @api.multi def _print_report(self, report_type): self.ensure_one() data = self._prepare_report_aged_partner_balance() @@ -90,19 +87,16 @@ class AgedPartnerBalanceWizard(models.TransientModel): .report_action(self, data=data) ) - @api.multi def button_export_html(self): self.ensure_one() report_type = "qweb-html" return self._export(report_type) - @api.multi def button_export_pdf(self): self.ensure_one() report_type = "qweb-pdf" return self._export(report_type) - @api.multi def button_export_xlsx(self): self.ensure_one() report_type = "xlsx" diff --git a/account_financial_report/wizard/aged_partner_balance_wizard_view.xml b/account_financial_report/wizard/aged_partner_balance_wizard_view.xml index 7e27f8ef..bcebe58a 100644 --- a/account_financial_report/wizard/aged_partner_balance_wizard_view.xml +++ b/account_financial_report/wizard/aged_partner_balance_wizard_view.xml @@ -73,7 +73,6 @@ id="action_aged_partner_balance_wizard" name="Aged Partner Balance" res_model="aged.partner.balance.report.wizard" - view_type="form" view_mode="form" view_id="aged_partner_balance_wizard" target="new" diff --git a/account_financial_report/wizard/general_ledger_wizard.py b/account_financial_report/wizard/general_ledger_wizard.py index 05b83be5..d7ab2d40 100644 --- a/account_financial_report/wizard/general_ledger_wizard.py +++ b/account_financial_report/wizard/general_ledger_wizard.py @@ -34,10 +34,10 @@ class GeneralLedgerReportWizard(models.TransientModel): [("posted", "All Posted Entries"), ("all", "All Entries")], string="Target Moves", required=True, - default="all", + default="posted", ) account_ids = fields.Many2many( - comodel_name="account.account", string="Filter accounts", + comodel_name="account.account", string="Filter accounts" ) centralize = fields.Boolean(string="Activate centralization", default=True) hide_account_at_0 = fields.Boolean( @@ -47,7 +47,7 @@ class GeneralLedgerReportWizard(models.TransientModel): "If partners are filtered, " "debits and credits totals will not match the trial balance.", ) - show_analytic_tags = fields.Boolean(string="Show analytic tags",) + show_analytic_tags = fields.Boolean(string="Show analytic tags") receivable_accounts_only = fields.Boolean() payable_accounts_only = fields.Boolean() partner_ids = fields.Many2many( @@ -56,13 +56,13 @@ class GeneralLedgerReportWizard(models.TransientModel): default=lambda self: self._default_partners(), ) analytic_tag_ids = fields.Many2many( - comodel_name="account.analytic.tag", string="Filter analytic tags", + comodel_name="account.analytic.tag", string="Filter analytic tags" ) account_journal_ids = fields.Many2many( - comodel_name="account.journal", string="Filter journals", + comodel_name="account.journal", string="Filter journals" ) cost_center_ids = fields.Many2many( - comodel_name="account.analytic.account", string="Filter cost centers", + comodel_name="account.analytic.account", string="Filter cost centers" ) not_only_one_unaffected_earnings_account = fields.Boolean( @@ -79,27 +79,29 @@ class GeneralLedgerReportWizard(models.TransientModel): def _init_date_from(self): """set start date to begin of current year if fiscal year running""" today = fields.Date.context_today(self) - cur_month = fields.Date.from_string(today).month - cur_day = fields.Date.from_string(today).day last_fsc_month = self.env.user.company_id.fiscalyear_last_month last_fsc_day = self.env.user.company_id.fiscalyear_last_day if ( - cur_month < last_fsc_month - or cur_month == last_fsc_month - and cur_day <= last_fsc_day + today.month < int(last_fsc_month) + or today.month == int(last_fsc_month) + and today.day <= last_fsc_day ): return time.strftime("%Y-01-01") + else: + return False def _default_foreign_currency(self): return self.env.user.has_group("base.group_multi_currency") @api.depends("date_from") def _compute_fy_start_date(self): - for wiz in self.filtered("date_from"): - date = fields.Datetime.from_string(wiz.date_from) - res = self.company_id.compute_fiscalyear_dates(date) - wiz.fy_start_date = fields.Date.to_string(res["date_from"]) + for wiz in self: + if wiz.date_from: + res = self.company_id.compute_fiscalyear_dates(wiz.date_from) + wiz.fy_start_date = res["date_from"] + else: + wiz.fy_start_date = False @api.onchange("company_id") def onchange_company_id(self): @@ -171,7 +173,6 @@ class GeneralLedgerReportWizard(models.TransientModel): self.date_from = self.date_range_id.date_start self.date_to = self.date_range_id.date_end - @api.multi @api.constrains("company_id", "date_range_id") def _check_company_id_date_range_id(self): for rec in self.sudo(): @@ -210,7 +211,6 @@ class GeneralLedgerReportWizard(models.TransientModel): else: self.receivable_accounts_only = self.payable_accounts_only = False - @api.multi @api.depends("company_id") def _compute_unaffected_earnings_account(self): account_type = self.env.ref("account.data_unaffected_earnings") @@ -228,7 +228,6 @@ class GeneralLedgerReportWizard(models.TransientModel): store=True, ) - @api.multi def _print_report(self, report_type): self.ensure_one() data = self._prepare_report_general_ledger() @@ -245,19 +244,16 @@ class GeneralLedgerReportWizard(models.TransientModel): .report_action(self, data=data) ) - @api.multi def button_export_html(self): self.ensure_one() report_type = "qweb-html" return self._export(report_type) - @api.multi def button_export_pdf(self): self.ensure_one() report_type = "qweb-pdf" return self._export(report_type) - @api.multi def button_export_xlsx(self): self.ensure_one() report_type = "xlsx" diff --git a/account_financial_report/wizard/general_ledger_wizard_view.xml b/account_financial_report/wizard/general_ledger_wizard_view.xml index e8782b37..2831f748 100644 --- a/account_financial_report/wizard/general_ledger_wizard_view.xml +++ b/account_financial_report/wizard/general_ledger_wizard_view.xml @@ -124,7 +124,6 @@ id="action_general_ledger_wizard" name="General Ledger" res_model="general.ledger.report.wizard" - view_type="form" view_mode="form" view_id="general_ledger_wizard" target="new" @@ -134,14 +133,13 @@ id="act_action_general_ledger_wizard_partner_relation" name="General Ledger" res_model="general.ledger.report.wizard" - src_model="res.partner" + binding_model="res.partner" view_mode="form" context="{ 'default_receivable_accounts_only':1, 'default_payable_accounts_only':1, }" groups="account.group_account_manager" - key2="client_action_multi" target="new" /> diff --git a/account_financial_report/wizard/journal_ledger_wizard.py b/account_financial_report/wizard/journal_ledger_wizard.py index 13d09359..aaff6a6b 100644 --- a/account_financial_report/wizard/journal_ledger_wizard.py +++ b/account_financial_report/wizard/journal_ledger_wizard.py @@ -17,14 +17,14 @@ class JournalLedgerReportWizard(models.TransientModel): required=False, ondelete="cascade", ) - date_range_id = fields.Many2one(comodel_name="date.range", string="Date range",) + date_range_id = fields.Many2one(comodel_name="date.range", string="Date range") date_from = fields.Date(string="Start date", required=True) date_to = fields.Date(string="End date", required=True) journal_ids = fields.Many2many( - comodel_name="account.journal", string="Journals", required=False, + comodel_name="account.journal", string="Journals", required=False ) move_target = fields.Selection( - selection="_get_move_targets", default="all", required=True, + selection="_get_move_targets", default="posted", required=True ) foreign_currency = fields.Boolean() sort_option = fields.Selection( @@ -39,7 +39,7 @@ class JournalLedgerReportWizard(models.TransientModel): default="journal", required=True, ) - with_account_name = fields.Boolean(default=False,) + with_account_name = fields.Boolean(default=False) @api.model def _get_move_targets(self): @@ -47,17 +47,11 @@ class JournalLedgerReportWizard(models.TransientModel): @api.model def _get_sort_options(self): - return [ - ("move_name", _("Entry number")), - ("date", _("Date")), - ] + return [("move_name", _("Entry number")), ("date", _("Date"))] @api.model def _get_group_options(self): - return [ - ("journal", _("Journal")), - ("none", _("No group")), - ] + return [("journal", _("Journal")), ("none", _("No group"))] @api.onchange("date_range_id") def onchange_date_range_id(self): @@ -84,7 +78,6 @@ class JournalLedgerReportWizard(models.TransientModel): res["domain"]["journal_ids"] += [("company_id", "=", self.company_id.id)] return res - @api.multi def _print_report(self, report_type): self.ensure_one() data = self._prepare_report_journal_ledger() @@ -101,24 +94,20 @@ class JournalLedgerReportWizard(models.TransientModel): .report_action(self, data=data) ) - @api.multi def button_export_html(self): self.ensure_one() report_type = "qweb-html" return self._export(report_type) - @api.multi def button_export_pdf(self): report_type = "qweb-pdf" return self._export(report_type) - @api.multi def button_export_xlsx(self): self.ensure_one() report_type = "xlsx" return self._export(report_type) - @api.multi def _prepare_report_journal_ledger(self): self.ensure_one() journals = self.journal_ids diff --git a/account_financial_report/wizard/journal_ledger_wizard_view.xml b/account_financial_report/wizard/journal_ledger_wizard_view.xml index 96195a6b..d5660322 100644 --- a/account_financial_report/wizard/journal_ledger_wizard_view.xml +++ b/account_financial_report/wizard/journal_ledger_wizard_view.xml @@ -68,7 +68,6 @@ id="action_journal_ledger_wizard" name="Journal Ledger" res_model="journal.ledger.report.wizard" - view_type="form" view_mode="form" view_id="journal_ledger_wizard" target="new" diff --git a/account_financial_report/wizard/open_items_wizard.py b/account_financial_report/wizard/open_items_wizard.py index f27f3b66..1a5446be 100644 --- a/account_financial_report/wizard/open_items_wizard.py +++ b/account_financial_report/wizard/open_items_wizard.py @@ -25,7 +25,7 @@ class OpenItemsReportWizard(models.TransientModel): [("posted", "All Posted Entries"), ("all", "All Entries")], string="Target Moves", required=True, - default="all", + default="posted", ) account_ids = fields.Many2many( comodel_name="account.account", @@ -95,7 +95,6 @@ class OpenItemsReportWizard(models.TransientModel): domain += [("reconcile", "=", True)] self.account_ids = self.env["account.account"].search(domain) - @api.multi def _print_report(self, report_type): self.ensure_one() data = self._prepare_report_open_items() @@ -112,19 +111,16 @@ class OpenItemsReportWizard(models.TransientModel): .report_action(self, data=data) ) - @api.multi def button_export_html(self): self.ensure_one() report_type = "qweb-html" return self._export(report_type) - @api.multi def button_export_pdf(self): self.ensure_one() report_type = "qweb-pdf" return self._export(report_type) - @api.multi def button_export_xlsx(self): self.ensure_one() report_type = "xlsx" diff --git a/account_financial_report/wizard/open_items_wizard_view.xml b/account_financial_report/wizard/open_items_wizard_view.xml index 58f5899a..e1b73174 100644 --- a/account_financial_report/wizard/open_items_wizard_view.xml +++ b/account_financial_report/wizard/open_items_wizard_view.xml @@ -74,7 +74,6 @@ id="action_open_items_wizard" name="Open Items" res_model="open.items.report.wizard" - view_type="form" view_mode="form" view_id="open_items_wizard" target="new" @@ -84,14 +83,13 @@ id="act_action_open_items_wizard_partner_relation" name="Open Items Partner" res_model="open.items.report.wizard" - src_model="res.partner" + binding_model="res.partner" view_mode="form" context="{ 'default_receivable_accounts_only':1, 'default_payable_accounts_only':1, }" groups="account.group_account_manager" - key2="client_action_multi" target="new" /> diff --git a/account_financial_report/wizard/trial_balance_wizard.py b/account_financial_report/wizard/trial_balance_wizard.py index b993757b..c8f533b7 100644 --- a/account_financial_report/wizard/trial_balance_wizard.py +++ b/account_financial_report/wizard/trial_balance_wizard.py @@ -29,7 +29,7 @@ class TrialBalanceReportWizard(models.TransientModel): [("posted", "All Posted Entries"), ("all", "All Entries")], string="Target Moves", required=True, - default="all", + default="posted", ) hierarchy_on = fields.Selection( [ @@ -52,7 +52,7 @@ class TrialBalanceReportWizard(models.TransientModel): "Do not display parent levels", default=False ) account_ids = fields.Many2many( - comodel_name="account.account", string="Filter accounts", + comodel_name="account.account", string="Filter accounts" ) hide_account_at_0 = fields.Boolean( string="Hide accounts at 0", @@ -64,10 +64,8 @@ class TrialBalanceReportWizard(models.TransientModel): receivable_accounts_only = fields.Boolean() payable_accounts_only = fields.Boolean() show_partner_details = fields.Boolean() - partner_ids = fields.Many2many( - comodel_name="res.partner", string="Filter partners", - ) - journal_ids = fields.Many2many(comodel_name="account.journal",) + partner_ids = fields.Many2many(comodel_name="res.partner", string="Filter partners") + journal_ids = fields.Many2many(comodel_name="account.journal") not_only_one_unaffected_earnings_account = fields.Boolean( readonly=True, string="Not only one unaffected earnings account" @@ -80,7 +78,6 @@ class TrialBalanceReportWizard(models.TransientModel): "will display initial and final balance in that currency.", ) - @api.multi @api.constrains("hierarchy_on", "show_hierarchy_level") def _check_show_hierarchy_level(self): for rec in self: @@ -91,10 +88,12 @@ class TrialBalanceReportWizard(models.TransientModel): @api.depends("date_from") def _compute_fy_start_date(self): - for wiz in self.filtered("date_from"): - date = fields.Datetime.from_string(wiz.date_from) - res = self.company_id.compute_fiscalyear_dates(date) - wiz.fy_start_date = fields.Date.to_string(res["date_from"]) + for wiz in self: + if wiz.date_from: + res = self.company_id.compute_fiscalyear_dates(wiz.date_from) + wiz.fy_start_date = res["date_from"] + else: + wiz.fy_start_date = False @api.onchange("company_id") def onchange_company_id(self): @@ -155,7 +154,6 @@ class TrialBalanceReportWizard(models.TransientModel): self.date_from = self.date_range_id.date_start self.date_to = self.date_range_id.date_end - @api.multi @api.constrains("company_id", "date_range_id") def _check_company_id_date_range_id(self): for rec in self.sudo(): @@ -194,7 +192,6 @@ class TrialBalanceReportWizard(models.TransientModel): else: self.receivable_accounts_only = self.payable_accounts_only = False - @api.multi @api.depends("company_id") def _compute_unaffected_earnings_account(self): account_type = self.env.ref("account.data_unaffected_earnings") @@ -212,7 +209,6 @@ class TrialBalanceReportWizard(models.TransientModel): store=True, ) - @api.multi def _print_report(self, report_type): self.ensure_one() data = self._prepare_report_trial_balance() @@ -229,19 +225,16 @@ class TrialBalanceReportWizard(models.TransientModel): .report_action(self, data=data) ) - @api.multi def button_export_html(self): self.ensure_one() report_type = "qweb-html" return self._export(report_type) - @api.multi def button_export_pdf(self): self.ensure_one() report_type = "qweb-pdf" return self._export(report_type) - @api.multi def button_export_xlsx(self): self.ensure_one() report_type = "xlsx" diff --git a/account_financial_report/wizard/trial_balance_wizard_view.xml b/account_financial_report/wizard/trial_balance_wizard_view.xml index 5b7ca04b..22221f8c 100644 --- a/account_financial_report/wizard/trial_balance_wizard_view.xml +++ b/account_financial_report/wizard/trial_balance_wizard_view.xml @@ -133,7 +133,6 @@ id="action_trial_balance_wizard" name="Trial Balance" res_model="trial.balance.report.wizard" - view_type="form" view_mode="form" view_id="trial_balance_wizard" target="new" diff --git a/account_financial_report/wizard/vat_report_wizard.py b/account_financial_report/wizard/vat_report_wizard.py index f7bfceb2..49bec66c 100644 --- a/account_financial_report/wizard/vat_report_wizard.py +++ b/account_financial_report/wizard/vat_report_wizard.py @@ -34,7 +34,7 @@ class VATReportWizard(models.TransientModel): and self.date_range_id.company_id != self.company_id ): self.date_range_id = False - res = {"domain": {"date_range_id": [],}} + res = {"domain": {"date_range_id": []}} if not self.company_id: return res else: @@ -51,7 +51,6 @@ class VATReportWizard(models.TransientModel): self.date_from = self.date_range_id.date_start self.date_to = self.date_range_id.date_end - @api.multi @api.constrains("company_id", "date_range_id") def _check_company_id_date_range_id(self): for rec in self.sudo(): @@ -67,7 +66,6 @@ class VATReportWizard(models.TransientModel): ) ) - @api.multi def _print_report(self, report_type): self.ensure_one() data = self._prepare_vat_report() @@ -84,19 +82,16 @@ class VATReportWizard(models.TransientModel): .report_action(self, data=data) ) - @api.multi def button_export_html(self): self.ensure_one() report_type = "qweb-html" return self._export(report_type) - @api.multi def button_export_pdf(self): self.ensure_one() report_type = "qweb-pdf" return self._export(report_type) - @api.multi def button_export_xlsx(self): self.ensure_one() report_type = "xlsx" diff --git a/account_financial_report/wizard/vat_report_wizard_view.xml b/account_financial_report/wizard/vat_report_wizard_view.xml old mode 100755 new mode 100644 index d0960aff..ed82894c --- a/account_financial_report/wizard/vat_report_wizard_view.xml +++ b/account_financial_report/wizard/vat_report_wizard_view.xml @@ -53,7 +53,6 @@ id="action_vat_report_wizard" name="VAT Report" res_model="vat.report.wizard" - view_type="form" view_mode="form" view_id="vat_report_wizard" target="new" diff --git a/oca_dependencies.txt b/oca_dependencies.txt index 9b5df92e..5cd2498e 100644 --- a/oca_dependencies.txt +++ b/oca_dependencies.txt @@ -1 +1,2 @@ server-ux +reporting-engine