From d9a0eeb87855d4b0b03041fb1958ae8f83d6e5a0 Mon Sep 17 00:00:00 2001 From: luis Date: Mon, 9 Mar 2026 17:09:55 +0100 Subject: [PATCH] [16.0] add purchase_report_received_amount --- purchase_report_received_amount/README.rst | 47 ++++++++++++++++++ purchase_report_received_amount/__init__.py | 1 + .../__manifest__.py | 13 +++++ purchase_report_received_amount/i18n/es.po | 48 +++++++++++++++++++ .../i18n/purchase_report_received_amount.pot | 46 ++++++++++++++++++ .../report/__init__.py | 1 + .../report/purchase_report.py | 37 ++++++++++++++ 7 files changed, 193 insertions(+) create mode 100644 purchase_report_received_amount/README.rst create mode 100644 purchase_report_received_amount/__init__.py create mode 100644 purchase_report_received_amount/__manifest__.py create mode 100644 purchase_report_received_amount/i18n/es.po create mode 100644 purchase_report_received_amount/i18n/purchase_report_received_amount.pot create mode 100644 purchase_report_received_amount/report/__init__.py create mode 100644 purchase_report_received_amount/report/purchase_report.py diff --git a/purchase_report_received_amount/README.rst b/purchase_report_received_amount/README.rst new file mode 100644 index 0000000..d0b0279 --- /dev/null +++ b/purchase_report_received_amount/README.rst @@ -0,0 +1,47 @@ +================================ +Purchase Report Received Amount +================================ + +This module adds two new measures to the Purchase Report (purchase.report): + +* **Received Amount**: The monetary value of received quantities with discounts applied +* **Received Amount (Undiscounted)**: The monetary value of received quantities without discounts + +Features +======== + +* Adds ``price_received`` field: Amount of received quantity with discount applied +* Adds ``price_received_undiscounted`` field: Amount of received quantity without discount +* Both fields are converted to company currency for multi-currency support +* Compatible with unit of measure conversions + +Installation +============ + +Install the module from the Odoo Apps menu. + +This module depends on: +* ``purchase`` +* ``purchase_discount`` (OCA) + +Configuration +============= + +No configuration needed. After installation, the new measures will be available +in the Purchase Analysis report. + +Usage +===== + +1. Go to Purchase > Reporting > Purchase Analysis +2. Click on "Measures" button +3. Select "Received Amount" or "Received Amount (Undiscounted)" +4. The pivot/graph view will display the values + +Credits +======= + +Authors +~~~~~~~ + +* Criptomart diff --git a/purchase_report_received_amount/__init__.py b/purchase_report_received_amount/__init__.py new file mode 100644 index 0000000..4c4f242 --- /dev/null +++ b/purchase_report_received_amount/__init__.py @@ -0,0 +1 @@ +from . import report diff --git a/purchase_report_received_amount/__manifest__.py b/purchase_report_received_amount/__manifest__.py new file mode 100644 index 0000000..4e2fc31 --- /dev/null +++ b/purchase_report_received_amount/__manifest__.py @@ -0,0 +1,13 @@ +{ + "name": "Purchase Report Received Amount", + "version": "16.0.1.0.0", + "depends": ["purchase", "purchase_discount"], + "author": "Criptomart", + "category": "Purchases", + "summary": "Add received amount measures to purchase report", + "license": "AGPL-3", + "data": [], + "installable": True, + "application": False, + "auto_install": False, +} diff --git a/purchase_report_received_amount/i18n/es.po b/purchase_report_received_amount/i18n/es.po new file mode 100644 index 0000000..5c761e3 --- /dev/null +++ b/purchase_report_received_amount/i18n/es.po @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_report_received_amount +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-03-09 16:04+0000\n" +"PO-Revision-Date: 2026-03-09 17:07+0100\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 3.8\n" + +#. module: purchase_report_received_amount +#: model:ir.model.fields,help:purchase_report_received_amount.field_purchase_report__price_received +msgid "Amount of received quantity (with discount applied)" +msgstr "Precio total recibido (con descuentos aplicados)" + +#. module: purchase_report_received_amount +#: model:ir.model.fields,help:purchase_report_received_amount.field_purchase_report__price_received_undiscounted +msgid "Amount of received quantity without discount" +msgstr "Precio total recibido (sin descuentos aplicados)" + +#. module: purchase_report_received_amount +#: model:ir.model,name:purchase_report_received_amount.model_purchase_report +msgid "Purchase Report" +msgstr "Informe de compra" + +#. module: purchase_report_received_amount +#: model:ir.model.fields,field_description:purchase_report_received_amount.field_purchase_report__price_received +msgid "Received Amount" +msgstr "Precio total recibido" + +#. module: purchase_report_received_amount +#: model:ir.model.fields,field_description:purchase_report_received_amount.field_purchase_report__price_received_undiscounted +msgid "Received Amount (Undiscounted)" +msgstr "Precio total recibido sin descuentos" + +#. module: purchase_report_received_amount +#: model:ir.model.fields,field_description:purchase_report_received_amount.field_purchase_report__smart_search +msgid "Smart Search" +msgstr "Búsqueda inteligente" diff --git a/purchase_report_received_amount/i18n/purchase_report_received_amount.pot b/purchase_report_received_amount/i18n/purchase_report_received_amount.pot new file mode 100644 index 0000000..be680d4 --- /dev/null +++ b/purchase_report_received_amount/i18n/purchase_report_received_amount.pot @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_report_received_amount +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-03-09 16:03+0000\n" +"PO-Revision-Date: 2026-03-09 16:03+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: purchase_report_received_amount +#: model:ir.model.fields,help:purchase_report_received_amount.field_purchase_report__price_received +msgid "Amount of received quantity (with discount applied)" +msgstr "" + +#. module: purchase_report_received_amount +#: model:ir.model.fields,help:purchase_report_received_amount.field_purchase_report__price_received_undiscounted +msgid "Amount of received quantity without discount" +msgstr "" + +#. module: purchase_report_received_amount +#: model:ir.model,name:purchase_report_received_amount.model_purchase_report +msgid "Purchase Report" +msgstr "" + +#. module: purchase_report_received_amount +#: model:ir.model.fields,field_description:purchase_report_received_amount.field_purchase_report__price_received +msgid "Received Amount" +msgstr "" + +#. module: purchase_report_received_amount +#: model:ir.model.fields,field_description:purchase_report_received_amount.field_purchase_report__price_received_undiscounted +msgid "Received Amount (Undiscounted)" +msgstr "" + +#. module: purchase_report_received_amount +#: model:ir.model.fields,field_description:purchase_report_received_amount.field_purchase_report__smart_search +msgid "Smart Search" +msgstr "" diff --git a/purchase_report_received_amount/report/__init__.py b/purchase_report_received_amount/report/__init__.py new file mode 100644 index 0000000..84b6eef --- /dev/null +++ b/purchase_report_received_amount/report/__init__.py @@ -0,0 +1 @@ +from . import purchase_report diff --git a/purchase_report_received_amount/report/purchase_report.py b/purchase_report_received_amount/report/purchase_report.py new file mode 100644 index 0000000..8597867 --- /dev/null +++ b/purchase_report_received_amount/report/purchase_report.py @@ -0,0 +1,37 @@ +# Copyright 2024 Criptomart +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class PurchaseReport(models.Model): + _inherit = "purchase.report" + + price_received = fields.Float( + string="Received Amount", + readonly=True, + help="Amount of received quantity (with discount applied)", + ) + price_received_undiscounted = fields.Float( + string="Received Amount (Undiscounted)", + readonly=True, + help="Amount of received quantity without discount", + ) + + def _select(self): + res = super()._select() + # Add received amount with discount (uses the already discounted price from purchase_discount) + res += """, + sum( + l.qty_received / line_uom.factor * product_uom.factor + * (1.0 - COALESCE(l.discount, 0.0) / 100.0) * l.price_unit + / COALESCE(po.currency_rate, 1.0) + )::decimal(16,2) * currency_table.rate as price_received""" + # Add received amount without discount + res += """, + sum( + l.qty_received / line_uom.factor * product_uom.factor + * l.price_unit + / COALESCE(po.currency_rate, 1.0) + )::decimal(16,2) * currency_table.rate as price_received_undiscounted""" + return res