fix #I7N69Y [app_odoo_customize]开发者模式下增加可查看应用所在目录

This commit is contained in:
Chill
2023-07-31 17:12:23 +08:00
parent cd1422e423
commit 6da3d3f98e
12 changed files with 333 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from . import models
from . import wizard
from . import hooks
from .hooks import pre_init_hook
from .hooks import post_init_hook

View File

@@ -23,7 +23,7 @@
{
'name': 'odoo 16 Customize OEM(Boost, Data reset)',
'version': '16.23.05.25',
'version': '16.23.07.31',
'author': 'odooai.cn',
'category': 'Productivity',
'website': 'https://www.odooai.cn',
@@ -55,6 +55,7 @@
'views/ir_views.xml',
'views/ir_module_module_views.xml',
'views/ir_translation_views.xml',
'views/ir_module_addons_path_views.xml',
'views/ir_ui_menu_views.xml',
'views/ir_ui_view_views.xml',
'views/ir_model_fields_views.xml',

View File

@@ -4,10 +4,10 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0+e-20230423\n"
"Project-Id-Version: Odoo Server 16.0+e-20230721\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-05-24 13:01+0000\n"
"PO-Revision-Date: 2023-05-24 13:01+0000\n"
"POT-Creation-Date: 2023-07-31 09:10+0000\n"
"PO-Revision-Date: 2023-07-31 09:10+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -88,6 +88,11 @@ msgstr "<span class=\"col-3 col-lg-2 text-left\">销售</span>"
msgid "<span class=\"col-3 col-lg-2 text-left\">Website And Blog</span>"
msgstr "<span class=\"col-3 col-lg-2 text-left\">网站与博客</span>"
#. module: app_odoo_customize
#: model_terms:ir.ui.view,arch_db:app_odoo_customize.ir_module_addons_path_form_view
msgid "<span class=\"o_stat_text\"> Modules </span>"
msgstr "<span class=“o_stat_text”> 模块 </span>"
#. module: app_odoo_customize
#: model_terms:ir.ui.view,arch_db:app_odoo_customize.view_app_theme_config_settings
msgid "<span>Set to False to hide</span>"
@@ -115,11 +120,30 @@ msgstr "激活开发者模式"
msgid "Activate the developer mode (with assets)"
msgstr "激活开发者模式 (assets)"
#. module: app_odoo_customize
#: model:ir.model.fields,field_description:app_odoo_customize.field_ir_module_module__addons_path
#: model:ir.model.fields,field_description:app_odoo_customize.field_ir_module_module__addons_path_id
#: model_terms:ir.ui.view,arch_db:app_odoo_customize.app_view_module_filter
msgid "Addons Path"
msgstr "模块路径"
#. module: app_odoo_customize
#: model:ir.actions.act_window,name:app_odoo_customize.action_ir_module_addons_path
#: model:ir.ui.menu,name:app_odoo_customize.menu_ir_module_addons_path
msgid "Addons Paths"
msgstr "模块路径"
#. module: app_odoo_customize
#: model_terms:ir.ui.view,arch_db:app_odoo_customize.view_app_theme_config_settings
msgid "Apply"
msgstr "应用"
#. module: app_odoo_customize
#: model:ir.model.fields.selection,name:app_odoo_customize.selection__res_config_settings__app_navbar_pos_mobile__bottom
#: model:ir.model.fields.selection,name:app_odoo_customize.selection__res_config_settings__app_navbar_pos_pc__bottom
msgid "Bottom"
msgstr "底部"
#. module: app_odoo_customize
#: model_terms:ir.ui.view,arch_db:app_odoo_customize.view_app_theme_config_settings
msgid "Cancel"
@@ -135,6 +159,11 @@ msgstr "清除会计科目,便于重置"
msgid "Click to set"
msgstr "点击设置"
#. module: app_odoo_customize
#: model:ir.model.fields,field_description:app_odoo_customize.field_ir_module_addons_path__color
msgid "Color"
msgstr "颜色"
#. module: app_odoo_customize
#: model:ir.model,name:app_odoo_customize.model_res_config_settings
msgid "Config Settings"
@@ -145,6 +174,16 @@ msgstr "配置设置"
msgid "Copyright &amp;copy;"
msgstr "版权所有 &amp;copy;"
#. module: app_odoo_customize
#: model:ir.model.fields,field_description:app_odoo_customize.field_ir_module_addons_path__create_uid
msgid "Created by"
msgstr "创建者"
#. module: app_odoo_customize
#: model:ir.model.fields,field_description:app_odoo_customize.field_ir_module_addons_path__create_date
msgid "Created on"
msgstr "创建于"
#. module: app_odoo_customize
#: model:ir.actions.act_window,name:app_odoo_customize.action_app_theme_config
#: model:ir.ui.menu,name:app_odoo_customize.menu_app_theme_config
@@ -267,6 +306,11 @@ msgstr "开发者手册链接"
msgid "Developer Manual"
msgstr "开发者手册"
#. module: app_odoo_customize
#: model:ir.model.fields,field_description:app_odoo_customize.field_ir_module_addons_path__display_name
msgid "Display Name"
msgstr "显示名称"
#. module: app_odoo_customize
#. odoo-javascript
#: code:addons/app_odoo_customize/static/src/js/user_menu.js:0
@@ -290,11 +334,31 @@ msgstr "导出翻译"
msgid "HTTP Routing"
msgstr "HTTP 路由"
#. module: app_odoo_customize
#: model:ir.model.fields,field_description:app_odoo_customize.field_ir_module_addons_path__id
msgid "ID"
msgstr "ID"
#. module: app_odoo_customize
#: model:ir.model,name:app_odoo_customize.model_base_language_install
msgid "Install Language"
msgstr "安装语言"
#. module: app_odoo_customize
#: model:ir.model.fields,field_description:app_odoo_customize.field_ir_module_addons_path____last_update
msgid "Last Modified on"
msgstr "上次修改时间"
#. module: app_odoo_customize
#: model:ir.model.fields,field_description:app_odoo_customize.field_ir_module_addons_path__write_uid
msgid "Last Updated by"
msgstr "最后更新者"
#. module: app_odoo_customize
#: model:ir.model.fields,field_description:app_odoo_customize.field_ir_module_addons_path__write_date
msgid "Last Updated on"
msgstr "最后更新于"
#. module: app_odoo_customize
#. odoo-javascript
#: code:addons/app_odoo_customize/static/src/js/user_menu.js:0
@@ -315,9 +379,20 @@ msgstr "可本地更新"
#. module: app_odoo_customize
#: model:ir.model,name:app_odoo_customize.model_ir_module_module
#: model:ir.model.fields,field_description:app_odoo_customize.field_ir_module_addons_path__module_ids
msgid "Module"
msgstr "模块"
#. module: app_odoo_customize
#: model:ir.model.fields,field_description:app_odoo_customize.field_ir_module_addons_path__module_count
msgid "Module Count"
msgstr "模块计数"
#. module: app_odoo_customize
#: model_terms:ir.ui.view,arch_db:app_odoo_customize.ir_module_addons_path_kanban_view
msgid "Modules"
msgstr "模块"
#. module: app_odoo_customize
#: model:ir.model.fields,field_description:app_odoo_customize.field_res_config_settings__app_account_title
msgid "My Odoo.com Account Title"
@@ -328,6 +403,16 @@ msgstr "我的帐户显示标题"
msgid "My Odoo.com Account Url"
msgstr "我的帐户链接"
#. module: app_odoo_customize
#: model:ir.model.fields,field_description:app_odoo_customize.field_res_config_settings__app_navbar_pos_mobile
msgid "Navbar Mobile"
msgstr "导航栏移动"
#. module: app_odoo_customize
#: model:ir.model.fields,field_description:app_odoo_customize.field_res_config_settings__app_navbar_pos_pc
msgid "Navbar PC"
msgstr "导航栏电脑"
#. module: app_odoo_customize
#: model_terms:ir.ui.view,arch_db:app_odoo_customize.app_view_model_data_search
msgid "No Updatable"
@@ -338,6 +423,16 @@ msgstr "无需更新"
msgid "Odoo Customize Setting"
msgstr "odoo自定义设置"
#. module: app_odoo_customize
#: model:ir.model.fields,field_description:app_odoo_customize.field_ir_module_addons_path__path
msgid "Path"
msgstr "路径"
#. module: app_odoo_customize
#: model:ir.model.fields,field_description:app_odoo_customize.field_ir_module_addons_path__path_temp
msgid "Path Temp"
msgstr "路径Temp"
#. module: app_odoo_customize
#: model_terms:ir.ui.view,arch_db:app_odoo_customize.view_app_theme_config_settings
msgid "Please confirm to delete the select data?"
@@ -355,7 +450,7 @@ msgstr "技术支持 <span>odooai.cn</span>"
#: code:addons/app_odoo_customize/static/src/js/user_menu.js:0
#, python-format
msgid "Preferences"
msgstr ""
msgstr "偏好"
#. module: app_odoo_customize
#. odoo-javascript
@@ -385,6 +480,11 @@ msgstr "计划任务"
msgid "Setup System Name,which replace Odoo"
msgstr "设定系统名称,代替原 Odoo 字样"
#. module: app_odoo_customize
#: model:ir.model.fields,field_description:app_odoo_customize.field_ir_module_addons_path__name
msgid "Short Name"
msgstr "简称"
#. module: app_odoo_customize
#: model:ir.model.fields,field_description:app_odoo_customize.field_res_config_settings__group_show_author_in_apps
#: model:res.groups,name:app_odoo_customize.group_show_author_in_apps
@@ -489,6 +589,17 @@ msgstr "你选择的翻译语言已更新。但你仍然需要更新相关模块
msgid "Top Menu"
msgstr "顶级菜单"
#. module: app_odoo_customize
#: model:ir.model.fields.selection,name:app_odoo_customize.selection__res_config_settings__app_navbar_pos_mobile__top
#: model:ir.model.fields.selection,name:app_odoo_customize.selection__res_config_settings__app_navbar_pos_pc__top
msgid "Top(Default)"
msgstr "顶部(默认)"
#. module: app_odoo_customize
#: model_terms:ir.ui.view,arch_db:app_odoo_customize.view_app_theme_config_settings
msgid "UI Config"
msgstr "用户界面配置"
#. module: app_odoo_customize
#: model:ir.model.fields,help:app_odoo_customize.field_res_config_settings__group_show_author_in_apps
msgid "Uncheck to Hide Author and Website in Apps Dashboard"
@@ -524,6 +635,11 @@ msgstr "卸载"
msgid "Uninstall Modules"
msgstr "卸载应用"
#. module: app_odoo_customize
#: model:ir.model,name:app_odoo_customize.model_base_module_update
msgid "Update Module"
msgstr "更新模块"
#. module: app_odoo_customize
#: model_terms:ir.ui.view,arch_db:app_odoo_customize.app_module_view_kanban
msgid "Upgrade"
@@ -579,6 +695,11 @@ msgstr "启用后,会显示在线支持链接"
msgid "When enable,everyone login can see the debug menu"
msgstr "启用后,会显示快速调试菜单"
#. module: app_odoo_customize
#: model:ir.model,name:app_odoo_customize.model_ir_module_addons_path
msgid "ir.module.addons.path"
msgstr "ir.module.addons.path"
#. module: app_odoo_customize
#. odoo-javascript
#: code:addons/app_odoo_customize/static/src/xml/res_config_edition.xml:0

View File

@@ -5,5 +5,6 @@ from . import base_language_install
from . import ir_module_module
from . import web_environment_ribbon_backend
from . import ir_http
from . import ir_module_addons_path
# from . import ir_ui_view
# from . import ir_ui_menu

View File

@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
import random
from odoo import api, fields, models, modules, tools, _
class IrModuleAddonsPath(models.Model):
_name = "ir.module.addons.path"
def _default_bg_color(self):
colors = ['#F06050', '#F4A45F', '#F7CD2E', '#6CC1ED', '#EB7E7F', '#5CC482',
'#2c8297', '#D8485E', '#9365B8', '#804967', '#475576', ]
res = '#FFFFFF'
try:
res = random.choice(colors)
except:
pass
return res
name = fields.Char(string='Short Name')
path = fields.Char(string='Path')
path_temp = fields.Char(string='Path Temp')
color = fields.Char(default=_default_bg_color)
module_ids = fields.One2many('ir.module.module', 'addons_path_id')
module_count = fields.Integer(compute='_compute_module_count')
def _compute_module_count(self):
for rec in self:
rec.module_count = len(rec.module_ids)
def open_apps_view(self):
self.ensure_one()
return {'type': 'ir.actions.act_window',
'name': 'Apps',
'view_mode': 'kanban,tree,form',
'res_model': 'ir.module.module',
'context': {},
'domain': [('addons_path_id', '=', self.id)],
}

View File

@@ -4,6 +4,7 @@ from odoo import api, fields, models, modules, tools, _
import operator
class IrModule(models.Model):
_inherit = 'ir.module.module'
@@ -15,6 +16,8 @@ class IrModule(models.Model):
# latest_version = fields.Char('Installed Version', readonly=True)
local_updatable = fields.Boolean('Local updatable', compute=False, default=False, store=True)
addons_path_id = fields.Many2one('ir.module.addons.path', string='Addons Path', readonly=True)
addons_path = fields.Char(string='Addons Path', related='addons_path_id.path', readonly=True)
def module_multi_uninstall(self):
""" Perform the various steps required to uninstall a module completely

View File

@@ -1,2 +1,3 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_ir_config_parameter_system","ir_config_parameter_system","base.model_ir_config_parameter","base.group_user",1,0,0,0
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_ir_config_parameter_system,ir_config_parameter_system,base.model_ir_config_parameter,base.group_user,1,0,0,0
access_ir_module_addons_path_user,ir_module_addons_path_user,app_odoo_customize.model_ir_module_addons_path,base.group_system,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_ir_config_parameter_system ir_config_parameter_system base.model_ir_config_parameter base.group_user 1 0 0 0
3 access_ir_module_addons_path_user ir_module_addons_path_user app_odoo_customize.model_ir_module_addons_path base.group_system 1 1 1 1

View File

@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="ir_module_addons_path_tree_view" model="ir.ui.view">
<field name="name">ir.module.addons.path.tree</field>
<field name="model">ir.module.addons.path</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="path"/>
</tree>
</field>
</record>
<record id="ir_module_addons_path_form_view" model="ir.ui.view">
<field name="name">ir.module.addons.path.form</field>
<field name="model">ir.module.addons.path</field>
<field name="arch" type="xml">
<form>
<sheet>
<div class="oe_button_box" name="button_box">
<button name="open_apps_view" type="object"
class="oe_stat_button" icon="fa-cubes"
attrs="{'invisible': [('module_count', '=', 0)]}">
<div class="o_stat_info">
<field name="module_count" class="o_stat_value"/>
<span class="o_stat_text"> Modules </span>
</div>
</button>
</div>
<group>
<group>
<field name="name"/>
<field name="path"/>
</group>
<group>
<field name="color"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<record id="ir_module_addons_path_kanban_view" model="ir.ui.view">
<field name="name">ir.module.addons.path.kanban</field>
<field name="model">ir.module.addons.path</field>
<field name="arch" type="xml">
<kanban class="o_kanban_mobile" create="0" edit="0" delete="0">
<field name="name"/>
<field name="path"/>
<field name="path_temp"/>
<field name="color"/>
<templates>
<t t-name="kanban-box">
<div t-attf-style="border-left: 3px solid #{record.color.raw_value}" t-attf-class="oe_kanban_global_click">
<div class="oe_kanban_details">
<strong class="o_kanban_record_title"><field name="name"/></strong>
<ul>
<li class="text-muted"><field name="path_temp"/></li>
<li>
<a name="open_apps_view" href="#" type="object"><field name="module_count"/> Modules</a>
</li>
</ul>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<record id="action_ir_module_addons_path" model="ir.actions.act_window">
<field name="name">Addons Paths</field>
<field name="res_model">ir.module.addons.path</field>
<field name="view_mode">kanban,tree,form</field>
<field name="context">{}</field>
<field name="domain">[]</field>
</record>
</odoo>

View File

@@ -12,6 +12,7 @@
<field name="installed_version" position="after">
<field name="latest_version" optional="hide"/>
<field name="local_updatable" optional="show"/>
<field name="addons_path" optional="hide"/>
</field>
<field name="website" position="attributes">
<attribute name="optional">hide</attribute>
@@ -27,6 +28,9 @@
<filter name="not_installed" position="after">
<filter name="is_local_updatable" string="Local updatable" domain="[('local_updatable', '=', True)]"/>
</filter>
<xpath expr="//search/group" position="inside">
<filter string="Addons Path" name="addons_path" domain="[]" context="{'group_by': 'addons_path_id'}"/>
</xpath>
</field>
</record>
<record id="app_module_form" model="ir.ui.view">
@@ -40,6 +44,12 @@
<field name="website" position="attributes">
<attribute name="groups">app_odoo_customize.group_show_author_in_apps</attribute>
</field>
<xpath expr="//notebook/page/group" position="inside">
<group name="module_path">
<field name="addons_path_id" invisible="1"/>
<field name="addons_path"/>
</group>
</xpath>
</field>
</record>
<record id="app_module_view_kanban" model="ir.ui.view">

View File

@@ -54,18 +54,26 @@
sequence="91"
action="base.ir_cron_act"
groups="base.group_system"/>
<menuitem
id="menu_ir_module_addons_path"
name="Addons Paths"
parent="menu_app_group"
sequence="92"
action="action_ir_module_addons_path"
groups="base.group_system"/>
<!--增加导入Demo数据-->
<menuitem
id="menu_app_demo_data"
parent="menu_app_group"
sequence="92"
sequence="93"
action="base.demo_force_install_action"
groups="base.group_system"/>
<menuitem
id="menu_ir_config_list"
name="System Parameters"
parent="menu_app_group"
sequence="93"
sequence="94"
action="base.ir_config_list_action"
groups="base.group_system"/>
</data>

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import base_module_update

View File

@@ -0,0 +1,56 @@
# -*- coding: utf-8 -*-
import os
import lxml.html
import odoo
import logging
from odoo import api, fields, models, addons, modules, tools, Command
from odoo.modules.module import get_module_path
_logger = logging.getLogger(__name__)
STANDARD_MODULES = ['web', 'web_enterprise', 'theme_common', 'base']
class BaseModuleUpdate(models.TransientModel):
_inherit = "base.module.update"
def update_addons_paths(self):
addons_path_obj = self.env['ir.module.addons.path']
ad_paths = addons.__path__
path_sep = os.path.sep
for path in ad_paths:
if not addons_path_obj.search([('path', '=', path)]):
path_temp = path
if len(path_temp) > 42:
path_temp = '%s......%s' % (path[:12], path[-19:])
addons_path_obj.sudo().create({
'name': path.split(path_sep)[-1],
'path': path,
'path_temp': path_temp,
})
for addons_path_id in addons_path_obj.search([]):
if addons_path_id.path not in ad_paths:
addons_path_id.unlink()
def update_module_addons_paths(self):
addons_path_obj = self.env['ir.module.addons.path']
path_sep = os.path.sep
for module_id in self.env['ir.module.module'].search([]):
module_path = get_module_path(module_id.name)
if not module_path:
continue
addons_path = module_path.rstrip(module_id.name).rstrip(path_sep)
addons_path_id = addons_path_obj.search([('path', '=', addons_path)])
if addons_path_id:
module_id.addons_path_id = addons_path_id.id
def update_module(self):
res = super(BaseModuleUpdate, self).update_module()
self.update_addons_paths()
self.update_module_addons_paths()
return res