Odoo Help

0

[SOLVE] How to add custom CSS to report template in Odoo v8.0?

By
NhuVanTran
on 2/11/15, 9:17 AM 1,933 views

Hi all,

 

I use Odoo v8.0. I want to add custom css to modify report template "sale.report_saleorder_document". So, I create a forder in addons forder with name "modify_company". In this, I create some file as below :

__init__.py (empty)

 

__openerp__

{
   'name' : "Modify report template",
   'description' : """Modify report template for Quotation/Sale report""",
   'author' : "Nhu Van Tran",
   'category' : "Tools",
   'depends' : ['sale'],
   'data' : ['modify_report_quotation.xml'],
   'css': ['static/css/content.css'],
   'demo' : [],
   'installable' : True,
}

modify_report_quotation.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <template id="my_report_quotation" inherit_id="sale.report_saleorder_document">
            <xpath expr="//div[@class='page']" position="replace">
        <link rel="stylesheet" href="/modify_company/static/css/content.css"/>
                <div class = "page">
             <div class="nhuvantran">
            <h2 >HERE IS DEMO DIV</h2>
             </div>

            </div><!-- end div page -->
            </xpath>
        </template>
    </data>
</openerp>

and in forder "modify_company", I create .css file "modify_company/static/css/content.css" as below

.nhuvantran{
    width:800px;
    height:500px;
    background-color:red;
}

Unluckly, It's not work. Please help me

Thank all you so much.

--------------------

SOLVE : Add .CSS directly into the .xml file

I think it is not possible for now, refer : https://github.com/odoo/odoo/issues/4359

Sajin Aziz
on 2/12/15, 12:53 AM
1
Sajin Aziz
On 2/12/15, 12:02 AM


1) inherit report_saleorder template then add your css before calling 'report.html_container' template

<template id="my_report_quotation_one" inherit_id="sale.report_saleorder">
    <xpath expr="//t[@t-call='report.html_container']" position="before">
          <style type="text/css">
              .nhuvantran{
                width:800px;
                height:500px;
                background-color:red;
                }
         </style>
    </xpath>
</template>

2) inherit report_saleorder_document

 <template id="my_report_quotation_two" inherit_id="sale.report_saleorder_document">
            <xpath expr="//div[@class='page']" position="replace">
                <div class = "page">
                 <div class="nhuvantran">
                  <h2 >HERE IS DEMO DIV</h2>
                </div>
             </div><!-- end div page -->
            </xpath>
  </template>

0
NhuVanTran
On 2/12/15, 12:38 AM

Hi Sajin Aziz

 

1/ Yes It worked, but that seem too bad because the content of .css file (mine) is so long

2/ I try modifing follow this link : https://www.odoo.com/forum/help-1/question/how-to-add-a-custom-css-5783

I want to create a .css, add into __openerp__.py, and use  <link rel="stylesheet" href=""> in .xml file, same as this link. But it 's not work. Can you help me?

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 2/11/15, 9:17 AM
Seen: 1933 times
Last updated: 3/16/15, 8:10 AM