From a892a7b20e557d02156caa5aa69c719b1f2619c2 Mon Sep 17 00:00:00 2001 From: gsinghpal Date: Mon, 27 Apr 2026 20:40:08 -0400 Subject: [PATCH] =?UTF-8?q?feat(sub12a):=20recipe=20form=20=E2=80=94=20but?= =?UTF-8?q?tons=20+=20is=5Ftemplate=20+=20Step=20Authoring=20tab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Process node form: - Header: keep 'Open Tree Editor' (primary, existing); add 'Open Simple Editor' (secondary). Both visible only for recipe-type nodes. - Recipe Settings group: add preferred_editor + is_template (the latter supervisor-only). - New 'Step Authoring' notebook page (visible for step/operation): Stations, default_kind, material_callout, predecessor/rack/transition flags, time/temp targets, voltage/viscosity, readonly source_template_id. Model: - New action_open_simple_editor (sibling of action_open_tree_editor). - New _resolve_preferred_editor() — per-recipe preferred_editor wins, 'auto' falls back to company.x_fc_default_recipe_editor, final fallback 'tree'. - New action_open_recipe_with_preferred_editor() — one-click route through the resolver. Reserved for menu-list / context-menu callers that want the simple-loving foreman path. Tree editor + every existing battle test path untouched. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../fusion_plating/models/fp_process_node.py | 35 +++++++++++++++++ .../views/fp_process_node_views.xml | 39 +++++++++++++++++++ 2 files changed, 74 insertions(+) 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'"/> +