Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
3041 Widoki

Hi,

in the Barcode Operation screen, I am trying to split the barcode into (barcode, date, and lot) and show every part of these 3 into corresponding fields in XML 

I found a way to split the barcode into 3 variables after the barcode  scanned, 

the question is: How to fill the corresponding fields (barcode, lot name, expiration date) in XML?

in general, what is the connection between js and XML files??

Awatar
Odrzuć
Najlepsza odpowiedź

In Odoo, the relationship between JavaScript and XML files is that XML files are used to define the structure and layout of views, while JavaScript is used to add logic and interactivity to the views. In your case, you can use JavaScript to split the barcode into its different parts, and then use the $el property of the view to access the corresponding XML elements and update their values.

For example, to set the value of a field with the id attribute set to barcode_field, you can use the following code:

var barcodeField = this.$el.find('#barcode_field');
barcodeField.val(barcodeValue);

This code will find the element with the id attribute set to barcode_field in the view's XML, and set its value to barcodeValue. You can use a similar approach to set the values of the other fields.

Keep in mind that you need to make sure that the JavaScript code is executed after the view has been rendered, so you may need to use a deferred object or the on_attach_callback function to make sure that the fields are available when the code is executed.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
cze 24
987
1
sie 20
8751
2
cze 20
3759
2
lip 24
983
2
cze 23
41921