from openerp import api, models class report_registro_caja(models.AbstractModel): _name = 'report.account_bank_statement_report.report_registro_caja' @api.multi def render_html(self, data=None): report_obj = self.env['report'] report = report_obj._get_report_from_name('account_bank_statement_report.report_registro_caja') docargs = { 'doc_ids': self._ids, 'doc_model': report.model, 'docs': self.env[report.model].browse(self._ids), 'get_sub_total_pos': self._get_sub_total_pos, 'get_sub_total_neg': self._get_sub_total_neg, 'get_total': self._get_total, } return report_obj.render('account_bank_statement_report.report_registro_caja', docargs) def _get_sub_total_pos(self,statement_line_ids): subtotal = 0.0 for line in statement_line_ids: if line.amount > 0: subtotal += line.amount return subtotal def _get_sub_total_neg(self,statement_line_ids): subtotal = 0.0 for line in statement_line_ids: if line.amount < 0: subtotal += line.amount return subtotal def _get_total(self, statement_line_ids): total = 0.0 for line in statement_line_ids: total += line.amount return total