[FIX] mrp: allow overviewing of bom with decimal quantity
Steps to reproduce the bug:
- Create a storable product with BoM:
- add any product as component
- save
- Click on the BoM overview widget
- Change the quantity of a BOM with a number that has a decimal
value.
Problem:
The quantity is converted to an integer because this input does not
accept a decimal value.
opw-3288403
closes odoo/odoo#123024
X-original-commit: de5087df501bffdaa14ca6a8b7a19da802f4e016
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
@@ -15,7 +15,9 @@
|
||||
changeWarehouse.bind="onChangeWarehouse"
|
||||
changeVariant.bind="onChangeVariant"
|
||||
changeBomQuantity.bind="onChangeBomQuantity"
|
||||
changeDisplay.bind="onChangeDisplay"/>
|
||||
changeDisplay.bind="onChangeDisplay"
|
||||
precision="state.precision"
|
||||
/>
|
||||
|
||||
<BomOverviewTable
|
||||
uomName="uomName"
|
||||
|
||||
+7
-1
@@ -5,6 +5,7 @@ import { BomOverviewDisplayFilter } from "../bom_overview_display_filter/mrp_bom
|
||||
import { Dropdown } from "@web/core/dropdown/dropdown";
|
||||
import { DropdownItem } from "@web/core/dropdown/dropdown_item";
|
||||
import { Many2XAutocomplete } from "@web/views/fields/relational_utils";
|
||||
import { formatFloat } from "@web/views/fields/formatters";
|
||||
|
||||
const { Component } = owl;
|
||||
|
||||
@@ -16,7 +17,7 @@ export class BomOverviewControlPanel extends Component {
|
||||
//---- Handlers ----
|
||||
|
||||
updateQuantity(ev) {
|
||||
const newVal = isNaN(ev.target.value) ? 1 : parseInt(ev.target.value);
|
||||
const newVal = isNaN(ev.target.value) ? 1 : parseFloat(formatFloat(parseFloat(ev.target.value), { digits: [false, this.precision] }));
|
||||
this.props.changeBomQuantity(newVal);
|
||||
}
|
||||
|
||||
@@ -35,6 +36,10 @@ export class BomOverviewControlPanel extends Component {
|
||||
const keys = Object.keys(this.props.variants);
|
||||
return [['id', 'in', keys]];
|
||||
}
|
||||
|
||||
get precision() {
|
||||
return this.props.precision;
|
||||
}
|
||||
}
|
||||
|
||||
BomOverviewControlPanel.template = "mrp.BomOverviewControlPanel";
|
||||
@@ -60,6 +65,7 @@ BomOverviewControlPanel.props = {
|
||||
changeVariant: Function,
|
||||
changeBomQuantity: Function,
|
||||
changeDisplay: Function,
|
||||
precision: Number,
|
||||
};
|
||||
BomOverviewControlPanel.defaultProps = {
|
||||
variants: {},
|
||||
|
||||
Reference in New Issue
Block a user