Odoo Help

Welcome!

This community 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.

0

How to build HTML report from scratch

By
Dr Obx
on 10/29/15, 6:58 AM 406 views

Guys, how to create HTML report from scratch.

Whatever I do it gives me only error messages.

Tried to use forms from other modules .... same result. Is there any manual how to achieve it ?

Are you asking how to create Qweb reports or how to parse HTML fields into a report or? Gives us some more details.

Yenthe
on 10/29/15, 7:01 AM
0
Dr Obx
On 10/29/15, 7:57 AM

I would like to change xml/xsl report a'm currently using to the HTML which is much simplier and easier to modify.

Currently using slightly changed report based on product_report.

It would be ok if I can add table header or for example summary at the end.

That's all i actually need. But completely don't understand xml/xsl ... so ....

how can I add table header into the existing form ?

<pre>

<lots>

<lot-line type="fields" name="id">

<title type="field" name="name"/>

<quantity type="field" name="qty_available"/>

<location type="field" name="location_id"/>

<available type="field" name="virtual_available"/>

</lot-line>

</lots>

</pre>

<pre>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:variable name="initial_bottom_pos">20.5</xsl:variable>

<xsl:variable name="initial_left_pos">2.5</xsl:variable>

<xsl:variable name="height_increment">0.5</xsl:variable>

<xsl:variable name="width_increment">1</xsl:variable>

<xsl:variable name="frame_height">8cm</xsl:variable>

<xsl:variable name="frame_width">18cm</xsl:variable>

<xsl:variable name="number_columns">1</xsl:variable>

<xsl:variable name="max_frames">20</xsl:variable>

<xsl:template match="/">

<xsl:apply-templates select="lots"/>

</xsl:template>

<xsl:template match="lots">

<document>

<template leftMargin="2.0cm" rightMargin="1.5cm" topMargin="2.0cm" bottomMargin="2.0cm" title="Address list" author="">

<pageTemplate id="all">

<pageGraphics/>

<xsl:apply-templates select="lot-line" mode="frames"/>

</pageTemplate>

</template>

<stylesheet>

<paraStyle name="nospace" fontName="Verdana" fontSize="8" spaceBefore="0" spaceAfter="0"/>

<blockTableStyle id="mytable1">

<blockBackground colorName="lightgrey" start="0,0" stop="0,0"/>

<blockBackground colorName="lightgrey" start="1,0" stop="-1,0"/>

<blockBackground colorName="lightgrey" start="2,0" stop="-1,0"/>

</blockTableStyle>

<blockTableStyle id="mytable">

<blockBackground colorName="white" start="0,0" stop="0,0"/>

<blockBackground colorName="lightgrey" start="1,0" stop="2,0"/>

<blockBackground colorName="lightblue" start="2,0" stop="3,0"/>

<blockBackground colorName="lightgreen" start="3,0" stop="4,0"/>

</blockTableStyle>

</stylesheet>

<story>

<xsl:apply-templates select="lot-line" mode="story"/>

</story>

</document>

</xsl:template>

<xsl:template match="lot-line" mode="frames">

<xsl:if test="position() &lt; $max_frames + 1">

<frame>

<xsl:attribute name="width">

<xsl:value-of select="$frame_width"/>

</xsl:attribute>

<xsl:attribute name="height">

<xsl:value-of select="$frame_height"/>

</xsl:attribute>

<xsl:attribute name="x1">

<xsl:value-of select="$initial_left_pos + ((position()-1) mod $number_columns) * $width_increment"/>

<xsl:text>cm</xsl:text>

</xsl:attribute>

<xsl:attribute name="y1">

<xsl:value-of select="$initial_bottom_pos - floor((position()-1) div $number_columns) * $height_increment"/>

<xsl:text>cm</xsl:text>

</xsl:attribute>

</frame>

</xsl:if>

</xsl:template>

<xsl:param name="pmaxChars" as="xs:integer" select="80"/>

<xsl:template match="lot-line" mode="story">

<blockTable style="mytable1" colWidths="12cm,1.5cm,1.5cm,1.5cm">

<tr>

<td>Title</td><td>Qty</td><td>Available</td><td>Location</td>

</tr>

</blockTable>

<nextFrame/>

</xsl:template>

<xsl:template match="lot-line" mode="story">

<blockTable style="mytable" colWidths="12cm,1.5cm,1.5cm,1.5cm">

<tr>

<td>

<para style="nospace"><xsl:value-of select="title" /></para>

</td>

<td>

<para style="nospace"><xsl:value-of select="location" /></para>

</td>

<td>

<para style="nospace"><xsl:value-of select="available" /></para>

</td>

<td>

<para style="nospace"><xsl:value-of select="quantity" /></para>

</td>

</tr>

<tr>

<td></td><td></td><td></td><td></td>

</tr>

</blockTable>

<nextFrame/>

</xsl:template>

</xsl:stylesheet>

</pre>

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/29/15, 6:58 AM
Seen: 406 times
Last updated: 10/29/15, 7:58 AM