first commit
This commit is contained in:
commit
3d9a58dcbf
1
__init__.py
Normal file
1
__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from . import models
|
||||
15
__manifest__.py
Normal file
15
__manifest__.py
Normal file
@ -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',
|
||||
}
|
||||
BIN
__pycache__/__init__.cpython-312.pyc
Normal file
BIN
__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
1
models/__init__.py
Normal file
1
models/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from . import purchase_report
|
||||
BIN
models/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
models/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
models/__pycache__/purchase_report.cpython-312.pyc
Normal file
BIN
models/__pycache__/purchase_report.cpython-312.pyc
Normal file
Binary file not shown.
37
models/purchase_report.py
Normal file
37
models/purchase_report.py
Normal file
@ -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
|
||||
Loading…
Reference in New Issue
Block a user