bzr revid: fp@tinyerp.com-20100303135927-5epxq2gx7x1lh348
This commit is contained in:
Fabien Pinckaers 2010-03-03 14:59:27 +01:00
commit 3f90a3cf4a
9 changed files with 144 additions and 55 deletions

View File

@ -38,7 +38,7 @@ months = {
def get_recurrent_dates(rrulestring, exdate, startdate=None):
def todate(date):
val = parser.parse(''.join((re.compile('\d')).findall(date)) + 'Z')
val = parser.parse(''.join((re.compile('\d')).findall(date)))
return val
if not startdate:
startdate = datetime.now()
@ -778,13 +778,15 @@ rule or repeating pattern for anexception to a recurrence set"),
def modify_this(self, cr, uid, ids, defaults, context=None, *args):
datas = self.read(cr, uid, ids[0], context=context)
date = datas.get('date')
defaults.update({
'recurrent_uid': base_calendar_id2real_id(datas['id']),
'recurrent_id': defaults.get('date'),
'rrule_type': 'none',
'rrule': ''
})
exdate = datas['exdate'] and datas['exdate'].split(',') or []
exdate.append(defaults.get('date'))
self.write(cr, uid, ids, {'exdate': ','.join(exdate)}, context=context)
new_id = self.copy(cr, uid, ids[0], default=defaults, context=context)
return new_id

View File

@ -192,7 +192,12 @@ class CalDAV(object):
vals = alarm.import_cal(cr, uid, cal_data, context=ctx)
self.ical_set(cal_data.name.lower(), vals, 'value')
continue
if cal_data.name.lower() == 'exdate':
exval = map(lambda x: str(x), cal_data.value)
self.ical_set(cal_data.name.lower(), ','.join(exval), 'value')
continue
if cal_data.name.lower() in self.__attribute__:
if cal_data.params.get('X-VOBJ-ORIGINAL-TZID'):
self.ical_set('vtimezone', cal_data.params.get('X-VOBJ-ORIGINAL-TZID'), 'value')
self.ical_set(cal_data.name.lower(), cal_data.value, 'value')
@ -248,15 +253,15 @@ class CalDAV(object):
data[map_field], ical, context=context)
elif data[map_field]:
if map_type in ("char", "text"):
vevent.add(field).value = tools.ustr(data[map_field])
elif map_type in ('datetime', 'date') and data[map_field]:
if field in ('exdate'):
vevent.add(field).value = [parser.parse(data[map_field])]
vevent.add(field).value = map(parser.parse, (data[map_field]).split(','))
else:
dtfield = vevent.add(field)
dtfield.value = parser.parse(data[map_field])
if tzval:
dtfield.params['TZID'] = [tzval.title()]
vevent.add(field).value = tools.ustr(data[map_field])
elif map_type in ('datetime', 'date') and data[map_field]:
dtfield = vevent.add(field)
dtfield.value = parser.parse(data[map_field])
if tzval:
dtfield.params['TZID'] = [tzval.title()]
elif map_type == "timedelta":
vevent.add(field).value = timedelta(hours=data[map_field])
elif map_type == "many2one":
@ -275,11 +280,13 @@ class CalDAV(object):
def check_import(self, cr, uid, vals, context={}):
ids = []
model_obj = self.pool.get(context.get('model'))
recur_pool = {}
try:
for val in vals:
exists, r_id = uid2openobjectid(cr, val['id'], context.get('model'), \
val.get('recurrent_id'))
if val.has_key('create_date'): val.pop('create_date')
u_id = val.get('id', None)
val.pop('id')
if exists and r_id:
val.update({'recurrent_uid': exists})
@ -289,8 +296,14 @@ class CalDAV(object):
model_obj.write(cr, uid, [exists], val)
ids.append(exists)
else:
event_id = model_obj.create(cr, uid, val)
ids.append(event_id)
if u_id in recur_pool and val.get('recurrent_id'):
val.update({'recurrent_uid': recur_pool[u_id]})
revent_id = model_obj.create(cr, uid, val)
ids.append(revent_id)
else:
event_id = model_obj.create(cr, uid, val)
recur_pool[u_id] = event_id
ids.append(event_id)
except Exception, e:
raise osv.except_osv(('Error !'), (str(e)))
return ids
@ -369,6 +382,7 @@ class Calendar(CalDAV, osv.osv):
def import_cal(self, cr, uid, content, data_id=None, context=None):
if not context:
context = {}
vals = []
ical_data = base64.decodestring(content)
parsedCal = vobject.readOne(ical_data)
if not data_id:
@ -385,11 +399,12 @@ class Calendar(CalDAV, osv.osv):
})
self.__attribute__ = get_attribute_mapping(cr, uid, child.name.lower(), context=context)
val = self.parse_ics(cr, uid, child, cal_children=cal_children, context=context)
vals.append(val)
obj = self.pool.get(cal_children[child.name.lower()])
if hasattr(obj, 'check_import'):
obj.check_import(cr, uid, [val], context=context)
else:
self.check_import(cr, uid, [val], context=context)
if hasattr(obj, 'check_import'):
obj.check_import(cr, uid, vals, context=context)
else:
self.check_import(cr, uid, vals, context=context)
return {}
Calendar()

