odoo12 后台添加安排的活动
2020-01-18 本文已影响0人
隔壁小红馆
此功能用于创建记录时同时创建一个活动,这个活动的类型


这个活动的类型好几种供选择,此处用于提醒功能,提醒员工的资产是否到期功能
@api.model
def create(self, vals):
res = super(AssetRequest, self).create(vals)
model_id = self.env['ir.model']._get(self._name).id
activity_type = self.env['mail.activity.type'].search([('category', '=', 'reminder')])
if res.asset_mode == 'borrow':
res.activity_ids = [(0, 0, {"activity_type_id": activity_type.id,
'res_id': res.id, 'res_model_id': model_id,
'date_deadline': res.return_time,
'user_id': self.env.user.id})]
return res