From 80c9239d69f11561982d9795574d4d236d960bd9 Mon Sep 17 00:00:00 2001 From: Kev-Roche Date: Wed, 6 Sep 2023 19:33:13 +0200 Subject: [PATCH 1/2] [14.0][IMP] support company dependent fields --- pattern_import_export/models/pattern_file.py | 7 +++++++ pattern_import_export/wizard/import_pattern_wizard.py | 1 + 2 files changed, 8 insertions(+) diff --git a/pattern_import_export/models/pattern_file.py b/pattern_import_export/models/pattern_file.py index ccbe4879..07c7147c 100644 --- a/pattern_import_export/models/pattern_file.py +++ b/pattern_import_export/models/pattern_file.py @@ -29,6 +29,13 @@ class PatternFile(models.Model): chunk_ids = fields.One2many("pattern.chunk", "pattern_file_id", "Chunk") date_done = fields.Datetime() + company_id = fields.Many2one( + comodel_name="res.company", + default=lambda self: self.env.company.id, + required=False, + string="Company", + ) + @api.depends("chunk_ids.nbr_error", "chunk_ids.nbr_success") def _compute_stat(self): for record in self: diff --git a/pattern_import_export/wizard/import_pattern_wizard.py b/pattern_import_export/wizard/import_pattern_wizard.py index fbe5449e..bf0469e5 100644 --- a/pattern_import_export/wizard/import_pattern_wizard.py +++ b/pattern_import_export/wizard/import_pattern_wizard.py @@ -36,6 +36,7 @@ def action_launch_import(self): "datas": self.import_file, "kind": "import", "pattern_config_id": self.pattern_config_id.id, + "company_id": self.env.company.id, } ) pattern_file_import.with_delay( From c8524f87a7ffd539710b28bd713ef32d6b793c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20BEAU?= Date: Wed, 17 Jan 2024 22:35:42 +0100 Subject: [PATCH 2/2] pattern_import_export: propagate company to the load function --- pattern_import_export/models/pattern_chunk.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pattern_import_export/models/pattern_chunk.py b/pattern_import_export/models/pattern_chunk.py index e4cf6ed4..29297643 100644 --- a/pattern_import_export/models/pattern_chunk.py +++ b/pattern_import_export/models/pattern_chunk.py @@ -37,6 +37,7 @@ def run_import(self): res = ( self.with_context(pattern_config={"model": model, "record_ids": []}) .env[model] + .with_company(self.pattern_file_id.company_id) .load([], self.data) ) self.write(self._prepare_chunk_result(res))