init name mixin

This commit is contained in:
Ivan x360
2023-09-11 04:35:44 +08:00
parent 9785348829
commit 48ce4105fd
23 changed files with 552 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
from .hooks import pre_init_hook
from .hooks import post_init_hook
from . import controllers
from . import models
from . import ir
from . import res

View File

@@ -0,0 +1,93 @@
# -*- coding: utf-8 -*-
# Created on 2023-08-28
# author: 欧度智能https://www.odooai.cn
# email: 300883@qq.com
# Copyright (C) 2009~2023 odooAi.cn
# Odoo16在线用户手册长期更新
# https://www.odooai.cn/documentation/16.0/zh_CN/index.html
# Odoo16在线开发者手册长期更新
# https://www.odooai.cn/documentation/16.0/zh_CN/developer.html
# Odoo13在线用户手册长期更新
# https://www.odooai.cn/documentation/user/13.0/zh_CN/index.html
# Odoo13在线开发者手册长期更新
# https://www.odooai.cn/documentation/13.0/index.html
# Odoo10在线中文用户手册长期更新
# https://www.odooai.cn/documentation/user/10.0/zh_CN/index.html
# Odoo10离线中文用户手册下载
# https://www.odooai.cn/odoo10_user_manual_document_offline/
# Odoo10离线开发手册下载-含python教程jquery参考Jinja2模板PostgresSQL参考odoo开发必备
# https://www.odooai.cn/odoo10_developer_document_offline/
##############################################################################
# Copyright (C) 2009-TODAY odooAi.cn Ltd. https://www.odooai.cn
# Author: Ivan Deng300883@qq.com
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
# See <http://www.gnu.org/licenses/>.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
##############################################################################
{
'name': 'mixin english name增加英文名字段',
'version': '16.23.07.27',
'author': 'odooai.cn',
'category': 'Base',
'website': 'https://www.odooai.cn',
'live_test_url': 'https://demo.odooapp.cn',
'license': 'OPL-1',
'sequence': 2,
'price': 98.00,
'currency': 'EUR',
'images': ['static/description/banner.png'],
'summary': '''
Chinese enhance. Out of the box use in china.
Set all chinese default value.
Add quick set of english name.
Default country, timezone, currency, partner...
''',
'description': '''
Support Odoo 16,15,14,13,12, Enterprise and Community and odoo.sh Edition
1.
2.
11. Multi-language Support. Multi-Company Support.
12. Support Odoo 16,15,14,13,12, Enterprise and Community and odoo.sh Edition.
13. Full Open Source.
==========
odoo Chinese Enhance. 中国化增强-基础
1. mixin, 增加英文名字段, 自动设定lang=en_US的名称为英文名
2.
11. 多语言支持,多公司支持
12. Odoo 16,15,14,13,12, 企业版社区版在线SaaS.sh版等全版本支持
13. 代码完全开源
''',
'depends': [
'web',
],
'data': [
'views/res_partner_views.xml',
],
'assets': {
'web.assets_frontend': [
# 'app_/static/src/scss/*.scss',
],
'web.assets_backend': [
# 'app_/static/src/js/*.js',
],
},
'demo': [],
# 'pre_init_hook': 'pre_init_hook',
# 'post_init_hook': 'post_init_hook',
# 'uninstall_hook': 'uninstall_hook',
'installable': True,
'application': True,
'auto_install': False,
}

View File

@@ -0,0 +1 @@
# -*- coding: utf-8 -*-

View File

@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
# Created on 2017-11-22
# author: 广州尚鹏https://www.sunpop.cn
# email: 300883@qq.com
# resource of Sunpop
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Odoo在线中文用户手册长期更新
# https://www.sunpop.cn/documentation/user/10.0/zh_CN/index.html
# Odoo10离线中文用户手册下载
# https://www.sunpop.cn/odoo10_user_manual_document_offline/
# Odoo10离线开发手册下载-含python教程jquery参考Jinja2模板PostgresSQL参考odoo开发必备
# https://www.sunpop.cn/odoo10_developer_document_offline/
# description:
from odoo import api, SUPERUSER_ID, _
def pre_init_hook(cr):
"""
数据初始化,只在安装时执行,更新时不执行
"""
pass
def post_init_hook(cr, registry):
"""
数据初始化,只在安装后执行,更新时不执行
"""
pass
def uninstall_hook(cr, registry):
"""
数据初始化,卸载时执行
"""
pass

View File

@@ -0,0 +1,48 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * app_mixin_name_en
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-07-01 08:44+0000\n"
"PO-Revision-Date: 2020-07-01 08:44+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: app_mixin_name_en
#: model:ir.model,name:app_mixin_name_en.model_res_partner
msgid "Contact"
msgstr "联系人"
#. module: app_mixin_name_en
#: model:ir.model.fields,field_description:app_mixin_name_en.field_mixin_name_en__display_name
msgid "Display Name"
msgstr ""
#. module: app_mixin_name_en
#: model:ir.model.fields,field_description:app_mixin_name_en.field_mixin_name_en__name_en_US
#: model:ir.model.fields,field_description:app_mixin_name_en.field_res_partner__name_en_US
#: model:ir.model.fields,field_description:app_mixin_name_en.field_res_users__name_en_US
msgid "English Name"
msgstr "英文名"
#. module: app_mixin_name_en
#: model:ir.model.fields,field_description:app_mixin_name_en.field_mixin_name_en__id
msgid "ID"
msgstr ""
#. module: app_mixin_name_en
#: model:ir.model.fields,field_description:app_mixin_name_en.field_mixin_name_en____last_update
msgid "Last Modified on"
msgstr ""
#. module: app_mixin_name_en
#: model:ir.model,name:app_mixin_name_en.model_mixin_name_en
msgid "Mixin Auto english name"
msgstr "Mixin 自动英文名"

View File

@@ -0,0 +1 @@
# -*- coding: utf-8 -*-

View File

@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from . import mixin_name_en
from . import res_partner

View File

@@ -0,0 +1,56 @@
# -*- coding: utf-8 -*-
import logging
from odoo import api, fields, models, _
_logger = logging.getLogger(__name__)
class MixinNameEn(models.AbstractModel):
_name = 'mixin.name.en'
_description = 'Mixin Auto english name'
# name_en_US 只要某个模型有此字段,且放在界面上,就会进行此处理
# 无此字段不处理
name_en_US = fields.Char('English Name')
# todo: 以下处理方式不同最好直接做一个widget
# 非开发者模式时,能显示出非英文时值,并可点击改多语种。
# 将原 widget加 options 处理
@api.model_create_multi
def create(self, vals_list):
res = super(MixinNameEn, self).create(vals_list)
if self.env.lang == 'en_US':
return res
# todo: 这里已为了提高性能不检查。不需检查当前odoo是否有英文没英文就不给安装此模块。同时也不检查条件
# if name_field and name_field.translate and name_field.type in ["char", "text"]:
# # todo: 符合条件,后续为提高性能,无需做此判断
# pass
# else:
# return res
# 处理写 en
for index, vals in enumerate(vals_list):
name_en_US = vals.get('name_en_US')
if name_en_US:
try:
res[index].with_context(lang='en_US').write(dict(name=name_en_US))
except Exception as e:
_logger.error('============== name_en mixin create error from name_en_US: %s' % str(e))
return res
def write(self, vals):
res = super(MixinNameEn, self).write(vals)
if self.env.lang == 'en_US':
return res
name_en_US = vals.get('name_en_US')
name = vals.get('name')
if name_en_US:
try:
self.with_context(lang='en_US').write(dict(name=name_en_US))
except Exception as e:
_logger.error('============== name_en mixin write error:%s' % str(e))
return res

View File

@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
from odoo import api, models, fields, _
from odoo.exceptions import UserError, ValidationError
class ResPartner(models.Model):
_name = 'res.partner'
_inherit = ['res.partner', 'mixin.name.en']

View File

@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-

View File

@@ -0,0 +1 @@
# -*- coding: utf-8 -*-

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

View File