View File

@ -39,8 +39,8 @@ class crm_fundraising(osv.osv):
'partner_name2': fields.char('Employee Email', size=64),
'partner_phone': fields.char('Phone', size=32),
'partner_mobile': fields.char('Mobile', size=32),
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id)]"),
'type_id': fields.many2one('crm.case.resource.type', 'Fundraising Type', domain="[('section_id','=',section_id)]"),
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]"),
'type_id': fields.many2one('crm.case.resource.type', 'Fundraising Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]"),
'duration': fields.float('Duration'),
'ref' : fields.reference('Reference', selection=crm._links_get, size=128),
'ref2' : fields.reference('Reference 2', selection=crm._links_get, size=128),

View File

@ -23,11 +23,10 @@ from osv import fields, osv
from crm import crm
from caldav import caldav
from base_calendar import base_calendar
class crm_meeting(osv.osv):
_inherit = 'crm.meeting'
def export_cal(self, cr, uid, ids, context={}):
ids = map(lambda x: base_calendar.base_calendar_id2real_id(x), ids)
event_data = self.read(cr, uid, ids)
@ -39,29 +38,7 @@ class crm_meeting(osv.osv):
event_obj = self.pool.get('basic.calendar.event')
vals = event_obj.import_cal(cr, uid, data, context=context)
return self.check_import(cr, uid, vals, context=context)
def check_import(self, cr, uid, vals, context={}):
ids = []
for val in vals:
exists, r_id = caldav.uid2openobjectid(cr, val['id'], \
self._name, val.get('recurrent_id'))
if val.has_key('create_date'): val.pop('create_date')
val['base_calendar_url'] = context.get('url') or ''
val.pop('id')
if exists and r_id:
val.update({'recurrent_uid': exists})
self.write(cr, uid, [r_id], val)
ids.append(r_id)
elif exists:
self.write(cr, uid, [exists], val)
ids.append(exists)
else:
event_id = self.create(cr, uid, val)
ids.append(event_id)
return ids
crm_meeting()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -21,6 +21,7 @@
import time
from osv import fields, osv
from mx import DateTime as dt
class hr_evaluation_plan(osv.osv):
_name = "hr_evaluation.plan"
@ -75,13 +76,36 @@ class hr_employee(osv.osv):
_inherit="hr.employee"
_columns = {
'evaluation_plan_id': fields.many2one('hr_evaluation.plan', 'Evaluation Plan'),
'evaluation_date': fields.date('Next Evaluation', help="Date of the next evaluation"),
'evaluation_date': fields.date('Next Evaluation', help="Date of the next evaluation",readonly=True),
}
def onchange_evaluation_plan_id(self, *args):
# return the right evaluation date
pass
def onchange_evaluation_plan_id(self,cr,uid,ids,evaluation_plan_id,context={}):
evaluation_date = self.browse(cr, uid, ids)[0].evaluation_date or ''
evaluation_plan_obj=self.pool.get('hr_evaluation.plan')
if evaluation_plan_id:
for evaluation_plan in evaluation_plan_obj.browse(cr,uid,[evaluation_plan_id]):
if not evaluation_date:
evaluation_date=(dt.ISO.ParseAny(dt.now().strftime('%Y-%m-%d'))+ dt.RelativeDateTime(months=+evaluation_plan.month_first)).strftime('%Y-%m-%d')
else:
evaluation_date=(dt.ISO.ParseAny(evaluation_date)+ dt.RelativeDateTime(months=+evaluation_plan.month_next)).strftime('%Y-%m-%d')
return {'value': {'evaluation_date':evaluation_date}}
hr_employee()
class hr_evaluation_interview(osv.osv):
_name = "hr.evaluation.interview"
_inherit = "survey.request"
def default_get(self, cr, uid, fields, context={}):
data = super(hr_evaluation_interview, self).default_get(cr, uid, fields, context)
if context.has_key('phase_id'):
data['survey_id'] =self.pool.get('hr_evaluation.plan.phase').browse(cr, uid, context['phase_id']).survey_id.id
return data
_columns = {
'user_to_review_id': fields.many2one('hr.employee', 'Employee'),
}
hr_evaluation_interview()
class hr_evaluation(osv.osv):
_name = "hr_evaluation.evaluation"
_description = "Employee Evaluation"
@ -89,7 +113,6 @@ class hr_evaluation(osv.osv):
_columns = {
'date': fields.date("Evaluation Deadline", required=True),
'employee_id': fields.many2one('hr.employee', "Employee", required=True),
'manager_id': fields.many2one('res.users', "Manager", required=True),
'note_summary': fields.text('Evaluation Summary'),
'note_action': fields.text('Action Plan',
help="If the evaluation does not meet the expectations, you can propose"+
@ -101,7 +124,7 @@ class hr_evaluation(osv.osv):
('3','Exceeds expectations'),
('4','Significantly exceeds expectations'),
], "Overall Rating", help="This is the overall rating on that summarize the evaluation"),
'survey_request_ids': fields.many2many('survey.request',
'survey_request_ids': fields.many2many('hr.evaluation.interview',
'hr_evaluation_evaluation_requests',
'evaluation_id',
'survey_id',
@ -139,4 +162,3 @@ class hr_evaluation(osv.osv):
hr_evaluation()

View File

@ -1577,13 +1577,23 @@ Once the form had been filled, the employee send it to his supervisor.
<field eval="1" name="wait"/>
</record>
</data>
<data noupdate="1">
<record id="hr_evaluation_interview_1" model="hr.evaluation.interview">
<field name="state">waiting_answer</field>
<field name="survey_id" ref="hr_evaluation.survey_2"/>
<field name="user_id" ref="base.user_root"/>
<field name="email">fp@tinyerp.com</field>
<field name="date_deadline">2010-02-21</field>
</record>
</data>
<data noupdate="1">
<record id="hr_evaluation_evaluation_0" model="hr_evaluation.evaluation">
<field name="rating">0</field>
<field name="employee_id" ref="hr.employee1"/>
<field name="plan_id" ref="hr_evaluation_plan_managersevaluationplan0"/>
<field name="state">draft</field>
<field eval="[(6,0,[ref('survey_request_1')])]" name="survey_request_ids"/>
<field eval="[(6,0,[ref('hr_evaluation_interview_1')])]" name="survey_request_ids"/>
<field name="date">2010-01-21</field>
<field name="phase_id" ref="hr_evaluation_plan_phase_sendtomanagers0"/>
<field name="manager_id" ref="base.user_root"/>

View File

@ -106,7 +106,7 @@
<field name="arch" type="xml">
<notebook position="inside">
<page string="Evaluation">
<field name="evaluation_plan_id"/>
<field name="evaluation_plan_id" on_change="onchange_evaluation_plan_id(evaluation_plan_id)"/>
<field name="evaluation_date"/>
</page>
</notebook>
@ -123,13 +123,12 @@
<field name="date" select="1"/>
<field name="rating"/>
<field name="employee_id" select="1"/>
<field name="manager_id" select="1"/>
<field name="plan_id"/>
<field name="phase_id" domain="[('plan_id', '=', plan_id)]"/>
</group>
<notebook colspan="4">
<page string="Appraisal">
<field name="survey_request_ids" nolabel="1" colspan="4"/>
<field name="survey_request_ids" context="{'phase_id': phase_id}" nolabel="1" colspan="4"/>
</page>
<page string="Action Plan">
<field name="note_action" colspan="4" nolabel="1"/>
@ -169,7 +168,6 @@
<tree string="Evaluation">
<field name="date"/>
<field name="employee_id"/>
<field name="manager_id"/>
</tree>
</field>
</record>
@ -182,5 +180,70 @@
name="Evaluation" parent="menu_eval_hr"
id="menu_open_view_hr_evaluation_tree"
action="open_view_hr_evaluation_tree"/>
<record model="ir.ui.view" id="view_hr_evaluation_interview_form">
<field name="name">hr_evaluation.interview.form</field>
<field name="model">hr.evaluation.interview</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Survey Request">
<group col="4" colspan="4">
<field name="survey_id" widget="selection" colspan="3"/>
<group colspan="1">
<button name="%(survey.action_view_survey_question_message)d" string="Interview Question" type="action"
icon="gtk-execute" context="{'survey_id': survey_id, 'response_id': response, 'active' : response, 'object' : 'hr.evaluation.interview', 'cur_id' : active_id}" attrs="{'readonly':[('survey_id','=',False)]}"/>
<button name="%(survey.survey_browse_response)d" string="Print Interview" type="action"
icon="gtk-print" context="{'survey_id': survey_id, 'response_id' : response,}" attrs="{'readonly':[('response','!=',True),('survey_id','!=',True)]}" />
</group>
</group>
<group col="4" colspan="4">
<field name="date_deadline"/>
<field name="response" readonly="1"/>
<field name="user_to_review_id"/>
<field name="user_id"/>
</group>
<newline/>
<separator string="State" colspan="4"/>
<group colspan="4" col="5">
<field name="state"/>
<button name="survey_req_waiting_answer" string="Set to Watting Answer" states="cancel,done" type="object" icon="gtk-new"/>
<button name="survey_req_done" string="Done" states="waiting_answer" type="object" icon="gtk-ok"/>
<button name="survey_req_cancel" string="Cancelled" states="waiting_answer" type="object" icon="gtk-cancel"/>
</group>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_hr_evaluation_interview_tree">
<field name="name">hr_evaluation.interview.tree</field>
<field name="model">hr.evaluation.interview</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Evaluation Plan Phase">
<field name="date_deadline"/>
<field name="survey_id" widget="selection"/>
<field name="user_to_review_id"/>
<field name="response" readonly="1" invisible="True"/>
<button name="%(survey.action_view_survey_question_message)d" string="Interview Question" type="action" states="waiting_answer,done,cancel"
icon="gtk-execute" context="{'survey_id': survey_id, 'response_id': response, 'active' : response, 'object' : 'hr.evaluation.interview', 'cur_id' : active_id}" attrs="{'readonly':[('survey_id','=',False)]}"/>
<button name="%(survey.survey_browse_response)d" string="Print Interview" type="action" states="waiting_answer,done,cancel"
icon="gtk-print" context="{'survey_id': survey_id, 'response_id' : response,}" attrs="{'readonly':[('response','!=',True),('survey_id','!=',True)]}" />
<field name="state" />
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="action_hr_evaluation_interview_tree">
<field name="res_model">hr.evaluation.interview</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem
name="Intreview Requests" parent="menu_eval_hr"
id="menu_open_hr_evaluation_interview_requests"
action="action_hr_evaluation_interview_tree"/>
</data>
</openerp>

View File

@ -1579,7 +1579,7 @@ class survey_request(osv.osv):
'user_id' : fields.many2one("res.users", "User"),
'email' : fields.char("E-mail", size=64),
'survey_id' : fields.many2one("survey", "Survey", required=1),
'answer_ids' : fields.one2many('survey.answer', 'question_id', 'Answer'),
'response' : fields.many2one('survey.response', 'Answer'),
'state' : fields.selection([('waiting_answer', 'Wating Answer'),('done', 'Done'),('cancel', 'Cancelled')], 'State', readonly=1)
}
_defaults = {

View File

@ -1022,7 +1022,7 @@
<field name="survey_id" widget="selection"/>
<field name="user_id" on_change="on_change_user(user_id)"/>
<field name="email"/>
<field name="answer_ids" nolabel="1" colspan="4"/>
<field name="response"/>
<group colspan="4" col="5">
<field name="state"/>
<button name="survey_req_waiting_answer" string="Set to Watting Answer" states="cancel,done" type="object" icon="gtk-new"/>