diff --git a/polars_process/data/action.xml b/polars_process/data/action.xml index 08e8c8d69..79956c9e0 100644 --- a/polars_process/data/action.xml +++ b/polars_process/data/action.xml @@ -1,7 +1,7 @@ - Populate Polars data source + ⚙ Populate data source code diff --git a/polars_process/models/df_source.py b/polars_process/models/df_source.py index c371897ff..17f7e9a90 100644 --- a/polars_process/models/df_source.py +++ b/polars_process/models/df_source.py @@ -16,10 +16,34 @@ class DfSource(models.Model): ) name = fields.Char(help="Supported files: .xlsx") sequence = fields.Integer() + state = fields.Selection(selection=[('draft', "Draft"), ("ready", "Ready"), ("done", "Done")], default="draft") rename = fields.Boolean(help="Display renamed Dataframe in wizard") template = fields.Binary(string="File", attachment=False) readonly = fields.Boolean(help="Imported records from module are readonly created") + def start(self): + self.ensure_one() + vals = { + "filename": self.name, + "df_source_id": self.id, + "model_map_id": self.model_map_id.id, + } + if ".xlsx" in self.name: + vals["file"] = base64.b64encode(self._get_file()) + transient = self.env["df.process.wiz"].create(vals) + action = self.env.ref("polars_process.df_process_wiz_action")._get_action_dict() + action["res_id"] = transient.id + self.state = "done" + return action + + def reset_process(self): + self.ensure_one() + self._reset_process() + + def _reset_process(self): + "Inherit me" + self.state = "draft" + def _populate(self): def create_attach(myfile, addon, idstring, relative_path): with open(myfile, "rb") as f: @@ -45,20 +69,6 @@ def create_attach(myfile, addon, idstring, relative_path): action = self.env.ref("polars_process.df_source_action")._get_action_dict() return action - def start(self): - self.ensure_one() - vals = { - "filename": self.name, - "df_source_id": self.id, - "model_map_id": self.model_map_id.id, - } - if ".xlsx" in self.name: - vals["file"] = base64.b64encode(self._get_file()) - transient = self.env["df.process.wiz"].create(vals) - action = self.env.ref("polars_process.df_process_wiz_action")._get_action_dict() - action["res_id"] = transient.id - return action - def _get_file(self, name=None): # TODO Clean if self.template: @@ -90,17 +100,6 @@ def _get_test_file_paths(self): } } - def ui_form(self): - self.ensure_one() - return { - "name": _("Dataframe source"), - "res_model": self._name, - "view_mode": "form", - "res_id": self.id, - "type": "ir.actions.act_window", - "target": "current", - } - def _file_hook(self, file): "Overide me in your own module" return {} diff --git a/polars_process/views/df_source.xml b/polars_process/views/df_source.xml index 884b87391..98a6e4269 100644 --- a/polars_process/views/df_source.xml +++ b/polars_process/views/df_source.xml @@ -29,7 +29,6 @@ -