fix(plating): tree-editor back button honours part-scoped context
When the Recipe Tree Editor is opened from the part-scoped Process Composer (Sub 3), the composer already passes part_id via the action context. The editor was ignoring it and routing onBackToList to the generic Recipes list, stranding the user away from the part they came from. Capture ctx.part_id at onMounted, expose a state.fromPart flag, and branch onBackToList: if part_id is set, open the fp.part.catalog form; otherwise keep the current Recipes-list behaviour. XML button label flips "Recipes" → "Part" accordingly so the user knows where the button will take them. fusion_plating → 19.0.6.1.0 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
{
|
||||
'name': 'Fusion Plating',
|
||||
'version': '19.0.6.0.0',
|
||||
'version': '19.0.6.1.0',
|
||||
'category': 'Manufacturing/Plating',
|
||||
'summary': 'Core plating / metal finishing ERP: facilities, processes, tanks, baths, jobs, operators.',
|
||||
'description': """
|
||||
|
||||
@@ -112,13 +112,23 @@ export class RecipeTreeEditor extends Component {
|
||||
addingTo: null, // parent node id when "add" dialog is open
|
||||
newNodeName: "",
|
||||
newNodeType: "operation",
|
||||
// True when this editor instance was opened from the part-
|
||||
// scoped Process Composer; drives the back-button label.
|
||||
fromPart: false,
|
||||
});
|
||||
|
||||
this._recipeId = null;
|
||||
// When the tree editor is opened from the part-scoped Process
|
||||
// Composer, the composer passes `part_id` in the action context.
|
||||
// Capture it so the back button returns to the part form instead
|
||||
// of the generic Recipes list.
|
||||
this._partId = null;
|
||||
|
||||
onMounted(async () => {
|
||||
const ctx = this.props.action?.context || {};
|
||||
this._recipeId = ctx.recipe_id || null;
|
||||
this._partId = ctx.part_id || null;
|
||||
this.state.fromPart = !!this._partId;
|
||||
if (this._recipeId) {
|
||||
await this.loadTree();
|
||||
}
|
||||
@@ -415,6 +425,19 @@ export class RecipeTreeEditor extends Component {
|
||||
// ---- Navigation ---------------------------------------------------------
|
||||
|
||||
onBackToList() {
|
||||
// If the editor was opened from the part-scoped Process Composer
|
||||
// (context carried part_id), return to that part's form instead
|
||||
// of the generic Recipes list.
|
||||
if (this._partId) {
|
||||
this.action.doAction({
|
||||
type: "ir.actions.act_window",
|
||||
res_model: "fp.part.catalog",
|
||||
res_id: this._partId,
|
||||
views: [[false, "form"]],
|
||||
target: "current",
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.action.doAction("fusion_plating.action_fp_process_recipe");
|
||||
}
|
||||
|
||||
|
||||
@@ -150,8 +150,10 @@
|
||||
<div class="o_fp_re_header">
|
||||
<button class="o_fp_re_back"
|
||||
t-on-click="onBackToList"
|
||||
title="Back to recipes">
|
||||
<i class="fa fa-arrow-left me-2"/>Recipes
|
||||
t-att-title="state.fromPart ? 'Back to part' : 'Back to recipes'">
|
||||
<i class="fa fa-arrow-left me-2"/>
|
||||
<t t-if="state.fromPart">Part</t>
|
||||
<t t-else="">Recipes</t>
|
||||
</button>
|
||||
<div class="o_fp_re_header_title" t-if="state.recipe">
|
||||
<h2 class="o_fp_re_h2 mb-0">
|
||||
|
||||
Reference in New Issue
Block a user