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.

90 lines
4.0 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_partner_balance_reports import CommonPartnerBalanceReportHeaderWebkit
  26. from webkit_parser_header_fix import HeaderFooterTextWebKitParser
  27. class PartnerBalanceWebkit(report_sxw.rml_parse, CommonPartnerBalanceReportHeaderWebkit):
  28. def __init__(self, cursor, uid, name, context):
  29. super(PartnerBalanceWebkit, self).__init__(cursor, uid, name, context=context)
  30. self.pool = pooler.get_pool(self.cr.dbname)
  31. self.cursor = self.cr
  32. company = self.pool.get('res.users').browse(self.cr, uid, uid, context=context).company_id
  33. header_report_name = ' - '.join((_('PARTNER BALANCE'), company.name, company.currency_id.name))
  34. footer_date_time = self.formatLang(str(datetime.today()), date_time=True)
  35. self.localcontext.update({
  36. 'cr': cursor,
  37. 'uid': uid,
  38. 'report_name': _('Partner Balance'),
  39. 'display_account': self._get_display_account,
  40. 'display_account_raw': self._get_display_account_raw,
  41. 'filter_form': self._get_filter,
  42. 'target_move': self._get_target_move,
  43. 'display_target_move': self._get_display_target_move,
  44. 'display_partner_account': self._get_display_partner_account,
  45. 'accounts': self._get_accounts_br,
  46. 'additional_args': [
  47. ('--header-font-name', 'Helvetica'),
  48. ('--footer-font-name', 'Helvetica'),
  49. ('--header-font-size', '10'),
  50. ('--footer-font-size', '6'),
  51. ('--header-left', header_report_name),
  52. ('--header-spacing', '2'),
  53. ('--footer-left', footer_date_time),
  54. ('--footer-right', ' '.join((_('Page'), '[page]', _('of'), '[topage]'))),
  55. ('--footer-line',),
  56. ],
  57. })
  58. def _get_initial_balance_mode(self, start_period):
  59. """ Force computing of initial balance for the partner balance,
  60. because we cannot use the entries generated by
  61. OpenERP in the opening period.
  62. OpenERP allows to reconcile move lines between different partners,
  63. so the generated entries in the opening period are wrong.
  64. """
  65. return 'initial_balance'
  66. def set_context(self, objects, data, ids, report_type=None):
  67. """Populate a ledger_lines attribute on each browse record that will be used
  68. by mako template"""
  69. objects, new_ids, context_report_values = self.compute_partner_balance_data(data)
  70. self.localcontext.update(context_report_values)
  71. return super(PartnerBalanceWebkit, self).set_context(objects, data, new_ids,
  72. report_type=report_type)
  73. HeaderFooterTextWebKitParser('report.account.account_report_partner_balance_webkit',
  74. 'account.account',
  75. 'addons/account_financial_report_webkit/report/templates/account_report_partner_balance.mako',
  76. parser=PartnerBalanceWebkit)