Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
20 ตอบกลับ
102729 มุมมอง

What is the best way to add custom css to openerp 7 without modifying any original file of openerp?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Yes it will not work in odoo 8, in odoo 8 you need to inherit the css template in your module and include your css file there e.g

<template id="my_assets_id" name="website assets for my module" inherit_id="website.theme">
        <xpath expr="." position="inside">
        <link rel="stylesheet" href="/website_my_module/static/src/css/my.css"/>
        </xpath>
    </template>

 

อวตาร
ละทิ้ง

I can't get any good result! My css isn't loaded yet!

It would be helpful if you could also tell us where to put the file, how to name it (if there is a naming convention) and how to configure __openerp__py accordingly, since everything I tried results in a 500 Odoo Server error.

Is there only one guy here who managed to use a custom CSS in odoo?

Which extension should the file have? .py? .xml?

Much better for Odoo v8 : https://www.odoo.com/forum/help-1/question/how-to-change-existing-css-creating-a-new-module-46099

คำตอบที่ดีที่สุด

Just create a module and add your css file in __openerp__.py as described in the documentation.

 # __openerp__.py
 {
     'name': "CSS Example",
     'description': "new css example",
     'category': 'Generic Modules/Others',
     'depends': ['web'],
     'data': [],
     'css': ['static/src/css/my_css.css'],
 }
อวตาร
ละทิ้ง
ผู้เขียน

Thank you! - Trunk docu is growning pretty fast - a good sign :)

คำตอบที่ดีที่สุด

if you need to write custom css in frontend odoo then you please try (1) , in case of backend try (2):

1:
    <template id="id" name="your name" inherit_id="website.assets_frontend">
      <xpath expr="." position="inside">
         <link href="/youraddon/static/src/css/yourcssfilename.css" rel="stylesheet" type="text/css"/>
    </xpath>
    </template>
2:
     <template id="id" name="your name" inherit_id="website.assets_backend">
         <xpath expr="." position="inside">
             <link href="/youraddon/static/src/css/yourcssfilename.css" rel="stylesheet" type="text/css"/>
         </xpath>
     </template>

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

If you are using Odoo v8, you must add this

        <template id="assets_backend" name="mymodule css assets" inherit_id="web.assets_backend">

            <xpath expr="." position="inside">

                <link rel="stylesheet" href="/my_module/static/src/css/my_module_css_file.css"/>
            </xpath>
        </template>

 

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Try as like this. It worked fine for me:

<template id="report.style" name="style">

<style type="text/css">

body {

color: #000 !important;

}

.background {

background-color: blue;

}

.p {

font-size: 22px;

color: green;

}

<!-- More of CUSTOM CSS here -->

</style>

</template>

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด



Watch on YouTube : https://www.youtube.com/ How to add css file in odoo 10

Or simply you can use style attribute 

<p style="color:green;margin:0;font-weight:bold/* write your css instead of my example*/">
     Write something
<p>
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Here is a Module that can help easily implement Custom CSS and Custom JS to Groups and Actions. 

https://www.odoo.com/apps/modules/11.0/custom_cssjs

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

thank you Laurent Destailleur for answer.

It work for me !

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

That doesn't work for me too on Odoo.

Neither with the css directly in my module nor inheriting template

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

https://github.com/odoo/odoo/issues/4359

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

The right answer is here: http://www.odoo.yenthevg.com/adding-static-resources-css-and-javascript-to-odoo/

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

I think that this does not work in odoo 8.0, isn't it?!

อวตาร
ละทิ้ง

still searching too!

คำตอบที่ดีที่สุด

Looking for solution> trying to make vartical labels in tree view.

In my case, css is loaded but I cant make it work ... :(

Whatever I change in css I can't see it in tree view.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
10
เม.ย. 23
34158
5
ธ.ค. 22
29368
2
มี.ค. 15
6013
0
มี.ค. 15
4773
1
มี.ค. 15
4946