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.

66 lines
2.3 KiB

  1. # -*- coding: utf-8 -*-
  2. # Author: Damien Crier, Andrea Stirpe, Kevin Graveman, Dennis Sluijk
  3. # Copyright 2016 Camptocamp SA, Onestein B.V.
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. from datetime import datetime
  6. from openerp.exceptions import Warning as UserError
  7. from openerp import api, fields, models
  8. class AccountAgedTrialBalance(models.TransientModel):
  9. _name = 'account.aged.trial.balance.wizard'
  10. _description = 'Aged partner balanced'
  11. company_id = fields.Many2one(
  12. 'res.company',
  13. string='Company',
  14. required=True,
  15. default=lambda s: s.env.user.company_id
  16. )
  17. target_move = fields.Selection([('posted', 'All Posted Entries'),
  18. ('all', 'All Entries')],
  19. string='Target Moves',
  20. required=True,
  21. default='posted')
  22. result_selection = fields.Selection(
  23. [('customer', 'Receivable Accounts'),
  24. ('supplier', 'Payable Accounts'),
  25. ('customer_supplier', 'Receivable and Payable Accounts')
  26. ],
  27. string="Partner's",
  28. default='customer')
  29. partner_ids = fields.Many2many(
  30. 'res.partner',
  31. string='Filter partners',
  32. )
  33. at_date = fields.Date(
  34. required=True,
  35. default=fields.Date.to_string(datetime.today()))
  36. until_date = fields.Date(
  37. "Clearance date", required=True,
  38. help="""The clearance date is essentially a tool used for debtors
  39. provisionning calculation.
  40. By default, this date is equal to the the end date (
  41. ie: 31/12/2011 if you select fy 2011).
  42. By amending the clearance date, you will be, for instance,
  43. able to answer the question : 'based on my last
  44. year end debtors open invoices, which invoices are still
  45. unpaid today (today is my clearance date)?'""")
  46. @api.onchange('at_date')
  47. def onchange_atdate(self):
  48. self.until_date = self.at_date
  49. @api.onchange('until_date')
  50. def onchange_untildate(self):
  51. # ---- until_date must be always >= of at_date
  52. if self.until_date:
  53. if self.until_date < self.at_date:
  54. raise UserError(
  55. 'Until Date must be equal or greater than At Date')
  56. @api.multi
  57. def check_report(self):
  58. return True