I have to call the python function in the xml script function. i tried rpc, but i can't use rpc in xml.
Is there any solution for this?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
I have to call the python function in the xml script function. i tried rpc, but i can't use rpc in xml.
Is there any solution for this?
If I understand you correctly, there are several ways you could achieve this.
You could use eval in an xml field, for example:
[field name="field_name" model="model.name" eval="obj().env.ref('name')._method_name()"/]
Alternatively you could use a function record in xml, see example below taken from the product module product_demo.xml (https://github.com/odoo/odoo/blob/15.0/addons/product/data/product_demo.xml#L204):
[function model="ir.model.data" name="_update_xmlids"]
[value model="base" eval="[{
'xml_id': 'product.product_product_1_variant_1',
'record': obj().env.ref('product.product_product_1_product_template')._create_product_variant(obj().env.ref('product.product_1_attribute_1_value_1') + obj().env.ref('product.product_1_attribute_2_value_1')),
'noupdate': True,
}, {
'xml_id': 'product.product_product_1_variant_2',
'record': obj().env.ref('product.product_product_1_product_template')._create_product_variant(obj().env.ref('product.product_1_attribute_1_value_1') + obj().env.ref('product.product_1_attribute_2_value_2')),
'noupdate': True,
},]"]
[/function]
My advice is to look at demo data from Odoo modules to find something that resembles your problem. and use this to achive what you want. I hope this answers your question.
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 4 24
|
1287 | ||
|
1
thg 4 24
|
1516 | ||
|
1
thg 12 22
|
44928 | ||
|
0
thg 4 21
|
3263 | ||
Field Automatically get Rounded
Đã xử lý
|
|
3
thg 11 19
|
3694 |