Modifs timesheet
bzr revid: pinky-e71f1c2e8d72af0477efb07b2f156ef7e2ae92ad
This commit is contained in:
parent
e12814a760
commit
18049778c2
|
@ -59,7 +59,9 @@ class hr_analytic_timesheet(osv.osv):
|
|||
return super(hr_analytic_timesheet, self).unlink(cr, uid, ids, context)
|
||||
|
||||
def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount, unit, context={}):
|
||||
res = self.pool.get('account.analytic.line').on_change_unit_amount(cr, uid, id, prod_id, unit_amount,unit, context)
|
||||
res = {}
|
||||
if prod_id and unit_amount:
|
||||
res = self.pool.get('account.analytic.line').on_change_unit_amount(cr, uid, id, prod_id, unit_amount,unit, context)
|
||||
return res
|
||||
|
||||
def _getEmployeeProduct(self, cr, uid, context):
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
import time
|
||||
from osv import fields
|
||||
from osv import osv
|
||||
import netsvc
|
||||
|
||||
from mx import DateTime
|
||||
|
||||
|
@ -149,11 +150,20 @@ class hr_timesheet_sheet(osv.osv):
|
|||
result[day.id] = 'none'
|
||||
return result
|
||||
|
||||
def date_today(self, cr, uid, ids, context):
|
||||
def button_confirm(self, cr, uid, ids, context):
|
||||
for sheet in self.browse(cr, uid, ids, context):
|
||||
self.write(cr, uid, [sheet.id], {
|
||||
'date_current': DateTime.strptime(sheet.date_current, '%Y-%m-%d')
|
||||
})
|
||||
di = sheet.user_id.company_id.timesheet_max_difference
|
||||
if (abs(sheet.total_difference) < di) or not di:
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'hr_timesheet_sheet.sheet', sheet.id, 'confirm', cr)
|
||||
else:
|
||||
raise osv.except_osv('Warning !', 'Please verify that the total difference of the sheet is lower than %.2f !' %(di,))
|
||||
return True
|
||||
|
||||
def date_today(self, cr, uid, ids, context):
|
||||
self.write(cr, uid, ids, {
|
||||
'date_current': time.strftime('%Y-%m-%d')
|
||||
})
|
||||
return True
|
||||
def date_previous(self, cr, uid, ids, context):
|
||||
for sheet in self.browse(cr, uid, ids, context):
|
||||
|
@ -201,11 +211,31 @@ class hr_timesheet_sheet(osv.osv):
|
|||
'period_ids': fields.one2many('hr_timesheet_sheet.sheet.day', 'sheet_id', 'Period', readonly=True),
|
||||
'account_ids': fields.one2many('hr_timesheet_sheet.sheet.account', 'sheet_id', 'Analytic accounts', readonly=True),
|
||||
}
|
||||
def _default_date_from(self,cr, uid, context={}):
|
||||
user = self.pool.get('res.users').browse(cr, uid, uid, context)
|
||||
r = user.company_id.timesheet_range
|
||||
if r=='month':
|
||||
return time.strftime('%Y-%m-01')
|
||||
elif r=='week':
|
||||
return (DateTime.now() + DateTime.RelativeDateTime(weekday=(DateTime.Monday,0))).strftime('%Y-%m-%d')
|
||||
elif r=='year':
|
||||
return time.strftime('%Y-01-01')
|
||||
return time.strftime('%Y-%m-%d')
|
||||
def _default_date_to(self,cr, uid, context={}):
|
||||
user = self.pool.get('res.users').browse(cr, uid, uid, context)
|
||||
r = user.company_id.timesheet_range
|
||||
if r=='month':
|
||||
return (DateTime.now() + DateTime.RelativeDateTime(months=+1,day=1,days=-1)).strftime('%Y-%m-%d')
|
||||
elif r=='week':
|
||||
return (DateTime.now() + DateTime.RelativeDateTime(weekday=(DateTime.Sunday,0))).strftime('%Y-%m-%d')
|
||||
elif r=='year':
|
||||
return time.strftime('%Y-12-31')
|
||||
return time.strftime('%Y-%m-%d')
|
||||
_defaults = {
|
||||
'user_id': lambda self,cr,uid,c: uid,
|
||||
'date_from' : lambda *a:time.strftime('%Y-%m-01'),
|
||||
'date_current' : lambda *a:time.strftime('%Y-%m-%d'),
|
||||
'date_to' : lambda *a: (DateTime.now() + DateTime.RelativeDateTime(months=+1,day=1,days=-1)).strftime('%Y-%m-%d'),
|
||||
'date_from' : _default_date_from,
|
||||
'date_current' : lambda *a: time.strftime('%Y-%m-%d'),
|
||||
'date_to' : _default_date_to,
|
||||
'state': lambda *a: 'draft'
|
||||
}
|
||||
hr_timesheet_sheet()
|
||||
|
@ -356,11 +386,11 @@ hr_timesheet_sheet_sheet_account()
|
|||
class res_company(osv.osv):
|
||||
_inherit = 'res.company'
|
||||
_columns = {
|
||||
'timesheet_range': fields.selection([('day','Day'),('week','Week'),('month','Month')], 'Timeshet range', required=True),
|
||||
'timesheet_max_difference': fields.float('Maximum difference'),
|
||||
'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',
|
||||
'timesheet_max_difference': lambda *args: 1.0
|
||||
'timesheet_max_difference': lambda *args: 0.0
|
||||
}
|
||||
res_company()
|
||||
|
|
|
@ -64,14 +64,14 @@
|
|||
</tree>
|
||||
</field>
|
||||
<field name="state_attendance"/>
|
||||
<field name="total_attendance_day"/>
|
||||
<field name="total_attendance_day" widget="float_time"/>
|
||||
<field name="timesheet_ids" colspan="4" nolabel="1" domain="[('name','=',date_current)]">
|
||||
<tree string="Timesheet" editable="top">
|
||||
<field name="user_id" required="1"/>
|
||||
<field name="date" />
|
||||
<field name="account_id" on_change="on_change_account_id(account_id)" domain="[('type','=','normal')]"/>
|
||||
<field name="name" />
|
||||
<field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, product_uom_id)" />
|
||||
<field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, product_uom_id)" widget="float_time"/>
|
||||
<field name="product_id" invisible="True"/>
|
||||
<field name="product_uom_id" invisible="True" on_change="on_change_unit_amount(product_id, unit_amount, product_uom_id)" />
|
||||
<field name="amount" invisible="True"/>
|
||||
|
@ -79,11 +79,11 @@
|
|||
<field name="to_invoice"/>
|
||||
</tree>
|
||||
</field>
|
||||
<field name="total_difference_day"/>
|
||||
<field name="total_timesheet_day"/>
|
||||
<field name="total_difference_day" widget="float_time"/>
|
||||
<field name="total_timesheet_day" widget="float_time"/>
|
||||
<field name="state"/>
|
||||
<group col="4" colspan="2">
|
||||
<button string="Confirm" name="confirm" states="draft"/>
|
||||
<button string="Confirm" name="button_confirm" states="draft" type="object"/>
|
||||
<button string="Cancel" name="cancel" states="done"/>
|
||||
<button string="Refuse" name="cancel" states="confirm"/>
|
||||
<button string="Accept" name="done" states="confirm"/>
|
||||
|
@ -92,19 +92,19 @@
|
|||
<field name="period_ids" colspan="4" nolabel="1">
|
||||
<tree string="Period" colors="red:total_difference<=0.1;blue:total_difference>=0.1">
|
||||
<field name="name"/>
|
||||
<field name="total_attendance"/>
|
||||
<field name="total_timesheet"/>
|
||||
<field name="total_difference"/>
|
||||
<field name="total_attendance" widget="float_time"/>
|
||||
<field name="total_timesheet" widget="float_time"/>
|
||||
<field name="total_difference" widget="float_time"/>
|
||||
</tree>
|
||||
</field>
|
||||
<field name="total_attendance"/>
|
||||
<field name="total_timesheet"/>
|
||||
<field name="total_difference"/>
|
||||
<field name="total_attendance" widget="float_time"/>
|
||||
<field name="total_timesheet" widget="float_time"/>
|
||||
<field name="total_difference" widget="float_time"/>
|
||||
</page><page string="By account">
|
||||
<field name="account_ids" colspan="4" nolabel="1">
|
||||
<tree string="Analytic accounts">
|
||||
<field name="name"/>
|
||||
<field name="total"/>
|
||||
<field name="total" widget="float_time"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
|
@ -181,6 +181,24 @@
|
|||
id="menu_act_hr_timesheet_sheet_form_all_valid"
|
||||
action="act_hr_timesheet_sheet_form_all_valid" />
|
||||
|
||||
<!--
|
||||
Company inheritancy
|
||||
-->
|
||||
|
||||
<record model="ir.ui.view" id="hr_timesheet_sheet_company">
|
||||
<field name="name">res.company.sheet</field>
|
||||
<field name="model">res.company</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="base.view_company_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="rml_footer2" position="after">
|
||||
<newline/>
|
||||
<field name="timesheet_range"/>
|
||||
<field name="timesheet_max_difference"/>
|
||||
<newline/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
|
|
Loading…
Reference in New Issue