return (reconciled, len(credits)+len(debits))
def reconcile(self, cr, uid, ids, context=None):
- service = netsvc.LocalService("object_proxy")
move_line_obj = self.pool.get('account.move.line')
obj_model = self.pool.get('ir.model.data')
if context is None:
account_automatic_reconcile()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
}
def check_spread(self, cr, uid, ids, context=None):
- service = netsvc.LocalService("object_proxy")
if context is None:
context = {}
- data = self.read(cr, uid, ids, [])[0]
- res = service.execute(cr.dbname, uid, 'account.budget.post', 'spread', context['active_ids'], data['fiscalyear'], data['amount'])
+ data = self.browse(cr, uid, ids, context=context)[0]
+ res = self.pool.get('account.budget.post').spread(cr, uid, context['active_ids'], data.fiscalyear.id, data.amount)
return {}
account_budget_spread()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
report_int.__init__(self, name)
def create(self,cr, uid, ids, datas, context):
- service = netsvc.LocalService("object_proxy")
- lots = service.execute(cr.dbname,uid, 'auction.lots', 'read', ids, ['ach_inv_id'])
+ lots = self.pool.get('auction.lots').read(cr,uid, ids, ['ach_inv_id'], context=context)
invoices = {}
for l in lots:
<field name="act_window_id" ref="action_report_crm_phonecall"/>
</record>
- <menuitem name="Phone Calls"
+ <menuitem name="Phone Calls Analysis"
action="action_report_crm_phonecall"
id="menu_report_crm_phonecalls_tree" parent="base.next_id_64" />
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_hr_employee_category","hr.employee.category","model_hr_employee_category","hr.group_hr_user",1,0,0,0
"access_hr_employee","hr.employee","model_hr_employee","hr.group_hr_user",1,1,1,1
+"access_hr_employee_resource","resource.resource","resource.model_resource_resource","hr.group_hr_user",1,1,1,1
"access_hr_department","hr.department","model_hr_department","hr.group_hr_user",1,0,0,0
"access_hr_employee_category_manager","hr.employee.category.manager","model_hr_employee_category","hr.group_hr_manager",1,1,1,1
"access_hr_department_manager","hr.department.manager","model_hr_department","hr.group_hr_manager",1,1,1,1
class report_custom(report_rml):
def create_xml(self, cr, uid, ids, datas, context):
- service = netsvc.LocalService('object_proxy')
-
month = DateTime.DateTime(datas['form']['year'], datas['form']['month'], 1)
-
user_xml = ['<month>%s</month>' % month2name[month.month], '<year>%s</year>' % month.year]
-
for employee_id in ids:
- emp = service.execute(cr.dbname, uid, 'hr.employee', 'read', [employee_id])[0]
+ emp = self.pool.get('hr.employee').read(cr, uid, 'read', [employee_id], ['name'])[0]
stop, days_xml = False, []
user_repr = '''
<user>
num2day = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
def to_hour(h):
- return int(h), int(round((h - int(h)) * 60, 0))
+ return int(h), int(round((h - int(h)) * 60, 0))
class report_custom(report_rml):
- def create_xml(self, cr, uid, ids, datas, context):
- service = netsvc.LocalService('object_proxy')
+ def create_xml(self, cr, uid, ids, datas, context):
- start_date = DateTime.strptime(datas['form']['init_date'], '%Y-%m-%d')
- end_date = DateTime.strptime(datas['form']['end_date'], '%Y-%m-%d')
- first_monday = start_date - DateTime.RelativeDateTime(days=start_date.day_of_week)
- last_monday = end_date + DateTime.RelativeDateTime(days=7 - end_date.day_of_week)
+ start_date = DateTime.strptime(datas['form']['init_date'], '%Y-%m-%d')
+ end_date = DateTime.strptime(datas['form']['end_date'], '%Y-%m-%d')
+ first_monday = start_date - DateTime.RelativeDateTime(days=start_date.day_of_week)
+ last_monday = end_date + DateTime.RelativeDateTime(days=7 - end_date.day_of_week)
- if last_monday < first_monday:
- first_monday, last_monday = last_monday, first_monday
+ if last_monday < first_monday:
+ first_monday, last_monday = last_monday, first_monday
- user_xml = []
+ user_xml = []
- for employee_id in ids:
- emp = service.execute(cr.dbname, uid, 'hr.employee', 'read', [employee_id], ['id', 'name'])[0]
- monday, n_monday = first_monday, first_monday + one_week
- stop, week_xml = False, []
- user_repr = '''
- <user>
- <name>%s</name>
- %%s
- </user>
- ''' % toxml(emp['name'])
- while monday != last_monday:
- #### Work hour calculation
- sql = '''
- select action, att.name
- from hr_employee as emp inner join hr_attendance as att
- on emp.id = att.employee_id
- where att.name between %s and %s and emp.id = %s
- order by att.name
- '''
- for idx in range(7):
- cr.execute(sql, (monday.strftime('%Y-%m-%d %H:%M:%S'), (monday + DateTime.RelativeDateTime(days=idx+1)).strftime('%Y-%m-%d %H:%M:%S'), employee_id))
- attendances = cr.dictfetchall()
- week_wh = {}
- # Fake sign ins/outs at week ends, to take attendances across week ends into account
- # XXX this is wrong for the first sign-in ever and the last sign out to this date
- if attendances and attendances[0]['action'] == 'sign_out':
- attendances.insert(0, {'name': monday.strftime('%Y-%m-%d %H:%M:%S'), 'action':'sign_in'})
- if attendances and attendances[-1]['action'] == 'sign_in':
- attendances.append({'name' : n_monday.strftime('%Y-%m-%d %H:%M:%S'), 'action':'sign_out'})
- # sum up the attendances' durations
- for att in attendances:
- dt = DateTime.strptime(att['name'], '%Y-%m-%d %H:%M:%S')
- if att['action'] == 'sign_out':
- week_wh[ldt.day_of_week] = week_wh.get(ldt.day_of_week, 0) + (dt - ldt).hours
- ldt = dt
+ for employee_id in ids:
+ emp = self.pool.get('hr.employee').read(cr, uid, [employee_id], ['id', 'name'])[0]
+ monday, n_monday = first_monday, first_monday + one_week
+ stop, week_xml = False, []
+ user_repr = '''
+ <user>
+ <name>%s</name>
+ %%s
+ </user>
+ ''' % toxml(emp['name'])
+ while monday != last_monday:
+ #### Work hour calculation
+ sql = '''
+ select action, att.name
+ from hr_employee as emp inner join hr_attendance as att
+ on emp.id = att.employee_id
+ where att.name between %s and %s and emp.id = %s
+ order by att.name
+ '''
+ for idx in range(7):
+ cr.execute(sql, (monday.strftime('%Y-%m-%d %H:%M:%S'), (monday + DateTime.RelativeDateTime(days=idx+1)).strftime('%Y-%m-%d %H:%M:%S'), employee_id))
+ attendances = cr.dictfetchall()
+ week_wh = {}
+ # Fake sign ins/outs at week ends, to take attendances across week ends into account
+ # XXX this is wrong for the first sign-in ever and the last sign out to this date
+ if attendances and attendances[0]['action'] == 'sign_out':
+ attendances.insert(0, {'name': monday.strftime('%Y-%m-%d %H:%M:%S'), 'action':'sign_in'})
+ if attendances and attendances[-1]['action'] == 'sign_in':
+ attendances.append({'name' : n_monday.strftime('%Y-%m-%d %H:%M:%S'), 'action':'sign_out'})
+ # sum up the attendances' durations
+ for att in attendances:
+ dt = DateTime.strptime(att['name'], '%Y-%m-%d %H:%M:%S')
+ if att['action'] == 'sign_out':
+ week_wh[ldt.day_of_week] = week_wh.get(ldt.day_of_week, 0) + (dt - ldt).hours
+ ldt = dt
- # Week xml representation
- week_repr = ['<week>', '<weekstart>%s</weekstart>' % monday.strftime('%Y-%m-%d'), '<weekend>%s</weekend>' % n_monday.strftime('%Y-%m-%d')]
- for idx in range(7):
- week_repr.append('<%s>' % num2day[idx])
- if idx in week_wh:
- week_repr.append('<workhours>%sh%02d</workhours>' % to_hour(week_wh[idx]))
- week_repr.append('</%s>' % num2day[idx])
- week_repr.append('<total>')
- week_repr.append('<worked>%sh%02d</worked>' % to_hour(reduce(lambda x,y:x+y, week_wh.values(), 0)))
- week_repr.append('</total>')
- week_repr.append('</week>')
- if len(week_repr) > 21: # 21 = minimal length of week_repr
- week_xml.append('\n'.join(week_repr))
-
- monday, n_monday = n_monday, n_monday + one_week
- user_xml.append(user_repr % '\n'.join(week_xml))
-
- xml = '''<?xml version="1.0" encoding="UTF-8" ?>
- <report>
- %s
- </report>
- ''' % '\n'.join(user_xml)
- return self.post_process_xml_data(cr, uid, xml, context)
+ # Week xml representation
+ week_repr = ['<week>', '<weekstart>%s</weekstart>' % monday.strftime('%Y-%m-%d'), '<weekend>%s</weekend>' % n_monday.strftime('%Y-%m-%d')]
+ for idx in range(7):
+ week_repr.append('<%s>' % num2day[idx])
+ if idx in week_wh:
+ week_repr.append('<workhours>%sh%02d</workhours>' % to_hour(week_wh[idx]))
+ week_repr.append('</%s>' % num2day[idx])
+ week_repr.append('<total>')
+ week_repr.append('<worked>%sh%02d</worked>' % to_hour(reduce(lambda x,y:x+y, week_wh.values(), 0)))
+ week_repr.append('</total>')
+ week_repr.append('</week>')
+ if len(week_repr) > 21: # 21 = minimal length of week_repr
+ week_xml.append('\n'.join(week_repr))
+
+ monday, n_monday = n_monday, n_monday + one_week
+ user_xml.append(user_repr % '\n'.join(week_xml))
+
+ xml = '''<?xml version="1.0" encoding="UTF-8" ?>
+ <report>
+ %s
+ </report>
+ ''' % '\n'.join(user_xml)
+ return self.post_process_xml_data(cr, uid, xml, context)
report_custom('report.hr.attendance.allweeks', 'hr.employee', '', 'addons/hr_attendance/report/timesheet.xsl')
# vim:noexpandtab:tw=0
"access_hr_action_reason_employee","hr action reason employee","model_hr_action_reason","hr.group_hr_manager",1,1,1,1
"access_hr_attendance_employee","hr attendance employee","model_hr_attendance","hr_attendance.group_hr_attendance",1,1,1,1
"access_hr_sign_in_out","hr attendance sign in out","model_hr_sign_in_out","hr_attendance.group_hr_attendance",1,1,1,1
+"access_hr_attendance_employee","hr employee attendance sign in out","hr.model_hr_employee","hr_attendance.group_hr_attendance",1,0,0,0
+"access_hr_attendance_resource","hr resource attendance sign in out","resource.model_resource_resource","hr_attendance.group_hr_attendance",1,0,0,0
'emp_id': fields.char('Empoyee ID', size=32, required=True, readonly=True),
}
def _get_empname(self, cr, uid, context=None):
- service = netsvc.LocalService('object_proxy')
- emp_id = service.execute(cr.dbname, uid, 'hr.employee', 'search', [('user_id', '=', uid)])
+ emp_id = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context)
if emp_id:
- employee = service.execute(cr.dbname, uid, 'hr.employee', 'read', emp_id)[0]
+ employee = self.pool.get('hr.employee').browse(cr, uid, emp_id, context=context)[0].name
return employee['name']
return ''
def _get_empid(self, cr, uid, context=None):
- service = netsvc.LocalService('object_proxy')
- emp_id = service.execute(cr.dbname, uid, 'hr.employee', 'search', [('user_id', '=', uid)])
+ emp_id = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context)
if emp_id:
return emp_id[0]
return False
}
def _get_empid(self, cr, uid, context=None):
- service = netsvc.LocalService('object_proxy')
- emp_id = service.execute(cr.dbname, uid, 'hr.employee', 'search', [('user_id', '=', uid)])
+ emp_id = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context)
if emp_id:
- employee = service.execute(cr.dbname, uid, 'hr.employee', 'read', emp_id)[0]
- return {'name': employee['name'], 'state': employee['state'], 'emp_id': emp_id[0]}
+ employee = self.pool.get('hr.employee').browse(cr, uid, emp_id, context=context)[0]
+ return {'name': employee.name, 'state': employee.state, 'emp_id': emp_id[0]}
return {}
def default_get(self, cr, uid, fields_list, context=None):
return res
def si_check(self, cr, uid, ids, context=None):
- service = netsvc.LocalService('object_proxy')
obj_model = self.pool.get('ir.model.data')
+ att_obj = self.pool.get('hr.attendance')
data = self.read(cr, uid, ids, [])[0]
emp_id = data['emp_id']
- att_id = service.execute(cr.dbname, uid, 'hr.attendance', 'search', [('employee_id', '=', emp_id)], limit=1, order='name desc')
- last_att = service.execute(cr.dbname, uid, 'hr.attendance', 'read', att_id)
+ att_id = att_obj.search(cr, uid, [('employee_id', '=', emp_id)], limit=1, order='name desc')
+ last_att = att_obj.browse(cr, uid, att_id)
if last_att:
last_att = last_att[0]
- cond = not last_att or last_att['action'] == 'sign_out'
+ cond = not last_att or last_att.action == 'sign_out'
if cond:
return self.sign_in(cr, uid, data, context)
else:
}
def so_check(self, cr, uid, ids, context=None):
- service = netsvc.LocalService('object_proxy')
obj_model = self.pool.get('ir.model.data')
data = self.read(cr, uid, ids, [])[0]
+ att_obj = self.pool.get('hr.attendance')
emp_id = data['emp_id']
- att_id = service.execute(cr.dbname, uid, 'hr.attendance', 'search', [('employee_id', '=', emp_id),('action','!=','action')], limit=1, order='name desc')
- last_att = service.execute(cr.dbname, uid, 'hr.attendance', 'read', att_id)
+ att_id = att_obj.search(cr, uid, [('employee_id', '=', emp_id),('action','!=','action')], limit=1, order='name desc')
+ last_att = att_obj.browse(cr, uid, att_id, context=context)
if last_att:
last_att = last_att[0]
if not att_id and not last_att:
}
def sign_in(self, cr, uid, data, context=None):
- service = netsvc.LocalService('object_proxy')
emp_id = data['emp_id']
if 'last_time' in data:
if data['last_time'] > time.strftime('%Y-%m-%d %H:%M:%S'):
raise osv.except_osv(_('UserError'), _('The sign-out date must be in the past'))
- service.execute(cr.dbname, uid, 'hr.attendance', 'create', {
+ self.pool.get('hr.attendance').create(cr, uid, {
'name': data['last_time'],
'action': 'sign_out',
'employee_id': emp_id
})
try:
- success = service.execute(cr.dbname, uid, 'hr.employee', 'attendance_action_change', [emp_id], 'sign_in')
+ success = self.pool.get('hr.employee').attendance_action_change(cr, uid, [emp_id], 'sign_in')
except:
raise osv.except_osv(_('UserError'), _('A sign-in must be right after a sign-out !'))
return {} # To do: Return Success message
def sign_out(self, cr, uid, data, context=None):
- service = netsvc.LocalService('object_proxy')
emp_id = data['emp_id']
if 'last_time' in data:
if data['last_time'] > time.strftime('%Y-%m-%d %H:%M:%S'):
raise osv.except_osv(_('UserError'), _('The Sign-in date must be in the past'))
- service.execute(cr.dbname, uid, 'hr.attendance', 'create', {'name':data['last_time'], 'action':'sign_in', 'employee_id':emp_id})
+ self.pool.get('hr.attendance').create(cr, uid, {'name':data['last_time'], 'action':'sign_in', 'employee_id':emp_id})
try:
- success = service.execute(cr.dbname, uid, 'hr.employee', 'attendance_action_change', [emp_id], 'sign_out')
+ success = self.pool.get('hr.employee').attendance_action_change(cr, uid, [emp_id], 'sign_out')
except:
raise osv.except_osv(_('UserError'), _('A sign-out must be right after a sign-in !'))
return {} # To do: Return Success message
hr_sign_in_out()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
- <record id="view_hr_attendance_sigh_in_out" model="ir.ui.view">
+ <record id="view_hr_attendance_sigh_in_out" model="ir.ui.view">
<field name="name">hr.sign.in.out.form</field>
<field name="model">hr.sign.in.out</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Sign in / Sign out">
- <group colspan="4" >
- <separator string="You are now ready to sign in or out of the attendance follow up" colspan="4" />
- <field name="name" />
- <field name="state" />
- </group>
+ <group colspan="4" >
+ <separator string="You are now ready to sign in or out of the attendance follow up" colspan="4" />
+ <field name="name" />
+ <field name="state" />
+ </group>
<group colspan="4" col="6">
- <button icon="gtk-cancel" special="cancel" string="Cancel"/>
- <button icon="gtk-go-back" string="Sign in" name="si_check" type="object"/>
- <button icon="gtk-go-forward" string="Sign out" name="so_check" type="object"/>
+ <button icon="gtk-cancel" special="cancel" string="Cancel"/>
+ <button icon="gtk-go-back" string="Sign in" name="si_check" type="object"/>
+ <button icon="gtk-go-forward" string="Sign out" name="so_check" type="object"/>
</group>
</form>
</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Sign in / Sign out">
- <label string="Sign-Out Entry must follow Sign-In." colspan="4" />
+ <label string="Sign-Out Entry must follow Sign-In." colspan="4" />
<group colspan="4" col="6">
- <button icon="gtk-cancel" special="cancel" string="Ok"/>
+ <button icon="gtk-cancel" special="cancel" string="Ok"/>
</group>
</form>
</field>
</record>
- <record id="action_hr_attendance_sigh_in_out" model="ir.actions.act_window">
+ <record id="action_hr_attendance_sigh_in_out" model="ir.actions.act_window">
<field name="name">Sign in / Sign out</field>
<field name="res_model">hr.sign.in.out</field>
<field name="view_type">form</field>
</record>
<menuitem action="action_hr_attendance_sigh_in_out"
- id="menu_hr_attendance_sigh_in_out"
- parent="menu_hr_time_tracking" groups="base.group_extended" />
+ id="menu_hr_attendance_sigh_in_out"
+ parent="menu_hr_time_tracking"/>
<record id="view_hr_attendance_so_ask" model="ir.ui.view">
<field name="name">hr.sign.in.out.ask.form</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="hr.sign.out.ask">
- <group colspan="4" >
- <separator string="You did not sign out the last time. Please enter the date and time you signed out." colspan="4" />
- <field name="name" />
- <field name="last_time" string="Your last sign out" />
- </group>
+ <group colspan="4" >
+ <separator string="You did not sign out the last time. Please enter the date and time you signed out." colspan="4" />
+ <field name="name" />
+ <field name="last_time" string="Your last sign out" />
+ </group>
<group colspan="4" col="6">
- <button icon="gtk-cancel" special="cancel" string="Cancel"/>
- <button icon="gtk-go-back" string="Sign in" name="sign_in" type="object"/>
+ <button icon="gtk-cancel" special="cancel" string="Cancel"/>
+ <button icon="gtk-go-back" string="Sign in" name="sign_in" type="object"/>
</group>
</form>
</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="hr.sign.in.out.ask">
- <group colspan="4" >
- <separator string="You did not sign in the last time. Please enter the date and time you signed in." colspan="4" />
- <field name="name" />
- <field name="last_time" string="Your last sign in" />
- </group>
+ <group colspan="4" >
+ <separator string="You did not sign in the last time. Please enter the date and time you signed in." colspan="4" />
+ <field name="name" />
+ <field name="last_time" string="Your last sign in" />
+ </group>
<group colspan="4" col="6">
- <button icon="gtk-cancel" special="cancel" string="Cancel"/>
- <button icon="gtk-go-back" string="Sign out" name="sign_out" type="object"/>
+ <button icon="gtk-cancel" special="cancel" string="Cancel"/>
+ <button icon="gtk-go-back" string="Sign out" name="sign_out" type="object"/>
</group>
</form>
</field>
"access_hr_contract_user","hr.contract user","model_hr_contract","hr.group_hr_user",1,0,0,0
"access_hr_contract","hr.contract","model_hr_contract","group_hr_contract",1,1,1,1
"access_hr_employee_contract","hr.employee contract","hr.model_hr_employee","group_hr_contract",1,0,0,0
+"access_hr_resource_contract","hr.employee.resource contract","resource.model_resource_resource","group_hr_contract",1,0,0,0
+"access_hr_resource_calendar_contract","hr.employee.resource.calendar contract","resource.model_resource_calendar","group_hr_contract",1,0,0,0
+"access_hr_job_contract","hr.employee.job contract","hr.model_hr_job","group_hr_contract",1,0,0,0
"access_hr_contract_type_user","hr.contract.type user","model_hr_contract_type","hr.group_hr_user",1,0,0,0
"access_hr_contract_type","hr.contract.type","model_hr_contract_type","group_hr_contract",1,1,1,1
id="menu_mrp_configuration"
name="Configuration"
parent="base.menu_mrp_root"
- groups="base.group_extended"
+ groups="group_mrp_manager"
sequence="50" />
<record id="mrp_property_tree_view" model="ir.ui.view">