merge
[odoo/odoo.git] / addons / hr_timesheet_sheet / hr_timesheet_sheet.py
index 53e5087..d405dce 100644 (file)
@@ -1,30 +1,22 @@
 # -*- encoding: utf-8 -*-
 ##############################################################################
 #
-# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
+#    OpenERP, Open Source Management Solution  
+#    Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+#    $Id$
 #
-# $Id$
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
 #
-# WARNING: This program as such is intended to be used by professional
-# programmers who take the whole responsability of assessing all potential
-# consequences resulting from its eventual inadequacies and bugs
-# End users who are looking for a ready-to-use solution with commercial
-# garantees and support are strongly adviced to contract a Free Software
-# Service Company
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
 #
-# This program is Free Software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
 
@@ -222,8 +214,8 @@ class hr_timesheet_sheet(osv.osv):
                 'new': [('readonly', False)]}
             ),
         'attendances_ids' : one2many_mod2('hr.attendance', 'sheet_id', 'Attendances', readonly=True, states={'draft':[('readonly',False)],'new':[('readonly',False)]}),
-        'state' : fields.selection([('new', 'New'),('draft','Draft'),('confirm','Confirmed'),('done','Done')], 'State', select=True, required=True, readonly=True),
-        'state_attendance' : fields.function(_state_attendance, method=True, type='selection', selection=[('absent', 'Absent'), ('present', 'Present'),('none','No employee defined')], string='Current state'),
+        'state' : fields.selection([('new', 'New'),('draft','Draft'),('confirm','Confirmed'),('done','Done')], 'Status', select=True, required=True, readonly=True),
+        'state_attendance' : fields.function(_state_attendance, method=True, type='selection', selection=[('absent', 'Absent'), ('present', 'Present'),('none','No employee defined')], string='Current Status'),
         'total_attendance_day': fields.function(_total_day, method=True, string='Total Attendance'),
         'total_timesheet_day': fields.function(_total_day, method=True, string='Total Timesheet'),
         'total_difference_day': fields.function(_total_day, method=True, string='Difference'),
@@ -269,8 +261,8 @@ class hr_timesheet_sheet(osv.osv):
             cr.execute('SELECT id \
                     FROM hr_timesheet_sheet_sheet \
                     WHERE (date_from < %s and %s < date_to) \
-                        AND user_id=%d \
-                        AND id <> %d', (sheet.date_to, sheet.date_from,
+                        AND user_id=%s \
+                        AND id <> %s', (sheet.date_to, sheet.date_from,
                             sheet.user_id.id, sheet.id))
             if cr.fetchall():
                 return False
@@ -284,7 +276,7 @@ class hr_timesheet_sheet(osv.osv):
 
 
     _constraints = [
-        (_sheet_date, 'You can not have 2 timesheets that overlaps !', ['date_from','date_to']),
+        (_sheet_date, 'You can not have 2 timesheets that overlaps !\nPlease use the menu \'My Current Timesheet\' to avoid this problem.', ['date_from','date_to']),
         (_date_current_check, 'You must select a Current date wich is in the timesheet dates !', ['date_current']),
     ]
 
@@ -643,7 +635,7 @@ class hr_timesheet_sheet_sheet_account(osv.osv):
         'sheet_id': fields.many2one('hr_timesheet_sheet.sheet', 'Sheet', readonly=True),
         'total': fields.float('Total Time', digits=(16,2), readonly=True),
         'invoice_rate': fields.many2one('hr_timesheet_invoice.factor', 'Invoice rate', readonly=True),
-    }
+        }
 
     def init(self, cr):
         cr.execute("""create or replace view hr_timesheet_sheet_sheet_account as (
@@ -667,11 +659,16 @@ class hr_timesheet_sheet_sheet_account(osv.osv):
 hr_timesheet_sheet_sheet_account()
 
 
+
 class res_company(osv.osv):
     _inherit = 'res.company'
     _columns = {
-        'timesheet_range': fields.selection([('day','Day'),('week','Week'),('month','Month'),('year','Year')], 'Timeshet range'),
-        'timesheet_max_difference': fields.float('Timesheet allowed difference', help="Allowed difference between the sign in/out and the timesheet computation for one sheet. Set this to 0 if you do not want any control."),
+        'timesheet_range': fields.selection(
+            [('day','Day'),('week','Week'),('month','Month'),('year','Year')], 'Timeshet range',
+            required=True),
+        'timesheet_max_difference': fields.float('Timesheet allowed difference',
+            help="Allowed difference between the sign in/out and the timesheet " \
+                 "computation for one sheet. Set this to 0 if you do not want any control."),
     }
     _defaults = {
         'timesheet_range': lambda *args: 'month',