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
1=== modified file 'hr_attendance/__openerp__.py'
2--- hr_attendance/__openerp__.py 2011-07-06 12:29:28 +0000
3+++ hr_attendance/__openerp__.py 2011-09-15 11:57:57 +0000
4@@ -46,7 +46,7 @@
5 'wizard/hr_attendance_error_view.xml',
6 'wizard/hr_attendance_sign_in_out_view.xml',
7 ],
8- 'demo_xml': ['hr_attendance_demo.xml'],
9+ 'demo_xml': ['hr_attendance_demo.yml'],
10 'test': ['test/test_hr_attendance.yml',
11 'test/hr_attendance_report.yml'
12 ],
13
14=== removed file 'hr_attendance/hr_attendance_demo.xml'
15--- hr_attendance/hr_attendance_demo.xml 2011-07-07 12:25:42 +0000
16+++ hr_attendance/hr_attendance_demo.xml 1970-01-01 00:00:00 +0000
17@@ -1,142 +0,0 @@
18-<?xml version="1.0" encoding="utf-8"?>
19-<openerp>
20- <data noupdate="True">
21-
22- <record id="attendance1" model="hr.attendance">
23- <field eval="time.strftime('%Y-%m-01 08:21')" name="name"/>
24- <field name="action">sign_in</field>
25- <field name="employee_id" ref="hr.employee1"/>
26- </record>
27-
28- <record id="attendance2" model="hr.attendance">
29- <field eval="time.strftime('%Y-%m-01 11:51')" name="name"/>
30- <field name="action">sign_out</field>
31- <field name="employee_id" ref="hr.employee1"/>
32- </record>
33-
34- <record id="attendance3" model="hr.attendance">
35- <field eval="time.strftime('%Y-%m-02 12:47')" name="name"/>
36- <field name="action">sign_in</field>
37- <field name="employee_id" ref="hr.employee1"/>
38- </record>
39-
40- <record id="attendance4" model="hr.attendance">
41- <field eval="time.strftime('%Y-%m-02 19:53')" name="name"/>
42- <field name="action">sign_out</field>
43- <field name="employee_id" ref="hr.employee1"/>
44- </record>
45-
46- <record id="attendance5" model="hr.attendance">
47- <field eval="time.strftime('%Y-%m-03 07:32')" name="name"/>
48- <field name="action">sign_in</field>
49- <field name="employee_id" ref="hr.employee1"/>
50- </record>
51-
52- <record id="attendance6" model="hr.attendance">
53- <field eval="time.strftime('%Y-%m-03 12:32')" name="name"/>
54- <field name="action">sign_out</field>
55- <field name="employee_id" ref="hr.employee1"/>
56- </record>
57-
58- <record id="attendance7" model="hr.attendance">
59- <field eval="time.strftime('%Y-%m-04 14:01')" name="name"/>
60- <field name="action">sign_in</field>
61- <field name="employee_id" ref="hr.employee1"/>
62- </record>
63-
64- <record id="attendance8" model="hr.attendance">
65- <field eval="time.strftime('%Y-%m-04 17:21')" name="name"/>
66- <field name="action">sign_out</field>
67- <field name="employee_id" ref="hr.employee1"/>
68- </record>
69-
70- <record id="attendance9" model="hr.attendance">
71- <field eval="time.strftime('%Y-%m-05 09:10')" name="name"/>
72- <field name="action">sign_in</field>
73- <field name="employee_id" ref="hr.employee1"/>
74- </record>
75-
76- <record id="attendance10" model="hr.attendance">
77- <field eval="time.strftime('%Y-%m-05 12:42')" name="name"/>
78- <field name="action">sign_out</field>
79- <field name="employee_id" ref="hr.employee1"/>
80- </record>
81-
82- <record id="attendance11" model="hr.attendance">
83- <field eval="time.strftime('%Y-%m-06 13:10')" name="name"/>
84- <field name="action">sign_in</field>
85- <field name="employee_id" ref="hr.employee1"/>
86- </record>
87-
88- <record id="attendance12" model="hr.attendance">
89- <field eval="time.strftime('%Y-%m-06 18:34')" name="name"/>
90- <field name="action">sign_out</field>
91- <field name="employee_id" ref="hr.employee1"/>
92- </record>
93-
94- <record id="attendance13" model="hr.attendance">
95- <field eval="time.strftime('%Y-%m-07 08:21')" name="name"/>
96- <field name="action">sign_in</field>
97- <field name="employee_id" ref="hr.employee1"/>
98- </record>
99-
100- <record id="attendance14" model="hr.attendance">
101- <field eval="time.strftime('%Y-%m-07 18:21')" name="name"/>
102- <field name="action">sign_out</field>
103- <field name="employee_id" ref="hr.employee1"/>
104- </record>
105-
106- <record id="attendance15" model="hr.attendance">
107- <field eval="time.strftime('%Y-%m-08 08:21')" name="name"/>
108- <field name="action">sign_in</field>
109- <field name="employee_id" ref="hr.employee1"/>
110- </record>
111-
112- <record id="attendance16" model="hr.attendance">
113- <field eval="time.strftime('%Y-%m-08 12:54')" name="name"/>
114- <field name="action">sign_out</field>
115- <field name="employee_id" ref="hr.employee1"/>
116- </record>
117-
118- <record id="attendance17" model="hr.attendance">
119- <field eval="time.strftime('%Y-%m-09 13:32')" name="name"/>
120- <field name="action">sign_in</field>
121- <field name="employee_id" ref="hr.employee1"/>
122- </record>
123-
124- <record id="attendance18" model="hr.attendance">
125- <field eval="time.strftime('%Y-%m-09 19:31')" name="name"/>
126- <field name="action">sign_out</field>
127- <field name="employee_id" ref="hr.employee1"/>
128- </record>
129-
130- <record id="attendance19" model="hr.attendance">
131- <field eval="time.strftime('%Y-%m-10 07:10')" name="name"/>
132- <field name="action">sign_in</field>
133- <field name="employee_id" ref="hr.employee1"/>
134- </record>
135-
136- <record id="attendance20" model="hr.attendance">
137- <field eval="time.strftime('%Y-%m-10 12:34')" name="name"/>
138- <field name="action">sign_out</field>
139- <field name="employee_id" ref="hr.employee1"/>
140- </record>
141-
142-<!-- FIXME! Commented out to enable installation without creating conflicts
143- during the first days of a month. To be properly fixed, see
144- launchpad bug 791087!
145-
146- <record id="attendance21" model="hr.attendance">
147- <field eval="time.strftime('%Y-%m-%d 10:00')" name="name"/>
148- <field name="action">sign_in</field>
149- <field name="employee_id" ref="hr.employee1"/>
150- </record>
151-
152- <record id="attendance22" model="hr.attendance">
153- <field eval="time.strftime('%Y-%m-%d 18:00')" name="name"/>
154- <field name="action">sign_out</field>
155- <field name="employee_id" ref="hr.employee1"/>
156- </record>
157--->
158- </data>
159-</openerp>
160
161=== added file 'hr_attendance/hr_attendance_demo.yml'
162--- hr_attendance/hr_attendance_demo.yml 1970-01-01 00:00:00 +0000
163+++ hr_attendance/hr_attendance_demo.yml 2011-09-15 11:57:57 +0000
164@@ -0,0 +1,131 @@
165+-
166+ Creating demo data for attendance for current week consisting of five working days.
167+-
168+ !python {model: hr.attendance}: |
169+ import time
170+ from datetime import datetime, date
171+ from datetime import timedelta
172+ current_date = date(datetime.today().year, datetime.today().month, datetime.today().day)
173+ day_of_week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday','Saturday', 'Sunday']
174+ current_day = day_of_week[date.weekday(current_date)]
175+ days = {'Monday': 1, 'Tuesday': 2, 'Wednesday': 3, 'Thursday': 4, 'Friday': 5}
176+ loop = days[current_day]
177+ employee_id = ref('hr.employee1')
178+ names_in = [(current_date - timedelta(i)).strftime('%Y-%m-%d 10:00:00') for i in range(loop)]
179+ names_out = [(current_date - timedelta(i)).strftime('%Y-%m-%d 19:00:00') for i in range(loop)]
180+ attendance_ids = self.search(cr, uid, ['|',('name', 'in', names_in), ('name', 'in', names_out), ('employee_id','=',employee_id)])
181+ names = []
182+ if attendance_ids:
183+ names = self.read(cr, uid, attendance_ids, ['id','name'], context=context)
184+
185+ def check_data(data, names=names):
186+ if data['name'] in [i['name'] for i in names]:
187+ return [i['id'] for i in names if data['name']==i['name']]
188+
189+ if current_day in ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']:
190+ sign_in = {
191+ 'name': (current_date).strftime('%Y-%m-%d 10:00:00'),
192+ 'action': 'sign_in',
193+ 'employee_id': employee_id
194+ }
195+ ids = check_data(sign_in)
196+ if ids:
197+ self.write(cr, uid, ids, sign_in, context=context)
198+ else:
199+ self.create(cr, uid, sign_in, context=context)
200+ sign_out = {
201+ 'name': (current_date).strftime('%Y-%m-%d 19:00:00'),
202+ 'action': 'sign_out',
203+ 'employee_id': employee_id
204+ }
205+ ids = check_data(sign_out)
206+ if ids:
207+ self.write(cr, uid, ids, sign_out, context=context)
208+ else:
209+ self.create(cr, uid, sign_out, context=context)
210+ if current_day in ['Tuesday', 'Wednesday', 'Thursday', 'Friday']:
211+ sign_in = {
212+ 'name': (current_date - timedelta(1)).strftime('%Y-%m-%d 10:00:00'),
213+ 'action': 'sign_in',
214+ 'employee_id': employee_id
215+ }
216+ ids = check_data(sign_in)
217+ if ids:
218+ self.write(cr, uid, ids, sign_in, context=context)
219+ else:
220+ self.create(cr, uid, sign_in, context=context)
221+ sign_out = {
222+ 'name': (current_date - timedelta(1)).strftime('%Y-%m-%d 19:00:00'),
223+ 'action': 'sign_out',
224+ 'employee_id': employee_id
225+ }
226+ ids = check_data(sign_out)
227+ if ids:
228+ self.write(cr, uid, ids, sign_out, context=context)
229+ else:
230+ self.create(cr, uid, sign_out, context=context)
231+ if current_day in ['Wednesday', 'Thursday', 'Friday']:
232+ sign_in = {
233+ 'name': (current_date - timedelta(2)).strftime('%Y-%m-%d 10:00:00'),
234+ 'action': 'sign_in',
235+ 'employee_id': employee_id
236+ }
237+ ids = check_data(sign_in)
238+ if ids:
239+ self.write(cr, uid, ids, sign_in, context=context)
240+ else:
241+ self.create(cr, uid, sign_in, context=context)
242+ sign_out = {
243+ 'name': (current_date - timedelta(2)).strftime('%Y-%m-%d 19:00:00'),
244+ 'action': 'sign_out',
245+ 'employee_id': employee_id
246+ }
247+ ids = check_data(sign_out)
248+ if ids:
249+ self.write(cr, uid, ids, sign_out, context=context)
250+ else:
251+ self.create(cr, uid, sign_out, context=context)
252+ if current_day in ['Thursday', 'Friday']:
253+ sign_in = {
254+ 'name': (current_date - timedelta(3)).strftime('%Y-%m-%d 10:00:00'),
255+ 'action': 'sign_in',
256+ 'employee_id': employee_id
257+ }
258+ ids = check_data(sign_in)
259+ if ids:
260+ self.write(cr, uid, ids, sign_in, context=context)
261+ else:
262+ self.create(cr, uid, sign_in, context=context)
263+ sign_out = {
264+ 'name': (current_date - timedelta(3)).strftime('%Y-%m-%d 19:00:00'),
265+ 'action': 'sign_out',
266+ 'employee_id': employee_id
267+ }
268+ ids = check_data(sign_out)
269+ if ids:
270+ self.write(cr, uid, ids, sign_out, context=context)
271+ else:
272+ self.create(cr, uid, sign_out, context=context)
273+ if current_day == 'Friday':
274+ sign_in = {
275+ 'name': (current_date - timedelta(4)).strftime('%Y-%m-%d 10:00:00'),
276+ 'action': 'sign_in',
277+ 'employee_id': employee_id
278+ }
279+ ids = check_data(sign_in)
280+ if ids:
281+ self.write(cr, uid, ids, sign_in, context=context)
282+ else:
283+ self.create(cr, uid, sign_in, context=context)
284+ sign_out = {
285+ 'name': (current_date - timedelta(4)).strftime('%Y-%m-%d 19:00:00'),
286+ 'action': 'sign_out',
287+ 'employee_id': employee_id
288+ }
289+ ids = check_data(sign_out)
290+ if ids:
291+ self.write(cr, uid, ids, sign_out, context=context)
292+ else:
293+ self.create(cr, uid, sign_out, context=context)
294+
295+

Subscribers

People subscribed via source and target branches

to all changes: