RML Test of Page Number - odoo

Moin Moin,
I'm working on Openerp 7 and there pdf's get created with rml.
Problem is: I need Page Numbers, but just starting of the second Page.
I tried some rml if clause statements, but Page 1 gets printed all the time and the things that get printet are pretty wierd.
<header>
<pageTemplate id="second">
<frame id="second" x1="2.2cm" y1="2.5cm" width="16.9cm" height="22.3cm"/>
<pageGraphics>
<image file="images/isatech_water_header_medium.jpg" x="0.0cm" y="24.4cm" width="19.0cm" height="6.0cm"/>
<image file="images/isatech_water_footer.jpg" x="0.0cm" y="-0.5cm" width="16.9cm" height="2.6cm"/>
</pageGraphics>
</pageTemplate>
<pageTemplate id="first">
<frame id="first" x1="2.2cm" y1="2.5cm" width="16.9cm" height="22.3cm"/>
<pageGraphics>
<image file="images/isatech_water_header.jpg" x="0.0cm" y="24.4cm" width="19.0cm" height="6.0cm"/>
<image file="images/isatech_water_footer.jpg" x="0.0cm" y="-0.5cm" width="16.9cm" height="2.6cm"/>
[[ <pageNumber/> != '1' and <drawCentredString x="10cm" y="0.3cm"><pageNumber/></drawCentredString> ]]
</pageGraphics>
</pageTemplate>
</header>
What gets printed on the pdf is:
]] 1(2,3,...)
The pageTemplate second is for printing different header after page 1. I hope to get that straigt after the page numbers.
I really have no idea why the code behaves like he does. Different solutions are also welcome.
mfg Chris

I found a different way to do it.
It is not a good Idea to check the pageNumber in RML.
If I got it right, then the pageNumber is processed as one of the last steps. (Same goes for PageCount where it makes sense as you can't know the pageCount until the end of building your document)
Even if you call a python function with a pageNumber it gets handled as a String. I can just imagine it is the same reason.
I helped myself with a <setNextTemplate name="pageTemplate id"/>
Uncheck Add RML header in Settings > Actions > Reports > "Your Report"
Change your RML File and define the different pageTemplates
<template title="Sales Order" author="OpenERP S.A.(sales#openerp.com)" allowSplitting="20" showBoundary="0">
<pageTemplate id="first">
<frame id="first" x1="2.2cm" y1="2.5cm" width="16.9cm" height="22.3cm"/>
<pageGraphics>
<image file="images/header_page_1.jpg" x="0.8cm" y="24.7cm" width="16,9cm" height="4cm"/>
<image file="images/footer_page_1.jpg" x="0.4cm" y="-0.4cm" width="16.9cm" height="2.3cm"/>
</pageGraphics>
</pageTemplate>
<pageTemplate id="second">
<frame id="first" x1="2.2cm" y1="2.5cm" width="16.9cm" height="22.3cm"/>
<pageGraphics>
<image file="images/header_page_2.jpg" x="0.8cm" y="24.7cm" width="16,9cm" height="4cm"/>
<image file="images/header_page_2.jpg" x="0.4cm" y="-0.4cm" width="16.9cm" height="2.3cm"/>
</pageGraphics>
</pageTemplate>
Somewhere on page x add <setNextTemplate name="pageTemplate id"/>
or <setNextTemplate name="pageTemplate id"/>
<nextFrame/> to change the pageTemplate of page x+1
<setNextTemplate name="pageTemplate id"/> simply defines the pageTemplate of the next page and
<nextFrame/> additionaly end the current page.
Edit(Multi-Company-Header): I kind of forgot that we have multi Company Headers. Still I use this method. I just copy the .rml for every Company and hardcode the different company logos. Then in the reports setting page for every company(database) I specific the right .rml file.
I's very redundant, but I didn't found a better solution.
VG Chris

Related

Adding footer in an RML document

I have a document in which I already managed to insert a header. The body starts after the header and continues on to next pages where my header is there.
That said, I am not able to properly add a footer. From checking the RML reference there seems to be no tag I can add that will act as a footer so I have to come up with a solution. So far nothing I have tried works. Here is my template section:
<template pageSize="(595.0,842.0)" title="Test" author="geof" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="24.0" y1="-80.0" width="530" height="796"/>
<header>
<pageGraphics>
<image x="5.3cm" y="8.9cm" height="280.0">[[ get_background() ]]</image>
<image x="6.3cm" y="25.7cm" height="80.0" >[[ company.logo or removeParentNode('image') ]]</image>
<!-- <drawString x="1.0cm" y="28.1cm">[[ company.name ]]</drawString>
<drawRightString x="20cm" y="28.1cm"> Reference Guide </drawRightString>
<lines>1cm 28cm 20cm 28cm</lines> -->
<drawString x="7.0cm" y="1.1cm" height="50.0">[[ get_footer() ]]</drawString>
</pageGraphics>
</header>
</pageTemplate>
</template>
"-Go to "Settings" -Choose "Company"; select your company
You can customize the footer on the bottem field on the initial screen
-Choose the "Footer/header-text" tab
You can edit the header (and footer) text here; you can view your changes by using the preview button on the top right hand corner of this screen."
UPDATE:
----------
how to add a user defined header in a rml report in openerp?

How to display RML custom header and footer in all page

I add my own custom header and footer in RML report, the problem is when I select all the record and print, first page prints correctly, the problem occurs in second page, header and report data overlapped, so how to set header in all the pages without overlapping
<template title="High_Value_Item" author="OpenERP S.A.(sales#openerp.com)" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="30.0" y1="27.0" width="508" height="815"/>
<pageGraphics>
<image x="1.3cm" y="26.0cm" height="90.0">[[company.logo or removeParentNode('image')]]</image>
<place x="16.6cm" y="25.3cm" height="1.8cm" width="15.0cm">
<para fontSize="7.0" fontName="Helvetica" >[[ display_address(company.partner_id) or '' ]]</para>
</place>
<lines>1.3cm 24.9cm 19.9cm 24.9cm</lines>
</pageGraphics>
</pageTemplate>
The above code from my RML report
try this,
<template title="High_Value_Item" author="OpenERP S.A.(sales#openerp.com)" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="8.7cm" y1="5.0cm" height="24.0cm" width="21.5cm"/>
<pageGraphics>
<image x="1.3cm" y="26.0cm" height="90.0">[[company.logo or removeParentNode('image')]]</image>
<place x="16.6cm" y="25.3cm" height="1.8cm" width="15.0cm">
<para fontSize="7.0" fontName="Helvetica" >[[ display_address(company.partner_id) or '' ]]</para>
</place>
<lines>1.3cm 24.9cm 19.9cm 24.9cm</lines>
</pageGraphics>
</pageTemplate>
I coded in air so if any content comes in undesired place than you may change the x and y coordinate.
Hope this will help you.

Appcelerator Titanium Alloy: How to set the TableViewStyle to GROUPED in xml

I've tried various things along the lines of (also tried just setting style to GROUPED):
<Alloy>
<Window title="Add Remember">
<TableView id="table" style="Ti.UI.iPhone.TableViewStyle.GROUPED">
<!-->
<TableViewSection headerTitle="Title">
<TableViewRow><TextField hintText="Title" id="title"></TextField></TableViewRow>
</TableViewSection>
<TableViewSection headerTitle="Location">
<TableViewRow><TextField hintText="Location" id="location"></TextField></TableViewRow>
</TableViewSection>
<TableViewSection headerTitle="Notes">
<TableViewRow><TextArea hintText="Notes"></TextArea></TableViewRow>
</TableViewSection>
</!-->
</TableView>
</Window>
</Alloy>
But no shebang.
I've also noticed that setting it programmatically in the controller file works, but only if I haven't added any sections or rows to the TableView yet (this is why the sections and rows are commented out above).
How do I set this property in the xml.
I do it this way:
In form.xml:
<TableView class="form">
...
</TableView>
In app.tss:
".form": {
style: Ti.UI.iPhone.TableViewStyle.GROUPED
}
Ok, the solution is to set style="1" in the xml for the TableView; this works with the sections and rows uncommented as well. I figured this out by logging Ti.UI.iPhone.TableViewStyle.GROUPED to the console; evidently the macro doesn't work in the xml.

Exporting More Info Row to PDF using LogiXML not showing up

I am having some trouble trying to export a report to PDF format. I have an action report element to show the more info row, meaning, it is hidden by default (Show Mode : None) until the user clicks a particular element. However, this is creating problems when trying to export since, when I check the option in the Target.PDF element as to "Keep Show Elements", I'm coming up with a blank page. Any help would be appreciated. Thank you.
The best way to troubleshoot these types of export problems is to start simplifying the definition file so that you can easily isolate the issue. For your reports, I might start by remarking the MoreInfoRow so that it's effectively not impacting the export.
-Does the report export to PDF once the MoreInfoRow is gone? If yes, the we can assume the problem has to do with the MoreInfoRow. If no, then there is a different issue. If you've removed the MoreInfoRow and it still doesn't export properly, I might guess that the problem is either : 1) You're passing incorrect showmodes with the export or 2) the report requires parameters to be passed with the Action PDF as well that aren't getting set properly.
For additional details on ShowModes, I'd visit:
http://devnet.logixml.com/rdPage.aspx?rdReport=Article&dnDocID=1043
If the MoreInfoRow is the problem, you might try simplifying the report, in general. Here's a quick example that you can try:
<Report ID="Default" SavedBy="test">
<StyleSheet Theme="SimpleBlue" />
<Body>
<Label Caption="Export PDF" Class="ThemeLinkButton">
<Action Type="PDF">
<Target Type="PDF" KeepShowElements="True" Report="CurrentReport" />
</Action>
</Label>
<LineBreak LineCount="3" />
<DataTable ID="dtExport" Width="450">
<DataLayer Type="Static" ID="myData1">
<StaticDataRow id="001" name="Sample Row 1" />
<StaticDataRow id="002" name="Sample Row 2" />
<StaticDataRow id="003" name="Sample Row 3" />
</DataLayer>
<DataTableColumn ID="colid" Header="id">
<Label ID="lblid" Caption="#Data.id~">
<Action Type="ShowElement" ElementID="mirTest" ID="actShowMir" />
</Label>
</DataTableColumn>
<DataTableColumn ID="colname" Header="name">
<Label ID="lblname" Caption="#Data.name~" />
</DataTableColumn>
<MoreInfoRow ShowModes="None" ID="mirTest">
<Label Caption="This is the More Info Row" />
</MoreInfoRow>
</DataTable>
</Body>
</Report>

Flex - returning a window to its original state

I have been tearing my hair out now for a week or so, it's time I sought some help...
I am coding a small app to show me the next train leaving the station. Normally only the hour of the next train is shown, but if you click on the prefs button, the application window enlarges and a datagrid is shown with the trains and hours. Clicking on the close button in that state returns you to the 'start' state, or should do so.
The problem is that the datagrid disappears, but the application window stays the same size. It should return to it's original size.
I've been trying lots of different approaches, replacing VBoxes by Canvas or Panels but none worked. In design mode everything work as expected when switching between states.
This is the first time I've been using states, so I might be missing something fundamental.
Here's a code sample - I'm using 2 view states, Start and Prefs.
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="init();"
cornerRadius="12"
currentState='Start' width="350" height="250">
<mx:states>
<mx:State name="Start">
<mx:AddChild>
<mx:VBox id="box_parent" width="100%" height="100%" verticalGap="2">
<mx:Label text="Next Train Leaves At" textAlign="center" width="100%"/>
<mx:Label text="--:--" width="100%" height="100" fontSize="64" id="timetext" textAlign="center" fontWeight="bold"/>
<mx:HBox width="100%" height="25" id="hbox1">
<mx:Button label="Prefs"
id="buttonPrefs"
click="currentState='Prefs'"/>
<mx:Spacer width="70%" id="spacer1"/>
<mx:Button
label="Next"
click="findNextTrain()" id="buttonNext"/>
</mx:HBox>
</mx:VBox>
</mx:AddChild>
<mx:SetProperty name="layout" value="vertical"/>
<mx:SetProperty name="width" value="350"/>
<mx:SetProperty name="height" value="220"/>
</mx:State>
<mx:State name="Prefs" basedOn="Start">
<mx:AddChild relativeTo="{box_parent}" position="lastChild">
<mx:DataGrid height="80%" width="100%" dataProvider="{trains}" id="traindata" editable="false">
<mx:columns>
<mx:DataGridColumn headerText="Station" dataField="stationid"/>
<mx:DataGridColumn headerText="Leave" dataField="leave"/>
</mx:columns>
</mx:DataGrid>
</mx:AddChild>
<mx:RemoveChild target="{buttonPrefs}"/>
<mx:SetProperty target="{box_parent}" name="height" value="500"/>
<mx:AddChild relativeTo="{spacer1}" position="before">
<mx:Button label="Close" click="currentState='Start'"/>
</mx:AddChild>
<mx:SetProperty name="height" value="570"/>
</mx:State>
</mx:states>
<mx:transitions>
<mx:Transition fromState="*" toState="*">
<mx:Resize target="{this}" duration="500"/>
</mx:Transition>
</mx:transitions>
</mx:WindowedApplication>
I have yet to find a way to reset a state in Flex to the values provided in the MXML. You have to reset what values you need your self programmatically. In the case of the provided sample code, you can reset the height of the application when changing back to the start state by adding the following into the WindowedApplication tag
currentStateChange="if(currentState == 'Start') this.height = 220"
This tells the WindowedApplication tag to handle the event dispatched after changing the current state to check if the new current state is Start, and to set the window height if it is.