mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
IMP hr_payroll_slip_ytd Add totals for Quantity and Amount for better YTD reporting.
This commit is contained in:
committed by
Cedric Collins
parent
caff2a713a
commit
f5f73f352c
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
'name': 'Payroll Report Year to Date',
|
'name': 'Payroll Report Year to Date',
|
||||||
'author': 'Hibou Corp. <hello@hibou.io>',
|
'author': 'Hibou Corp. <hello@hibou.io>',
|
||||||
'version': '12.0.1.0.0',
|
'version': '12.0.1.1.0',
|
||||||
'category': 'Human Resources',
|
'category': 'Human Resources',
|
||||||
'sequence': 95,
|
'sequence': 95,
|
||||||
'summary': 'Show YTD computations on Payslip Report',
|
'summary': 'Show YTD computations on Payslip Report',
|
||||||
|
|||||||
@@ -9,11 +9,20 @@ class Payslip(models.Model):
|
|||||||
from_date = str(self.date_to.year) + '-01-01'
|
from_date = str(self.date_to.year) + '-01-01'
|
||||||
state_allowed = ('done', 'verify') if not allow_draft else ('done', 'verify', 'draft')
|
state_allowed = ('done', 'verify') if not allow_draft else ('done', 'verify', 'draft')
|
||||||
self.env.cr.execute("""
|
self.env.cr.execute("""
|
||||||
SELECT sum(total) as sum
|
SELECT sum(total) as total,
|
||||||
|
sum(quantity) as quantity,
|
||||||
|
sum(amount) as amount
|
||||||
FROM hr_payslip as hp
|
FROM hr_payslip as hp
|
||||||
JOIN hr_payslip_line as pi ON hp.id = pi.slip_id
|
JOIN hr_payslip_line as pi ON hp.id = pi.slip_id
|
||||||
WHERE hp.employee_id = %s
|
WHERE hp.employee_id = %s
|
||||||
AND hp.state in %s
|
AND hp.state in %s
|
||||||
AND hp.date_to >= %s AND hp.date_to <= %s AND pi.code = %s""",
|
AND hp.date_to >= %s AND hp.date_to <= %s AND pi.code = %s""",
|
||||||
(self.employee_id.id, state_allowed, from_date, to_date, code))
|
(self.employee_id.id, state_allowed, from_date, to_date, code))
|
||||||
return self.env.cr.fetchone()[0] or 0.0
|
res = self.env.cr.dictfetchone()
|
||||||
|
if res:
|
||||||
|
# Can return dictionary with NULL aka Nones
|
||||||
|
for key in res:
|
||||||
|
res[key] = res[key] or 0.0
|
||||||
|
else:
|
||||||
|
res = {'total': 0.0, 'quantity': 0.0, 'amount': 0.0}
|
||||||
|
return res
|
||||||
|
|||||||
@@ -3,12 +3,17 @@
|
|||||||
<template id="report_payslip_inherit" name="Payslip YTD" inherit_id="hr_payroll.report_payslip">
|
<template id="report_payslip_inherit" name="Payslip YTD" inherit_id="hr_payroll.report_payslip">
|
||||||
<!-- Add YTD to the table head-->
|
<!-- Add YTD to the table head-->
|
||||||
<xpath expr="//table[2]/thead/tr//th[last()]" position="after">
|
<xpath expr="//table[2]/thead/tr//th[last()]" position="after">
|
||||||
<th>YTD</th>
|
<th>YTD Quantity</th>
|
||||||
|
<th>YTD Amount</th>
|
||||||
|
<th>YTD Total</th>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
<!-- Add YTD table data-->
|
<!-- Add YTD table data-->
|
||||||
<xpath expr="//table[2]/tbody//td[last()]" position="after">
|
<xpath expr="//table[2]/tbody//td[last()]" position="after">
|
||||||
<td><span t-esc="o.ytd(line.code, allow_draft=True)" t-options="{"widget": "monetary", "display_currency": o.company_id.currency_id}"/></td>
|
<t t-set="ytd" t-value="o.ytd(line.code, allow_draft=True)"/>
|
||||||
|
<td><span t-esc="ytd.get('quantity', 0.0)"/></td>
|
||||||
|
<td><span t-esc="ytd.get('amount', 0.0)" t-options="{"widget": "monetary", "display_currency": o.company_id.currency_id}"/></td>
|
||||||
|
<td><span t-esc="ytd.get('total', 0.0)" t-options="{"widget": "monetary", "display_currency": o.company_id.currency_id}"/></td>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
</odoo>
|
</odoo>
|
||||||
Reference in New Issue
Block a user