MIG hr_payroll_timesheet to 12.0

This commit is contained in:
Jared Kipe
2019-03-12 11:51:07 -07:00
parent e5d1225b0f
commit 003699c7d7
3 changed files with 7 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
{ {
'name': 'Timesheets on Payslips', 'name': 'Timesheets on Payslips',
'description': 'Get Timesheet hours onto Employee Payslips.', 'description': 'Get Timesheet hours onto Employee Payslips.',
'version': '11.0.1.0.0', 'version': '12.0.1.0.0',
'website': 'https://hibou.io/', 'website': 'https://hibou.io/',
'author': 'Hibou Corp. <hello@hibou.io>', 'author': 'Hibou Corp. <hello@hibou.io>',
'license': 'AGPL-3', 'license': 'AGPL-3',

View File

@@ -1,7 +1,5 @@
from datetime import datetime
from collections import defaultdict from collections import defaultdict
from odoo import api, models from odoo import api, models
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
class HrPayslip(models.Model): class HrPayslip(models.Model):
@@ -50,8 +48,7 @@ class HrPayslip(models.Model):
days = set() days = set()
for ts in self.env['account.analytic.line'].search(valid_ts): for ts in self.env['account.analytic.line'].search(valid_ts):
if ts.unit_amount: if ts.unit_amount:
ts_date = datetime.strptime(ts.date, DEFAULT_SERVER_DATE_FORMAT) ts_iso = ts.date.isocalendar()
ts_iso = ts_date.isocalendar()
if ts_iso not in days: if ts_iso not in days:
values['number_of_days'] += 1 values['number_of_days'] += 1
days.add(ts_iso) days.add(ts_iso)
@@ -79,8 +76,7 @@ class HrPayslip(models.Model):
day_values = defaultdict(float) day_values = defaultdict(float)
for ts in timesheets: for ts in timesheets:
if ts.unit_amount: if ts.unit_amount:
ts_date = datetime.strptime(ts.date, DEFAULT_SERVER_DATE_FORMAT) ts_iso = ts.date.isocalendar()
ts_iso = ts_date.isocalendar()
day_values[ts_iso] += ts.unit_amount day_values[ts_iso] += ts.unit_amount
return day_values return day_values
elif hasattr(super(HrPayslip, self), 'hour_break_down'): elif hasattr(super(HrPayslip, self), 'hour_break_down'):

View File

@@ -40,12 +40,14 @@ class TestPayslipTimesheet(common.TransactionCase):
'project_id': self.project.id, 'project_id': self.project.id,
'date': '2018-01-01', 'date': '2018-01-01',
'unit_amount': 5.0, 'unit_amount': 5.0,
'name': 'test',
}) })
self.env['account.analytic.line'].create({ self.env['account.analytic.line'].create({
'employee_id': self.employee.id, 'employee_id': self.employee.id,
'project_id': self.project.id, 'project_id': self.project.id,
'date': '2018-01-01', 'date': '2018-01-01',
'unit_amount': 3.0, 'unit_amount': 3.0,
'name': 'test',
}) })
# Day 2 # Day 2
@@ -54,6 +56,7 @@ class TestPayslipTimesheet(common.TransactionCase):
'project_id': self.project.id, 'project_id': self.project.id,
'date': '2018-01-02', 'date': '2018-01-02',
'unit_amount': 1.0, 'unit_amount': 1.0,
'name': 'test',
}) })
# Make one that should be excluded. # Make one that should be excluded.
@@ -62,6 +65,7 @@ class TestPayslipTimesheet(common.TransactionCase):
'project_id': self.project.id, 'project_id': self.project.id,
'date': '2017-01-01', 'date': '2017-01-01',
'unit_amount': 5.0, 'unit_amount': 5.0,
'name': 'test',
}) })
# Create slip like a batch run. # Create slip like a batch run.