Skip to content

Commit 90ff23a

Browse files
committed
[MIG] hr_leave_date_to_custom_hour: migration to 18.0
1 parent 5564e49 commit 90ff23a

4 files changed

Lines changed: 26 additions & 26 deletions

File tree

hr_leave_date_to_custom_hour/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Date to for custom hours",
66
"summary": "Display Date to when custom hours is selected.",
7-
"version": "16.0.1.0.0",
7+
"version": "18.0.1.0.0",
88
"license": "AGPL-3",
99
"author": "PyTech, Odoo Community Association (OCA)",
1010
"website": "https://github.com/OCA/hr-holidays",

hr_leave_date_to_custom_hour/models/hr_leave.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ class HRLeave(models.Model):
1515
"custom_hours_request_date_to",
1616
)
1717
def _compute_date_from_to(self):
18-
return super()._compute_date_from_to()
19-
20-
def _get_attendances(self, employee, request_date_from, request_date_to):
21-
if len(self) == 1 and self.request_unit_hours:
22-
self.request_date_to = request_date_to = (
23-
self.custom_hours_request_date_to or self.request_date_to
18+
res = super()._compute_date_from_to()
19+
if (
20+
len(self) == 1
21+
and self.request_unit_hours
22+
and self.custom_hours_request_date_to
23+
):
24+
self.date_to = self._to_utc(
25+
self.custom_hours_request_date_to,
26+
self.request_hour_to,
27+
self.employee_id or self,
2428
)
25-
return super()._get_attendances(employee, request_date_from, request_date_to)
29+
return res

hr_leave_date_to_custom_hour/tests/test_hr_leave.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from datetime import datetime, timedelta
55

6-
from odoo.tests.common import Form
6+
from odoo.tests import Form
77

88
from odoo.addons.hr_holidays.tests.common import TestHrHolidaysCommon
99

@@ -63,4 +63,4 @@ def test_custom_hours_date_to(self):
6363
leave = self._create_user_leave(user, leave_from, leave_to)
6464

6565
# Assert
66-
self.assertEqual(leave.number_of_hours_display, leave_duration_hours)
66+
self.assertEqual(leave.number_of_hours, leave_duration_hours)

hr_leave_date_to_custom_hour/views/hr_leave_views.xml

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,21 @@
99
<field name="model">hr.leave</field>
1010
<field name="inherit_id" ref="hr_holidays.hr_leave_view_form" />
1111
<field name="arch" type="xml">
12-
<field name="request_date_from" position="before">
13-
<span class="text-muted">From</span>
14-
</field>
15-
<field name="request_date_from" position="after">
16-
<span class="text-muted">To</span>
17-
<field
18-
name="custom_hours_request_date_to"
19-
widget="daterange"
20-
options="{
21-
'related_start_date': 'request_date_from',
22-
}"
23-
/>
24-
</field>
25-
<field name="request_date_from" position="attributes">
12+
<xpath
13+
expr="//div[hasclass('o_row')]/field[@name='request_date_from']"
14+
position="after"
15+
>
16+
<field name="custom_hours_request_date_to" invisible="1" />
17+
</xpath>
18+
<xpath
19+
expr="//div[hasclass('o_row')]/field[@name='request_date_from']"
20+
position="attributes"
21+
>
2622
<attribute name="widget">daterange</attribute>
2723
<attribute name="options">{
28-
'related_end_date': 'custom_hours_request_date_to',
24+
'end_date_field': 'custom_hours_request_date_to'
2925
}</attribute>
30-
</field>
26+
</xpath>
3127
</field>
3228
</record>
3329
</odoo>

0 commit comments

Comments
 (0)