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.

59 lines
2.5 KiB

  1. ##############################################################################
  2. #
  3. # Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
  4. #
  5. # WARNING: This program as such is intended to be used by professional
  6. # programmers who take the whole responsability of assessing all potential
  7. # consequences resulting from its eventual inadequacies and bugs
  8. # End users who are looking for a ready-to-use solution with commercial
  9. # garantees and support are strongly adviced to contract a Free Software
  10. # Service Company
  11. #
  12. # This program is Free Software; you can redistribute it and/or
  13. # modify it under the terms of the GNU General Public License
  14. # as published by the Free Software Foundation; either version 2
  15. # of the License, or (at your option) any later version.
  16. #
  17. # This program is distributed in the hope that it will be useful,
  18. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. # GNU General Public License for more details.
  21. #
  22. # You should have received a copy of the GNU General Public License
  23. # along with this program; if not, write to the Free Software
  24. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  25. #
  26. ##############################################################################
  27. import time
  28. from report import report_sxw
  29. #import xml.dom.minidom
  30. #import re
  31. class account_hours_block(report_sxw.rml_parse):
  32. def __init__(self, cr, uid, name, context=None):
  33. super(account_hours_block, self).__init__(cr, uid, name, context)
  34. self.localcontext.update({
  35. 'time': time,
  36. 'format_date': self._get_and_change_date_format_for_swiss,
  37. 'analytic_lines': self._get_analytic_lines,
  38. })
  39. self.context = context
  40. def _get_analytic_lines(self, hours_block):
  41. al_pool = self.pool.get('account.analytic.line')
  42. al_ids = al_pool.search(self.cr, self.uid,
  43. [['invoice_id', '=', hours_block.invoice_id.id]],
  44. order='date desc')
  45. res = al_pool.browse(self.cr, self.uid, al_ids)
  46. return res
  47. def _get_and_change_date_format_for_swiss(self, date_to_format):
  48. date_formatted = ''
  49. if date_to_format:
  50. date_formatted = strptime(date_to_format, '%Y-%m-%d').strftime('%d.%m.%Y')
  51. return date_formatted
  52. report_sxw.report_sxw('report.account.hours.block', 'account.hours.block', 'addons/analytic_hours_block/report/hours_block.rml', parser=account_hours_block)