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.

60 lines
2.2 KiB

  1. # -*- coding: utf-8 -*-
  2. ###############################################################################
  3. #
  4. # OpenERP, Open Source Management Solution
  5. # Copyright (C) 2014 Savoir-faire Linux (<www.savoirfairelinux.com>).
  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 openerp.report import report_sxw
  22. class AccountChar(report_sxw.rml_parse):
  23. _name = 'report.account.print.chart'
  24. def __init__(self, cr, uid, name, context=None):
  25. super(AccountChar, self).__init__(cr, uid, name, context=context)
  26. self.localcontext.update({
  27. "get_lst_account": self._get_lst_account,
  28. "cr": cr,
  29. "uid": uid,
  30. "actual_context": context,
  31. })
  32. def _get_lst_account(self, cr, uid, account_id, context):
  33. account_obj = self.pool['account.account']
  34. actual_account = account_obj.browse(cr, uid, account_id,
  35. context=context)
  36. lst_account = []
  37. self._fill_list_account_with_child(lst_account, actual_account)
  38. return lst_account
  39. def _fill_list_account_with_child(self, lst_account, account):
  40. # no more child
  41. lst_account.append(account)
  42. if not account.child_id:
  43. return
  44. for child in account.child_id:
  45. self._fill_list_account_with_child(lst_account, child)
  46. report_sxw.report_sxw(
  47. 'report.account.print.chart',
  48. 'account.account',
  49. 'account_chart_report/report/chart_of_accounts.rml',
  50. parser=AccountChar,
  51. )