From 3d9a58dcbf9feacb594c0639ef594848b78f42dd Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Fri, 2 Jan 2026 16:54:42 +0700 Subject: [PATCH] first commit --- __init__.py | 1 + __manifest__.py | 15 +++++++ __pycache__/__init__.cpython-312.pyc | Bin 0 -> 219 bytes models/__init__.py | 1 + models/__pycache__/__init__.cpython-312.pyc | Bin 0 -> 235 bytes .../purchase_report.cpython-312.pyc | Bin 0 -> 2116 bytes models/purchase_report.py | 37 ++++++++++++++++++ 7 files changed, 54 insertions(+) create mode 100644 __init__.py create mode 100644 __manifest__.py create mode 100644 __pycache__/__init__.cpython-312.pyc create mode 100644 models/__init__.py create mode 100644 models/__pycache__/__init__.cpython-312.pyc create mode 100644 models/__pycache__/purchase_report.cpython-312.pyc create mode 100644 models/purchase_report.py 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 0000000000000000000000000000000000000000..75f27c5898b6415361326a3127fd8b78fcb99bd7 GIT binary patch literal 219 zcmXwzF$%&!5Jh(qkRS*a+IWLBE>k|3%i-Hn=Nt@&)`|SfrX8gonV*B z3FvR;{m%@4Zj;Gau$sle%y~Ws^H=hN&y?XJw9sIMgA;)0l01C@$2r_bjx^e^%agnC zDQ8#l87}*ytjM7Zu|lsqx$oMF>XMfwX`0B}<)o``q>*&{&@ literal 0 HcmV?d00001 diff --git a/models/__pycache__/purchase_report.cpython-312.pyc b/models/__pycache__/purchase_report.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7b54bbd1732e256b61895af16a882add206af9b8 GIT binary patch literal 2116 zcmb_d&1)n@6tC|2NM|;aL^9DaD{cwmOlz3gc*w$%#Lws+)?sm@fnlNObk&#+)!k!N z_qsDg$RS`n2s?;GPkNQ?A0YS-2wnp2A=`KmJczfEthnsSSKTvlK2{X5p^Nvb-h1^v ze(%-y`Fsw+_wB-_^FkJ(pB2;pGCksS4TwWT5!Eiz3W`0$SsYls{!#I^u*7Ygl(jL@G_n6aNAU=XC8LDd()pe@XQ#xYlo!Hqy z6$CEO)SdK^p6u4Me=C<6lAAa{4UJ~^jk*z26F^NKpj%o!cO98VG<_`;_O>P2+pOt} zpgq&<@fDG5Ol|mq#qp~S=ZtQcT4V@jQQzaOcHtc_ux>Gm2Ssdcz;Bfr^`BN?`Aj=R z!P()*`Y!qeQh(Ij`B2-{sMgLSq$u!BueI;x@W8i-W$2b=xJ4|NSGHn@NT9qUwryU% zOquPt7B4R?FTQBv=dm3M!92S~0&9!2im(EPEr|ye|Ji<+g!td@88UEoA0Q+n!zL5a z1d)t0J1|pG8mLB;OL!s!5ls?eb4yA>q)H>kdk-7cZQo^88E!K{Th(i=VB7a>09nEJ^6twmMQsI?EAvJVqS4_((~Gy%={Ew>+BxzFvFf`a0gcvR+H92*+jw z&>15VKeLK2;*H_MRQSrbG0`}!gQ6gXeaN)RN37~lyb7BYhni#B9{^C5-9$2IH5pb_Dmfl;yqi8` zt+a?0Cs-r&XldL6l*yyYf(%p-LuyO5ssS&JUDg*JuPSyV_WS^QAs>(MJ>iE84xtjMFt_B z$c<_+#!K{PcuFrz|`8^TvSEMkwNd~aew zbvPlWmPDrBgqM@J)C(%qqMlv33d@6ibTWhYuKYB2;r8<3N@wM(>2C^m=hpVFo}4dz zzWn9N7c0l*weJdd&)1IA#rtU^v+ze@HdE{(SmO9%do?o?rPU0Ky%*|{jWTbk*Ec@? u8YQACxetw%Bn4~YX<(IivIt8zrD@tP=)(Oh){3{^J-pGm@jC)C*8CG}Wiamm literal 0 HcmV?d00001 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