[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) <arm@odoo.com>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -31,6 +31,16 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex d-sm-contents">
|
||||
<div class="o_cell flex-grow-0 flex-sm-grow-0 text-900 pe-3">
|
||||
<label class="o_form_label" for="keep_lines_0">Keep current lines</label>
|
||||
</div>
|
||||
<div class="o_cell flex-grow-1 flex-sm-grow-0">
|
||||
<div name="keep_lines" class="o_input">
|
||||
<input type="checkbox" t-ref="keepLines" id="keep_lines_0"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
<t t-if="props.type === 'import'" class="d-flex">
|
||||
@@ -47,6 +57,16 @@
|
||||
class="o_input" t-ref="lots" id="next_serial_0" type="text"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex d-sm-contents">
|
||||
<div class="o_cell flex-grow-0 flex-sm-grow-0 text-900 pe-3">
|
||||
<label class="o_form_label" for="keep_lines_0">Keep current lines</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="o_cell flex-grow-1 flex-sm-grow-0">
|
||||
<div name="keep_lines" class="o_input">
|
||||
<input type="checkbox" t-ref="keepLines" id="keep_lines_0"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user