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
=== modified file 'hr_attendance_analysis/company_view.xml'
--- hr_attendance_analysis/company_view.xml 2013-03-08 13:40:53 +0000
+++ hr_attendance_analysis/company_view.xml 2014-06-03 06:21:00 +0000
@@ -9,6 +9,10 @@
9 <page string="Configuration" position="inside">9 <page string="Configuration" position="inside">
10 <group name="attendance_analysis_grp" string="Attendance analysis">10 <group name="attendance_analysis_grp" string="Attendance analysis">
11 <field name="working_time_precision" widget="float_time"/>11 <field name="working_time_precision" widget="float_time"/>
12 <button name="update_attendance_data" type="object"
13 string="Update all the attendance data"
14 confirm="This will update all the attendance data and may take a while"
15 />
12 </group>16 </group>
13 </page>17 </page>
14 </field>18 </field>
1519
=== modified file 'hr_attendance_analysis/hr_attendance.py'
--- hr_attendance_analysis/hr_attendance.py 2014-05-21 22:04:08 +0000
+++ hr_attendance_analysis/hr_attendance.py 2014-06-03 06:21:00 +0000
@@ -42,6 +42,12 @@
42 'working_time_precision': 1.0 / 60 # hours42 'working_time_precision': 1.0 / 60 # hours
43 }43 }
4444
45 def update_attendance_data(self, cr, uid, ids, context=None):
46 attendance_pool = self.pool.get('hr.attendance')
47 att_ids = attendance_pool.search(cr, uid, [], context=context)
48 attendance_pool.button_dummy(cr, uid, att_ids, context=context)
49 return True
50
4551
46class hr_attendance(orm.Model):52class hr_attendance(orm.Model):
4753
@@ -298,7 +304,7 @@
298 attendance_start.hour + attendance_start.minute / 60.0304 attendance_start.hour + attendance_start.minute / 60.0
299 + attendance_start.second / 60.0 / 60.0305 + attendance_start.second / 60.0 / 60.0
300 )306 )
301 if attendance_start_hour >= (307 if (attendance_start_hour >=
302 calendar_attendance.hour_from and308 calendar_attendance.hour_from and
303 (attendance_start_hour - (calendar_attendance.hour_from +309 (attendance_start_hour - (calendar_attendance.hour_from +
304 calendar_attendance.tolerance_to)) < 0.01310 calendar_attendance.tolerance_to)) < 0.01
@@ -315,7 +321,7 @@
315 + attendance_stop.second / 60.0 / 60.0321 + attendance_stop.second / 60.0 / 60.0
316 )322 )
317 calendar_attendance = attendance_pool.browse(cr, uid, matched_schedule_ids[0], context=context)323 calendar_attendance = attendance_pool.browse(cr, uid, matched_schedule_ids[0], context=context)
318 if attendance_stop_hour <= (324 if (attendance_stop_hour <=
319 calendar_attendance.hour_to and325 calendar_attendance.hour_to and
320 (attendance_stop_hour - (calendar_attendance.hour_to -326 (attendance_stop_hour - (calendar_attendance.hour_to -
321 calendar_attendance.tolerance_from)) > -0.01327 calendar_attendance.tolerance_from)) > -0.01
@@ -414,4 +420,9 @@
414 store=_store_rules),420 store=_store_rules),
415 }421 }
416422
417423 def button_dummy(self, cr, uid, ids, context=None):
424 for att in self.browse(cr, uid, ids, context=context):
425 # By writing the 'action' field without changing it,
426 # I'm forcing the '_get_attendance_duration' to be executed
427 att.write({'action': att.action})
428 return True
418429
=== modified file 'hr_attendance_analysis/hr_attendance_view.xml'
--- hr_attendance_analysis/hr_attendance_view.xml 2013-03-05 11:28:38 +0000
+++ hr_attendance_analysis/hr_attendance_view.xml 2014-06-03 06:21:00 +0000
@@ -11,6 +11,7 @@
11 <field name="duration" widget="float_time"/>11 <field name="duration" widget="float_time"/>
12 <field name="outside_calendar_duration" widget="float_time"/>12 <field name="outside_calendar_duration" widget="float_time"/>
13 <field name="inside_calendar_duration" widget="float_time" />13 <field name="inside_calendar_duration" widget="float_time" />
14 <button name="button_dummy" string="Update attendance analysis" type="object"/>
14 </field>15 </field>
15 </field>16 </field>
16 </record>17 </record>

Subscribers

People subscribed via source and target branches