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.

56 lines
2.0 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. account_type = fields.Selection(
  25. [('receivable', 'Receivable'),
  26. ('payable', 'Payable')], string='Account type', default='receivable')
  27. @api.multi
  28. def button_export_pdf(self):
  29. self.ensure_one()
  30. return self._export()
  31. def _prepare_outstanding_statement(self):
  32. self.ensure_one()
  33. return {
  34. 'date_end': self.date_end,
  35. 'company_id': self.company_id.id,
  36. 'partner_ids': self._context['active_ids'],
  37. 'show_aging_buckets': self.show_aging_buckets,
  38. 'filter_non_due_partners': self.filter_partners_non_due,
  39. 'account_type': self.account_type,
  40. }
  41. def _export(self):
  42. """Export to PDF."""
  43. data = self._prepare_outstanding_statement()
  44. return self.env.ref(
  45. 'customer_outstanding_statement'
  46. '.action_print_customer_outstanding_statement').report_action(
  47. self, data=data)