From 06b25146a1aeccdccf9cd5224df7569ca42c8dc2 Mon Sep 17 00:00:00 2001 From: David Beal Date: Thu, 31 Oct 2024 08:33:57 +0100 Subject: [PATCH] fixup --- polars_db_process/models/df_source.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/polars_db_process/models/df_source.py b/polars_db_process/models/df_source.py index 0a2e42a79..c25f40ae3 100644 --- a/polars_db_process/models/df_source.py +++ b/polars_db_process/models/df_source.py @@ -41,9 +41,6 @@ def _reset_process(self): return res # def tmp(self, file, vals=None): - # db_confs = {x.name: x.id for x in self.env['db.config'].search([])} - # if meta: - # vals['params'] = meta # def guess_model_and_db(): # domain=[] # if meta.get("model"): @@ -61,12 +58,15 @@ def _file_hook(self, file): vals = super()._file_hook(file) if ".sql" in file: # TODO: improve + db_confs = {x.name: x.id for x in self.env['db.config'].search([])} content = self._get_file(file).decode("utf-8") contents = content.split("\n") if contents: # we only detect first line - metadata = safe_eval(contents[0].replace("--", "")) - model_name = metadata.get("model") + meta = safe_eval(contents[0].replace("--", "")) + if meta: + vals['params'] = meta + model_name = meta.get("model") model = self.env["ir.model"].search([("model", "=", model_name)]) if model_name: # we don't want to use these model_maps @@ -86,7 +86,7 @@ def _file_hook(self, file): # TODO use first vals["model_map_id"] = model_map[0].id db_config = self.env["db.config"].search( - [("name", "ilike", metadata.get("db_conf_id"))] + [("name", "ilike", meta.get("db_conf_id"))] ) vals["db_conf_id"] = db_config and db_config[0].id or False else: