fix #I1E17T【app_base_chinese】对英文名的快速支持

fix data
This commit is contained in:
ivan deng
2020-04-11 02:42:32 +08:00
parent 1d9a994452
commit 72a5a561ab
11 changed files with 99 additions and 29 deletions

View File

@@ -18,7 +18,7 @@
{ {
'name': "App base chinese中国化基本模块增强", 'name': "App base chinese中国化基本模块增强",
'version': '13.20.03.19', 'version': '13.20.04.11',
'author': 'Sunpop.cn', 'author': 'Sunpop.cn',
'category': 'Base', 'category': 'Base',
'website': 'https://www.sunpop.cn', 'website': 'https://www.sunpop.cn',
@@ -29,6 +29,7 @@
'summary': """ 'summary': """
Chinese enhance. Out of the box use in china. Chinese enhance. Out of the box use in china.
Set all chinese default value. Set all chinese default value.
Add quick set of english name.
Default country, timezone, currency, partner... Default country, timezone, currency, partner...
""", """,
'description': """ 'description': """
@@ -45,7 +46,8 @@
9. 时间格式年月日为 2019-12-30时间为 22:10 9. 时间格式年月日为 2019-12-30时间为 22:10
10. 国家增加排序,中国排第一 10. 国家增加排序,中国排第一
11. 收款相关显示中国习惯 11. 收款相关显示中国习惯
12. 翻译导出默认中文默认po 12. 翻译导出默认中文默认po
13. 在 base 模型增加 name_en_US 字段,赋值后同时改翻译值
21. todo:中文演示数据(只有demo模式才加载) 21. todo:中文演示数据(只有demo模式才加载)
""", """,
'pre_init_hook': 'pre_init_hook', 'pre_init_hook': 'pre_init_hook',
@@ -65,7 +67,6 @@
'views/templates.xml', 'views/templates.xml',
'wizard/sale_make_invoice_advance_views.xml', 'wizard/sale_make_invoice_advance_views.xml',
'data/ir_default_data.xml', 'data/ir_default_data.xml',
'data/ir_sequence_data.xml',
'data/base_data.xml', 'data/base_data.xml',
'data/res_country_data.xml', 'data/res_country_data.xml',
'data/res_currency_data.xml', 'data/res_currency_data.xml',

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data noupdate="1">
<!-- product_category 序号器 -->
<record id="sequence_product_category_normal" model="ir.sequence">
<field name="name">产品目录常规编号规则</field>
<field name="code">product.category.seq.normal</field>
<field name="prefix">CAT</field>
<field name="padding">4</field>
</record>
</data>
</odoo>

View File

@@ -6,15 +6,24 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 13.0+e\n" "Project-Id-Version: Odoo Server 13.0+e\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-01-18 15:21+0000\n" "POT-Creation-Date: 2020-04-10 18:20+0000\n"
"PO-Revision-Date: 2020-01-18 23:22+0800\n" "PO-Revision-Date: 2020-04-10 18:20+0000\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: \n"
"Plural-Forms: \n" "Plural-Forms: \n"
"X-Generator: Poedit 1.7.7\n"
#. module: app_base_chinese
#: model:ir.model.fields,field_description:app_base_chinese.field_account_tax_group__active
msgid "Active"
msgstr "激活"
#. module: app_base_chinese
#: model:ir.model,name:app_base_chinese.model_base
msgid "Base"
msgstr "基础"
#. module: app_base_chinese #. module: app_base_chinese
#: model:ir.model.fields,field_description:app_base_chinese.field_product_category__complete_name #: model:ir.model.fields,field_description:app_base_chinese.field_product_category__complete_name
@@ -41,11 +50,23 @@ msgstr "币种"
msgid "Determine the display order. Sort ascending." msgid "Determine the display order. Sort ascending."
msgstr "决定显示顺序,数字越小排序越前" msgstr "决定显示顺序,数字越小排序越前"
#. module: app_base_chinese
#: model:ir.model.fields,field_description:app_base_chinese.field_res_partner__name_en_US
#: model:ir.model.fields,field_description:app_base_chinese.field_res_users__name_en_US
msgid "English Name"
msgstr "英文名"
#. module: app_base_chinese #. module: app_base_chinese
#: model_terms:ir.ui.view,arch_db:app_base_chinese.app_view_sale_advance_payment_inv #: model_terms:ir.ui.view,arch_db:app_base_chinese.app_view_sale_advance_payment_inv
msgid "FaPiao / Invoice Orders" msgid "FaPiao / Invoice Orders"
msgstr "创建收据/发票" msgstr "创建收据/发票"
#. module: app_base_chinese
#: model:ir.model.fields,field_description:app_base_chinese.field_res_partner__fax
#: model:ir.model.fields,field_description:app_base_chinese.field_res_users__fax
msgid "Fax"
msgstr "传真"
#. module: app_base_chinese #. module: app_base_chinese
#: model:ir.model.fields,field_description:app_base_chinese.field_stock_location__complete_name #: model:ir.model.fields,field_description:app_base_chinese.field_stock_location__complete_name
msgid "Full Location Name" msgid "Full Location Name"
@@ -80,15 +101,30 @@ msgstr "过帐"
#. module: app_base_chinese #. module: app_base_chinese
#: model:ir.model,name:app_base_chinese.model_product_category #: model:ir.model,name:app_base_chinese.model_product_category
msgid "Product Category" msgid "Product Category"
msgstr "品类" msgstr "品类"
#. module: app_base_chinese #. module: app_base_chinese
#: model:ir.model.fields,field_description:app_base_chinese.field_res_currency__sequence #: model:ir.model.fields,field_description:app_base_chinese.field_res_currency__sequence
msgid "Sequence" msgid "Sequence"
msgstr "单号规则" msgstr "单号规则"
#. module: app_base_chinese
#: model:ir.model.fields,help:app_base_chinese.field_account_tax_group__active
msgid "Set active to false to hide the tax without removing it."
msgstr "请不要删除指定税率,可以将其归档。"
#. module: app_base_chinese #. module: app_base_chinese
#: model:ir.model.fields,field_description:app_base_chinese.field_res_partner__short_name #: model:ir.model.fields,field_description:app_base_chinese.field_res_partner__short_name
#: model:ir.model.fields,field_description:app_base_chinese.field_res_users__short_name #: model:ir.model.fields,field_description:app_base_chinese.field_res_users__short_name
msgid "Short Name" msgid "Short Name"
msgstr "简称" msgstr "简称"
#. module: app_base_chinese
#: model:ir.model,name:app_base_chinese.model_account_tax_group
msgid "Tax Group"
msgstr "税组"
#. module: app_base_chinese
#: model:ir.sequence,name:app_base_chinese.sequence_product_category_normal
msgid "产品目录常规编号规则"
msgstr ""

View File

@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from . import base
from . import res_partner from . import res_partner
from . import res_currency from . import res_currency
from . import product_category from . import product_category

View File

@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
import logging
from odoo import api, fields, models, _
_logger = logging.getLogger(__name__)
class Base(models.AbstractModel):
_inherit = 'base'
# name_en_US 只要某个模型有此字段,且放在界面上,就会进行此处理
# 无此字段不处理
# todo: 为了性能,暂时不在 create 时处理
# todo: create_multi ?
# todo: 在 ir.translation 中处理以提高性能, 或反向写回
@api.model
def create(self, vals):
name_field = self._fields.get("name")
name_en_field = self._fields.get("name_en_US")
name_en_US = None
if name_field and name_field.translate and name_field.type in ["char", "text"] \
and name_en_field and name_en_field.type in["char", "text"] and 'name_en_US' in vals:
name_en_US = vals.get('name_en_US')
rec = super(Base, self).create(vals)
if name_en_US:
try:
rec.with_context(lang='en_US').name = name_en_US
except Exception as e:
pass
return rec
def write(self, vals):
name_field = self._fields.get("name")
name_en_field = self._fields.get("name_en_US")
if name_field and name_field.translate and name_field.type in ["char", "text"] \
and name_en_field and name_en_field.type in["char", "text"] and 'name_en_US' in vals:
name_en_US = vals.get('name_en_US')
if name_en_US != None:
try:
self.with_context(lang='en_US').write(dict(name=name_en_US))
except Exception as e:
pass
return super(Base, self).write(vals)

View File

@@ -8,6 +8,7 @@ class ResPartner(models.Model):
_inherit = 'res.partner' _inherit = 'res.partner'
name = fields.Char(index=True, translate=True) name = fields.Char(index=True, translate=True)
name_en_US = fields.Char('English Name')
short_name = fields.Char('Short Name') # 简称 short_name = fields.Char('Short Name') # 简称
fax = fields.Char('Fax') # 简称 fax = fields.Char('Fax') # 简称

View File

@@ -13,6 +13,7 @@
<!--</xpath>--> <!--</xpath>-->
<xpath expr="//field[@name='type']" position="after"> <xpath expr="//field[@name='type']" position="after">
<field name="short_name"/> <field name="short_name"/>
<field name="name_en_US"/>
</xpath> </xpath>
<!-- 信用额度 --> <!-- 信用额度 -->
<xpath expr="//field[@name='category_id']" position="after"> <xpath expr="//field[@name='category_id']" position="after">

View File

@@ -41,7 +41,7 @@
{ {
'name': 'Product Brand Manager', 'name': 'Product Brand Manager',
'version': '13.19.12.12', 'version': '13.20.04.11',
'author': 'Sunpop.cn', 'author': 'Sunpop.cn',
'category': 'Product', 'category': 'Product',
'website': 'https://www.sunpop.cn', 'website': 'https://www.sunpop.cn',

View File

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

View File

@@ -7,10 +7,7 @@ from odoo import fields, models
class AccountInvoiceReport(models.Model): class AccountInvoiceReport(models.Model):
_inherit = "account.invoice.report" _inherit = "account.invoice.report"
product_brand_id = fields.Many2one( product_brand_id = fields.Many2one('product.brand', string='Brand')
comodel_name='product.product_brand_id',
string='Brand',
)
def _select(self): def _select(self):
select_str = super()._select() select_str = super()._select()

View File

@@ -7,10 +7,7 @@ from odoo import fields, models
class SaleReport(models.Model): class SaleReport(models.Model):
_inherit = "sale.report" _inherit = "sale.report"
product_brand_id = fields.Many2one( product_brand_id = fields.Many2one('product.brand', string='Brand')
comodel_name='product.brand',
string='Brand',
)
# pylint:disable=dangerous-default-value # pylint:disable=dangerous-default-value
def _query(self, with_clause='', fields={}, groupby='', from_clause=''): def _query(self, with_clause='', fields={}, groupby='', from_clause=''):