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
=== modified file 'hr_timesheet_fulfill/__init__.py'
--- hr_timesheet_fulfill/__init__.py 2011-08-12 12:53:16 +0000
+++ hr_timesheet_fulfill/__init__.py 2013-05-02 15:51:48 +0000
@@ -1,32 +1,25 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2##############################################################################2##############################################################################
3#3#
4# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)4# Author: Guewen Baconnier (Camptocamp)
5# All Right Reserved5# Author: Vincent Renaville
6#6# Copyright 2012 Camptocamp SA
7# Author : Guewen Baconnier (Camptocamp)7#
8#8# This program is free software: you can redistribute it and/or modify
9# WARNING: This program as such is intended to be used by professional9# it under the terms of the GNU Affero General Public License as
10# programmers who take the whole responsability of assessing all potential10# published by the Free Software Foundation, either version 3 of the
11# consequences resulting from its eventual inadequacies and bugs11# License, or (at your option) any later version.
12# End users who are looking for a ready-to-use solution with commercial12#
13# garantees and support are strongly adviced to contract a Free Software13# This program is distributed in the hope that it will be useful,
14# Service Company14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15#15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# This program is Free Software; you can redistribute it and/or16# GNU Affero General Public License for more details.
17# modify it under the terms of the GNU General Public License17#
18# as published by the Free Software Foundation; either version 218# You should have received a copy of the GNU Affero General Public License
19# of the License, or (at your option) any later version.19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21# This program is distributed in the hope that it will be useful,
22# but WITHOUT ANY WARRANTY; without even the implied warranty of
23# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24# GNU General Public License for more details.
25#
26# You should have received a copy of the GNU General Public License
27# along with this program; if not, write to the Free Software
28# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29#20#
30##############################################################################21##############################################################################
3122
32import wizard23import wizard
24
25# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
3326
=== modified file 'hr_timesheet_fulfill/__openerp__.py'
--- hr_timesheet_fulfill/__openerp__.py 2012-12-13 12:20:12 +0000
+++ hr_timesheet_fulfill/__openerp__.py 2013-05-02 15:51:48 +0000
@@ -1,57 +1,46 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2##############################################################################2##############################################################################
3#3#
4# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)4# Author: Guewen Baconnier (Camptocamp)
5# All Right Reserved5# Author: Vincent Renaville
6#6# Copyright 2012 Camptocamp SA
7# Author : Guewen Baconnier (Camptocamp)7#
8# Author : Vincent Renaville8# This program is free software: you can redistribute it and/or modify
9#9# it under the terms of the GNU Affero General Public License as
10# WARNING: This program as such is intended to be used by professional10# published by the Free Software Foundation, either version 3 of the
11# programmers who take the whole responsability of assessing all potential11# License, or (at your option) any later version.
12# consequences resulting from its eventual inadequacies and bugs12#
13# End users who are looking for a ready-to-use solution with commercial13# This program is distributed in the hope that it will be useful,
14# garantees and support are strongly adviced to contract a Free Software14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# Service Company15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16#16# GNU Affero General Public License for more details.
17# This program is Free Software; you can redistribute it and/or17#
18# modify it under the terms of the GNU General Public License18# You should have received a copy of the GNU Affero General Public License
19# as published by the Free Software Foundation; either version 219# along with this program. If not, see <http://www.gnu.org/licenses/>.
20# of the License, or (at your option) any later version.
21#
22# This program is distributed in the hope that it will be useful,
23# but WITHOUT ANY WARRANTY; without even the implied warranty of
24# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25# GNU General Public License for more details.
26#
27# You should have received a copy of the GNU General Public License
28# along with this program; if not, write to the Free Software
29# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30#20#
31##############################################################################21##############################################################################
3222
3323{'name' : 'Timesheet Fullfill Wizard',
34{24 'version' : '1.0',
35 "name" : "Timesheet fullfill wizard",25 'category' : 'Generic Modules/Human Resources',
36 "version" : "1.0",26 'description':
37 "author" : "Camptocamp",27 '''
38 "category" : "Generic Modules/Human Resources",28 Add a wizard into timesheet allowing people to complete a long period of time with the given values.
39 "description":29 This is mainly useful to handle a long period of time like holidays.
40"""30 Known limitation:
41Add a wizard into timesheet allowing people to complete a long period of time with the given values.31 - Will complete all day between dates
42This is mainly useful to handle a long period of time like holidays.32 ''',
43Known limitation:33 'author' : 'Camptocamp',
44 - Will complete all day between dates34 'website': 'http://camptocamp.com',
45""",35 'depends' : ['hr_timesheet_sheet',],
46 "website": "http://camptocamp.com",36 'data' : [
47 "depends" : [37 'wizard/timesheet_fulfill_view.xml',
48 "hr_timesheet_sheet",38 ],
49 ],39 'demo' : [],
50 "init_xml" : [],40 'test' : [],
51 "demo_xml" : [],41 'installable': True,
52 "update_xml" : [42 'auto_install' : False,
53 'wizard/timesheet_fulfill_view.xml',43 'application' : False,
54 ],
55 "active": False,
56 'installable': False
57}44}
45
46# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
5847
=== modified file 'hr_timesheet_fulfill/wizard/__init__.py'
--- hr_timesheet_fulfill/wizard/__init__.py 2011-08-12 12:53:16 +0000
+++ hr_timesheet_fulfill/wizard/__init__.py 2013-05-02 15:51:48 +0000
@@ -1,1 +1,4 @@
1
1import timesheet_fulfill2import timesheet_fulfill
3
4# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
2\ No newline at end of file5\ No newline at end of file
36
=== modified file 'hr_timesheet_fulfill/wizard/timesheet_fulfill.py'
--- hr_timesheet_fulfill/wizard/timesheet_fulfill.py 2011-09-01 13:44:19 +0000
+++ hr_timesheet_fulfill/wizard/timesheet_fulfill.py 2013-05-02 15:51:48 +0000
@@ -1,41 +1,29 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2##############################################################################2##############################################################################
3#3#
4# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)4# Author: Guewen Baconnier (Camptocamp)
5# All Right Reserved5# Author: Vincent Renaville
6#6# Copyright 2012 Camptocamp SA
7# Author : Guewen Baconnier (Camptocamp)7#
8# Author : Vincent Renaville8# This program is free software: you can redistribute it and/or modify
9#9# it under the terms of the GNU Affero General Public License as
10# WARNING: This program as such is intended to be used by professional10# published by the Free Software Foundation, either version 3 of the
11# programmers who take the whole responsability of assessing all potential11# License, or (at your option) any later version.
12# consequences resulting from its eventual inadequacies and bugs12#
13# End users who are looking for a ready-to-use solution with commercial13# This program is distributed in the hope that it will be useful,
14# garantees and support are strongly adviced to contract a Free Software14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# Service Company15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16#16# GNU Affero General Public License for more details.
17# This program is Free Software; you can redistribute it and/or17#
18# modify it under the terms of the GNU General Public License18# You should have received a copy of the GNU Affero General Public License
19# as published by the Free Software Foundation; either version 219# along with this program. If not, see <http://www.gnu.org/licenses/>.
20# of the License, or (at your option) any later version.
21#
22# This program is distributed in the hope that it will be useful,
23# but WITHOUT ANY WARRANTY; without even the implied warranty of
24# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25# GNU General Public License for more details.
26#
27# You should have received a copy of the GNU General Public License
28# along with this program; if not, write to the Free Software
29# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30#20#
31##############################################################################21##############################################################################
3222
3323from openerp.osv import fields, osv, orm
34from osv import fields, osv
35from tools.translate import _24from tools.translate import _
36from datetime import datetime, timedelta25from datetime import datetime, timedelta
3726
38
39def get_number_days_between_dates(date_from, date_to):27def get_number_days_between_dates(date_from, date_to):
40 datetime_from = datetime.strptime(date_from, '%Y-%m-%d')28 datetime_from = datetime.strptime(date_from, '%Y-%m-%d')
41 datetime_to = datetime.strptime(date_to, '%Y-%m-%d')29 datetime_to = datetime.strptime(date_to, '%Y-%m-%d')
@@ -44,7 +32,7 @@
44 return difference.days + 132 return difference.days + 1
4533
4634
47class FulfillTimesheet(osv.osv_memory):35class HrTimesheetFulfill(orm.TransientModel):
48 _name = 'hr.timesheet.fulfill'36 _name = 'hr.timesheet.fulfill'
49 _description = "Wizard to fill-in timesheet for many days"37 _description = "Wizard to fill-in timesheet for many days"
5038
@@ -52,16 +40,19 @@
52 'date_from': fields.date('Date From', required=True),40 'date_from': fields.date('Date From', required=True),
53 'date_to': fields.date('Date To', required=True),41 'date_to': fields.date('Date To', required=True),
54 'description': fields.char('Description', size=100, required=True),42 'description': fields.char('Description', size=100, required=True),
55 'nb_hours': fields.float('Hours per day', digits=(2, 2), required=True),43 'nb_hours': fields.float('Hours per Day', digits=(2, 2), required=True),
56 'analytic_account_id': fields.many2one('account.analytic.account',44 'analytic_account_id': fields.many2one('account.analytic.account',
57 'Analytic Account', required=True,45 'Analytic Account', required=True,
58 domain="[('type', '=', 'normal'),"46 domain="[('type', '=', 'normal'),"
59 "('state', '!=', 'pending'),"47 "('state', '!=', 'pending'),"
60 "('state', '!=', 'close')]"),48 "('state', '!=', 'close')]"),
61 'task_id':fields.many2one('project.task','Task', required=False)49 'task_id':fields.many2one('project.task', 'Task', required=False)
62 }50 }
6351
64 def fulfill_timesheet(self, cr, uid, ids, context):52 def fulfill_timesheet(self, cr, uid, ids, context=None):
53 if context is None:
54 context = {}
55
65 employee_obj = self.pool.get('hr.employee')56 employee_obj = self.pool.get('hr.employee')
66 timesheet_obj = self.pool.get('hr_timesheet_sheet.sheet')57 timesheet_obj = self.pool.get('hr_timesheet_sheet.sheet')
67 al_ts_obj = self.pool.get('hr.analytic.timesheet')58 al_ts_obj = self.pool.get('hr.analytic.timesheet')
@@ -117,23 +108,23 @@
117 'sheet_id': timesheet.id,108 'sheet_id': timesheet.id,
118 'journal_id': journal_id,109 'journal_id': journal_id,
119 }110 }
120
121 on_change_values = al_ts_obj.\111 on_change_values = al_ts_obj.\
122 on_change_unit_amount(cr, uid, False, product_id,112 on_change_unit_amount(cr, uid, False, product_id,
123 wizard.nb_hours, employee.company_id.id,113 wizard.nb_hours, employee.company_id.id,
124 task_id=wizard.task_id.id,114# task_id=wizard.task_id.id,
125 unit=unit_id, journal_id=journal_id,115 unit=unit_id, journal_id=journal_id,
126 context=context)116 context=context)
127 if on_change_values:117 if on_change_values:
128 res.update(on_change_values['value'])118 res.update(on_change_values['value'])
129 al_ts_obj.create(cr, uid, res, context)119 al_ts_obj.create(cr, uid, res, context)
130
131 # If there is no other attendances, create it120 # If there is no other attendances, create it
132 # create the attendances:121 # create the attendances:
133 existing_attendances = attendance_obj\122# print attendance_obj.read(cr,uid,['name'])
134 .search(cr, uid, [('name', '=', datetime_current),123 existing_attendances=0
135 ('employee_id', '=', employee_id)])124 att_id= attendance_obj.search(cr, uid, [('employee_id', '=', employee_id)])
136125 for record in attendance_obj.read(cr,uid,att_id,['name']):
126 if record['name'].startswith( datetime_current ):
127 existing_attendances=1
137 if not existing_attendances:128 if not existing_attendances:
138 att_date_start = datetime_current + " 00:00:00"129 att_date_start = datetime_current + " 00:00:00"
139 att_start = {130 att_start = {
@@ -154,6 +145,7 @@
154 }145 }
155 attendance_obj.create(cr, uid, att_start, context)146 attendance_obj.create(cr, uid, att_start, context)
156 attendance_obj.create(cr, uid, att_end, context)147 attendance_obj.create(cr, uid, att_end, context)
148
157 return {'type': 'ir.actions.act_window_close'}149 return {'type': 'ir.actions.act_window_close'}
158150
159FulfillTimesheet()151# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
160152
=== modified file 'hr_timesheet_fulfill/wizard/timesheet_fulfill_view.xml'
--- hr_timesheet_fulfill/wizard/timesheet_fulfill_view.xml 2011-08-12 12:53:16 +0000
+++ hr_timesheet_fulfill/wizard/timesheet_fulfill_view.xml 2013-05-02 15:51:48 +0000
@@ -1,43 +1,58 @@
1<?xml version="1.0" encoding="utf-8"?>1<?xml version="1.0" encoding="utf-8"?>
2<openerp>2<openerp>
3 <data>3 <data>
44
5 <record id="view_hr_timesheet_fulfill_form" model="ir.ui.view">5 <record id="view_hr_timesheet_fulfill_form" model="ir.ui.view">
6 <field name="name">hr.timesheet.fulfill.form</field>6 <field name="name">hr.timesheet.fulfill.form</field>
7 <field name="model">hr.timesheet.fulfill</field>7 <field name="model">hr.timesheet.fulfill</field>
8 <field name="type">form</field>8 <field name="arch" type="xml">
9 <field name="arch" type="xml">9 <form string="Enter the dates : ALL days between those dates will be completed." version="7.0">
10 <form string="Enter the dates : ALL days between those dates will be completed.">10 <group>
11 <field name="date_from"/>11 <group>
12 <field name="date_to"/>12 <field name="date_from"/>
13 <field name="analytic_account_id"/>13 </group>
14 <field name="task_id" domain="[('state','!=','cancel'),('state','!=','done')" context="{'account_id':analytic_account_id}"/>14 <group>
15 <field name="nb_hours" widget="float_time"/>15 <field name="date_to"/>
16 <field name="description" colspan="4"/>16 </group>
17 <group colspan="4" col="6">17 </group>
18 <button icon="gtk-cancel" special="cancel" string="Cancel"/>18 <group>
19 <button icon="gtk-ok" string="Fill in Timesheet" name="fulfill_timesheet" type="object"/>19 <group>
20 </group>20 <field name="analytic_account_id"/>
21 </form>21 </group>
22 </field>22 <group>
23 </record>23 <field name="task_id" domain="[('state','!=','cancel'),('state','!=','done')]" context="{'account_id':analytic_account_id}"/>
2424 </group>
25 <record id="action_hr_timesheet_fulfill" model="ir.actions.act_window">25 </group>
26 <field name="name">Fill in Timesheet</field>26 <group>
27 <field name="res_model">hr.timesheet.fulfill</field>27 <field name="nb_hours" widget="float_time"/>
28 <field name="view_type">form</field>28 </group>
29 <field name="view_mode">form</field>29 <group colspan="4">
30 <field name="view_id" ref="view_hr_timesheet_fulfill_form"/>30 <field name="description"/>
31 <field name="target">new</field>31 </group>
32 </record>32 <footer>
3333 <button icon="gtk-cancel" special="cancel" string="Cancel"/>
34 <record id="ir_action_hr_timesheet_fulfill_wizard" model="ir.values">34 <button icon="gtk-ok" string="Fill in Timesheet" name="fulfill_timesheet" type="object"/>
35 <field name="key2">client_action_multi</field>35 </footer>
36 <field name="model">hr_timesheet_sheet.sheet</field>36 </form>
37 <field name="name">Fill in Timesheet</field>37 </field>
38 <field eval="'ir.actions.act_window,%d'%action_hr_timesheet_fulfill" name="value"/>38 </record>
39 <field eval="True" name="object"/>39
40 </record>40 <record id="action_hr_timesheet_fulfill" model="ir.actions.act_window">
4141 <field name="name">Fill in Timesheet</field>
42</data>42 <field name="res_model">hr.timesheet.fulfill</field>
43 <field name="view_type">form</field>
44 <field name="view_mode">form</field>
45 <field name="view_id" ref="view_hr_timesheet_fulfill_form"/>
46 <field name="target">new</field>
47 </record>
48
49 <record id="ir_action_hr_timesheet_fulfill_wizard" model="ir.values">
50 <field name="key2">client_action_multi</field>
51 <field name="model">hr_timesheet_sheet.sheet</field>
52 <field name="name">Fill in Timesheet</field>
53 <field eval="'ir.actions.act_window,%d'%action_hr_timesheet_fulfill" name="value"/>
54 <field eval="True" name="object"/>
55 </record>
56
57 </data>
43</openerp>58</openerp>

Subscribers

People subscribed via source and target branches