Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][IMP][pattern_import_export]support company dependent fields #126

Open
wants to merge 2 commits into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pattern_import_export/models/pattern_chunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
7 changes: 7 additions & 0 deletions pattern_import_export/models/pattern_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions pattern_import_export/wizard/import_pattern_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading