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.

87 lines
3.7 KiB

  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # OpenERP, Open Source Management Solution
  5. # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as
  9. # published by the Free Software Foundation, either version 3 of the
  10. # License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. ##############################################################################
  21. from osv import osv, fields
  22. from tools.translate import _
  23. class account_bs_report(osv.osv_memory):
  24. """
  25. This wizard will provide the account balance sheet report by periods, between any two dates.
  26. """
  27. _name = 'account.bs.report'
  28. _inherit = "account_report_alt.common.account.report"
  29. _description = 'Account Balance Sheet Report'
  30. def _get_def_reserve_account(self, cr, uid, context=None):
  31. chart_id = self._get_account(cr, uid, context=context)
  32. res = self.onchange_chart_id(cr, uid, [], chart_id, context=context)
  33. if not res:
  34. return False
  35. return res['value']['reserve_account_id']
  36. _columns = {
  37. 'display_type': fields.boolean("Landscape Mode"),
  38. 'reserve_account_id': fields.many2one('account.account', 'Reserve & Profit/Loss Account',
  39. required=True,
  40. help='This Account is used for transfering Profit/Loss ' \
  41. '(Profit: Amount will be added, Loss: Amount will be duducted), ' \
  42. 'which is calculated from Profilt & Loss Report',
  43. domain = [('type','=','other')]),
  44. }
  45. _defaults={
  46. 'display_type': True,
  47. 'journal_ids': [],
  48. 'reserve_account_id': _get_def_reserve_account,
  49. }
  50. def onchange_chart_id(self, cr, uid, ids, chart_id, context=None):
  51. if not chart_id:
  52. return {}
  53. account = self.pool.get('account.account').browse(cr, uid, chart_id , context=context)
  54. if not account.company_id.property_reserve_and_surplus_account:
  55. return {'value': {'reserve_account_id': False}}
  56. return {'value': {'reserve_account_id': account.company_id.property_reserve_and_surplus_account.id}}
  57. def _print_report(self, cr, uid, ids, data, context=None):
  58. if context is None:
  59. context = {}
  60. data['form'].update(self.read(cr, uid, ids, ['display_type','reserve_account_id'])[0])
  61. if not data['form']['reserve_account_id']:
  62. raise osv.except_osv(_('Warning'),_('Please define the Reserve and Profit/Loss account for current user company !'))
  63. data = self.pre_print_report(cr, uid, ids, data, context=context)
  64. if data['form']['display_type']:
  65. return {
  66. 'type': 'ir.actions.report.xml',
  67. 'report_name': 'account.balancesheet.horizontal',
  68. 'datas': data,
  69. }
  70. else:
  71. return {
  72. 'type': 'ir.actions.report.xml',
  73. 'report_name': 'account.balancesheet',
  74. 'datas': data,
  75. }
  76. account_bs_report()
  77. # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: