registro_caja.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. from openerp import api, models
  2. class report_registro_caja(models.AbstractModel):
  3. _name = 'report.account_bank_statement_report.report_registro_caja'
  4. @api.multi
  5. def render_html(self, data=None):
  6. report_obj = self.env['report']
  7. report = report_obj._get_report_from_name('account_bank_statement_report.report_registro_caja')
  8. docargs = {
  9. 'doc_ids': self._ids,
  10. 'doc_model': report.model,
  11. 'docs': self.env[report.model].browse(self._ids),
  12. 'get_sub_total_pos': self._get_sub_total_pos,
  13. 'get_sub_total_neg': self._get_sub_total_neg,
  14. 'get_total': self._get_total,
  15. }
  16. return report_obj.render('account_bank_statement_report.report_registro_caja', docargs)
  17. def _get_sub_total_pos(self,statement_line_ids):
  18. subtotal = 0.0
  19. for line in statement_line_ids:
  20. if line.amount > 0:
  21. subtotal += line.amount
  22. return subtotal
  23. def _get_sub_total_neg(self,statement_line_ids):
  24. subtotal = 0.0
  25. for line in statement_line_ids:
  26. if line.amount < 0:
  27. subtotal += line.amount
  28. return subtotal
  29. def _get_total(self, statement_line_ids):
  30. total = 0.0
  31. for line in statement_line_ids:
  32. total += line.amount
  33. return total