From 0cac634df670807a30900ff33da3c789ae57e2a4 Mon Sep 17 00:00:00 2001 From: David Beal Date: Tue, 14 Jun 2022 17:23:21 +0200 Subject: [PATCH] IMP pattern: add company_id in import wizard --- pattern_import_export/wizard/import_pattern_wizard.py | 10 +++++++++- pattern_import_export/wizard/import_pattern_wizard.xml | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pattern_import_export/wizard/import_pattern_wizard.py b/pattern_import_export/wizard/import_pattern_wizard.py index fbe5449e..800ede21 100644 --- a/pattern_import_export/wizard/import_pattern_wizard.py +++ b/pattern_import_export/wizard/import_pattern_wizard.py @@ -23,6 +23,13 @@ class ImportPatternWizard(models.TransientModel): ) import_file = fields.Binary(string="File to import", required=True) filename = fields.Char() + company_id = fields.Many2one( + string="Company", + comodel_name="res.company", + help="If set, import data in the context of the specified company.\n" + "Allow to set company dependent fields in the right company\n" + "Default company is the active one.", + ) def action_launch_import(self): """ @@ -38,7 +45,8 @@ def action_launch_import(self): "pattern_config_id": self.pattern_config_id.id, } ) - pattern_file_import.with_delay( + company = self.company_id or self.env.company + pattern_file_import.with_company(company.id).with_delay( priority=self.pattern_config_id.job_priority ).split_in_chunk() return pattern_file_import diff --git a/pattern_import_export/wizard/import_pattern_wizard.xml b/pattern_import_export/wizard/import_pattern_wizard.xml index 676fa99f..9a5f7ff5 100644 --- a/pattern_import_export/wizard/import_pattern_wizard.xml +++ b/pattern_import_export/wizard/import_pattern_wizard.xml @@ -14,6 +14,7 @@ options="{'no_create_edit': True}" invisible="context.get('hide_pattern_config_id')" /> +