You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.8 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2017 Eficent Business and IT Consulting Services S.L.
  3. # (http://www.eficent.com)
  4. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  5. from datetime import date
  6. from openerp import api, fields, models
  7. class CustomerOutstandingStatementWizard(models.TransientModel):
  8. """Customer Outstanding Statement wizard."""
  9. _name = 'customer.outstanding.statement.wizard'
  10. _description = 'Customer Outstanding Statement Wizard'
  11. company_id = fields.Many2one(
  12. comodel_name='res.company',
  13. default=lambda self: self.env.user.company_id,
  14. string='Company'
  15. )
  16. date_end = fields.Date(required=True,
  17. default=fields.Date.to_string(date.today()))
  18. show_aging_buckets = fields.Boolean(string='Include Aging Buckets',
  19. default=True)
  20. number_partner_ids = fields.Integer(
  21. default=lambda self: len(self._context['active_ids'])
  22. )
  23. filter_partners_non_due = fields.Boolean(
  24. string='Don\'t show partners with no due entries', default=True)
  25. @api.multi
  26. def button_export_pdf(self):
  27. self.ensure_one()
  28. return self._export()
  29. def _prepare_outstanding_statement(self):
  30. self.ensure_one()
  31. return {
  32. 'date_end': self.date_end,
  33. 'company_id': self.company_id.id,
  34. 'partner_ids': self._context['active_ids'],
  35. 'show_aging_buckets': self.show_aging_buckets,
  36. 'filter_non_due_partners': self.filter_partners_non_due,
  37. }
  38. def _export(self):
  39. """Export to PDF."""
  40. data = self._prepare_outstanding_statement()
  41. return self.env['report'].with_context(landscape=True).get_action(
  42. self, 'customer_outstanding_statement.statement', data=data)