1 # 重写Model方法 2 # get_formview_id:分享出去的链接跳转到访问模型某条记录,指定form视图展示 3 def get_formview_id(self, access_uid=None): 4 if access_uid: 5 self_sudo = self.with_user(access_uid) 6 else: 7 self_sudo = self 8 if self_sudo.check_access_rights('read', raise_exception=False): # 权限校验 9 return super(HrEmployeePrivate, self).get_formview_id(access_uid=access_uid) 10 return self.env.ref('hr.hr_employee_public_view_form').id 11 12 # get_access_action:返回分享出去的链接跳转到访问模型某条记录时的action 13 def get_access_action(self, access_uid=None): 14 self.ensure_one() 15 user = access_uid and self.env['res.users'].sudo().browse(access_uid) or self.env.user 16 if not self.sale_order_template_id or (not user.share and not self.env.context.get('force_website')): 17 return super(SaleOrder, self).get_access_action(access_uid) 18 return { 19 'type': 'ir.actions.act_url', 20 'url': self.get_portal_url(), 21 'target': 'self', 22 'res_id': self.id, 23 }