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.

63 lines
2.3 KiB

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