From e9ddee05579c75a44e7d4f9f8479522980b2c82e Mon Sep 17 00:00:00 2001 From: Oihane Crucelaegui Date: Wed, 7 Aug 2024 14:48:13 +0200 Subject: [PATCH 1/3] [ADD] New module account_reporting_product_template --- account_reporting_product_template/README.rst | 52 +++++++++++++++++++ .../__init__.py | 1 + .../__manifest__.py | 18 +++++++ .../account_reporting_product_template.pot | 32 ++++++++++++ account_reporting_product_template/i18n/es.po | 32 ++++++++++++ .../reports/__init__.py | 1 + .../reports/account_invoice_report.py | 27 ++++++++++ .../reports/account_invoice_report_views.xml | 24 +++++++++ 8 files changed, 187 insertions(+) create mode 100644 account_reporting_product_template/README.rst create mode 100644 account_reporting_product_template/__init__.py create mode 100644 account_reporting_product_template/__manifest__.py create mode 100644 account_reporting_product_template/i18n/account_reporting_product_template.pot create mode 100644 account_reporting_product_template/i18n/es.po create mode 100644 account_reporting_product_template/reports/__init__.py create mode 100644 account_reporting_product_template/reports/account_invoice_report.py create mode 100644 account_reporting_product_template/reports/account_invoice_report_views.xml diff --git a/account_reporting_product_template/README.rst b/account_reporting_product_template/README.rst new file mode 100644 index 0000000000..7a12801ec6 --- /dev/null +++ b/account_reporting_product_template/README.rst @@ -0,0 +1,52 @@ +============================================== +Product template in the invoices analysis view +============================================== + +.. |badge1| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +|badge1| + +This module adds "Product template" in the invoices analysis view. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +You need to be at least "Accountant" on "Accounting & Finance" role for +seeing the report. + +Usage +===== + +#. Go to *Invoicing > Reporting > Management > Invoice Analysis*. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, +please check there if your issue has already been reported. If you spotted +it first, help us smash it by providing detailed and welcomed feedback. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* AvanzOSC + +Contributors +~~~~~~~~~~~~ + +* `AvanzOSC `_: + + * Oihane Crucelaegui diff --git a/account_reporting_product_template/__init__.py b/account_reporting_product_template/__init__.py new file mode 100644 index 0000000000..65323532b3 --- /dev/null +++ b/account_reporting_product_template/__init__.py @@ -0,0 +1 @@ +from . import reports diff --git a/account_reporting_product_template/__manifest__.py b/account_reporting_product_template/__manifest__.py new file mode 100644 index 0000000000..5d307ee229 --- /dev/null +++ b/account_reporting_product_template/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2024 Oihane Crucelaegui - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Product template in the invoices analysis view", + "version": "16.0.1.0.0", + "category": "Account", + "license": "AGPL-3", + "author": "AvanzOSC", + "website": "https://github.com/avanzosc/odoo-addons", + "depends": [ + "account", + ], + "data": [ + "reports/account_invoice_report_views.xml", + ], + "installable": True, +} diff --git a/account_reporting_product_template/i18n/account_reporting_product_template.pot b/account_reporting_product_template/i18n/account_reporting_product_template.pot new file mode 100644 index 0000000000..0637dafa37 --- /dev/null +++ b/account_reporting_product_template/i18n/account_reporting_product_template.pot @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_reporting_product_template +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-08-07 12:46+0000\n" +"PO-Revision-Date: 2024-08-07 12:46+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_reporting_product_template +#: model:ir.model,name:account_reporting_product_template.model_account_invoice_report +msgid "Invoices Statistics" +msgstr "" + +#. module: account_reporting_product_template +#: model_terms:ir.ui.view,arch_db:account_reporting_product_template.account_invoice_report_view_search +msgid "Product" +msgstr "" + +#. module: account_reporting_product_template +#: model:ir.model.fields,field_description:account_reporting_product_template.field_account_invoice_report__product_tmpl_id +#: model_terms:ir.ui.view,arch_db:account_reporting_product_template.account_invoice_report_view_search +msgid "Product Template" +msgstr "" diff --git a/account_reporting_product_template/i18n/es.po b/account_reporting_product_template/i18n/es.po new file mode 100644 index 0000000000..26c0f0321d --- /dev/null +++ b/account_reporting_product_template/i18n/es.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_reporting_product_template +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-08-07 12:46+0000\n" +"PO-Revision-Date: 2024-08-07 12:46+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_reporting_product_template +#: model:ir.model,name:account_reporting_product_template.model_account_invoice_report +msgid "Invoices Statistics" +msgstr "Estadísticas de facturación" + +#. module: account_reporting_product_template +#: model_terms:ir.ui.view,arch_db:account_reporting_product_template.account_invoice_report_view_search +msgid "Product" +msgstr "Producto" + +#. module: account_reporting_product_template +#: model:ir.model.fields,field_description:account_reporting_product_template.field_account_invoice_report__product_tmpl_id +#: model_terms:ir.ui.view,arch_db:account_reporting_product_template.account_invoice_report_view_search +msgid "Product Template" +msgstr "Plantilla de producto" diff --git a/account_reporting_product_template/reports/__init__.py b/account_reporting_product_template/reports/__init__.py new file mode 100644 index 0000000000..52e62702b3 --- /dev/null +++ b/account_reporting_product_template/reports/__init__.py @@ -0,0 +1 @@ +from . import account_invoice_report diff --git a/account_reporting_product_template/reports/account_invoice_report.py b/account_reporting_product_template/reports/account_invoice_report.py new file mode 100644 index 0000000000..cb626d3d63 --- /dev/null +++ b/account_reporting_product_template/reports/account_invoice_report.py @@ -0,0 +1,27 @@ +# Copyright 2024 Oihane Crucelaegui - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class AccountInvoiceReport(models.Model): + _inherit = "account.invoice.report" + + product_tmpl_id = fields.Many2one( + comodel_name="product.template", + string="Product Template", + ) + + @api.model + def _select(self): + select_str = super()._select() + select_str += """ + , template.id as product_tmpl_id + """ + return select_str + + @api.model + def _group_by(self): + group_by_str = super()._group_by() + group_by_str += ", template.id" + return group_by_str diff --git a/account_reporting_product_template/reports/account_invoice_report_views.xml b/account_reporting_product_template/reports/account_invoice_report_views.xml new file mode 100644 index 0000000000..7025daa13c --- /dev/null +++ b/account_reporting_product_template/reports/account_invoice_report_views.xml @@ -0,0 +1,24 @@ + + + + + account.invoice.report + + + + + + + + + + + From 650c4b303aa7304dffcf05c4664d943619784a0d Mon Sep 17 00:00:00 2001 From: Alfredo Date: Mon, 3 Nov 2025 10:55:07 +0100 Subject: [PATCH 2/3] [IMP] account_reporting_product_template: pre-commit auto fixes --- .../pyproject.toml | 3 ++ .../reports/account_invoice_report_views.xml | 30 ++++++++----------- 2 files changed, 16 insertions(+), 17 deletions(-) create mode 100644 account_reporting_product_template/pyproject.toml diff --git a/account_reporting_product_template/pyproject.toml b/account_reporting_product_template/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/account_reporting_product_template/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/account_reporting_product_template/reports/account_invoice_report_views.xml b/account_reporting_product_template/reports/account_invoice_report_views.xml index 7025daa13c..d4a3584303 100644 --- a/account_reporting_product_template/reports/account_invoice_report_views.xml +++ b/account_reporting_product_template/reports/account_invoice_report_views.xml @@ -1,24 +1,20 @@ - - - account.invoice.report - - - - - - + + account.invoice.report + + + + + + - - - - + + + + From 5b328a661218aa4790792f59f4075b08875eaef3 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Mon, 3 Nov 2025 10:56:26 +0100 Subject: [PATCH 3/3] [18.0][MIG] account_reporting_product_template: Migration to 18.0 --- .../__manifest__.py | 2 +- .../reports/account_invoice_report.py | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/account_reporting_product_template/__manifest__.py b/account_reporting_product_template/__manifest__.py index 5d307ee229..574854be6c 100644 --- a/account_reporting_product_template/__manifest__.py +++ b/account_reporting_product_template/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Product template in the invoices analysis view", - "version": "16.0.1.0.0", + "version": "18.0.1.0.0", "category": "Account", "license": "AGPL-3", "author": "AvanzOSC", diff --git a/account_reporting_product_template/reports/account_invoice_report.py b/account_reporting_product_template/reports/account_invoice_report.py index cb626d3d63..9129daef3c 100644 --- a/account_reporting_product_template/reports/account_invoice_report.py +++ b/account_reporting_product_template/reports/account_invoice_report.py @@ -2,6 +2,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from odoo import api, fields, models +from odoo.tools import SQL class AccountInvoiceReport(models.Model): @@ -14,14 +15,10 @@ class AccountInvoiceReport(models.Model): @api.model def _select(self): - select_str = super()._select() - select_str += """ - , template.id as product_tmpl_id + return SQL( """ - return select_str - - @api.model - def _group_by(self): - group_by_str = super()._group_by() - group_by_str += ", template.id" - return group_by_str + %s, + product.product_tmpl_id AS product_tmpl_id + """, + super()._select(), + )