Skip to Content
Menú
This question has been flagged

​In Odoo 16 Default functionality is to show the line of stock.quant on scanning the product barcode. this line contain four buttons edit with pencil logo, calcel button with 'X' logo, quantity increment and decrement button


Now I am developing the functionality that will provide opening the line edit view on Product Barcode scan.

while doing so I am facing the issue that all the default buttons like validate and discard are not functional and I am being stuck on that line edit view.

I did debug the code and get to know that, before appearing the line the code comes to the method in Enterprise/stock_barcode/static/src/components/main -> _scrollToSelectedLine()

which is as below

_scrollToSelectedLine() {
if (!this.displayBarcodeLines) {
this._scrollBehavior = 'auto';
return;
}
let selectedLine = document.querySelector('.o_sublines .o_barcode_line.o_highlight');
const isSubline = Boolean(selectedLine);
if (!selectedLine) {
selectedLine = document.querySelector('.o_barcode_line.o_highlight');
}
if (!selectedLine) {
const matchingLine = this.env.model.findLineForCurrentLocation();
if (matchingLine) {
selectedLine = document.querySelector(`.o_barcode_line[data-virtual-id="${matchingLine.virtual_id}"]`);
}
}
if (selectedLine) {
// If a line is selected, checks if this line is on the top of the
// page, and if it's not, scrolls until the line is on top.
const header = document.querySelector('.o_barcode_header');
const lineRect = selectedLine.getBoundingClientRect();
const navbar = document.querySelector('.o_main_navbar');
const page = document.querySelector('.o_barcode_lines');
// Computes the real header's height (the navbar is present if the page was refreshed).
const headerHeight = navbar ? navbar.offsetHeight + header.offsetHeight : header.offsetHeight;
if (lineRect.top (headerHeight + lineRect.height)) {
let top = lineRect.top - headerHeight + page.scrollTop;
if (isSubline) {
const parentLine = selectedLine.closest('.o_barcode_lines > .o_barcode_line');
const parentSummary = parentLine.querySelector('.o_barcode_line_summary');
top -= parentSummary.getBoundingClientRect().height;
}
page.scroll({ left: 0, top, behavior: this._scrollBehavior });
this._scrollBehavior = 'smooth';
}
var lines = this.lines;
var last_line = lines[lines.length - 1];
bus.trigger('edit-line', { line: last_line });
}
}

in the above method, I have written my custom code in bold font.
If anyone knows how to correct it or if anyone have a better solution then please let me know 





Avatar
Descartar
Related Posts Respostes Vistes Activitat
0
de juny 24
1845
2
de des. 23
6102
0
d’ag. 24
603
2
d’abr. 24
877
1
de juny 25
555