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.

52 lines
1.8 KiB

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