opt common 18与16一致

This commit is contained in:
Ivan Office
2025-01-26 00:33:20 +08:00
parent a881585412
commit 3ae4b1aafc
5 changed files with 33 additions and 19 deletions

View File

@@ -1,14 +1,10 @@
# -*- coding: utf-8 -*-
import base64
import io
import csv
import os.path
from odoo import api, fields, models, modules, tools, SUPERUSER_ID, _
from odoo.tools import pycompat
def app_quick_import(env, content_path, sep=None):
def app_quick_import(env, content_path, sep=None, context={}):
if not sep:
sep = '/'
dir_split = content_path.split(sep)
@@ -26,7 +22,8 @@ def app_quick_import(env, content_path, sep=None):
file_type = 'text/csv'
elif file_type in ['.xls', '.xlsx']:
file_type = 'application/vnd.ms-excel'
import_wizard = env['base_import.import'].create({
import_wizard = env['base_import.import'].with_context(context)
import_wizard = import_wizard.create({
'res_model': model_name,
'file_name': file_name,
'file_type': file_type,
@@ -42,8 +39,14 @@ def app_quick_import(env, content_path, sep=None):
preview = import_wizard.parse_preview({
'has_headers': True,
})
result = import_wizard.execute_import(
preview["headers"],
preview["headers"],
preview["options"]
)
else:
preview = False
if preview:
import_wizard.execute_import(
preview["headers"],
preview["headers"],
preview["options"]
)

View File

@@ -11,5 +11,5 @@ _logger = logging.getLogger(__name__)
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
app_saas_ok = fields.Boolean('Enable CN SaaS', help="Checked to Enable www.odooapp.cn cloud service.", default=True, config_parameter='app_saas_ok')
app_saas_ok = fields.Boolean('Enable CN SaaS', default=True, config_parameter='app_saas_ok',
help="Checked to Enable www.odooapp.cn cloud service.")