This question has been flagged

Hello

I am trying to create partner ledger report for individual partner. I added a report named "Partner Statements" in the print button of partner form.But when I click the print button its showing "RuntimeError: maximum recursion depth exceeded.

The below given is the code: account_partner_statement.py

class ReportPartnerStatement(models.AbstractModel):
     _name = 'report.cus_account.report_partner_statement'

    def _get_account_move_lines(self, partner_ids):
        res = dict(map(lambda x:(x,[]), partner_ids))
        self.env.cr.execute("SELECT m.name AS move_id, l.date, l.name, l.ref, l.date_maturity, l.partner_id, l.blocked, l.amount_currency, l.currency_id "
        "FROM account_move_line l "
        "JOIN account_account_type at ON (l.user_type_id = at.id) "
        "JOIN account_move m ON (l.move_id = m.id) "
        "WHERE l.partner_id IN %s AND at.type IN ('receivable', 'payable') GROUP BY l.date, l.name, l.ref, l.date_maturity, l.partner_id, at.type, l.blocked, l.amount_currency, l.currency_id, l.move_id, m.name", (((fields.date.today() ) + (tuple(partner_ids)))))
        for row in self.env.cr.dictfetchall():
            res[row.pop('partner_id')].append(row)
        return res

    @api.model
    def render_html(self, docids, data=None):
totals = {}
        lines = self._get_account_move_lines(docids)
        lines_to_display = {}
        company_currency = self.env.user.company_id.currency_id
        for partner_id in docids:
             lines_to_display[partner_id] = {}
             totals[partner_id] = {}
             for line_tmp in lines[partner_id]:
                 line = line_tmp.copy()
                 currency = line['currency_id'] and self.env['res.currency'].browse(line['currency_id']) or company_currency
         lines_to_display[partner_id][currency].append(line)
        docargs = {
            'doc_ids': docids,
            'doc_model': 'res.partner',
            'docs': self.env['res.partner'].browse(docids),
            'time': time,
            'Lines': lines_to_display,
            'Date': fields.date.today(),
            }
        return self.env['report'].render('cus_account.report_partner_statement', docargs)


Error:

RuntimeError: maximum recursion depth exceeded

load could not load templateTemplate:

cus_account.report_partner_statement

Avatar
Discard