Merge lp:~openerp-dev/openobject-addons/trunk-bug-791087-mtr into lp:openobject-addons

Proposed by Meera Trambadia (OpenERP)
Status: Rejected
Rejected by: Fabien (Open ERP)
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-791087-mtr
Merge into: lp:openobject-addons
Diff against target: 295 lines (+132/-143)
3 files modified
hr_attendance/__openerp__.py (+1/-1)
hr_attendance/hr_attendance_demo.xml (+0/-142)
hr_attendance/hr_attendance_demo.yml (+131/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-791087-mtr
Reviewer Review Type Date Requested Status
Mustufa Rangwala (Open ERP) (community) Approve
Ujjvala Collins (community) Needs Resubmitting
Meera Trambadia (OpenERP) (community) Needs Resubmitting
Olivier Dony (Odoo) Disapprove
qdp (OpenERP) Pending
Review via email: mp+63661@code.launchpad.net

Description of the change

hr_attendance:removed conflicting demo data" --fixes lp:791087
Note:-The demo data which has been removed was added for the bug-751411, but its removal doesn't affect the fixes of bug-751411

To post a comment you must log in.
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) :
review: Approve
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Hello,

I don't think removing the demo data records is the good solution, as it is interesting to have entries in the daily attendances when you install a new demo database.

Couldn't we instead replace the XML demo data with a YML demo file that does a smarter job: create 8 hours of attendance for every day of the current business week, using proper timedelta calculations, and making no conflict?

We could also do the same for the analytic entries, to have a match between them.

Thanks!

(I'm resetting the bug to Confirmed, as I don't think this is a proper fix)

review: Disapprove
Revision history for this message
Meera Trambadia (OpenERP) (mtr-openerp) wrote :

Hello,

I have replaced the xml demo data file with yml demo file which creates 8 hours of attendance for every day of the current business week.

Thanks,
mtr

review: Needs Resubmitting
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote :

Working as expected but need to improve few things,

=== renamed file 'hr_attendance/hr_attendance_demo.xml' => 'hr_attendance/hr_attendance_demo.xml.THIS' .. What is this changed for ?

Improve time of your days of week.. make it compatible with all the days

Improve the starting string of yaml

Thanks,
mra

review: Needs Fixing
4772. By mtr <mtr@mtr>

[FIX] hr_attendance:-replaced yml demo file in place of xml file for attendance demo data

4773. By mtr <mtr@mtr>

[MERGE] branch merged with main-addons

Revision history for this message
Meera Trambadia (OpenERP) (mtr-openerp) wrote :

Hello sir,

I have made the changes as specified above.

Thanks,
mtr

review: Needs Resubmitting
4774. By mtr <mtr@mtr>

[IMP] hr_attendance: improved path given for demo file

Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote :

Changes are ok as per comment,but now when i try to uninstall the module it gives error:

except_orm: ('ValidateError', u'Error occurred while validating the field(s) action: Error: Sign in (resp. Sign out) must follow Sign out (resp. Sign in)')

can you check and please fix it ?

Thanks,
mra

review: Needs Fixing
4775. By mtr <mtr@mtr>

[IMP] hr_attendance: improved code in yml demo to successfully install/uninstall the module

Revision history for this message
Meera Trambadia (OpenERP) (mtr-openerp) wrote :

Hello sir,

I have improved code in yaml to fix the error.

Thanks,
mtr

review: Needs Resubmitting
4776. By Ujjvala Collins

[IMP] hr_attendance: Improved demo yml to make it more dynamic with dates.

Revision history for this message
Ujjvala Collins (uco-openerp) wrote :

Hello,

I have changed the demo yml file to make it more dynamic in creating records. It will also update the records if needed.

Thanks,
Ujjvala

review: Needs Resubmitting
4777. By Ujjvala Collins

[IMP] hr_attendance: Improved demo yml.

4778. By Ujjvala Collins

[IMP] hr_attendance: Refactored demo yml with code optimization.

4779. By Ujjvala Collins

[IMP] hr_attendance: Small improvement.

4780. By Ujjvala Collins

[IMP] hr_attendance: Code optimiztion.

Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote :

Now using yaml demo file, attendances create for current business week.

review: Approve
4781. By Meera Trambadia (OpenERP)

[MERGE] branch merged with openobject-addons

Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

the implementation code is ugly.

Unmerged revisions

4781. By Meera Trambadia (OpenERP)

[MERGE] branch merged with openobject-addons

4780. By Ujjvala Collins

[IMP] hr_attendance: Code optimiztion.

4779. By Ujjvala Collins

