Merge lp:~camptocamp/hr-timesheet/7.0-port-hr_timesheet_fulfill into lp:~hr-core-editors/hr-timesheet/7.0

Proposed by Yannick Vaucher @ Camptocamp
Status: Merged
Merged at revision: 45
Proposed branch: lp:~camptocamp/hr-timesheet/7.0-port-hr_timesheet_fulfill
Merge into: lp:~hr-core-editors/hr-timesheet/7.0
Diff against target: 405 lines (+150/-158)
5 files modified
hr_timesheet_fulfill/__init__.py (+18/-25)
hr_timesheet_fulfill/__openerp__.py (+39/-50)
hr_timesheet_fulfill/wizard/__init__.py (+3/-0)
hr_timesheet_fulfill/wizard/timesheet_fulfill.py (+35/-43)
hr_timesheet_fulfill/wizard/timesheet_fulfill_view.xml (+55/-40)
To merge this branch: bzr merge lp:~camptocamp/hr-timesheet/7.0-port-hr_timesheet_fulfill
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Approve
Alexandre Fayolle - camptocamp code review, no test Approve
Review via email: mp+162123@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

LGTM

review: Approve (code review, no test)
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hr_timesheet_fulfill/__init__.py'
2--- hr_timesheet_fulfill/__init__.py 2011-08-12 12:53:16 +0000
3+++ hr_timesheet_fulfill/__init__.py 2013-05-02 15:51:48 +0000
4@@ -1,32 +1,25 @@
5 # -*- coding: utf-8 -*-
6 ##############################################################################
7 #
8-# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)
9-# All Right Reserved
10-#
11-# Author : Guewen Baconnier (Camptocamp)
12-#
13-# WARNING: This program as such is intended to be used by professional
14-# programmers who take the whole responsability of assessing all potential
15-# consequences resulting from its eventual inadequacies and bugs
16-# End users who are looking for a ready-to-use solution with commercial
17-# garantees and support are strongly adviced to contract a Free Software
18-# Service Company
19-#
20-# This program is Free Software; you can redistribute it and/or
21-# modify it under the terms of the GNU General Public License
22-# as published by the Free Software Foundation; either version 2
23-# of the License, or (at your option) any later version.
24-#
25-# This program is distributed in the hope that it will be useful,
26-# but WITHOUT ANY WARRANTY; without even the implied warranty of
27-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28-# GNU General Public License for more details.
29-#
30-# You should have received a copy of the GNU General Public License
31-# along with this program; if not, write to the Free Software
32-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33+# Author: Guewen Baconnier (Camptocamp)
34+# Author: Vincent Renaville
35+# Copyright 2012 Camptocamp SA
36+#
37+# This program is free software: you can redistribute it and/or modify
38+# it under the terms of the GNU Affero General Public License as
39+# published by the Free Software Foundation, either version 3 of the
40+# License, or (at your option) any later version.
41+#
42+# This program is distributed in the hope that it will be useful,
43+# but WITHOUT ANY WARRANTY; without even the implied warranty of
44+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45+# GNU Affero General Public License for more details.
46+#
47+# You should have received a copy of the GNU Affero General Public License
48+# along with this program. If not, see <http://www.gnu.org/licenses/>.
49 #
50 ##############################################################################
51
52 import wizard
53+
54+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
55
56=== modified file 'hr_timesheet_fulfill/__openerp__.py'
57--- hr_timesheet_fulfill/__openerp__.py 2012-12-13 12:20:12 +0000
58+++ hr_timesheet_fulfill/__openerp__.py 2013-05-02 15:51:48 +0000
59@@ -1,57 +1,46 @@
60 # -*- coding: utf-8 -*-
61 ##############################################################################
62 #
63-# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)
64-# All Right Reserved
65-#
66-# Author : Guewen Baconnier (Camptocamp)
67-# Author : Vincent Renaville
68-#
69-# WARNING: This program as such is intended to be used by professional
70-# programmers who take the whole responsability of assessing all potential
71-# consequences resulting from its eventual inadequacies and bugs
72-# End users who are looking for a ready-to-use solution with commercial
73-# garantees and support are strongly adviced to contract a Free Software
74-# Service Company
75-#
76-# This program is Free Software; you can redistribute it and/or
77-# modify it under the terms of the GNU General Public License
78-# as published by the Free Software Foundation; either version 2
79-# of the License, or (at your option) any later version.
80-#
81-# This program is distributed in the hope that it will be useful,
82-# but WITHOUT ANY WARRANTY; without even the implied warranty of
83-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84-# GNU General Public License for more details.
85-#
86-# You should have received a copy of the GNU General Public License
87-# along with this program; if not, write to the Free Software
88-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
89+# Author: Guewen Baconnier (Camptocamp)
90+# Author: Vincent Renaville
91+# Copyright 2012 Camptocamp SA
92+#
93+# This program is free software: you can redistribute it and/or modify
94+# it under the terms of the GNU Affero General Public License as
95+# published by the Free Software Foundation, either version 3 of the
96+# License, or (at your option) any later version.
97+#
98+# This program is distributed in the hope that it will be useful,
99+# but WITHOUT ANY WARRANTY; without even the implied warranty of
100+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
101+# GNU Affero General Public License for more details.
102+#
103+# You should have received a copy of the GNU Affero General Public License
104+# along with this program. If not, see <http://www.gnu.org/licenses/>.
105 #
106 ##############################################################################
107
108-
109-{
110- "name" : "Timesheet fullfill wizard",
111- "version" : "1.0",
112- "author" : "Camptocamp",
113- "category" : "Generic Modules/Human Resources",
114- "description":
115-"""
116-Add a wizard into timesheet allowing people to complete a long period of time with the given values.
117-This is mainly useful to handle a long period of time like holidays.
118-Known limitation:
119- - Will complete all day between dates
120-""",
121- "website": "http://camptocamp.com",
122- "depends" : [
123- "hr_timesheet_sheet",
124- ],
125- "init_xml" : [],
126- "demo_xml" : [],
127- "update_xml" : [
128- 'wizard/timesheet_fulfill_view.xml',
129- ],
130- "active": False,
131- 'installable': False
132+{'name' : 'Timesheet Fullfill Wizard',
133+ 'version' : '1.0',
134+ 'category' : 'Generic Modules/Human Resources',
135+ 'description':
136+ '''
137+ Add a wizard into timesheet allowing people to complete a long period of time with the given values.
138+ This is mainly useful to handle a long period of time like holidays.
139+ Known limitation:
140+ - Will complete all day between dates
141+ ''',
142+ 'author' : 'Camptocamp',
143+ 'website': 'http://camptocamp.com',
144+ 'depends' : ['hr_timesheet_sheet',],
145+ 'data' : [
146+ 'wizard/timesheet_fulfill_view.xml',
147+ ],
148+ 'demo' : [],
149+ 'test' : [],
150+ 'installable': True,
151+ 'auto_install' : False,
152+ 'application' : False,
153 }
154+
155+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
156
157=== modified file 'hr_timesheet_fulfill/wizard/__init__.py'
158--- hr_timesheet_fulfill/wizard/__init__.py 2011-08-12 12:53:16 +0000
159+++ hr_timesheet_fulfill/wizard/__init__.py 2013-05-02 15:51:48 +0000
160@@ -1,1 +1,4 @@
161+
162 import timesheet_fulfill
163+
164+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
165\ No newline at end of file
166
167=== modified file 'hr_timesheet_fulfill/wizard/timesheet_fulfill.py'
168--- hr_timesheet_fulfill/wizard/timesheet_fulfill.py 2011-09-01 13:44:19 +0000
169+++ hr_timesheet_fulfill/wizard/timesheet_fulfill.py 2013-05-02 15:51:48 +0000
170@@ -1,41 +1,29 @@
171 # -*- coding: utf-8 -*-
172 ##############################################################################
173 #
174-# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)
175-# All Right Reserved
176-#
177-# Author : Guewen Baconnier (Camptocamp)
178-# Author : Vincent Renaville
179-#
180-# WARNING: This program as such is intended to be used by professional
181-# programmers who take the whole responsability of assessing all potential
182-# consequences resulting from its eventual inadequacies and bugs
183-# End users who are looking for a ready-to-use solution with commercial
184-# garantees and support are strongly adviced to contract a Free Software
185-# Service Company
186-#
187-# This program is Free Software; you can redistribute it and/or
188-# modify it under the terms of the GNU General Public License
189-# as published by the Free Software Foundation; either version 2
190-# of the License, or (at your option) any later version.
191-#
192-# This program is distributed in the hope that it will be useful,
193-# but WITHOUT ANY WARRANTY; without even the implied warranty of
194-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
195-# GNU General Public License for more details.
196-#
197-# You should have received a copy of the GNU General Public License
198-# along with this program; if not, write to the Free Software
199-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
200+# Author: Guewen Baconnier (Camptocamp)
201+# Author: Vincent Renaville
202+# Copyright 2012 Camptocamp SA
203+#
204+# This program is free software: you can redistribute it and/or modify
205+# it under the terms of the GNU Affero General Public License as
206+# published by the Free Software Foundation, either version 3 of the
207+# License, or (at your option) any later version.
208+#
209+# This program is distributed in the hope that it will be useful,
210+# but WITHOUT ANY WARRANTY; without even the implied warranty of
211+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
212+# GNU Affero General Public License for more details.
213+#
214+# You should have received a copy of the GNU Affero General Public License
215+# along with this program. If not, see <http://www.gnu.org/licenses/>.
216 #
217 ##############################################################################
218
219-
220-from osv import fields, osv
221+from openerp.osv import fields, osv, orm
222 from tools.translate import _
223 from datetime import datetime, timedelta
224
225-
226 def get_number_days_between_dates(date_from, date_to):
227 datetime_from = datetime.strptime(date_from, '%Y-%m-%d')
228 datetime_to = datetime.strptime(date_to, '%Y-%m-%d')
229@@ -44,7 +32,7 @@
230 return difference.days + 1
231
232
233-class FulfillTimesheet(osv.osv_memory):
234+class HrTimesheetFulfill(orm.TransientModel):
235 _name = 'hr.timesheet.fulfill'
236 _description = "Wizard to fill-in timesheet for many days"
237
238@@ -52,16 +40,19 @@
239 'date_from': fields.date('Date From', required=True),
240 'date_to': fields.date('Date To', required=True),
241 'description': fields.char('Description', size=100, required=True),
242- 'nb_hours': fields.float('Hours per day', digits=(2, 2), required=True),
243+ 'nb_hours': fields.float('Hours per Day', digits=(2, 2), required=True),
244 'analytic_account_id': fields.many2one('account.analytic.account',
245 'Analytic Account', required=True,
246 domain="[('type', '=', 'normal'),"
247 "('state', '!=', 'pending'),"
248 "('state', '!=', 'close')]"),
249- 'task_id':fields.many2one('project.task','Task', required=False)
250- }
251-
252- def fulfill_timesheet(self, cr, uid, ids, context):
253+ 'task_id':fields.many2one('project.task', 'Task', required=False)
254+ }
255+
256+ def fulfill_timesheet(self, cr, uid, ids, context=None):
257+ if context is None:
258+ context = {}
259+
260 employee_obj = self.pool.get('hr.employee')
261 timesheet_obj = self.pool.get('hr_timesheet_sheet.sheet')
262 al_ts_obj = self.pool.get('hr.analytic.timesheet')
263@@ -117,23 +108,23 @@
264 'sheet_id': timesheet.id,
265 'journal_id': journal_id,
266 }
267-
268 on_change_values = al_ts_obj.\
269 on_change_unit_amount(cr, uid, False, product_id,
270 wizard.nb_hours, employee.company_id.id,
271- task_id=wizard.task_id.id,
272+# task_id=wizard.task_id.id,
273 unit=unit_id, journal_id=journal_id,
274 context=context)
275 if on_change_values:
276 res.update(on_change_values['value'])
277 al_ts_obj.create(cr, uid, res, context)
278-
279 # If there is no other attendances, create it
280 # create the attendances:
281- existing_attendances = attendance_obj\
282- .search(cr, uid, [('name', '=', datetime_current),
283- ('employee_id', '=', employee_id)])
284-
285+# print attendance_obj.read(cr,uid,['name'])
286+ existing_attendances=0
287+ att_id= attendance_obj.search(cr, uid, [('employee_id', '=', employee_id)])
288+ for record in attendance_obj.read(cr,uid,att_id,['name']):
289+ if record['name'].startswith( datetime_current ):
290+ existing_attendances=1
291 if not existing_attendances:
292 att_date_start = datetime_current + " 00:00:00"
293 att_start = {
294@@ -154,6 +145,7 @@
295 }
296 attendance_obj.create(cr, uid, att_start, context)
297 attendance_obj.create(cr, uid, att_end, context)
298+
299 return {'type': 'ir.actions.act_window_close'}
300
301-FulfillTimesheet()
302+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
303
304=== modified file 'hr_timesheet_fulfill/wizard/timesheet_fulfill_view.xml'
305--- hr_timesheet_fulfill/wizard/timesheet_fulfill_view.xml 2011-08-12 12:53:16 +0000
306+++ hr_timesheet_fulfill/wizard/timesheet_fulfill_view.xml 2013-05-02 15:51:48 +0000
307@@ -1,43 +1,58 @@
308 <?xml version="1.0" encoding="utf-8"?>
309 <openerp>
310- <data>
311-
312- <record id="view_hr_timesheet_fulfill_form" model="ir.ui.view">
313- <field name="name">hr.timesheet.fulfill.form</field>
314- <field name="model">hr.timesheet.fulfill</field>
315- <field name="type">form</field>
316- <field name="arch" type="xml">
317- <form string="Enter the dates : ALL days between those dates will be completed.">
318- <field name="date_from"/>
319- <field name="date_to"/>
320- <field name="analytic_account_id"/>
321- <field name="task_id" domain="[('state','!=','cancel'),('state','!=','done')" context="{'account_id':analytic_account_id}"/>
322- <field name="nb_hours" widget="float_time"/>
323- <field name="description" colspan="4"/>
324- <group colspan="4" col="6">
325- <button icon="gtk-cancel" special="cancel" string="Cancel"/>
326- <button icon="gtk-ok" string="Fill in Timesheet" name="fulfill_timesheet" type="object"/>
327- </group>
328- </form>
329- </field>
330- </record>
331-
332- <record id="action_hr_timesheet_fulfill" model="ir.actions.act_window">
333- <field name="name">Fill in Timesheet</field>
334- <field name="res_model">hr.timesheet.fulfill</field>
335- <field name="view_type">form</field>
336- <field name="view_mode">form</field>
337- <field name="view_id" ref="view_hr_timesheet_fulfill_form"/>
338- <field name="target">new</field>
339- </record>
340-
341- <record id="ir_action_hr_timesheet_fulfill_wizard" model="ir.values">
342- <field name="key2">client_action_multi</field>
343- <field name="model">hr_timesheet_sheet.sheet</field>
344- <field name="name">Fill in Timesheet</field>
345- <field eval="'ir.actions.act_window,%d'%action_hr_timesheet_fulfill" name="value"/>
346- <field eval="True" name="object"/>
347- </record>
348-
349-</data>
350+ <data>
351+
352+ <record id="view_hr_timesheet_fulfill_form" model="ir.ui.view">
353+ <field name="name">hr.timesheet.fulfill.form</field>
354+ <field name="model">hr.timesheet.fulfill</field>
355+ <field name="arch" type="xml">
356+ <form string="Enter the dates : ALL days between those dates will be completed." version="7.0">
357+ <group>
358+ <group>
359+ <field name="date_from"/>
360+ </group>
361+ <group>
362+ <field name="date_to"/>
363+ </group>
364+ </group>
365+ <group>
366+ <group>
367+ <field name="analytic_account_id"/>
368+ </group>
369+ <group>
370+ <field name="task_id" domain="[('state','!=','cancel'),('state','!=','done')]" context="{'account_id':analytic_account_id}"/>
371+ </group>
372+ </group>
373+ <group>
374+ <field name="nb_hours" widget="float_time"/>
375+ </group>
376+ <group colspan="4">
377+ <field name="description"/>
378+ </group>
379+ <footer>
380+ <button icon="gtk-cancel" special="cancel" string="Cancel"/>
381+ <button icon="gtk-ok" string="Fill in Timesheet" name="fulfill_timesheet" type="object"/>
382+ </footer>
383+ </form>
384+ </field>
385+ </record>
386+
387+ <record id="action_hr_timesheet_fulfill" model="ir.actions.act_window">
388+ <field name="name">Fill in Timesheet</field>
389+ <field name="res_model">hr.timesheet.fulfill</field>
390+ <field name="view_type">form</field>
391+ <field name="view_mode">form</field>
392+ <field name="view_id" ref="view_hr_timesheet_fulfill_form"/>
393+ <field name="target">new</field>
394+ </record>
395+
396+ <record id="ir_action_hr_timesheet_fulfill_wizard" model="ir.values">
397+ <field name="key2">client_action_multi</field>
398+ <field name="model">hr_timesheet_sheet.sheet</field>
399+ <field name="name">Fill in Timesheet</field>
400+ <field eval="'ir.actions.act_window,%d'%action_hr_timesheet_fulfill" name="value"/>
401+ <field eval="True" name="object"/>
402+ </record>
403+
404+ </data>
405 </openerp>

Subscribers

People subscribed via source and target branches