field-service
field-service copied to clipboard
Field service _prepare_calendar_event
Hey guys, im trying to make a diferent use of the event _prepare_calendar_event i want that if the field person_id that is the person assigned to do the work of that fieldservice in the clock menu should appear to him not the calendar team leader, i tried but im not able to do that any clues?
def _prepare_calendar_event(self):
model_id = self.env.ref("fieldservice.model_fsm_order").id
vals = {
"name": self.name,
"description": self.description,
"start": self.scheduled_date_start,
"stop": self.scheduled_date_end,
"allday": False,
"res_model_id": model_id, # link back with "Document" button
"res_id": self.id, # link back with "Document" button
"location": self._serialize_location(),
"user_id": self.team_id.calendar_user_id.id,
}
vals["partner_ids"] = [(4, self.team_id.calendar_user_id.partner_id.id, False)]
I tried this
if self.person_id :
vals = {
"name": self.name,
"description": self.description,
"start": self.scheduled_date_start,
"stop": self.scheduled_date_end,
"allday": False,
"res_model_id": model_id, # link back with "Document" button
"res_id": self.id, # link back with "Document" button
"location": self._serialize_location(),
"user_id": self.person_id.partner_id.id,
}
vals["partner_ids"] = [(4, self.person_id.partner_id.id, False)]
return vals