Initial commit of hr_payroll_slip_ytd for 11.0

This commit is contained in:
Jared Kipe
2019-01-17 11:37:38 -08:00
parent 78138afcbe
commit 2076d7b039
5 changed files with 53 additions and 0 deletions

View File

@@ -0,0 +1 @@
from . import models

View File

@@ -0,0 +1,18 @@
{
'name': 'Payroll Report Year to Date',
'author': 'Hibou Corp. <hello@hibou.io>',
'version': '11.0.1.0.0',
'category': 'Human Resources',
'sequence': 95,
'summary': 'Show YTD computations on Payslip Report',
'description': """
Show Year to Date (YTD) computations on Payslip Report.
""",
'website': 'https://hibou.io/',
'depends': ['hr_payroll'],
'data': [
'views/payslip_views.xml',
],
'installable': True,
'application': False,
}

View File

@@ -0,0 +1 @@
from . import payslip

View File

@@ -0,0 +1,19 @@
from odoo import models
class Payslip(models.Model):
_inherit = 'hr.payslip'
def ytd(self, code, allow_draft=False):
to_date = self.date_to
from_date = self.date_to[:4] + '-01-01'
state_allowed = ('done', 'verify') if not allow_draft else ('done', 'verify', 'draft')
self.env.cr.execute("""
SELECT sum(total) as sum
FROM hr_payslip as hp
JOIN hr_payslip_line as pi ON hp.id = pi.slip_id
WHERE hp.employee_id = %s
AND hp.state in %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))
return self.env.cr.fetchone()[0] or 0.0

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<template id="report_payslip_inherit" name="Payslip YTD" inherit_id="hr_payroll.report_payslip">
<!-- Add YTD to the table head-->
<xpath expr="//table[@class='table table-condensed']/thead/tr//th[last()]" position="after">
<th>YTD</th>
</xpath>
<!-- Add YTD table data-->
<xpath expr="//table[@class='table table-condensed']/tbody//td[last()]" position="after">
<td><span t-esc="o.ytd(line.code, allow_draft=True)" t-esc-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: o.company_id.currency_id}"/></td>
</xpath>
</template>
</odoo>