How can I display the line number without add another reporting module?

Asked by David Soria

Hi.

My question is as follows: How display the line number, in sale order report for example, without create another module.

...
<section>
 [[repeatIn(o.order_line, 'line')]]
 <blockTable colWidths="1cm..." style="table">
  <tr>
   <td><para style="my_style">[[ CODE ]]</para></td>
...

I've "solved" this issue in two steps:

1. Adding a line in the file: report/report_sxw.py, after line 168:

self.localcontext = {
...
 'enumerate': enumerate,
...

2. Changing the previous piece of code:

...
<section>
 [[repeatIn(enumerate(o.order_line), 'line')]]
 <blockTable colWidths="1cm..." style="table">
  <tr>
   <td><para style="my_style">[[ line[0] + 1 ]]</para></td>
...

And now my true line is line[1] and I can use it later.

Friends, is this the right solution? I think that OpenERP should provide a manner of import the module __builtins__ inside a RML file, without create another modules, or, provide by default the built-in functions in the RML reports. Easyly I can create a module a send the line numbers by self.localcontext.update(), but it's annoying. In 6.1 and 7 is the same history (look at the source code).

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
Serpent Consulting Services
Solved:
Last query:
Last reply:
Revision history for this message
Best Serpent Consulting Services (serpent-consulting-services) said :
#1

David,

Did you try with <seq> tag?

Thanks.

Revision history for this message
David Soria (zorobabel-omicron) said :
#2

Oh, that almost solved this problem, but sorry, how can I display with left zeros, like str.zfill()? Thanks a lot

Revision history for this message
Serpent Consulting Services (serpent-consulting-services) said :
#3

David,

You cannot use zfill, seq is a tag, not a string.

I recommend to use some functionl that does it for you from the class file of report.

Thanks.

Revision history for this message
David Soria (zorobabel-omicron) said :
#4

Sure, I know that 'seq' is a tag and as says my question: without add another module, only in the RML file. But I will be content with that for now (although this is limited). Again, thanks a lot!

Revision history for this message
David Soria (zorobabel-omicron) said :
#5

Thanks Serpent Consulting Services, that solved my question.

Revision history for this message
David Soria (zorobabel-omicron) said :
#6

But you did not tell me that I must add a 'seqReset' tag after the table/section of the 'seq' tag, as follows:

<section>
    [[repeatIn(o.order_line, 'line')]]
    <blockTable...>
     <tr>
      <td><para style="tiny_center"><seq id="seq1"/></para></td>
      ...
     </tr>
    </blockTable>
<section>
<para><seqReset id="seq1"/></para>

HTH too

Revision history for this message
Serpent Consulting Services (serpent-consulting-services) said :
#7

David,

I thought you would search for an example and you will get a better understanding!

Had I sent you complete code,you would not have researched and learnt! :)

Thanks.

Revision history for this message
David Soria (zorobabel-omicron) said :
#8

Oh, haha, I know that, and I made it by inertia. Anyway, you gave me the clue! =]

Thanks, again.

Revision history for this message
hkim (hakim-rachedi) said :
#9

Thanks a million Serpent Consulting good solution but i suggest openerp report devlopper to add this feater.