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

Asked by David Soria on 2012-12-05

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:
OpenERP Server Edit question
Assignee:
No assignee Edit question
Solved by:
Serpent Consulting Services
Solved:
2012-12-10
Last query:
2012-12-10
Last reply:
2012-12-10

David,

Did you try with <seq> tag?

Thanks.

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

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.

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!

Thanks Serpent Consulting Services, that solved my question.

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

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.

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

Thanks, again.

hkim (hakim-rachedi) said : #9

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