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. # 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. _description = "Vat Report XLSX Report"
  7. _inherit = "report.account_financial_report.abstract_report_xlsx"
  8. def _get_report_name(self, report, data):
  9. company_id = data.get("company_id", False)
  10. report_name = _("Vat Report")
  11. if company_id:
  12. company = self.env["res.company"].browse(company_id)
  13. suffix = " - {} - {}".format(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"), "field": "net", "type": "amount", "width": 14},
  21. 3: {"header": _("Tax"), "field": "tax", "type": "amount", "width": 14},
  22. }
  23. def _get_report_filters(self, report):
  24. return [
  25. [_("Date from"), report.date_from.strftime("%d/%m/%Y")],
  26. [_("Date to"), report.date_to.strftime("%d/%m/%Y")],
  27. [
  28. _("Based on"),
  29. _("Tax Tags") if report.based_on == "taxtags" else _("Tax Groups"),
  30. ],
  31. ]
  32. def _get_col_count_filter_name(self):
  33. return 0
  34. def _get_col_count_filter_value(self):
  35. return 2
  36. def _generate_report_content(self, workbook, report, data):
  37. res_data = self.env[
  38. "report.account_financial_report.vat_report"
  39. ]._get_report_values(report, data)
  40. vat_report = res_data["vat_report"]
  41. tax_detail = res_data["tax_detail"]
  42. # For each tax_tag tax_group
  43. self.write_array_header()
  44. for tag_or_group in vat_report:
  45. # Write taxtag line
  46. self.write_line_from_dict(tag_or_group)
  47. # For each tax if detail taxes
  48. if tax_detail:
  49. for tax in tag_or_group["taxes"]:
  50. self.write_line_from_dict(tax)