odoo根据模型生成security配置信息
来源:互联网 发布:c语言函数声明的标准 编辑:程序博客网 时间:2024/06/08 10:18
在odoo开发中,根据model生成security也是重复性且容易犯错的阶段,因此我也写了一个简单的生成程序,可以生成相应的,下面是我的程序。
#coding=utf-8import reimport osname_re = re.compile(r"\'([^\']*)\'")name_line_re = re.compile(r" _name")def get_security_config(file_names,target_file): fwrite = open(target_file, 'w') head_str = "id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink" fwrite.write(head_str) fwrite.write("\n") fwrite.close() name_re = re.compile(r"\'([^\']*)\'") for file in file_names: if os.path.exists(file): if os.path.isfile(file): write_security_config(file,target_file) else: file_list = os.listdir(file) for file in file_list: if endwith(file,'.py'): write_security_config(file,target_file)def endwith(s,*endstring): array = map(s.endswith,endstring) if True in array: return True else: return Falsedef write_security_config(file_name,target_file): fwrite = open(target_file, 'a') with open(file_name, 'r') as f: for line in f.readlines(): if name_line_re.findall(line): names = name_re.findall(line.strip()) if names: print names names_formate = names[0].replace('.', '_') print names_formate first = "access_{}_user,{}.user,model_{},base.group_user,1,0,0,0".format(names_formate, names[0], names_formate) second = "access_{}_user_operate,{}.user,model_{},define.group_system,1,1,1,0".format( names_formate, names[0], names_formate) third = "access_{}_user_group_system,{}.user,model_{},base.group_system,1,1,1,1".format( names_formate, names[0], names_formate) print first print second print third fwrite.write(first) fwrite.write("\n") fwrite.write(second) fwrite.write("\n") fwrite.write(third) fwrite.write("\n") fwrite.write("\n") fwrite.close()if __name__ =='__main__': file_name = [ 'model.py' ] new_file_name = 'security_tmp.txt' get_security_config(file_name,new_file_name)注意在生成过程中,first,second,third根据自己产品的security配置写相应的配置信息。
0 0
- odoo根据模型生成security配置信息
- odoo中根据模型生成viwe视图的框架代码
- odoo config配置信息
- odoo根据当前时间生成序列号
- odoo根据当前时间自动生成序列号
- 根据模型生成数据库
- odoo 新手之路-__openerp__.py配置信息
- mybatis 根据数据库表映射配置生成 模型 XML文件 Dao
- 根据浇注信息划分大坝模型程序设计
- Spring security --- Acegi部分配置信息
- 根据用户配置生成EXE
- hibernate 根据配置生成数据库
- 根据PowerDesigner的模型生成数据库表
- 修改Odoo 8版权信息
- [odoo]替换Powered by信息
- Odoo 8.0深入浅出开发教程(九) Odoo模型层详解
- odoo 新手之路-xmlrpclib获取odoo内容信息
- Docker odoo客方配置
- hdu 1011 Starship Troopers dp 带点坑的树形背包 ★
- 欢迎使用CSDN-markdown编辑器
- 【Codeforces Round 363 (Div 2) E】【概率DP 期望DP 逆推等价法】LRU Cache替换LRU原则超多步数后每个数据在Cache中的概率
- .Net AOP (四)EnterpriseLibary 实现方法
- centos7 python升级
- odoo根据模型生成security配置信息
- POJ 1328 Radar Installation 贪心(区间选点)
- JavaSE学习笔记之-----常用类
- Leetcode常用五大算法思想
- NYOJ 102 次方求模(快速求幂)
- 常用代码片段整理
- byteConvertInputStream
- Spark的worker运行分析
- unity调用java