Reports: printing a variable title or reference on the header/footer of an RML report

Bug #551485 reported by Numérigraphe
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Won't Fix
Wishlist
Unassigned
Nominated for Trunk by Numérigraphe

Bug Description

Our users asked us to have a reference printed on each page of each document, along with the page number and total number of pages in the document.
This is important when printers are shared because pages can get mixed up when people are not careful enough.

For the moment, the best way I found for this is to
- add a small feature to report_sxw.py to get/set a page title (see patch attached)
- change the company header/footer and add :
    <drawRightString x="19.7cm" y="28.3cm">[[pageTitle]] - <pageNumber/> / </drawRightString>
    <drawString x="19.8cm" y="28.3cm"><pageCount/></drawString>
- in the reports they use, add something like "[[ setPageTitle(o.name) ]]" in each main repeatIn(), usually next to the setLang().

I think this is a useful generic improvement, and I would love to see it integrated in the trunk.
Lionel.

Revision history for this message
Numérigraphe (numerigraphe) wrote :
Revision history for this message
Numérigraphe (numerigraphe) wrote :

Usability experts, could you please give your opinion about the usefulness of this feature?
Framework experts, could you please give your opinion about the best way to implement it?

Revision history for this message
Ferdinand (office-chricar) wrote :

you are addressing a long term usability issue
https://blueprints.launchpad.net/openobject-server/+spec/page-numbers

Revision history for this message
Dhara Shah (OpenERP) (dsh-openerp) wrote :

Hi ,

It is really nice idea to print page title on every page.It is working fine, if I print report of single object.
But there is limitation of the patch.
We can print report for more than one objects,same time.Report engine process data of report first and then the page template(header/footer..etc).Thus all page will have name of last object processed as page title in case of page_title = "o.name".
So,I suggest to add "page_title" in ir.act.report or to use some combination of company and report object.
Second possible thing is to hack methods of "doctemplate" of "reportlab" to pass right "o" information to canvas on every page,to get right o.name on page.

Thanks,
Dhara

Revision history for this message
Numérigraphe (numerigraphe) wrote :

dsh, thanks for pointing this. I thought my naive patch would work but sadly it doesn't.
I can try and follow your suggestion, but I need time - and any help is welcome of course.
Lionel

Revision history for this message
Dhara Shah (OpenERP) (dsh-openerp) wrote :

Hi,

OpenERP team will be always here for any kind of help.

Thanks,
Dhara

Revision history for this message
Numérigraphe (numerigraphe) wrote : Re: [Bug 551485] Re: Reports: printing a title or reference on each page

> Report engine process data of report first and then the page template(header/footer..etc).
If I understand this right, that means we can't use a python expression
at all: it has to be an RML tag like <pageNumber> and <pageCount>.

I tried to find such a tag in the RML DTD and found out tags <name> and
<getName> may do the trick.
Are they implemented in OpenERP?
Lionel

Revision history for this message
Dhara Shah (OpenERP) (dsh-openerp) wrote : Re: Reports: printing a title or reference on each page

HI,

> Report engine process data of report first and then the page template(header/footer..etc).

By this ,I mean story tag of rml is processed first,and we have number of story = number of object for which we want to print the report.
At last, pageTemplate will be processed (template tag of rml).At this time o.name will have name of object which processed last by story(suppose we are printing report for id 1,2,3 - so o.name will have name of order id =3 ) while processing template.

Your patch works perfectly fine when I print report for one object.

Below are the steps I follow after applying your patch of report_sxw
1) Added [[ setPageTitle(o.name) ]] in sale order report.
2) Added [[page_title]] in footer
3) From tree view selected more than one sale order and print order report
All page title will have same value ,no matter sale order are different.I was trying to point this scenario.

We can use [[]] in header/footer.

I hope I am clear.
Thanks ,
Dhara

Revision history for this message
Numérigraphe (numerigraphe) wrote : Re: [Bug 551485] Re: Reports: printing a title or reference on each page

Yes, Dhara, I think i got it. Yes we can use [[expresion]] in the
header, but it's useless to our purpose here isn't it?

About using tags, it turns out <name> is implemented but stangrely
enough I found no reference to <genName>.
I think it can be implemented rather simply (I'll wrote a patch, I'll
post it if it works).
Lionel

Revision history for this message
Numérigraphe (numerigraphe) wrote : Re: Reports: printing a title or reference on each page

Here's a trivial implementation of getName.
Now if only I can place a <name id="pageTitle" value="???"> with a relevant value in each <story>, then I think I can use <getName id="pageTitle"> in the corporate header.
Lionel

Revision history for this message
Numérigraphe (numerigraphe) wrote :

Well, it seems <name> and <getName> are used to write a value once in a stylesheet and reuse it several times. So, I think it's just like calling functions, it will get the last value no matter what.
What we want is propably more like what is done with pageNumber and pageCount.
I'm stuck here for the moment.
Lionel

Revision history for this message
Dhara Shah (OpenERP) (dsh-openerp) wrote :

Hi,

I worked around pageNumber and pageCount but didnt worked out well.I think afterPage of doctemplate and getCurrentPageContent of canvas can help.I'll try it soon and let you know for this.

Thanks,
Regards,
Dhara

Revision history for this message
Numérigraphe (numerigraphe) wrote :

dsh (Open ERP) , have been succesful to any amout adding a variable title or reference on each page of an RML report ?
Lionel

Changed in openobject-server:
status: New → Confirmed
summary: - Reports: printing a title or reference on each page
+ Reports: printing a variable title or reference on each page of an RML
+ report
summary: - Reports: printing a variable title or reference on each page of an RML
- report
+ Reports: printing a variable title or reference on the header/footer of
+ an RML report
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Hello Lionel,

Like for other features requests regarding our RML engine, I must remind you that due to the fact we had to implement a custom RML renderer (because reportlab's engine is not open source), you may of course find many features that are not supported by default.

We cannot consider these as bugs (documentation should be updated to explain this), but we would of course consider any merge proposal that implements in a clean manner any of these missing features, as was done for <pto> tag (bug 509266). This explains why I am closing this bug for the moment, but do not hesitate to submit a merge proposal.

Thank you for the detailed report, it can be very useful to start an implementation.

Changed in openobject-server:
importance: Undecided → Wishlist
status: Confirmed → Won't Fix
Revision history for this message
Numérigraphe (numerigraphe) wrote :

Please don't mark "won't fix" or community members cannot reopen the bug.

tags: added: feature long-term
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.