This question has been flagged


I have a custom report (like Partner Ledger/General Ledger under Reporting menu) which inherits the template below: templates['line_template'] = 'account_reports.line_template'

My columns in the custom report:

def _get_columns_name(self, options):
        columns = [
            {},
            {'name': _('A_Total'), 'class': 'number'},
            {'name': _('B_Total'), 'class': 'number'},
            {'name': _('C_Total'), 'class': 'number'},
            {'name': _('D_Total'), 'class': 'number'},
            {'name': _('E_Total'), 'class': 'number'},
            {'name': _('F_Total'), 'class': 'number'},
            {'name': _('G_Total'), 'class': 'number'},
            {'name': _('H_Total'), 'class': 'number'},
            {'name': _('Rate')},
            {'name': _('I_Total'), 'class': 'number'}]

        return columns

Here's how I define my columns after getting the totals:

columns = [{'name': v} for v in [self.format_value(a_total), self.format_value(b_total), self.format_value(c_total), self.format_value(d_total), self.format_value(e_total), self.format_value(f_total), self.format_value(g_total), self.format_value(h_total), 'Sample' ,self.format_value(i_total)]]

partner_lines.append({
                    'id': 'partner_' + str(partner_id.id),
                    'name': partner_id.name,
                    'columns': columns,
                    'level': 2,
                    'unfoldable': True,
                     'unfolded': 'partner_' + str(partner_id.id) in options.get('unfolded_lines') or unfold_all,
                     'colspan': 4,
                        })

I expected the output would be the total computations but I get the error:


Traceback (most recent call last):
  File "/home/developer/EclipseWorkspace/odoo12/odoo/addons/base/models/qweb.py", line 344, in _compiled_fn
    return compiled(self, append, new, options, log)
  File "<template>", line 1, in template_account_reports_line_template_73
  File "<template>", line 2, in foreach_72
  File "<template>", line 52, in foreach_71
IndexError: list index out of range

Error to render compiling AST
IndexError: list index out of range
Template: account_reports.line_template
Path: /templates/t/t/tr/t[2]/td
Node: <td t-att-class="'o_account_report_line ' + (column.get('class', lines.get('columns_header')[-1][column_index+line.get('colspan', 1)].get('class', '')) + (line.get('unfoldable') and ' o_foldable_total' or '')) + ('' if hierarchies_enabled else ' o_account_report_line_indent')" t-att-style="column.get('style', lines.get('columns_header')[-1][column_index+line.get('colspan', 1)].get('style', ''))">
                    <span class="o_account_report_column_value" t-att-title="column.get('title')">
                        <t t-esc="column.get('name')"/>
                    </span>
                </td>
Avatar
Discard
Author Best Answer

I removed it but there's still an error.

Avatar
Discard
Best Answer

remove the empty dict

  • columns = [ {'name': _('A_Total'), 'class': 'number'},
                {'name': _('B_Total'), 'class': 'number'},
                {'name': _('C_Total'), 'class': 'number'},
                {'name': _('D_Total'), 'class': 'number'},
                {'name': _('E_Total'), 'class': 'number'},
                {'name': _('F_Total'), 'class': 'number'},
                {'name': _('G_Total'), 'class': 'number'},
                {'name': _('H_Total'), 'class': 'number'},
                {'name': _('Rate')},
                {'name': _('I_Total'), 'class': 'number'}]


Avatar
Discard