hi everyone how can i call a field values in file js odoo 15 please i need help
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
In Odoo 15, you can call a field value in a JavaScript file by using the instance.web.form.FieldChar or instance.web.form.FieldSelection class, depending on the type of field you want to call.
For example, if you want to call the value of a Char field named "field_name", you can use the following code:
var field_value = instance.web.form.FieldChar.extend({
init: function () {
this._super.apply(this, arguments);
this.field_value = this.get_value();
},
});
And if you want to call the value of a Selection field named "field_name", you can use the following code
var field_value = instance.web.form.FieldSelection.extend({ init: function () { this._super.apply(this, arguments); this.field_value = this.get_value(); }, });
You can then use the field_value variable to access the value of the field in your JavaScript code. It's also important to note that you will have to import the 'web.form_common' module first in your file.
odoo.define('module_name', function (require) {
"use strict";
var form_common = require('web.form_common');
// your code here
}
Hey there,
Could you elaborate your answer ?
=> you say "if your field is called field_name", but you actually don't use "field_name" anywhere.
=> you import "web.form_common", but you don't use your variable "form_common" anywhere !
=> you use "instance.web.[...]", but "instance" of what exactly ? Used like, this, the browser won't understand "instance" which is undefined.
Thank you
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
0
thg 1 23
|
1874 | ||
|
1
thg 6 25
|
3920 | ||
|
2
thg 5 24
|
1563 | ||
|
2
thg 2 22
|
5146 | ||
|
1
thg 9 19
|
10775 |