Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
998 views
in Technique[技术] by (71.8m points)

xml - How to add css files to a custom module in Odoo?

How can I add css files to my custom module to change xml views? I found this post but the solution is not working.

I want modify all the elements from my module, such as forms, lists, inputs, etc.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  1. You must create the css file in this route: /module_name/static/src/css/module_name.css. Example of file:

     .openerp .classname{
         margin: 12px 0px 12px 0px;
     }
    
  2. Create the file /module_name/views/module_name.xml with this content:

     <?xml version="1.0"?>
     <openerp>
         <data>
             <template id="assets_backend" name="module_name assets" inherit_id="web.assets_backend">
                 <xpath expr="." position="inside">
                     <link rel="stylesheet" href="/module_name/static/src/css/module_name.css"/>
                 </xpath>
             </template>
         </data>     
     </openerp>
    
  3. Add the xml file to your __openerp.__py

     'data': [
         'views/module_name.xml',
     ],
    
  4. Add the class to the elements in the view

     <div class="classname">                            
         <field name="field_name" class="other_class"/>
     </div>
    

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...