コンテンツへスキップ
メニュー
この質問にフラグが付けられました
3 返信
10502 ビュー

There is a way to remove an attribute completely:

<xpath expr="//field[@name='order_line']/tree" position="attributes">
    <attribute name="editable"/>
</xpath>

And there is a way to completely replace an attribute with smth else:

<xpath expr="//label[@for='type']" position="attributes">
    <attribute name="groups">sale.group_delivery_invoice_address</attribute>
    <attribute name="invisible">False</attribute>
</xpath>

But is there a short way to append a value to an attribute?

So that after appending my_second_class to attribute class in <div class="my_first_class"> we receive <div class="my_first_class my_second_class">.

アバター
破棄
最善の回答

I think there is no way to do such thing for attributes.
Your only choice is to retype the previous value of the attribute!

アバター
破棄
著作者

Looks like nobody knows of a better solution, indeed. Let's mark yours as a good one then.

最善の回答

Yes, there is. If you have an element like


    <div id="my_div" class="my_first_class">


You can add something to the class-attribute using the following xpath:


    <xpath expr="//div[@id='my_div']" position="attributes">
    <attribute name="class" separator=" " add="my_second_class"/>
    </xpath>

The resulting div would look like:

    <div id="my_div" class="my_first_class my_second_class">

アバター
破棄

this is a new thingI guess, which odoo version?

I didn't check older versions than V13, but I can say that it works at least in V13, V14, V15, V16 and V17.

最善の回答

Look at this article  https://dev.to/opencode/don-t-break-your-and-others-odoo-xml-373i

アバター
破棄
関連投稿 返信 ビュー 活動
0
1月 22
1665
1
1月 19
8332
0
12月 24
938
0
12月 24
806
2
7月 24
2502