Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
3062 Vues

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??

Avatar
Ignorer
Meilleure réponse

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.

Avatar
Ignorer
Publications associées Réponses Vues Activité
1
juin 24
997
1
août 20
8784
2
juin 20
3792
2
juil. 24
1001
2
juin 23
41955