mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
fix #I7TD3E 【app_ai_seo】网站快速seo功能
This commit is contained in:
@@ -7,7 +7,8 @@ import os.path
|
|||||||
|
|
||||||
from odoo import api, fields, models, modules, tools, SUPERUSER_ID, _
|
from odoo import api, fields, models, modules, tools, SUPERUSER_ID, _
|
||||||
from odoo.tools import pycompat
|
from odoo.tools import pycompat
|
||||||
|
from odoo.tests import common
|
||||||
|
ADMIN_USER_ID = common.ADMIN_USER_ID
|
||||||
|
|
||||||
def app_quick_import(cr, content_path, sep=None):
|
def app_quick_import(cr, content_path, sep=None):
|
||||||
if not sep:
|
if not sep:
|
||||||
@@ -19,7 +20,11 @@ def app_quick_import(cr, content_path, sep=None):
|
|||||||
model_name = file_name.replace(file_type, '')
|
model_name = file_name.replace(file_type, '')
|
||||||
file_path = modules.get_module_resource(module_name, dir_split[1], file_name)
|
file_path = modules.get_module_resource(module_name, dir_split[1], file_name)
|
||||||
content = open(file_path, 'rb').read()
|
content = open(file_path, 'rb').read()
|
||||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
uid = SUPERUSER_ID
|
||||||
|
if model_name == 'mail.channel':
|
||||||
|
# todo: 创建mail.channel时,如果用root用户会报错
|
||||||
|
uid = 2
|
||||||
|
env = api.Environment(cr, uid, {})
|
||||||
if file_type == '.csv':
|
if file_type == '.csv':
|
||||||
file_type = 'text/csv'
|
file_type = 'text/csv'
|
||||||
elif file_type in ['.xls', '.xlsx']:
|
elif file_type in ['.xls', '.xlsx']:
|
||||||
@@ -30,10 +35,15 @@ def app_quick_import(cr, content_path, sep=None):
|
|||||||
'file_type': file_type,
|
'file_type': file_type,
|
||||||
'file': content,
|
'file': content,
|
||||||
})
|
})
|
||||||
|
if file_type == 'text/csv':
|
||||||
|
preview = import_wizard.parse_preview({
|
||||||
|
'separator': ',',
|
||||||
|
'has_headers': True,
|
||||||
|
'quoting': '"',
|
||||||
|
})
|
||||||
|
elif file_type == 'application/vnd.ms-excel':
|
||||||
preview = import_wizard.parse_preview({
|
preview = import_wizard.parse_preview({
|
||||||
# 'separator': ',',
|
|
||||||
'has_headers': True,
|
'has_headers': True,
|
||||||
# 'quoting': '"',
|
|
||||||
})
|
})
|
||||||
result = import_wizard.execute_import(
|
result = import_wizard.execute_import(
|
||||||
preview["headers"],
|
preview["headers"],
|
||||||
|
|||||||
Reference in New Issue
Block a user