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.

41 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 odoo import api, fields, models
  4. class WizardOpenTaxBalances(models.TransientModel):
  5. _name = 'wizard.open.tax.balances'
  6. _description = 'Wizard Open Tax Balances'
  7. company_id = fields.Many2one(
  8. 'res.company', 'Company', required=True,
  9. default=lambda self: self.env.user.company_id)
  10. from_date = fields.Date('From date', required=True)
  11. to_date = fields.Date('To date', required=True)
  12. date_range_id = fields.Many2one('date.range', 'Date range')
  13. target_move = fields.Selection([
  14. ('posted', 'All Posted Entries'),
  15. ('all', 'All Entries'),
  16. ], 'Target Moves', required=True, default='posted')
  17. @api.onchange('date_range_id')
  18. def onchange_date_range_id(self):
  19. if self.date_range_id:
  20. self.from_date = self.date_range_id.date_start
  21. self.to_date = self.date_range_id.date_end
  22. else:
  23. self.from_date = self.to_date = None
  24. @api.multi
  25. def open_taxes(self):
  26. self.ensure_one()
  27. action = self.env.ref('account_tax_balance.action_tax_balances_tree')
  28. vals = action.read()[0]
  29. vals['context'] = {
  30. 'from_date': self.from_date,
  31. 'to_date': self.to_date,
  32. 'target_move': self.target_move,
  33. 'company_id': self.company_id.id,
  34. }
  35. return vals