Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
hh_ccs
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
贺阳
hh_ccs
Commits
84438fd6
提交
84438fd6
authored
5月 21, 2024
作者:
郑笛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
完成翻译功能
上级
2e915111
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
77 行增加
和
3 行删除
+77
-3
__manifest__.py
ccs_base/__manifest__.py
+1
-0
data.xml
ccs_base/data/data.xml
+15
-0
zh_CN.po
ccs_base/i18n/zh_CN.po
+15
-0
cc_bill_loading.py
ccs_base/models/cc_bill_loading.py
+29
-3
cc_bl_line_view.xml
ccs_base/views/cc_bl_line_view.xml
+15
-0
requirements.txt
requirements.txt
+2
-0
没有找到文件。
ccs_base/__manifest__.py
浏览文件 @
84438fd6
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
'data'
:
[
'data'
:
[
'security/account_security.xml'
,
'security/account_security.xml'
,
'security/ir.model.access.csv'
,
'security/ir.model.access.csv'
,
'data/data.xml'
,
'views/menu_view.xml'
,
'views/menu_view.xml'
,
'views/cc_node_view.xml'
,
'views/cc_node_view.xml'
,
'views/cc_process_view.xml'
,
'views/cc_process_view.xml'
,
...
...
ccs_base/data/data.xml
0 → 100644
浏览文件 @
84438fd6
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data
noupdate=
"1"
>
<!-- 代理-->
<!--{'http': 'http://localhost:10809', 'https': 'http://localhost:10809'}-->
<!--公司代理:{'https': 'socks5://192.168.0.254:1080'}-->
<record
id=
"proxy_url"
model=
"ir.config_parameter"
>
<field
name=
"key"
>
proxy_url
</field>
<field
name=
"value"
>
{'https': 'socks5://192.168.0.254:1080'}
</field>
</record>
</data>
</odoo>
\ No newline at end of file
ccs_base/i18n/zh_CN.po
浏览文件 @
84438fd6
...
@@ -398,6 +398,16 @@ msgstr "ID"
...
@@ -398,6 +398,16 @@ msgstr "ID"
msgid "ITEM DESCRIPTION"
msgid "ITEM DESCRIPTION"
msgstr "商品描述"
msgstr "商品描述"
#. module: ccs_base
#: model:ir.model.fields,field_description:ccs_base.field_cc_bl_line__item_description_translate
msgid "ITEM DESCRIPTION(EN)"
msgstr "商品描述(英文)"
#. module: ccs_base
#: model:ir.model.fields,field_description:ccs_base.field_cc_bl_line__receipient_county_translate
msgid "RECEIPIENT COUNTY(EN)"
msgstr "收件国家(英文)"
#. module: ccs_base
#. module: ccs_base
#: model:ir.model.fields,field_description:ccs_base.field_cc_bl_line__item_hs_code
#: model:ir.model.fields,field_description:ccs_base.field_cc_bl_line__item_hs_code
#: model:ir.model.fields,field_description:ccs_base.field_cc_customers_declaration_order_line__item_hs_code
#: model:ir.model.fields,field_description:ccs_base.field_cc_customers_declaration_order_line__item_hs_code
...
@@ -906,3 +916,8 @@ msgid ""
...
@@ -906,3 +916,8 @@ msgid ""
"[Customers] Not yet! Click the Create button in the top left corner and the "
"[Customers] Not yet! Click the Create button in the top left corner and the "
"sofa is yours!"
"sofa is yours!"
msgstr "[客户] 还没有!点击左上角的“创建”按钮,沙发就是你的了!"
msgstr "[客户] 还没有!点击左上角的“创建”按钮,沙发就是你的了!"
#. module: ccs_base
#: model:ir.actions.server,name:ccs_base.bl_line_translate_server_action
msgid "Translate"
msgstr "翻译"
ccs_base/models/cc_bill_loading.py
浏览文件 @
84438fd6
# 导入odoo
# 导入odoo
import
ast
import
base64
import
base64
import
re
from
datetime
import
timedelta
from
datetime
import
timedelta
from
pygtrans
import
Translate
import
xlrd
import
xlrd
import
pytz
import
pytz
from
odoo
import
models
,
fields
,
api
,
_
from
odoo
import
models
,
fields
,
api
,
_
...
@@ -61,6 +63,7 @@ class CcBLLine(models.Model):
...
@@ -61,6 +63,7 @@ class CcBLLine(models.Model):
receipient_city
=
fields
.
Char
(
string
=
'RECEIPIENT CITY'
)
receipient_city
=
fields
.
Char
(
string
=
'RECEIPIENT CITY'
)
# 收件人县
# 收件人县
receipient_county
=
fields
.
Char
(
string
=
'RECEIPIENT COUNTY'
)
receipient_county
=
fields
.
Char
(
string
=
'RECEIPIENT COUNTY'
)
receipient_county_translate
=
fields
.
Char
(
string
=
'RECEIPIENT COUNTY(EN)'
)
# 收件人邮编
# 收件人邮编
receipient_postcode
=
fields
.
Char
(
string
=
'RECEPIENT POSTCODE'
)
receipient_postcode
=
fields
.
Char
(
string
=
'RECEPIENT POSTCODE'
)
# 收件人邮件
# 收件人邮件
...
@@ -77,6 +80,7 @@ class CcBLLine(models.Model):
...
@@ -77,6 +80,7 @@ class CcBLLine(models.Model):
sku_number
=
fields
.
Char
(
string
=
'SKU NUMBER'
)
sku_number
=
fields
.
Char
(
string
=
'SKU NUMBER'
)
# 项目描述
# 项目描述
item_description
=
fields
.
Char
(
string
=
'ITEM DESCRIPTION'
)
item_description
=
fields
.
Char
(
string
=
'ITEM DESCRIPTION'
)
item_description_translate
=
fields
.
Char
(
string
=
'ITEM DESCRIPTION(EN)'
)
# 项目HS代码
# 项目HS代码
item_hs_code
=
fields
.
Char
(
string
=
'ITEM HS CODE'
)
item_hs_code
=
fields
.
Char
(
string
=
'ITEM HS CODE'
)
# 项目数量
# 项目数量
...
@@ -98,6 +102,28 @@ class CcBLLine(models.Model):
...
@@ -98,6 +102,28 @@ class CcBLLine(models.Model):
# 高度
# 高度
height
=
fields
.
Float
(
string
=
'HEIGHT'
)
height
=
fields
.
Float
(
string
=
'HEIGHT'
)
# 翻译
def
action_bl_line_translate
(
self
):
# http代理:proxies={'http': 'http://localhost:10809', 'https': 'http://localhost:10809'}
# socks5代理:proxies={'https': 'socks5://192.168.0.254:1080'}
proxy_url
=
self
.
env
[
'ir.config_parameter'
]
.
sudo
()
.
get_param
(
'proxy_url'
)
client
=
Translate
(
proxies
=
ast
.
literal_eval
(
proxy_url
))
if
proxy_url
else
Translate
()
# 判断是否包含中文
charge_zh
=
lambda
x
=
'ddd'
:
sum
([
1
if
u'
\u4e00
'
<=
i
<=
u'
\u9fff
'
else
0
for
i
in
x
])
>
0
for
item
in
self
:
if
not
item
.
item_description_translate
and
item
.
item_description
:
if
charge_zh
(
item
.
item_description
):
result
=
client
.
translate
(
item
.
item_description
,
target
=
'en'
)
item
.
item_description_translate
=
result
.
translatedText
.
replace
(
'''
,
"'"
)
.
replace
(
'"'
,
'"'
)
else
:
item
.
item_description_translate
=
item
.
item_description
if
not
item
.
receipient_county_translate
and
item
.
receipient_county
:
if
charge_zh
(
item
.
receipient_county
):
result
=
client
.
translate
(
item
.
receipient_county
,
target
=
'en'
)
item
.
receipient_county_translate
=
result
.
translatedText
.
replace
(
'''
,
"'"
)
.
replace
(
'"'
,
'"'
)
else
:
item
.
receipient_county_translate
=
item
.
receipient_county
# 创建一个业务对象,继承自models.Model, 用于管理业务数据.业务数据包括提单号、提单日期、提单总件数、提单总金额、所属客户、提单明细、清关进度明细、状态[待确认、清关中、已完成]
# 创建一个业务对象,继承自models.Model, 用于管理业务数据.业务数据包括提单号、提单日期、提单总件数、提单总金额、所属客户、提单明细、清关进度明细、状态[待确认、清关中、已完成]
class
CcBL
(
models
.
Model
):
class
CcBL
(
models
.
Model
):
...
@@ -268,7 +294,7 @@ class CcBL(models.Model):
...
@@ -268,7 +294,7 @@ class CcBL(models.Model):
'receipient_add_2'
:
email_lines
[
0
]
.
receipient_add_2
,
'receipient_add_2'
:
email_lines
[
0
]
.
receipient_add_2
,
'receipient_add_3'
:
email_lines
[
0
]
.
receipient_add_3
,
'receipient_add_3'
:
email_lines
[
0
]
.
receipient_add_3
,
'receipient_city'
:
email_lines
[
0
]
.
receipient_city
,
'receipient_city'
:
email_lines
[
0
]
.
receipient_city
,
'receipient_county'
:
email_lines
[
0
]
.
receipient_county
,
'receipient_county'
:
email_lines
[
0
]
.
receipient_county
_translate
,
'receipient_postcode'
:
email_lines
[
0
]
.
receipient_postcode
,
'receipient_postcode'
:
email_lines
[
0
]
.
receipient_postcode
,
'sender_name'
:
email_lines
[
0
]
.
sender_name
,
'sender_name'
:
email_lines
[
0
]
.
sender_name
,
'shipper_add_1'
:
email_lines
[
0
]
.
shipper_add_1
,
'shipper_add_1'
:
email_lines
[
0
]
.
shipper_add_1
,
...
@@ -290,7 +316,7 @@ class CcBL(models.Model):
...
@@ -290,7 +316,7 @@ class CcBL(models.Model):
'net_weight'
:
email_line
.
net_weight
,
'net_weight'
:
email_line
.
net_weight
,
'currency'
:
email_line
.
currency
,
'currency'
:
email_line
.
currency
,
'sku_number'
:
email_line
.
sku_number
,
'sku_number'
:
email_line
.
sku_number
,
'item_description'
:
email_line
.
item_description
,
'item_description'
:
email_line
.
item_description
_translate
,
'item_hs_code'
:
email_line
.
item_hs_code
,
'item_hs_code'
:
email_line
.
item_hs_code
,
'item_quantity'
:
email_line
.
item_quantity
,
'item_quantity'
:
email_line
.
item_quantity
,
'unit_value'
:
email_line
.
unit_value
,
'unit_value'
:
email_line
.
unit_value
,
...
...
ccs_base/views/cc_bl_line_view.xml
浏览文件 @
84438fd6
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
<field
optional=
"show"
name=
"receipient_add_3"
string=
"RECEIPIENT ADD 3"
/>
<field
optional=
"show"
name=
"receipient_add_3"
string=
"RECEIPIENT ADD 3"
/>
<field
optional=
"show"
name=
"receipient_city"
string=
"RECEIPIENT CITY"
/>
<field
optional=
"show"
name=
"receipient_city"
string=
"RECEIPIENT CITY"
/>
<field
optional=
"show"
name=
"receipient_county"
string=
"RECEIPIENT COUNTY"
/>
<field
optional=
"show"
name=
"receipient_county"
string=
"RECEIPIENT COUNTY"
/>
<field
optional=
"show"
name=
"receipient_county_translate"
/>
<field
optional=
"show"
name=
"receipient_postcode"
string=
"RECEPIENT POSTCODE"
/>
<field
optional=
"show"
name=
"receipient_postcode"
string=
"RECEPIENT POSTCODE"
/>
<field
optional=
"show"
name=
"recepient_email"
string=
"RECEPIENT EMAIL"
/>
<field
optional=
"show"
name=
"recepient_email"
string=
"RECEPIENT EMAIL"
/>
<field
optional=
"show"
name=
"phone_number"
string=
"PHONE NUMBER"
/>
<field
optional=
"show"
name=
"phone_number"
string=
"PHONE NUMBER"
/>
...
@@ -31,6 +32,7 @@
...
@@ -31,6 +32,7 @@
<field
optional=
"show"
name=
"currency"
string=
"Currency"
/>
<field
optional=
"show"
name=
"currency"
string=
"Currency"
/>
<field
optional=
"show"
name=
"sku_number"
string=
"SKU NUMBER"
/>
<field
optional=
"show"
name=
"sku_number"
string=
"SKU NUMBER"
/>
<field
optional=
"show"
name=
"item_description"
string=
"ITEM DESCRIPTION"
/>
<field
optional=
"show"
name=
"item_description"
string=
"ITEM DESCRIPTION"
/>
<field
optional=
"show"
name=
"item_description_translate"
/>
<field
optional=
"show"
name=
"item_hs_code"
string=
"ITEM HS CODE"
/>
<field
optional=
"show"
name=
"item_hs_code"
string=
"ITEM HS CODE"
/>
<field
optional=
"show"
name=
"item_quantity"
string=
"ITEM QUANTITY"
/>
<field
optional=
"show"
name=
"item_quantity"
string=
"ITEM QUANTITY"
/>
<field
optional=
"show"
name=
"unit_value"
string=
"UNIT VALUE"
/>
<field
optional=
"show"
name=
"unit_value"
string=
"UNIT VALUE"
/>
...
@@ -105,4 +107,16 @@
...
@@ -105,4 +107,16 @@
</p>
</p>
</field>
</field>
</record>
</record>
<record
id=
"bl_line_translate_server_action"
model=
"ir.actions.server"
>
<field
name=
"name"
>
Translate
</field>
<field
name=
"model_id"
ref=
"model_cc_bl_line"
/>
<field
name=
"binding_model_id"
ref=
"model_cc_bl_line"
/>
<field
name=
"state"
>
code
</field>
<field
name=
"code"
>
if records:
action = records.action_bl_line_translate()
</field>
</record>
</odoo>
</odoo>
\ No newline at end of file
requirements.txt
0 → 100644
浏览文件 @
84438fd6
pygtrans
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论