This question has been flagged
2 Replies
7031 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

Avatar
Discard

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

Best Answer


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>

Avatar
Discard
Author Best Answer

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?

Avatar
Discard