模块信息存储在ir.module.module 数据表中

平时在开发过程中经常会刷新本地模块列表,例如:新增了模块、更新了模块基础信息、更换了模块图标等等,在点击‘更新’按钮的时候odoo平台到底干了哪些事?

后台代码:

# update the list of available packages
@assert_log_admin_access
@api.model
def update_list(self):
res = [0, 0] # [update, add] default_version = modules.adapt_version('1.0')
known_mods = self.with_context(lang=None).search([])
known_mods_names = {mod.name: mod for mod in known_mods} # iterate through detected modules and update/create them in db
for mod_name in modules.get_modules():
mod = known_mods_names.get(mod_name)
terp = self.get_module_info(mod_name)
values = self.get_values_from_terp(terp) if mod:
updated_values = {}
for key in values:
old = getattr(mod, key)
updated = tools.ustr(values[key]) if isinstance(values[key], pycompat.string_types) else values[key]
if (old or updated) and updated != old:
updated_values[key] = values[key]
if terp.get('installable', True) and mod.state == 'uninstallable':
updated_values['state'] = 'uninstalled'
if parse_version(terp.get('version', default_version)) > parse_version(mod.latest_version or default_version):
res[0] += 1
if updated_values:
mod.write(updated_values)
else:
mod_path = modules.get_module_path(mod_name)
if not mod_path:
continue
if not terp or not terp.get('installable', True):
continue
mod = self.create(dict(name=mod_name, state='uninstalled', **values))
res[1] += 1 mod._update_dependencies(terp.get('depends', []))
mod._update_exclusions(terp.get('excludes', []))
mod._update_category(terp.get('category', 'Uncategorized')) return res

 注解1:

@assert_log_admin_access:验证是否为administrator用户,其实就是在验证是否具有管理员权限,跟踪了一下后台调用user._is_admin,如果在验证的时候如果不是administrator权限用户就会跳出异常。
注解2:
@staticmethod
def get_values_from_terp(terp):
return {
'description': terp.get('description', ''),
'shortdesc': terp.get('name', ''),
'author': terp.get('author', 'Unknown'),
'maintainer': terp.get('maintainer', False),
'contributors': ', '.join(terp.get('contributors', [])) or False,
'website': terp.get('website', ''),
'license': terp.get('license', 'LGPL-3'),
'sequence': terp.get('sequence', 100),
'application': terp.get('application', False),
'auto_install': terp.get('auto_install', False),
'icon': terp.get('icon', False),
'summary': terp.get('summary', ''),
'url': terp.get('url') or terp.get('live_test_url', ''),
'to_buy': False
} 在执行update_list方式中条用get_values_from_terp方法,返回应用信息,判断是否与old信息一致,执行更新write方法。
在icon字段方面,在模型ir.module.module中还有一个icon_image字段,以base64形式存储icon,在icon更新时触发icon_image的更新写入操作:
@api.depends('icon')
def _get_icon_image(self):
for module in self:
module.icon_image = ''
if module.icon:
path_parts = module.icon.split('/')
path = modules.get_module_resource(path_parts[1], *path_parts[2:])
else:
path = modules.module.get_module_icon(module.name)
if path:
with tools.file_open(path, 'rb') as image_file:
module.icon_image = base64.b64encode(image_file.read()) 以上为当前的理解,但仍有一事不明:
这两个_name = "ir.module.module"什么关系?

												