[IMP] hr_attendance: Small improvement.

4778. By Ujjvala Collins

[IMP] hr_attendance: Refactored demo yml with code optimization.

4777. By Ujjvala Collins

[IMP] hr_attendance: Improved demo yml.

4776. By Ujjvala Collins

[IMP] hr_attendance: Improved demo yml to make it more dynamic with dates.

4775. By mtr <mtr@mtr>

[IMP] hr_attendance: improved code in yml demo to successfully install/uninstall the module

4774. By mtr <mtr@mtr>

[IMP] hr_attendance: improved path given for demo file

4773. By mtr <mtr@mtr>

[MERGE] branch merged with main-addons

4772. By mtr <mtr@mtr>

[FIX] hr_attendance:-replaced yml demo file in place of xml file for attendance demo data

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hr_attendance/__openerp__.py'
--- hr_attendance/__openerp__.py 2011-07-06 12:29:28 +0000
+++ hr_attendance/__openerp__.py 2011-09-15 11:57:57 +0000
@@ -46,7 +46,7 @@
46 'wizard/hr_attendance_error_view.xml',46 'wizard/hr_attendance_error_view.xml',
47 'wizard/hr_attendance_sign_in_out_view.xml',47 'wizard/hr_attendance_sign_in_out_view.xml',
48 ],48 ],
49 'demo_xml': ['hr_attendance_demo.xml'],49 'demo_xml': ['hr_attendance_demo.yml'],
50 'test': ['test/test_hr_attendance.yml',50 'test': ['test/test_hr_attendance.yml',
51 'test/hr_attendance_report.yml'51 'test/hr_attendance_report.yml'
52 ],52 ],
5353
=== removed file 'hr_attendance/hr_attendance_demo.xml'
--- hr_attendance/hr_attendance_demo.xml 2011-07-07 12:25:42 +0000
+++ hr_attendance/hr_attendance_demo.xml 1970-01-01 00:00:00 +0000
@@ -1,142 +0,0 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data noupdate="True">
4
5 <record id="attendance1" model="hr.attendance">
6 <field eval="time.strftime('%Y-%m-01 08:21')" name="name"/>
7 <field name="action">sign_in</field>
8 <field name="employee_id" ref="hr.employee1"/>
9 </record>
10
11 <record id="attendance2" model="hr.attendance">
12 <field eval="time.strftime('%Y-%m-01 11:51')" name="name"/>
13 <field name="action">sign_out</field>
14 <field name="employee_id" ref="hr.employee1"/>
15 </record>
16
17 <record id="attendance3" model="hr.attendance">
18 <field eval="time.strftime('%Y-%m-02 12:47')" name="name"/>
19 <field name="action">sign_in</field>
20 <field name="employee_id" ref="hr.employee1"/>
21 </record>
22
23 <record id="attendance4" model="hr.attendance">
24 <field eval="time.strftime('%Y-%m-02 19:53')" name="name"/>
25 <field name="action">sign_out</field>
26 <field name="employee_id" ref="hr.employee1"/>
27 </record>
28
29 <record id="attendance5" model="hr.attendance">
30 <field eval="time.strftime('%Y-%m-03 07:32')" name="name"/>
31 <field name="action">sign_in</field>
32 <field name="employee_id" ref="hr.employee1"/>
33 </record>
34
35 <record id="attendance6" model="hr.attendance">
36 <field eval="time.strftime('%Y-%m-03 12:32')" name="name"/>
37 <field name="action">sign_out</field>
38 <field name="employee_id" ref="hr.employee1"/>
39 </record>
40
41 <record id="attendance7" model="hr.attendance">
42 <field eval="time.strftime('%Y-%m-04 14:01')" name="name"/>
43 <field name="action">sign_in</field>
44 <field name="employee_id" ref="hr.employee1"/>
45 </record>
46
47 <record id="attendance8" model="hr.attendance">
48 <field eval="time.strftime('%Y-%m-04 17:21')" name="name"/>
49 <field name="action">sign_out</field>
50 <field name="employee_id" ref="hr.employee1"/>
51 </record>
52
53 <record id="attendance9" model="hr.attendance">
54 <field eval="time.strftime('%Y-%m-05 09:10')" name="name"/>
55 <field name="action">sign_in</field>
56 <field name="employee_id" ref="hr.employee1"/>
57 </record>
58
59 <record id="attendance10" model="hr.attendance">
60 <field eval="time.strftime('%Y-%m-05 12:42')" name="name"/>
61 <field name="action">sign_out</field>
62 <field name="employee_id" ref="hr.employee1"/>
63 </record>
64
65 <record id="attendance11" model="hr.attendance">
66 <field eval="time.strftime('%Y-%m-06 13:10')" name="name"/>
67 <field name="action">sign_in</field>
68 <field name="employee_id" ref="hr.employee1"/>
69 </record>
70
71 <record id="attendance12" model="hr.attendance">
72 <field eval="time.strftime('%Y-%m-06 18:34')" name="name"/>
73 <field name="action">sign_out</field>
74 <field name="employee_id" ref="hr.employee1"/>
75 </record>
76
77 <record id="attendance13" model="hr.attendance">
78 <field eval="time.strftime('%Y-%m-07 08:21')" name="name"/>
79 <field name="action">sign_in</field>
80 <field name="employee_id" ref="hr.employee1"/>
81 </record>
82
83 <record id="attendance14" model="hr.attendance">
84 <field eval="time.strftime('%Y-%m-07 18:21')" name="name"/>
85 <field name="action">sign_out</field>
86 <field name="employee_id" ref="hr.employee1"/>
87 </record>
88
89 <record id="attendance15" model="hr.attendance">
90 <field eval="time.strftime('%Y-%m-08 08:21')" name="name"/>
91 <field name="action">sign_in</field>
92 <field name="employee_id" ref="hr.employee1"/>
93 </record>
94
95 <record id="attendance16" model="hr.attendance">
96 <field eval="time.strftime('%Y-%m-08 12:54')" name="name"/>
97 <field name="action">sign_out</field>
98 <field name="employee_id" ref="hr.employee1"/>
99 </record>
100
101 <record id="attendance17" model="hr.attendance">
102 <field eval="time.strftime('%Y-%m-09 13:32')" name="name"/>
103 <field name="action">sign_in</field>
104 <field name="employee_id" ref="hr.employee1"/>
105 </record>
106
107 <record id="attendance18" model="hr.attendance">
108 <field eval="time.strftime('%Y-%m-09 19:31')" name="name"/>
109 <field name="action">sign_out</field>
110 <field name="employee_id" ref="hr.employee1"/>
111 </record>
112
113 <record id="attendance19" model="hr.attendance">
114 <field eval="time.strftime('%Y-%m-10 07:10')" name="name"/>
115 <field name="action">sign_in</field>
116 <field name="employee_id" ref="hr.employee1"/>
117 </record>
118
119 <record id="attendance20" model="hr.attendance">
120 <field eval="time.strftime('%Y-%m-10 12:34')" name="name"/>
121 <field name="action">sign_out</field>
122 <field name="employee_id" ref="hr.employee1"/>
123 </record>
124
125<!-- FIXME! Commented out to enable installation without creating conflicts
126 during the first days of a month. To be properly fixed, see
127 launchpad bug 791087!
128
129 <record id="attendance21" model="hr.attendance">
130 <field eval="time.strftime('%Y-%m-%d 10:00')" name="name"/>
131 <field name="action">sign_in</field>
132 <field name="employee_id" ref="hr.employee1"/>
133 </record>
134
135 <record id="attendance22" model="hr.attendance">
136 <field eval="time.strftime('%Y-%m-%d 18:00')" name="name"/>
137 <field name="action">sign_out</field>
138 <field name="employee_id" ref="hr.employee1"/>
139 </record>
140-->
141 </data>
142</openerp>
1430
=== added file 'hr_attendance/hr_attendance_demo.yml'
--- hr_attendance/hr_attendance_demo.yml 1970-01-01 00:00:00 +0000
+++ hr_attendance/hr_attendance_demo.yml 2011-09-15 11:57:57 +0000
@@ -0,0 +1,131 @@
1-
2 Creating demo data for attendance for current week consisting of five working days.
3-
4 !python {model: hr.attendance}: |
5 import time
6 from datetime import datetime, date
7 from datetime import timedelta
8 current_date = date(datetime.today().year, datetime.today().month, datetime.today().day)
9 day_of_week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday','Saturday', 'Sunday']
10 current_day = day_of_week[date.weekday(current_date)]
11 days = {'Monday': 1, 'Tuesday': 2, 'Wednesday': 3, 'Thursday': 4, 'Friday': 5}
12 loop = days[current_day]
13 employee_id = ref('hr.employee1')
14 names_in = [(current_date - timedelta(i)).strftime('%Y-%m-%d 10:00:00') for i in range(loop)]
15 names_out = [(current_date - timedelta(i)).strftime('%Y-%m-%d 19:00:00') for i in range(loop)]
16 attendance_ids = self.search(cr, uid, ['|',('name', 'in', names_in), ('name', 'in', names_out), ('employee_id','=',employee_id)])
17 names = []
18 if attendance_ids:
19 names = self.read(cr, uid, attendance_ids, ['id','name'], context=context)
20
21 def check_data(data, names=names):
22 if data['name'] in [i['name'] for i in names]:
23 return [i['id'] for i in names if data['name']==i['name']]
24
25 if current_day in ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']:
26 sign_in = {
27 'name': (current_date).strftime('%Y-%m-%d 10:00:00'),
28 'action': 'sign_in',
29 'employee_id': employee_id
30 }
31 ids = check_data(sign_in)
32 if ids:
33 self.write(cr, uid, ids, sign_in, context=context)
34 else:
35 self.create(cr, uid, sign_in, context=context)
36 sign_out = {
37 'name': (current_date).strftime('%Y-%m-%d 19:00:00'),
38 'action': 'sign_out',
39 'employee_id': employee_id
40 }
41 ids = check_data(sign_out)
42 if ids:
43 self.write(cr, uid, ids, sign_out, context=context)
44 else:
45 self.create(cr, uid, sign_out, context=context)
46 if current_day in ['Tuesday', 'Wednesday', 'Thursday', 'Friday']:
47 sign_in = {
48 'name': (current_date - timedelta(1)).strftime('%Y-%m-%d 10:00:00'),
49 'action': 'sign_in',
50 'employee_id': employee_id
51 }
52 ids = check_data(sign_in)
53 if ids:
54 self.write(cr, uid, ids, sign_in, context=context)
55 else:
56 self.create(cr, uid, sign_in, context=context)
57 sign_out = {
58 'name': (current_date - timedelta(1)).strftime('%Y-%m-%d 19:00:00'),
59 'action': 'sign_out',
60 'employee_id': employee_id
61 }
62 ids = check_data(sign_out)
63 if ids:
64 self.write(cr, uid, ids, sign_out, context=context)
65 else:
66 self.create(cr, uid, sign_out, context=context)
67 if current_day in ['Wednesday', 'Thursday', 'Friday']:
68 sign_in = {
69 'name': (current_date - timedelta(2)).strftime('%Y-%m-%d 10:00:00'),
70 'action': 'sign_in',
71 'employee_id': employee_id
72 }
73 ids = check_data(sign_in)
74 if ids:
75 self.write(cr, uid, ids, sign_in, context=context)
76 else:
77 self.create(cr, uid, sign_in, context=context)
78 sign_out = {
79 'name': (current_date - timedelta(2)).strftime('%Y-%m-%d 19:00:00'),
80 'action': 'sign_out',
81 'employee_id': employee_id
82 }
83 ids = check_data(sign_out)
84 if ids:
85 self.write(cr, uid, ids, sign_out, context=context)
86 else:
87 self.create(cr, uid, sign_out, context=context)
88 if current_day in ['Thursday', 'Friday']:
89 sign_in = {
90 'name': (current_date - timedelta(3)).strftime('%Y-%m-%d 10:00:00'),
91 'action': 'sign_in',
92 'employee_id': employee_id
93 }
94 ids = check_data(sign_in)
95 if ids:
96 self.write(cr, uid, ids, sign_in, context=context)
97 else:
98 self.create(cr, uid, sign_in, context=context)
99 sign_out = {
100 'name': (current_date - timedelta(3)).strftime('%Y-%m-%d 19:00:00'),
101 'action': 'sign_out',
102 'employee_id': employee_id
103 }
104 ids = check_data(sign_out)
105 if ids:
106 self.write(cr, uid, ids, sign_out, context=context)
107 else:
108 self.create(cr, uid, sign_out, context=context)
109 if current_day == 'Friday':
110 sign_in = {
111 'name': (current_date - timedelta(4)).strftime('%Y-%m-%d 10:00:00'),
112 'action': 'sign_in',
113 'employee_id': employee_id
114 }
115 ids = check_data(sign_in)
116 if ids:
117 self.write(cr, uid, ids, sign_in, context=context)
118 else:
119 self.create(cr, uid, sign_in, context=context)
120 sign_out = {
121 'name': (current_date - timedelta(4)).strftime('%Y-%m-%d 19:00:00'),
122 'action': 'sign_out',
123 'employee_id': employee_id
124 }
125 ids = check_data(sign_out)
126 if ids:
127 self.write(cr, uid, ids, sign_out, context=context)
128 else:
129 self.create(cr, uid, sign_out, context=context)
130
131

Subscribers

People subscribed via source and target branches

to all changes: