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.

64 lines
2.2 KiB

  1. # Copyright 2018 Forest and Biomass Romania
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo import _, models
  4. class VATReportXslx(models.AbstractModel):
  5. _name = 'report.a_f_r.report_vat_report_xlsx'
  6. _inherit = 'report.account_financial_report.abstract_report_xlsx'
  7. def _get_report_name(self, report, data):
  8. company_id = data.get('company_id', False)
  9. report_name = _('Vat Report')
  10. if company_id:
  11. company = self.env['res.company'].browse(company_id)
  12. suffix = ' - %s - %s' % (
  13. company.name, company.currency_id.name)
  14. report_name = report_name + suffix
  15. return report_name
  16. def _get_report_columns(self, report):
  17. return {
  18. 0: {'header': _('Code'), 'field': 'code', 'width': 5},
  19. 1: {'header': _('Name'), 'field': 'name', 'width': 100},
  20. 2: {'header': _('Net'),
  21. 'field': 'net',
  22. 'type': 'amount',
  23. 'width': 14},
  24. 3: {'header': _('Tax'),
  25. 'field': 'tax',
  26. 'type': 'amount',
  27. 'width': 14},
  28. }
  29. def _get_report_filters(self, report):
  30. return [
  31. [_('Date from'), report.date_from.strftime("%d/%m/%Y")],
  32. [_('Date to'), report.date_to.strftime("%d/%m/%Y")],
  33. [_('Based on'), _('Tax Tags') if report.based_on == 'taxtags'else
  34. _('Tax Groups')]
  35. ]
  36. def _get_col_count_filter_name(self):
  37. return 0
  38. def _get_col_count_filter_value(self):
  39. return 2
  40. def _generate_report_content(self, workbook, report, data):
  41. res_data = self.env[
  42. 'report.account_financial_report.vat_report'
  43. ]._get_report_values(report, data)
  44. vat_report = res_data['vat_report']
  45. tax_detail = res_data['tax_detail']
  46. # For each tax_tag tax_group
  47. self.write_array_header()
  48. for tag_or_group in vat_report:
  49. # Write taxtag line
  50. self.write_line_from_dict(tag_or_group)
  51. # For each tax if detail taxes
  52. if tax_detail:
  53. for tax in tag_or_group['taxes']:
  54. self.write_line_from_dict(tax)