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.

39 lines
1.4 KiB

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