@@ -0,0 +1,244 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
# -*- coding: utf-8 -*-
##############################################################################
# Copyright (C) 2009~2023 odooAi.cn
##############################################################################
-->
<html>
<!-- begin title-->
<section class="oe_container container o_cc o_cc2">
<h1 class="text-center bg-warning text-white pt24 pb24">App Title</h1>
<h3 class="text-center">Description 1</h3>
<h4 class="text-center">Description 2</h4>
</section>
<!-- end title-->
<!-- begin features-->
<section class="oe_container container s_text_block o_colored_level pt16 pb16">
<h2 class="text-center bg-info text-white pt16 pb16">- Features -</h2>
</section>
<section class="s_features_grid pt24 pb24 o_colored_level" data-snippet="s_features_grid" data-name="Features Grid">
<div class="container">
<div class="row">
<div class="col-lg-6 s_col_no_bgcolor pb24">
<div class="row">
<div class="col-lg-12 pt16 pb16 o_colored_level" data-name="Box" data-tilt-feature="">
<i class="fa bg-primary text-white s_features_grid_icon rounded fa-2x">1</i>
<div class="s_features_grid_content">
<h4 class="pt16">
Quick Advance Search and navigator for all app data
</h4>
<p>20+ free odoo app search in box.</p>
</div>
</div>
<div class="col-lg-12 pt16 pb16 o_colored_level" data-name="Box">
<i class="fa fa-2x rounded bg-primary text-white s_features_grid_icon">2</i>
<div class="s_features_grid_content">
<h4 class="pt16">
Quick search in tree list header
</h4>
<p>Date range, Datetime, selection, number supported.</p>
</div>
</div>
<div class="col-lg-12 pt16 pb16 o_colored_level" data-name="Box" data-tilt-feature="">
<i class="fa bg-primary text-white s_features_grid_icon rounded fa-2x">3</i>
<div class="s_features_grid_content">
<h4 class="pt16">
Advance search sidebar for many2one, many2many field
</h4>
<p>m2o search, m2m search for multi select.<br></p>
</div>
</div>
</div>
</div>
<div class="col-lg-6 s_col_no_bgcolor pb24">
<div class="row">
<div class="col-lg-12 pt16 pb16 o_colored_level" data-name="Box" data-tilt-feature="">
<i class="fa bg-primary text-white s_features_grid_icon rounded fa-2x">4</i>
<div class="s_features_grid_content">
<h4 class="pt16">
Advance siderbar for date range search, datetime search
</h4>
<p>Extra for boolean search, selection search, number search.</p>
</div>
</div>
<div class="col-lg-12 pt16 pb16 o_colored_level" data-name="Box" data-tilt-feature="">
<i class="fa fa-2x rounded bg-primary text-white s_features_grid_icon">5</i>
<div class="s_features_grid_content">
<h4 class="pt16">
Search sidebar for list, kanban
</h4>
<p>Add more pivot, graph views than origin odoo.</p>
</div>
</div>
<div class="col-lg-12 pt16 pb16 o_colored_level" data-name="Box" data-tilt-feature="">
<i class="fa fa-check fa-2x rounded bg-primary text-white s_features_grid_icon">6</i>
<div class="s_features_grid_content">
<h4 class="pt16">
Full Open Source.Multi-language Support. Multi-Company Support
</h4>
<p>Support Odoo 16,15,14,13,12, Enterprise and Community and odoo.sh Edition.</p>
<p>代码完全开源多语言支持多公司支持。Odoo 16,15,14,13,12, 企业版社区版在线SaaS.sh版等全版本支持</p>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- end features-->
<!-- begin video-->
<section class="s_text_block o_colored_level pt16 pb16">
<div class="container s_allow_columns">
<h2 class="text-center bg-info text-white pt16 pb16">- Demo Video -</h2>
</div>
</section>
<section class="oe_container container s_text_block pt24 pb24 o_colored_level" data-snippet="s_text_block" data-name="文本">
<div class="s_allow_columns container">
<div data-oe-expression="//www.youtube.com/embed/whnmkTWsQkQ?rel=0&amp;autoplay=0" class="media_iframe_video">
<div class="css_editable_mode_display"></div>
<div class="media_iframe_video_size"></div>
<iframe src="//www.youtube.com/embed/whnmkTWsQkQ?rel=0&amp;autoplay=1" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
</div>
<p class="o_default_snippet_text"><br></p>
</div>
<div class="oe_row text-center">
<span>Click above Play. or go </span>
<a href="https://youtu.be/whnmkTWsQkQ" target="_blank" role="button" class="btn btn-link btn-lg">Youtube Video of odoo Advance Search Superbar</a>
</div>
<div class="oe_row text-center">
<p class="o_default_snippet_text">Demo Gif Animation if you can not get video</p>
<img class="oe_demo oe_screenshot img img-fluid" src="superbar.gif">
</div>
</section>
<!-- end video-->
<!-- begin snapshot-->
<section class="s_text_block o_colored_level pt16 pb16">
<div class="container s_allow_columns">
<h2 class="text-center bg-info text-white pt16 pb16">- Feature Guide -</h2>
</div>
</section>
<section class="s_table_of_content pt24 pb24 o_cc o_cc1 o_colored_level" data-snippet="s_table_of_content" data-name="Table of Content">
<div class="container">
<div class="row s_nb_column_fixed">
<div class="col-lg-2 col-md-3 s_table_of_content_navbar_wrap s_table_of_content_navbar_sticky s_table_of_content_vertical_navbar d-print-none d-none d-lg-block o_not_editable o_cc o_cc1 o_colored_level"
data-name="Navbar">
<div class="s_table_of_content_navbar list-group o_no_link_popover" style="top: 82px; max-height: calc(100vh - 102px);">
<a href="#toc_01" class="table_of_content_link list-group-item list-group-item-action py-2 border-0 rounded-0 active">
All in One Search
</a>
<a href="#toc_02" class="table_of_content_link list-group-item list-group-item-action py-2 border-0 rounded-0">
Product Search
</a>
<a href="#toc_11" class="table_of_content_link list-group-item list-group-item-action py-2 border-0 rounded-0">
Multi-language,Multi-Company
</a>
</div>
</div>
<div class="col-lg-10 col-md9 s_table_of_content_main oe_structure oe_empty o_colored_level" data-name="Content">
<section class="pb16 o_colored_level" style="background-image: none;">
<h3 data-anchor="true" id="toc_01">
All in One Search
</h3>
<h4 class="oe_slogan">Quick Advance Search and navigator for all app data.</h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="banner.png">
</div>
<h4 class="oe_slogan"Demo11</h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo11.png">
</div>
</section>
<section class="pb16 o_colored_level" style="background-image: none;">
<h3 data-anchor="true" id="toc_02">
Product Search
</h3>
<h4 class="oe_slogan">Use in product and Category.</h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo21.png">
</div>
<h4 class="oe_slogan">Filter product or any data in search more windows</h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo22.png">
</div>
</section>
<section class="pb16 o_colored_level" style="background-image: none;">
<h3 data-anchor="true" id="toc_11">
Multi-language,Multi-Company Support.
</h3>
<h4 class="oe_slogan">Support Odoo 16,15,14,13,12, Enterprise and Community and odoo.sh Edition.</h4>
<h4 class="oe_slogan">Full Open Source.</h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="cnreadme.png">
</div>
</section>
</div>
</div>
</div>
</section>
<!-- end snapshot-->
<!-- begin free-->
<!-- end free-->
<!-- begin howto-->
<section class="oe_container container s_text_block o_colored_level pt16 pb16">
<h2 class="text-center bg-info text-white pt16 pb16">- How to use -</h2>
<h3>This app need no extra module. The price already included</h3>
</section>
<section class="oe_container container">
<div class="oe_row oe_spaced">
<h4 class="pt16">
1. Buy and Install <a href="http://www.odoo.com/apps/modules/16.0/app_web_superbar/" target="_blank">app_web_superbar. </a>
</h4>
<div class="row">
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo1.png">
</div>
</div>
<h4 class="pt16">2. Easy use of superbar</h4>
<div class="row">
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo2.jpg">
</div>
</div>
</div>
</section>
<!-- end howto-->
<!-- begin upsell-->
<!-- end upsell-->
<!-- begin support-->
<section class="container oe_dark">
<div class="oe_row oe_spaced text-center">
<div class="row">
<h2 class="oe_slogan">Technical Help & Support</h2>
</div>
<div class="col-md-12 pad0">
<div class="oe_mt16">
<p><h4 class="pt16">
For any type of technical help & support requests, Feel free to contact us</h4></p>
<a style="background: #002e5a none repeat scroll 0% 0%; color: rgb(255, 255, 255);position: relative; overflow: hidden;"
class="btn btn-warning btn-lg" rel="nofollow" href="mailto:guohuadeng@hotmail.com"><span
style="height: 354px; width: 354px; top: -147.433px; left: -6.93335px;" class="o_ripple"></span>
<i class="fa fa-envelope"></i> guohuadeng@hotmail.com</a>
<p><h4 class="pt16">
Via QQ: 300883 (App user would not get QQ or any other IM support. Only for odoo project customize.)</h4></p>
<a style="background: #002e5a none repeat scroll 0% 0%; color: rgb(255, 255, 255);position: relative; overflow: hidden;"
class="btn btn-warning btn-lg" rel="nofollow" href="mailto:300883@qq.com"><span
style="height: 354px; width: 354px; top: -147.433px; left: -6.93335px;" class="o_ripple"></span>
<i class="fa fa-envelope"></i> 300883@qq.com</a>
</div>
<div class="oe_mt16">
<h4 class="pt16">Visit our website for more support.</h4>
<h4 class="pt16">https://www.odooai.cn</h4>
</div>
</div>
</div>
</section>
<!-- end support-->
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@@ -0,0 +1,26 @@
.o_form_view .o_address_format {
.o_address_country {
display: -webkit-inline-flex;
display: inline-flex;
width: 48%;
margin-right: 2%;
}
}
.o_form_view.o_form_editable .o_address_format {
div.o_address_state {
width: 50%;
margin-right: 0;
}
.o_address_city{
width: 48%;
margin-right: 2%;
}
.o_address_city_id{
width: 48%;
margin-right: 2%;
}
input.o_address_zip{
width: 50%;
margin-right: 0;
}
}

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- Partner Form视图用继承方式改写2018-11-21,ivan -->
<!--todo: 英文环境下不显示-->
<record id="app_view_partner_form" model="ir.ui.view">
<field name="name">app.res.partner.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='type']" position="after">
<!-- todo: 在英文环境不显示xml中可以直接调 env。或者是在原widget中加options如果无值时则显示同样的 name-->
<field name="name_en_US" place_holder="Default same as name, Input to set other"/>
</xpath>
</field>
</record>
</data>
</odoo>