diff --git a/fusion_plating/fusion_plating/models/fp_process_node.py b/fusion_plating/fusion_plating/models/fp_process_node.py index 8f877e7e..a13e23a9 100644 --- a/fusion_plating/fusion_plating/models/fp_process_node.py +++ b/fusion_plating/fusion_plating/models/fp_process_node.py @@ -544,6 +544,41 @@ class FpProcessNode(models.Model): 'context': {'recipe_id': root.id}, } + def action_open_simple_editor(self): + """Open the OWL Simple Recipe Editor for this recipe (Sub 12a).""" + self.ensure_one() + root = self if self.node_type == 'recipe' else self.recipe_root_id + return { + 'type': 'ir.actions.client', + 'tag': 'fp_simple_recipe_editor', + 'name': f'Recipe — {root.name}', + 'context': {'recipe_id': root.id}, + } + + def _resolve_preferred_editor(self): + """Returns 'tree' or 'simple' for this recipe. + + Per-recipe preferred_editor wins. 'auto' falls back to the + company-level default. 'tree' is the final fallback. + """ + self.ensure_one() + if self.preferred_editor in ('tree', 'simple'): + return self.preferred_editor + return self.env.company.x_fc_default_recipe_editor or 'tree' + + def action_open_recipe_with_preferred_editor(self): + """Routes to whichever editor the recipe (or company) prefers. + + Used by menu actions / context-menu opens — gives the + simple-loving foreman a one-click path that respects their + preference without forcing a tree-loving engineer to pick + between two buttons every time. + """ + self.ensure_one() + if self._resolve_preferred_editor() == 'simple': + return self.action_open_simple_editor() + return self.action_open_tree_editor() + # ---- Copy (deep-duplicate) ----------------------------------------------- def copy(self, default=None): diff --git a/fusion_plating/fusion_plating/views/fp_process_node_views.xml b/fusion_plating/fusion_plating/views/fp_process_node_views.xml index 2a45f665..88c885ee 100644 --- a/fusion_plating/fusion_plating/views/fp_process_node_views.xml +++ b/fusion_plating/fusion_plating/views/fp_process_node_views.xml @@ -40,6 +40,10 @@ string="Open Tree Editor" class="btn-primary" icon="fa-sitemap" invisible="node_type != 'recipe'"/> + @@ -90,11 +94,14 @@ widget="float_time"/> + + @@ -135,6 +142,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +