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

梦想与她 提交于 2019-11-29 02:27:46
  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;
}
  1. 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>
  1. Add the xml file to your __openerp.__py
'data': [
    'views/module_name.xml',
],
  1. Add the class to the elements in the view
<div class="classname">                            
    <field name="field_name" class="other_class"/>
</div>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!