mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
[app_base_chinese]增加中文说明功能
This commit is contained in:
@@ -79,6 +79,7 @@
|
|||||||
'data/product_pricelist_data.xml',
|
'data/product_pricelist_data.xml',
|
||||||
'data/stock_location_data.xml',
|
'data/stock_location_data.xml',
|
||||||
'data/sales_team_data.xml',
|
'data/sales_team_data.xml',
|
||||||
|
'views/ir_module_module_views.xml',
|
||||||
],
|
],
|
||||||
'assets': {
|
'assets': {
|
||||||
'web.assets_backend': [
|
'web.assets_backend': [
|
||||||
|
|||||||
@@ -6,6 +6,6 @@ from . import res_currency
|
|||||||
from . import product_category
|
from . import product_category
|
||||||
from . import stock_location
|
from . import stock_location
|
||||||
from . import account_tax_group
|
from . import account_tax_group
|
||||||
|
from . import ir_module_module
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
32
app_base_chinese/models/ir_module_module.py
Normal file
32
app_base_chinese/models/ir_module_module.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import lxml.html
|
||||||
|
from odoo import api, fields, models, modules, tools, _
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class Module(models.Model):
|
||||||
|
_inherit = "ir.module.module"
|
||||||
|
|
||||||
|
description_html_cn = fields.Html('Description HTML CN', compute='_get_desc_cn')
|
||||||
|
|
||||||
|
@api.depends('name', 'description')
|
||||||
|
def _get_desc_cn(self):
|
||||||
|
for module in self:
|
||||||
|
module_path = modules.get_module_path(module.name, display_warning=False) # avoid to log warning for fake community module
|
||||||
|
if module_path:
|
||||||
|
path = modules.check_resource_path(module_path, 'static/description/index_cn.html')
|
||||||
|
else:
|
||||||
|
module.description_html_cn = False
|
||||||
|
if module_path and path:
|
||||||
|
with tools.file_open(path, 'rb') as desc_file:
|
||||||
|
doc = desc_file.read()
|
||||||
|
html = lxml.html.document_fromstring(doc)
|
||||||
|
for element, attribute, link, pos in html.iterlinks():
|
||||||
|
if element.get('src') and not '//' in element.get('src') and not 'static/' in element.get('src'):
|
||||||
|
element.set('src', "/%s/static/description/%s" % (module.name, element.get('src')))
|
||||||
|
module.description_html_cn = tools.html_sanitize(lxml.html.tostring(html))
|
||||||
|
else:
|
||||||
|
module.description_html_cn = False
|
||||||
13
app_base_chinese/views/ir_module_module_views.xml
Normal file
13
app_base_chinese/views/ir_module_module_views.xml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<record id="app_base_chinese_module_module_form_view" model="ir.ui.view">
|
||||||
|
<field name="name">app.base.chinese.module.module.form</field>
|
||||||
|
<field name="model">ir.module.module</field>
|
||||||
|
<field name="inherit_id" ref="base.module_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='description_html']" position="before">
|
||||||
|
<field name="description_html_cn" class="oe_styling_v8" attrs="{'invisible': [('description_html_cn', '=', False)]}"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user