account_tax_analysis.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Author Vincent Renaville. Copyright 2013-2014 Camptocamp SA
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Affero General Public License as
  8. # published by the Free Software Foundation, either version 3 of the
  9. # License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. ##############################################################################
  20. from openerp import models, fields, api
  21. class AccountTaxDeclarationAnalysis(models.TransientModel):
  22. _name = 'account.vat.declaration.analysis'
  23. _description = 'Account Vat Declaration'
  24. fiscalyear_id = fields.Many2one(
  25. comodel_name='account.fiscalyear',
  26. string='Fiscalyear',
  27. help='Fiscalyear to look on',
  28. required=True,
  29. )
  30. period_list = fields.Many2many(
  31. comodel_name='account.period',
  32. relation='account_tax_period_rel',
  33. column1='tax_analysis',
  34. column2='period_id',
  35. string='Periods',
  36. help="If no period is selected, all the periods of the "
  37. "fiscal year will be used",
  38. )
  39. @api.multi
  40. def show_vat(self):
  41. periods = self.period_list
  42. if not periods:
  43. periods = self.fiscalyear_id.period_ids
  44. domain = [('period_id', 'in', periods.ids)]
  45. action = self.env.ref('account_tax_analysis.action_view_tax_analysis')
  46. action_fields = action.read()[0]
  47. action_fields['domain'] = domain
  48. return action_fields