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.

40 lines
1.4 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2016 Lorenzo Battistini - Agile Business Group
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from openerp import models, fields, api
  5. from openerp.tools.translate import _
  6. class OpenTaxBalances(models.TransientModel):
  7. _name = 'wizard.open.tax.balances'
  8. company_id = fields.Many2one(
  9. 'res.company', 'Company', required=True,
  10. default=lambda self: self.env.user.company_id)
  11. from_date = fields.Date('From date', required=True)
  12. to_date = fields.Date('To date', required=True)
  13. date_range_id = fields.Many2one('date.range', 'Date range')
  14. target_move = fields.Selection([
  15. ('posted', 'All Posted Entries'),
  16. ('all', 'All Entries'),
  17. ], 'Target Moves', required=True, default='posted')
  18. @api.onchange('date_range_id')
  19. def onchange_date_range_id(self):
  20. if self.date_range_id:
  21. self.from_date = self.date_range_id.date_start
  22. self.to_date = self.date_range_id.date_end
  23. else:
  24. self.from_date = self.to_date = None
  25. @api.multi
  26. def open_taxes(self):
  27. self.ensure_one()
  28. action = self.env.ref('account_tax_balance.action_tax_balances_tree')
  29. vals = action.read()[0]
  30. vals['context'] = {
  31. 'from_date': self.from_date,
  32. 'to_date': self.to_date,
  33. 'target_move': self.target_move,
  34. 'company_id': self.company_id.id,
  35. }
  36. return vals