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.

61 lines
2.3 KiB

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