hr_payroll_holidays
hr_payroll_input_name_report
hr_payroll_input_report
hr_payroll_payment
hr_payroll_timesheet
hr_payslip_line_date
l10n_us_fl_hr_payroll
l10n_us_hr_payroll
l10n_us_mo_hr_payroll
l10n_us_oh_hr_payroll
l10n_us_va_hr_payroll
This commit is contained in:
Jared Kipe
2018-04-30 08:15:31 -07:00
parent 01e60f6e35
commit ca0bf33ee4
5 changed files with 97 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import hr_payslip
from . import hr_contract

View File

@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
{
'name': 'Timesheets on Payslips',
'description': 'Get Timesheet and Attendence numbers onto Employee Payslips.',
'version': '11.0.0.0.0',
'website': 'https://hibou.io/',
'author': 'Hibou Corp. <hello@hibou.io>',
'license': 'AGPL-3',
'category': 'Human Resources',
'data': [
'hr_contract_view.xml',
],
'depends': [
'hr_payroll',
'hr_timesheet_attendance',
],
}

View File

@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
from odoo import models, fields
class HrContract(models.Model):
_inherit = 'hr.contract'
paid_hourly = fields.Boolean(string="Paid Hourly", default=False)

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="hr_contract_form_inherit" model="ir.ui.view">
<field name="name">hr.contract.form.inherit</field>
<field name="model">hr.contract</field>
<field name="priority">20</field>
<field name="inherit_id" ref="hr_contract.hr_contract_view_form"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='wage']" position="after">
<field name="paid_hourly"/>
</xpath>
</data>
</field>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
from odoo import api, models
class HrPayslip(models.Model):
_inherit = 'hr.payslip'
@api.model
def get_worked_day_lines(self, contracts, date_from, date_to):
def create_empty_worked_lines(employee_id, contract_id, date_from, date_to):
attendance = {
'name': 'Timesheet Attendance',
'sequence': 10,
'code': 'ATTN',
'number_of_days': 0.0,
'number_of_hours': 0.0,
'contract_id': contract_id,
}
valid_days = [
('sheet_id.employee_id', '=', employee_id),
('sheet_id.state', '=', 'done'),
('sheet_id.date_from', '>=', date_from),
('sheet_id.date_to', '<=', date_to),
]
return attendance, valid_days
attendances = []
for contract in contracts:
attendance, valid_days = create_empty_worked_lines(
contract.employee_id.id,
contract.id,
date_from,
date_to
)
for day in self.env['hr_timesheet_sheet.sheet.day'].search(valid_days):
if day.total_attendance >= 0.0:
attendance['number_of_days'] += 1
attendance['number_of_hours'] += day.total_attendance
# needed so that the shown hours matches any calculations you use them for
attendance['number_of_hours'] = round(attendance['number_of_hours'], 2)
attendances.append(attendance)
res = super(HrPayslip, self).get_worked_day_lines(contracts, date_from, date_to)
res.extend(attendances)
return res