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 do I limit an iteration in Mako?

By
Ademola Oke
on 3/30/13, 8:16 AM 1,311 views

Hi,

I have this bit of code:

%for analysis in inv.x_tcc_analysis_ids :   
            <td width="20%" style="text-align:left;border:1px solid #555;border-left:none;padding-top: 8px;">
              <table width="100%" cellspacing="0" cellpadding="10px">
                  <tbody>
                    <tr><td style="text-align:center;border:none;border-bottom:1px solid #555;;">Year ${ analysis.x_year or '' |entity }</td></tr>
                    <tr><td style="text-align:right;border:none;border-bottom:1px dashed #555;">N ${ formatLang(analysis.x_total_income) or ''|entity }</td></tr>
                    <tr><td style="text-align:right;border:none;border-bottom:1px dashed #555;">N ${ formatLang(analysis.x_tax_paid) or '' |entity }</td></tr>
                    <tr><td style="text-align:right;border:none;border-bottom:1px dashed #555;">${ analysis.x_gitr_number or '' |entity }</td></tr>
                    <tr><td style="text-align:right;border:none;border-bottom:1px dashed #555;">${ analysis.x_gitr_date or '' |entity }</td></tr>
                  </tbody>
              </table>
            </td>      
        %endfor

I'd like to be able to limit the number of iterations to 3. I've tried using the range function but no joy so far.

Any help will be hugely appreciated. Thanks

0

Francesco OpenCode

--Francesco OpenCode--
3608
| 5 7 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 3/30/13, 8:41 AM

use this:

<% i = 0 %>
%for analysis in inv.x_tcc_analysis_ids : 
    <% i+=1 %>
    %if i == 4:
        break
    %endif
    ...
    ...

Worked nicely. Thank you.

Bam Technologies Limited, Ademola Oke
on 3/30/13, 10:00 AM

sounds good..:)

Francesco OpenCode
on 3/30/13, 12:56 PM

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

0 follower(s)

Stats

Asked: 3/30/13, 8:16 AM
Seen: 1311 times
Last updated: 3/16/15, 8:10 AM