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.

82 lines
3.5 KiB

  1. # -*- encoding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Author: Guewen Baconnier
  5. # Copyright Camptocamp SA 2011
  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 report import report_sxw
  22. from tools.translate import _
  23. import pooler
  24. from datetime import datetime
  25. from common_balance_reports import CommonBalanceReportHeaderWebkit
  26. from webkit_parser_header_fix import HeaderFooterTextWebKitParser
  27. def sign(number):
  28. return cmp(number, 0)
  29. class TrialBalanceWebkit(report_sxw.rml_parse, CommonBalanceReportHeaderWebkit):
  30. def __init__(self, cursor, uid, name, context):
  31. super(TrialBalanceWebkit, self).__init__(cursor, uid, name, context=context)
  32. self.pool = pooler.get_pool(self.cr.dbname)
  33. self.cursor = self.cr
  34. company = self.pool.get('res.users').browse(self.cr, uid, uid, context=context).company_id
  35. header_report_name = ' - '.join((_('TRIAL BALANCE'), company.name, company.currency_id.name))
  36. footer_date_time = self.formatLang(str(datetime.today()), date_time=True)
  37. self.localcontext.update({
  38. 'cr': cursor,
  39. 'uid': uid,
  40. 'report_name': _('Trial Balance'),
  41. 'display_account': self._get_display_account,
  42. 'display_account_raw': self._get_display_account_raw,
  43. 'filter_form': self._get_filter,
  44. 'target_move': self._get_target_move,
  45. 'display_target_move': self._get_display_target_move,
  46. 'accounts': self._get_accounts_br,
  47. 'additional_args': [
  48. ('--header-font-name', 'Helvetica'),
  49. ('--footer-font-name', 'Helvetica'),
  50. ('--header-font-size', '10'),
  51. ('--footer-font-size', '6'),
  52. ('--header-left', header_report_name),
  53. ('--header-spacing', '2'),
  54. ('--footer-left', footer_date_time),
  55. ('--footer-right', ' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
  56. ('--footer-line',),
  57. ],
  58. })
  59. def set_context(self, objects, data, ids, report_type=None):
  60. """Populate a ledger_lines attribute on each browse record that will be used
  61. by mako template"""
  62. objects, new_ids, context_report_values = self.compute_balance_data(data)
  63. self.localcontext.update(context_report_values)
  64. return super(TrialBalanceWebkit, self).set_context(objects, data, new_ids,
  65. report_type=report_type)
  66. HeaderFooterTextWebKitParser('report.account.account_report_trial_balance_webkit',
  67. 'account.account',
  68. 'addons/account_financial_report_webkit/report/templates/account_report_trial_balance.mako',
  69. parser=TrialBalanceWebkit)