Community mailing list archives

community@mail.odoo.com

Re: A Qweb question

by
semah
- 08/26/2016 07:46:10
Hello,

@zahid: Actually modifying the Odoo sources files directly is not a best practice.

@Dominique: 
The accepted answer shows you how to create a custom layout in which you will personalize the header and footer for your reports and add whatever you want: images, divs... and align them according to your design.

For your personal requirement, you can proceed like below:

​1. ​
create your personal custom layout:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="custom_external_layout">
<!-- Multicompany -->
<t t-if="o and 'company_id' in o">
<t t-set="company" t-value="o.company_id"></t>
</t>
<t t-if="not o or not 'company_id' in o">
<t t-set="company" t-value="res_company"></t>
</t>
<t t-call="custom_external_layout_header"/>
</template>
​​

<template id="custom_external_layout_header">
<div class="header">
<div class="row">
<div class="col-xs-4 pull-left">
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % company.logo" width="100%"/>
/>
 
​                                       <!-- Add your text here -->​
<div class="col-xs-4 pull-right"/>
       <h3>Column 2</h3>
       <p>Lorem ipsum dolor sit am
​​
et, consectetur adipisicing elit...</p>
       <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>
     </div>
</div>
</div>
</template>
</data>
</openerp>
2. Call your layout in your reports:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="
​your
_report
​_id​
">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="
​doc
">
<t t-call="
​module_name
.
​custom_​
external_layout">
<div class="page"​
​ ........................​
​ 
​​
​Semah.​



On Fri, Aug 26, 2016 at 1:52 PM, Dominique KON SUN TACK <dominique.k@elico-corp.com.sg> wrote:
Hi Zahid,

I realised that my question is probably not clear...

I need to do a header with two columns. (class="col-xs etc..")

On the left, the company logo, and on the right column, the company name, address etc...

The text in the right column is quite long (many lines). The logo (img) is aligned so that the bottom of the image, is at the same level of the bottom of the text
I am looking for a way to make the top border of the logo, be aligned with the top of the text ...


And, yes, I want this to be applied everywhere, so it is done by creating a custom layout, and using xpath to update the report.external_layout
It would be appreciated if anyone got any suggestion ....

Cheers,

Dominique KON-SUN-TACK 

On 26 August 2016 at 18:23, zahid jalal <j.zahid@gmail.com> wrote:
Hi  @Dominique
if you mean by align on top = make the image the highest possible, you can simply adjust top margin by either :
- you change paper format margins  in /report/data/report_paperformat.xml
   set the field  <field name="margin_top">25</field>  to your choice.

- In layout xml file   in  /report/views/layout.xml , look for the header section , then adjust css margin propreties as you like
  
  <template id="external_layout_header">
    <div class="header">
        <div class="row">
            <div class="col-xs-8 col-xs-offset-2">
                <img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % company.logo" style="max-height: 120px;"/>
            </div>
        </div>
    </div>
</template>        



But this wil change and affect all your other reports.  So as @Semah suggests , creating a custom layout is more suitable.

rgrds


Odoo Integrator,
Data integration
BI and IT consulting.

j.zahid@auriumtechnologies.com
tél  0661360233 - 0636898882
fax 0528215738

On Fri, Aug 26, 2016 at 9:57 AM, Dominique KON SUN TACK <dominique.k@elico-corp.com.sg> wrote:
Thanks for replying, although that was not the question.

The link is about the inheritance mechanism for qweb - 
The question is about how to make an image align on the top, when the image is in the header.


Dominique KON-SUN-TACK 

On 26 August 2016 at 16:38, Semah Raddaoui <semeh.raddaoui@gmail.com> wrote:

Hello,

You can create a custom layout for your reports and call it in your report.
Check this subject https://www.odoo.com/forum/help-1/question/can-t-manage-to-use-a-custom-layout-in-odoo-8-98425

R.


On Aug 25, 2016 12:17, "Dominique KON SUN TACK" <dominique.k@elico-corp.com.sg> wrote:
Hi Guys,

I have been trying unsuccessfully to change change the header of qweb reports...

What I need to do, is to align on the top, the logo of the company, which appear on the header.

vertical-align:top or text-top does not work

Would anybody got a clue ?

Dominique KON-SUN-TACK

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe




--
Semah Raddaoui 
Software Developer
TUN Planet
@  : Tunis, Tunisia