[FIX] mrp: fold the MO after a replenishment
Steps to reproduce: - Create a two-layers Bill of Material (BoM and child BoM). - Create a Manufacturing Order with the top-level BoM and open the Overview. - Click 'Unfold', then hit the 'Replenish' button on the component. - Select 'Manufacture' as preferred route and confirm. Issue: The newly created Manufacturing Order is correctly added in the report but already unfolded, which can greatly change the visibility of the report if it has lots of components. This is due to an `undefined` value in the ComponentsBlock fold indexes as they were not updated after the new props update. closes odoo/odoo#137613 X-original-commit: 9dc2425dc69c1797cb85ecd794019ea44c541334 Signed-off-by: Tiffany Chang (tic) <tic@odoo.com> Signed-off-by: Quentin Wolfs (quwo) <quwo@odoo.com>
This commit is contained in:
+11
-6
@@ -1,6 +1,6 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { Component, useState } from "@odoo/owl";
|
||||
import { Component, onWillUpdateProps, useState } from "@odoo/owl";
|
||||
import { useBus } from "@web/core/utils/hooks";
|
||||
import { MoOverviewLine } from "../mo_overview_line/mrp_mo_overview_line";
|
||||
import { MoOverviewOperationsBlock } from "../mo_overview_operations_block/mrp_mo_overview_operations_block";
|
||||
@@ -10,7 +10,7 @@ export class MoOverviewComponentsBlock extends Component {
|
||||
|
||||
setup() {
|
||||
this.state = useState({
|
||||
fold: this.getIndexStates(),
|
||||
fold: this.getIndexStates(this.props),
|
||||
unfoldAll: this.props.unfoldAll || false,
|
||||
});
|
||||
|
||||
@@ -19,6 +19,11 @@ export class MoOverviewComponentsBlock extends Component {
|
||||
}
|
||||
|
||||
useBus(this.env.overviewBus, "unfold-all", () => this.unfoldAll());
|
||||
|
||||
onWillUpdateProps(newProps => {
|
||||
// Update the fold indexes so it matches the newly added lines.
|
||||
this.state.fold = { ...this.getIndexStates(newProps), ...this.state.fold };
|
||||
});
|
||||
}
|
||||
|
||||
//---- Handlers ----
|
||||
@@ -45,12 +50,12 @@ export class MoOverviewComponentsBlock extends Component {
|
||||
|
||||
//---- Helpers ----
|
||||
|
||||
getIndexStates() {
|
||||
getIndexStates(props) {
|
||||
const indexStates = {};
|
||||
(this.props?.components ?? []).forEach(component => {
|
||||
indexStates[component?.summary.index] = !this.props.unfoldAll;
|
||||
(props?.components ?? []).forEach(component => {
|
||||
indexStates[component?.summary.index] = !props.unfoldAll;
|
||||
(component?.replenishments ?? []).forEach(replenishment => {
|
||||
indexStates[replenishment?.summary.index] = !this.props.unfoldAll;
|
||||
indexStates[replenishment?.summary.index] = !props.unfoldAll;
|
||||
});
|
||||
});
|
||||
return indexStates;
|
||||
|
||||
Reference in New Issue
Block a user