[IMP] mrp: Restrict shown column on done MO in Overview

Product availabilities and their related replenishments are no longer
relevant when displaying a completed MO. Therefore, those columns are
disabled in the Overview when the the MO is either done or cancelled.

Part of task-3217757

Part-of: odoo/odoo#118023
This commit is contained in:
clesgow
2023-04-13 15:26:39 +02:00
parent ce840d14ba
commit 77531c5a67
3 changed files with 22 additions and 5 deletions
@@ -21,6 +21,7 @@ export class MoOverview extends Component {
this.state = useState({
data: {},
isDone: false,
showOptions: this.getDefaultConfig(),
});
@@ -40,6 +41,13 @@ export class MoOverview extends Component {
[this.activeId],
);
this.state.data = reportValues.data;
this.state.isDone = ['done', 'cancel'].some(doneState => reportValues.data?.summary?.state === doneState);
if (this.state.isDone) {
// Hide Availabilities / Receipts / Status columns when the MO is done.
this.state.showOptions.availabilities = false;
this.state.showOptions.receipts = false;
this.state.showOptions.replenishments = false;
}
this.state.showOptions.uom = reportValues.context.show_uom;
this.context = reportValues.context;
if (reportValues.data?.operations?.summary?.index) {
@@ -4,7 +4,7 @@
<div t-name="mrp.MoOverview" class="o_action" owl="1">
<Layout display="{ controlPanel: { 'top-right': false } }">
<t t-set-slot="control-panel-bottom-right">
<MoOverviewDisplayFilter showOptions="state.showOptions" changeDisplay.bind="onChangeDisplay"/>
<MoOverviewDisplayFilter showOptions="state.showOptions" limited="state.isDone" changeDisplay.bind="onChangeDisplay"/>
</t>
<t t-set-slot="control-panel-bottom-left">
@@ -3,10 +3,15 @@ import { BomOverviewDisplayFilter } from "../bom_overview_display_filter/mrp_bom
export class MoOverviewDisplayFilter extends BomOverviewDisplayFilter {
setup() {
if (!this.props.limited) {
this.displayOptions = {
replenishments: this.env._t("Replenishments"),
availabilities: this.env._t("Availabilities"),
receipts: this.env._t("Receipts"),
};
}
this.displayOptions = {
replenishments: this.env._t("Replenishments"),
availabilities: this.env._t("Availabilities"),
receipts: this.env._t("Receipts"),
...(this.displayOptions || {}),
moCosts: this.env._t("MO Costs"),
productCosts: this.env._t("Product Costs"),
};
@@ -23,7 +28,11 @@ MoOverviewDisplayFilter.props = {
receipts: Boolean,
moCosts: Boolean,
productCosts: Boolean,
}
},
},
changeDisplay: Function,
limited: { type: Boolean, optional: true },
};
MoOverviewDisplayFilter.defaultProps = {
limited: false,
};