From a73fa2c66ed5a3a8eccd5fa281ac1ef22df5ccd8 Mon Sep 17 00:00:00 2001 From: edo-neo Date: Tue, 29 Oct 2024 10:00:56 +0100 Subject: [PATCH] fix error during import --- src/ui/recipe_selection/recipe_selection.py | 6 ------ .../recipe_spec_and_step_editor.py | 7 +++++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/ui/recipe_selection/recipe_selection.py b/src/ui/recipe_selection/recipe_selection.py index 5c671f4..f30d06b 100755 --- a/src/ui/recipe_selection/recipe_selection.py +++ b/src/ui/recipe_selection/recipe_selection.py @@ -310,14 +310,9 @@ class Recipe_Selection(Widget): # create recipe or update existing one in DB try: recipe = Recipes.get_by_id(recipe_name) - steps = recipe.get_steps_map() recipe_is_new = False except Recipes.DoesNotExist: recipe = Recipes(name=recipe_name, part_number="TEMPORARY") - steps = {} - for step_name, step_spec in steps_specs.items(): - if step_name not in self.unsupported_steps: - steps[step_name] = step_spec recipe_is_new = True recipe.client = row.get("cliente", defaults["cliente"]) @@ -336,7 +331,6 @@ class Recipe_Selection(Widget): "leak_2": len(row.get("prova_tenuta_abilitata_2", defaults["prova_tenuta_abilitata_2"])) and "leak_2" not in self.unsupported_steps, "vision": len(row.get("test_visione_abilitato", defaults["test_visione_abilitato"])) and "vision" not in self.unsupported_steps, "print": len(row.get("stampa_etichetta_abilitata", defaults["stampa_etichetta_abilitata"])) and "print" not in self.unsupported_steps, - "steps": steps, } if recipe_is_new: recipe.save(force_insert=True) diff --git a/src/ui/recipe_spec_and_step_editor/recipe_spec_and_step_editor.py b/src/ui/recipe_spec_and_step_editor/recipe_spec_and_step_editor.py index e176ef2..b20c941 100644 --- a/src/ui/recipe_spec_and_step_editor/recipe_spec_and_step_editor.py +++ b/src/ui/recipe_spec_and_step_editor/recipe_spec_and_step_editor.py @@ -134,10 +134,13 @@ class Recipe_Spec_And_Step_Editor(Editor): def render(self, data, field_name=None, row_number=None, crud=None): super().render(data, field_name=field_name, row_number=row_number, crud=crud) self.crud = crud + steps_data = data.get("steps", {}) + for step_name, step_def in self.steps_map.items(): if not step_def.get("hidden", False): - step_def["enable"].setChecked(data.get(step_name,{}) in (True,1,"x") ) - self.steps_map[step_name]["spec"]=data["steps"].get(step_name,{}) + step_enabled = data.get(step_name, {}) in (True, 1, "x") + step_def["enable"].setChecked(step_enabled) + step_def["spec"] = steps_data.get(step_name, {}) self.render_steps()