fix error during import

This commit is contained in:
edo-neo 2024-10-29 10:00:56 +01:00
parent 3f8630bd7f
commit a73fa2c66e
2 changed files with 5 additions and 8 deletions

View File

@ -310,14 +310,9 @@ class Recipe_Selection(Widget):
# create recipe or update existing one in DB # create recipe or update existing one in DB
try: try:
recipe = Recipes.get_by_id(recipe_name) recipe = Recipes.get_by_id(recipe_name)
steps = recipe.get_steps_map()
recipe_is_new = False recipe_is_new = False
except Recipes.DoesNotExist: except Recipes.DoesNotExist:
recipe = Recipes(name=recipe_name, part_number="TEMPORARY") 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_is_new = True
recipe.client = row.get("cliente", defaults["cliente"]) 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, "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, "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, "print": len(row.get("stampa_etichetta_abilitata", defaults["stampa_etichetta_abilitata"])) and "print" not in self.unsupported_steps,
"steps": steps,
} }
if recipe_is_new: if recipe_is_new:
recipe.save(force_insert=True) recipe.save(force_insert=True)

View File

@ -134,10 +134,13 @@ class Recipe_Spec_And_Step_Editor(Editor):
def render(self, data, field_name=None, row_number=None, crud=None): 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) super().render(data, field_name=field_name, row_number=row_number, crud=crud)
self.crud = crud self.crud = crud
steps_data = data.get("steps", {})
for step_name, step_def in self.steps_map.items(): for step_name, step_def in self.steps_map.items():
if not step_def.get("hidden", False): if not step_def.get("hidden", False):
step_def["enable"].setChecked(data.get(step_name,{}) in (True,1,"x") ) step_enabled = data.get(step_name, {}) in (True, 1, "x")
self.steps_map[step_name]["spec"]=data["steps"].get(step_name,{}) step_def["enable"].setChecked(step_enabled)
step_def["spec"] = steps_data.get(step_name, {})
self.render_steps() self.render_steps()