Merge lp:~agilebg/hr-timesheet/fix-hr_attendance_analysis-bracket into lp:~hr-core-editors/hr-timesheet/7.0

Proposed by Lorenzo Battistini
Status: Work in progress
Proposed branch: lp:~agilebg/hr-timesheet/fix-hr_attendance_analysis-bracket
Merge into: lp:~hr-core-editors/hr-timesheet/7.0
Diff against target: 72 lines (+19/-3)
3 files modified
hr_attendance_analysis/company_view.xml (+4/-0)
hr_attendance_analysis/hr_attendance.py (+14/-3)
hr_attendance_analysis/hr_attendance_view.xml (+1/-0)
To merge this branch: bzr merge lp:~agilebg/hr-timesheet/fix-hr_attendance_analysis-bracket
Reviewer Review Type Date Requested Status
Alex Comba - Agile BG (community) Disapprove
Pedro Manuel Baeza Needs Resubmitting
Review via email: mp+221278@code.launchpad.net

Description of the change

[FIX] wrong opening bracket due to PEP8 restyle:
    http://bazaar.launchpad.net/~hr-core-editors/hr-timesheet/7.0/revision/40.2.21

    [ADD] button_dummy to force recomputing attendace (on attendance form and company form)

To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Lorenzo, don't you think it's better to use store triggers to recompute needed data?

Regards.

review: Needs Information (code review)
Revision history for this message
Lorenzo Battistini (elbati) wrote :

Hello Pedro,
what do you mean by store triggers?
I'm triggering recomputing because 'action' is in the store dictionary:
'hr.attendance': (_get_attendances, ['name', 'action', 'employee_id'], 20),

69. By Lorenzo Battistini

[ADD] 'Update all the attendance data' button on company

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, I mean that you can put on the field definition a keyword argument called store, with some trigger methods that recompute automatically the field. You can see an example here:

http://bazaar.launchpad.net/~account-payment-team/account-payment/7.0/view/head:/account_payment_extension/account_move_line.py#L200

Regards.

70. By Lorenzo Battistini

[FIX] comment

Revision history for this message
Lorenzo Battistini (elbati) wrote :

Ah, sure. It is so already.
See
http://bazaar.launchpad.net/~agilebg/hr-timesheet/fix-hr_attendance_analysis-bracket/view/69/hr_attendance_analysis/hr_attendance.py#L401

By writing the 'action' field without changing it, I'm forcing the '_get_attendance_duration' to be executed.
I'm doing this in order to allow the user to recompute values by clicking buttons on the interface, without changing the record (I don't know another way).

This is useful when the computation went wrong for some error and you want to explicit recompute the function fields without changing the data which the field depends on.

I improved the comment

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Thanks for the changes, Lorenzo.

Regards.

review: Approve (code review)
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

This project is now hosted on https://github.com/OCA/hr-timesheet. Please move your proposal there. This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

review: Needs Resubmitting
Revision history for this message
Alex Comba - Agile BG (tafaru) wrote :

Moved to https://github.com/OCA/hr-timesheet/pull/7
I prefer do not delete the proposal to keep all the associated comments that have been made.

review: Disapprove

Unmerged revisions

70. By Lorenzo Battistini

[FIX] comment

69. By Lorenzo Battistini

[ADD] 'Update all the attendance data' button on company

68. By Lorenzo Battistini

[FIX] wrong opening bracket due to PEP8 restyle:
http://bazaar.launchpad.net/~hr-core-editors/hr-timesheet/7.0/revision/40.2.21

[ADD] button_dummy to force recomputing attendace

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hr_attendance_analysis/company_view.xml'
2--- hr_attendance_analysis/company_view.xml 2013-03-08 13:40:53 +0000
3+++ hr_attendance_analysis/company_view.xml 2014-06-03 06:21:00 +0000
4@@ -9,6 +9,10 @@
5 <page string="Configuration" position="inside">
6 <group name="attendance_analysis_grp" string="Attendance analysis">
7 <field name="working_time_precision" widget="float_time"/>
8+ <button name="update_attendance_data" type="object"
9+ string="Update all the attendance data"
10+ confirm="This will update all the attendance data and may take a while"
11+ />
12 </group>
13 </page>
14 </field>
15
16=== modified file 'hr_attendance_analysis/hr_attendance.py'
17--- hr_attendance_analysis/hr_attendance.py 2014-05-21 22:04:08 +0000
18+++ hr_attendance_analysis/hr_attendance.py 2014-06-03 06:21:00 +0000
19@@ -42,6 +42,12 @@
20 'working_time_precision': 1.0 / 60 # hours
21 }
22
23+ def update_attendance_data(self, cr, uid, ids, context=None):
24+ attendance_pool = self.pool.get('hr.attendance')
25+ att_ids = attendance_pool.search(cr, uid, [], context=context)
26+ attendance_pool.button_dummy(cr, uid, att_ids, context=context)
27+ return True
28+
29
30 class hr_attendance(orm.Model):
31
32@@ -298,7 +304,7 @@
33 attendance_start.hour + attendance_start.minute / 60.0
34 + attendance_start.second / 60.0 / 60.0
35 )
36- if attendance_start_hour >= (
37+ if (attendance_start_hour >=
38 calendar_attendance.hour_from and
39 (attendance_start_hour - (calendar_attendance.hour_from +
40 calendar_attendance.tolerance_to)) < 0.01
41@@ -315,7 +321,7 @@
42 + attendance_stop.second / 60.0 / 60.0
43 )
44 calendar_attendance = attendance_pool.browse(cr, uid, matched_schedule_ids[0], context=context)
45- if attendance_stop_hour <= (
46+ if (attendance_stop_hour <=
47 calendar_attendance.hour_to and
48 (attendance_stop_hour - (calendar_attendance.hour_to -
49 calendar_attendance.tolerance_from)) > -0.01
50@@ -414,4 +420,9 @@
51 store=_store_rules),
52 }
53
54-
55+ def button_dummy(self, cr, uid, ids, context=None):
56+ for att in self.browse(cr, uid, ids, context=context):
57+ # By writing the 'action' field without changing it,
58+ # I'm forcing the '_get_attendance_duration' to be executed
59+ att.write({'action': att.action})
60+ return True
61
62=== modified file 'hr_attendance_analysis/hr_attendance_view.xml'
63--- hr_attendance_analysis/hr_attendance_view.xml 2013-03-05 11:28:38 +0000
64+++ hr_attendance_analysis/hr_attendance_view.xml 2014-06-03 06:21:00 +0000
65@@ -11,6 +11,7 @@
66 <field name="duration" widget="float_time"/>
67 <field name="outside_calendar_duration" widget="float_time"/>
68 <field name="inside_calendar_duration" widget="float_time" />
69+ <button name="button_dummy" string="Update attendance analysis" type="object"/>
70 </field>
71 </field>
72 </record>

Subscribers

People subscribed via source and target branches