odoo研究学习:刷新本地模块列表都干了什么事?的更多相关文章

  1. 基于python的opcode优化和模块按需加载机制研究(学习与个人思路)(原创)

    基于python的opcode优化和模块按需加载机制研究(学习与思考) 姓名:XXX 学校信息:XXX 主用编程语言:python3.5 个人技术博客:http://www.cnblogs.com/M ...

  2. python学习笔记(13)常用模块列表总结

    os模块: os.remove() 删除文件 os.unlink() 删除文件 os.rename() 重命名文件 os.listdir() 列出指定目录下所有文件 os.chdir() 改变当前工作 ...

  3. node 学习笔记 - Modules 模块加载系统 (1)

    本文同步自我的个人博客:http://www.52cik.com/2015/12/11/learn-node-modules-path.html 用了这么久的 require,但却没有系统的学习过 n ...

  4. Python学习 Part4:模块

    Python学习 Part4:模块 1. 模块是将定义保存在一个文件中的方法,然后在脚本中或解释器的交互实例中使用.模块中的定义可以被导入到其他模块或者main模块. 模块就是一个包含Python定义 ...

  5. Android学习系列(10)--App列表之拖拽ListView(上)

     研究了很久的拖拽ListView的实现,受益良多,特此与尔共飨.      鉴于这部分内容网上的资料少而简陋,而具体的实现过程或许对大家才有帮助,为了详尽而不失真,我们一步一步分析,分成两篇文章. ...

  6. Python学习笔记 - day9 - 模块与包

    模块与包 一个模块就是一个包含了Python定义和声明的文件,文件名就是模块名加上.py的后缀,导入一个py文件,解释器解释该py文件,导入一个包,解释器解释该包下的 __init__.py 文件,所 ...

  7. 05-Node.js学习笔记-第三方模块

    5.1什么是第三方模块 别人写好的,具有特定功能的,我们能直接使用的模块即第三方模块,由于第三方模块通常都是由多个文件组成并且被放置在一个文件夹中,所以又名包. 第三方模块有两种存在形式 以js文件的 ...

  8. 利用Mono.Cecil动态修改程序集来破解商业组件(仅用于研究学习)

    原文 利用Mono.Cecil动态修改程序集来破解商业组件(仅用于研究学习) Mono.Cecil是一个强大的MSIL的注入工具,利用它可以实现动态创建程序集,也可以实现拦截器横向切入动态方法,甚至还 ...

  9. 跟我一起学extjs5(37--单个模块的设计[5取得模块列表数据])

    跟我一起学extjs5(37--单个模块的设计[5取得模块列表数据])         写了几个月,总算有点盼头了,最终要从后台取得数据了.后台的spring mvc 和 service 仅仅能简单的 ...

随机推荐

  1. cannot find package "context"

    导入  github.com/go-sql-driver/mysql 和 database/sql 时,报cannot find package "context"的错误因为go1 ...

  2. windows server 2008 R2之tomcat开机自启

    方法一: 写一个批处理文件autostartup.bat用来启动tomcat,内容如下.复制时不要把复制内容也复制进去 set CATALINA_HOME=C:\apache-tomcat-8.5.3 ...

  3. 将文件夹下的所有csv文件存入数据库

    # 股票的多因子分层回测代码实现 import os import pymysql # import datetime, time # from config import * database_ta ...

  4. url集合

    restful方面 Java后台框架篇--Spring与Restful风格API接口开发 https://blog.csdn.net/hello_worldee/article/details/781 ...

  5. 使用 vue-cli-service inspect 来查看一个 Vue CLI 3 项目的 webpack 配置信息(包括:development、production)

    使用 vue-cli-service inspect 来查看一个 Vue CLI 3 项目的 webpack 配置信息(包括:development.production) --mode 指定环境模式 ...

  6. 2.4 Visio2007显示动态对齐网格

  7. Zookeeper的下载、安装和启动

    一.下载Zookeeper 版本 zookeeper-3.4.13 下载地址:https://archive.apache.org/dist/zookeeper/ 解压后放在/usr/local/zo ...

  8. Firebird 烂笔头(一)

    下载非安装版,将文件解压缩到D:\FireBird2.5下面.然后里面有.bat文件,选择自己适合的类型安装后,在服务里面会有一个firebirdserver开头的服务,右键启动. win+R,在命令 ...

  9. Windows下好用的git客户端--GitExtentions

    用git: https://git-scm.com/downloads GitExtentions: https://sourceforge.net/projects/gitextensions/ B ...

  10. 6.8 出口条件循环:do while

    while循环和for循环都是入口条件循环,即在循环的每次迭代之前检查测试条件,所以有可能根本不执行循环体中的内容.C语言还有出口条件循环(exit-condition loop),即在循环的每次迭代 ...