From 7c45aca3be04bf80882fd5ca1f2b464518125ab7 Mon Sep 17 00:00:00 2001 From: snd Date: Wed, 1 Nov 2023 11:44:38 +0100 Subject: [PATCH] [FIX] stock: remove old lines when generating serials When generating serial numbers or importing them, the old lines are still present and the quantity done gets raised by the quantity of the added lines. This forces the user to manually remove each old line one by one. This ensures that old lines are removed by the amount of newly created lines. closes odoo/odoo#140618 Signed-off-by: Arnold Moyaux (arm) --- .../static/src/widgets/generate_serial.js | 8 ++++++++ .../stock/static/src/widgets/lots_dialog.xml | 20 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/addons/stock/static/src/widgets/generate_serial.js b/addons/stock/static/src/widgets/generate_serial.js index 7ddbf48546a..bd33e074a92 100644 --- a/addons/stock/static/src/widgets/generate_serial.js +++ b/addons/stock/static/src/widgets/generate_serial.js @@ -20,6 +20,7 @@ export class GenerateDialog extends Component { this.nextSerial = useRef('nextSerial'); this.nextSerialCount = useRef('nextSerialCount'); + this.keepLines = useRef('keepLines'); this.lots = useRef('lots'); this.orm = useService("orm"); onMounted(() => { @@ -51,11 +52,18 @@ export class GenerateDialog extends Component { }) ); } + if (!this.keepLines.el.checked) { + await lines._applyCommands(lines._currentIds.map((currentId) => [ + x2ManyCommands.DELETE, + currentId, + ])); + } lines.records.push(...newlines); lines._commands.push(...newlines.map((record) => [ x2ManyCommands.CREATE, record._virtualId, ])); + lines._currentIds.push(...newlines.map((record) => record._virtualId)); await lines._onUpdate(); this.props.close(); } diff --git a/addons/stock/static/src/widgets/lots_dialog.xml b/addons/stock/static/src/widgets/lots_dialog.xml index c026a838719..c3df258dfb1 100644 --- a/addons/stock/static/src/widgets/lots_dialog.xml +++ b/addons/stock/static/src/widgets/lots_dialog.xml @@ -31,6 +31,16 @@ +
+
+ +
+
+
+ +
+
+
@@ -47,6 +57,16 @@ class="o_input" t-ref="lots" id="next_serial_0" type="text"/> +
+
+ +
+
+
+
+ +
+