Odoo14 重写Model中的方法
2022/8/2 23:24:17
本文主要是介绍Odoo14 重写Model中的方法,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
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 }
这篇关于Odoo14 重写Model中的方法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-20测试人员都是画画大神,让我看看谁还不会用代码图?
- 2024-05-20年薪百万的程序员都在用的摸鱼方式……
- 2024-05-19永别了,微服务架构!
- 2024-05-15鸿蒙生态设备数量超8亿台
- 2024-05-13TiDB + ES:转转业财系统亿级数据存储优化实践
- 2024-05-09“2024鸿蒙零基础快速实战-仿抖音App开发(ArkTS版)”实战课程已上线
- 2024-05-09聊聊如何通过arthas-tunnel-server来远程管理所有需要arthas监控的应用
- 2024-05-09log4j2这么配就对了
- 2024-05-09nginx修改Content-Type
- 2024-05-09Redis多数据源,看这篇就够了