From 003699c7d72b496ba78819e17f02e228decb29e2 Mon Sep 17 00:00:00 2001 From: Jared Kipe Date: Tue, 12 Mar 2019 11:51:07 -0700 Subject: [PATCH] MIG `hr_payroll_timesheet` to 12.0 --- hr_payroll_timesheet/__manifest__.py | 2 +- hr_payroll_timesheet/models/hr_payslip.py | 8 ++------ hr_payroll_timesheet/tests/test_payslip_timesheet.py | 4 ++++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hr_payroll_timesheet/__manifest__.py b/hr_payroll_timesheet/__manifest__.py index 7c842873..e3603436 100755 --- a/hr_payroll_timesheet/__manifest__.py +++ b/hr_payroll_timesheet/__manifest__.py @@ -1,7 +1,7 @@ { 'name': 'Timesheets on Payslips', 'description': 'Get Timesheet hours onto Employee Payslips.', - 'version': '11.0.1.0.0', + 'version': '12.0.1.0.0', 'website': 'https://hibou.io/', 'author': 'Hibou Corp. ', 'license': 'AGPL-3', diff --git a/hr_payroll_timesheet/models/hr_payslip.py b/hr_payroll_timesheet/models/hr_payslip.py index cd6299ba..7df4cdff 100644 --- a/hr_payroll_timesheet/models/hr_payslip.py +++ b/hr_payroll_timesheet/models/hr_payslip.py @@ -1,7 +1,5 @@ -from datetime import datetime from collections import defaultdict from odoo import api, models -from odoo.tools import DEFAULT_SERVER_DATE_FORMAT class HrPayslip(models.Model): @@ -50,8 +48,7 @@ class HrPayslip(models.Model): days = set() for ts in self.env['account.analytic.line'].search(valid_ts): 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: values['number_of_days'] += 1 days.add(ts_iso) @@ -79,8 +76,7 @@ class HrPayslip(models.Model): day_values = defaultdict(float) for ts in timesheets: 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 return day_values elif hasattr(super(HrPayslip, self), 'hour_break_down'): diff --git a/hr_payroll_timesheet/tests/test_payslip_timesheet.py b/hr_payroll_timesheet/tests/test_payslip_timesheet.py index f19e7c3d..571b6b20 100644 --- a/hr_payroll_timesheet/tests/test_payslip_timesheet.py +++ b/hr_payroll_timesheet/tests/test_payslip_timesheet.py @@ -40,12 +40,14 @@ class TestPayslipTimesheet(common.TransactionCase): 'project_id': self.project.id, 'date': '2018-01-01', 'unit_amount': 5.0, + 'name': 'test', }) self.env['account.analytic.line'].create({ 'employee_id': self.employee.id, 'project_id': self.project.id, 'date': '2018-01-01', 'unit_amount': 3.0, + 'name': 'test', }) # Day 2 @@ -54,6 +56,7 @@ class TestPayslipTimesheet(common.TransactionCase): 'project_id': self.project.id, 'date': '2018-01-02', 'unit_amount': 1.0, + 'name': 'test', }) # Make one that should be excluded. @@ -62,6 +65,7 @@ class TestPayslipTimesheet(common.TransactionCase): 'project_id': self.project.id, 'date': '2017-01-01', 'unit_amount': 5.0, + 'name': 'test', }) # Create slip like a batch run.