Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
915 Lượt xem

I tried to add custom css in following way to a button:

<button name="action_upload_file" type="object" string="Upload File" class="custom-attachment-button" />


But when I inspect the button I see that this class is not applied (it is in the manifest file of the module)

Even when I try to add just a simple icon it does not display it (also added to the manifest file, of specific module) 

<button name="action_upload_file" type="object" string="Upload File" icon="fa fa-paperclip" />


Where am I going wrong?

Ảnh đại diện
Huỷ bỏ

What's your source exactly?

Câu trả lời hay nhất

Hi,


1-  Create a new css file (your_module/static/src/css/your_style_sheet.css)


2-  Create a XML file (your_module/views/css_loader.xml)


3- In css_loader.xml

     

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- Load css File -->
<template id="my_custom_css_asset" name="my_custom_css assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/your_module/static/src/css/your_style_sheet.css"/>
</xpath>
</template>
</data>
</odoo>



Then you can use class ="your_custom_class" attribute in your button definition in xml file.


Hope it helps

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

May it be a problem with the css file permissions? Please, check in the inspector if your css file is being loaded.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 11 24
1212
1
thg 9 24
1572
0
thg 8 24
998
2
thg 6 24
1799
0
thg 3 25
842