From 7c29aceed073b1988d9dc1f015ce0fec9ee3f8aa Mon Sep 17 00:00:00 2001 From: Mantux11 Date: Thu, 24 Nov 2022 14:02:05 +0000 Subject: [PATCH] [15.0][FIX] excel_import_export, excel_import_export_demo: fix from PR #2283 together with @luc-demeyer suggestion https://github.com/OCA/server-tools/pull/2283#pullrequestreview-881026019 --- excel_import_export/models/common.py | 2 +- excel_import_export/models/ir_report.py | 3 +-- excel_import_export/models/xlsx_import.py | 4 ++-- excel_import_export/wizard/import_xlsx_wizard.py | 11 +++++------ .../report_action/sale_order/report.xml | 3 ++- requirements.txt | 4 ++-- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/excel_import_export/models/common.py b/excel_import_export/models/common.py index 0c8d9535b..e0e92bdf4 100644 --- a/excel_import_export/models/common.py +++ b/excel_import_export/models/common.py @@ -334,7 +334,7 @@ def _add_id_column(file_txt): if line and i == 0: line = '"id",' + line elif line: - line = "{}.{}".format("xls", uuid.uuid4()) + "," + line + line = f"__excel_import_export__.{uuid.uuid4()},{line}" txt_lines.append(line) i += 1 file_txt = "\n".join(txt_lines) diff --git a/excel_import_export/models/ir_report.py b/excel_import_export/models/ir_report.py index e322eddbf..211d00422 100644 --- a/excel_import_export/models/ir_report.py +++ b/excel_import_export/models/ir_report.py @@ -38,5 +38,4 @@ class ReportAction(models.Model): ("report_type", "in", qwebtypes), ("report_name", "=", report_name), ] - context = self.env["res.users"].context_get() - return report_obj.with_context(context=context).search(conditions, limit=1) + return report_obj.search(conditions, limit=1) diff --git a/excel_import_export/models/xlsx_import.py b/excel_import_export/models/xlsx_import.py index de571e877..c5cb0c923 100644 --- a/excel_import_export/models/xlsx_import.py +++ b/excel_import_export/models/xlsx_import.py @@ -50,7 +50,7 @@ class XLSXImport(models.AbstractModel): ModelData.create( { "name": "{}_{}".format(record._table, record.id), - "module": "excel_import_export", + "module": "__excel_import_export__", "model": record._name, "res_id": record.id, } @@ -205,7 +205,7 @@ class XLSXImport(models.AbstractModel): xml_id = ( record and self.get_external_id(record) - or "{}.{}".format("xls", uuid.uuid4()) + or "{}.{}".format("__excel_import_export__", uuid.uuid4()) ) out_st.write(0, 0, "id") # id and xml_id on first column out_st.write(1, 0, xml_id) diff --git a/excel_import_export/wizard/import_xlsx_wizard.py b/excel_import_export/wizard/import_xlsx_wizard.py index 7fb305e24..21ee44b7f 100644 --- a/excel_import_export/wizard/import_xlsx_wizard.py +++ b/excel_import_export/wizard/import_xlsx_wizard.py @@ -1,13 +1,9 @@ # Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) -import logging - from odoo import _, api, fields, models from odoo.exceptions import RedirectWarning, ValidationError -_logger = logging.getLogger(__name__) - class ImportXLSXWizard(models.TransientModel): """This wizard is used with the template (xlsx.template) to import @@ -102,8 +98,11 @@ class ImportXLSXWizard(models.TransientModel): if not template.datas: act = self.env.ref("excel_import_export.action_xlsx_template") raise RedirectWarning( - _('File "%(fname)s" not found in template, %(name)s.') - % {"fname": template.fname, "name": template.name}, + _( + 'File "%(fname)s" not found in template, %(name)s.', + fname=template.fname, + name=template.name, + ), act.id, _("Set Templates"), ) diff --git a/excel_import_export_demo/report_action/sale_order/report.xml b/excel_import_export_demo/report_action/sale_order/report.xml index fcd37598c..2c50e64cd 100644 --- a/excel_import_export_demo/report_action/sale_order/report.xml +++ b/excel_import_export_demo/report_action/sale_order/report.xml @@ -7,9 +7,10 @@ excel sale_order_form.xlsx sale_order + + report (object.state in ('draft', 'sent') and 'Quotation - %s' % (object.name)) or 'Order - %s' % (object.name) - diff --git a/requirements.txt b/requirements.txt index 42fc54e5c..eaf61086d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,8 +4,8 @@ dataclasses mako odoorpc openpyxl +xlrd +xlwt openupgradelib pysftp sentry_sdk -xlrd -xlwt