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')"
/>
+