commit 3d9a58dcbf9feacb594c0639ef594848b78f42dd Author: Suherdy Yacob Date: Fri Jan 2 16:54:42 2026 +0700 first commit diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/__manifest__.py b/__manifest__.py new file mode 100644 index 0000000..643632c --- /dev/null +++ b/__manifest__.py @@ -0,0 +1,15 @@ +{ + 'name': 'Purchase Report Billed Measures', + 'version': '1.0', + 'category': 'Purchase', + 'summary': 'Add Total Billed and Untaxed Total Billed to Purchase Analysis', + 'description': """ + This module adds 'Total Billed' and 'Untaxed Total Billed' measures to the Purchase Analysis Report. + It computes these values based on the account move lines linked to the purchase order lines. + """, + 'depends': ['purchase', 'account'], + 'data': [], + 'installable': True, + 'auto_install': False, + 'license': 'LGPL-3', +} diff --git a/__pycache__/__init__.cpython-312.pyc b/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..75f27c5 Binary files /dev/null and b/__pycache__/__init__.cpython-312.pyc differ diff --git a/models/__init__.py b/models/__init__.py new file mode 100644 index 0000000..84b6eef --- /dev/null +++ b/models/__init__.py @@ -0,0 +1 @@ +from . import purchase_report diff --git a/models/__pycache__/__init__.cpython-312.pyc b/models/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..e03401c Binary files /dev/null and b/models/__pycache__/__init__.cpython-312.pyc differ diff --git a/models/__pycache__/purchase_report.cpython-312.pyc b/models/__pycache__/purchase_report.cpython-312.pyc new file mode 100644 index 0000000..7b54bbd Binary files /dev/null and b/models/__pycache__/purchase_report.cpython-312.pyc differ diff --git a/models/purchase_report.py b/models/purchase_report.py new file mode 100644 index 0000000..befaf12 --- /dev/null +++ b/models/purchase_report.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +from odoo import fields, models + + +class PurchaseReport(models.Model): + _inherit = "purchase.report" + + billed_total = fields.Float('Total Billed', readonly=True) + billed_untaxed_total = fields.Float('Untaxed Total Billed', readonly=True) + + def _select(self): + select_str = super()._select() + # aml.balance is in company currency. + # We estimate tax included amount in company currency using the ratio of price_total/price_subtotal from the original currency. + select_str += """ + , sum(sub_aml.billed_total_cc)::decimal(16,2) * currency_table.rate as billed_total + , sum(sub_aml.billed_untaxed_total_cc)::decimal(16,2) * currency_table.rate as billed_untaxed_total + """ + return select_str + + def _from(self): + from_str = super()._from() + from_str += """ + left join ( + select + aml.purchase_line_id, + sum(aml.balance * CASE WHEN aml.price_subtotal != 0 THEN aml.price_total / aml.price_subtotal ELSE 1.0 END) as billed_total_cc, + sum(aml.balance) as billed_untaxed_total_cc + from account_move_line aml + join account_move am on (aml.move_id = am.id) + where am.move_type in ('in_invoice', 'in_refund') + and am.state != 'cancel' + and aml.purchase_line_id is not null + group by aml.purchase_line_id + ) sub_aml on (l.id = sub_aml.purchase_line_id) + """ + return from_str