mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Initial commit of hr_payroll_slip_ytd for 11.0
This commit is contained in:
1
hr_payroll_slip_ytd/__init__.py
Executable file
1
hr_payroll_slip_ytd/__init__.py
Executable file
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
18
hr_payroll_slip_ytd/__manifest__.py
Executable file
18
hr_payroll_slip_ytd/__manifest__.py
Executable 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,
|
||||
}
|
||||
1
hr_payroll_slip_ytd/models/__init__.py
Normal file
1
hr_payroll_slip_ytd/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import payslip
|
||||
19
hr_payroll_slip_ytd/models/payslip.py
Normal file
19
hr_payroll_slip_ytd/models/payslip.py
Normal 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
|
||||
14
hr_payroll_slip_ytd/views/payslip_views.xml
Normal file
14
hr_payroll_slip_ytd/views/payslip_views.xml
Normal 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="{"widget": "monetary", "display_currency": o.company_id.currency_id}"/></td>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user