【发布时间】:2022-07-14 22:42:37
【问题描述】:
我正在 Odoo 13 中开发一个自定义模块来生成个性化的 XMLS 报告,为此我使用了Base Report XLSX from OCA。问题是,在为翻译生成 PO 文档时,它无法识别我 explicitly marked to export 带有“_()”的变量,即使我遵循了官方文档中的所有指示(我认为)。
自定义模块代码:
# -*- coding: utf-8 -*-
from odoo import models, _
class PayrollBatchReportXLSX(models.AbstractModel):
_name = 'report.company_payroll.payroll_batch_report'
_inherit = 'report.report_xlsx.abstract'
def generate_xlsx_report(self, workbook, data, lines):
sheet = workbook.add_worksheet('Payroll Batch XLSX Report')
sheet.write(0, 0, _("ACCOUNT"))
sheet.write(0, 1, _("DEBIT"))
sheet.write(0, 2, _("CREDIT"))
sheet.write(0, 3, _("NAME"))
line_index = 0
for line_item in lines.slip_ids.line_ids:
if line_item.salary_rule_id.category_id.code in ['L10N_HN_NET']:
sheet.write(line_index+1, 2, line_item.total)
line_index += 1
for index, employee in enumerate(lines.slip_ids.employee_id):
sheet.write(index+1, 3, employee.name.upper())
if employee.bank_account_id.acc_number:
sheet.write(index+1, 0, employee.bank_account_id.acc_number)
这是生成的 PO 文件:
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * company_payroll
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-05-04 16:17+0000\n"
"PO-Revision-Date: 2022-05-04 16:17+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: company_payroll
#: model:ir.actions.report,print_report_name:company_payroll.payroll_batch_xlsx_report
msgid "'Payroll batch - %s' % (object.name)"
msgstr "'Nómina en lote - %s' % (object.name)"
#. module: company_payroll
#: model:ir.model.fields,field_description:company_payroll.field_report_company_payroll_payroll_batch_report__display_name
msgid "Display Name"
msgstr "Mostrar nombre"
#. module: company_payroll
#: model:ir.model.fields,field_description:company_payroll.field_report_company_payroll_payroll_batch_report__id
msgid "ID"
msgstr ""
#. module: company_payroll
#: model:ir.model.fields,field_description:company_payroll.field_report_company_payroll_payroll_batch_report____last_update
msgid "Last Modified on"
msgstr "Última modificación en"
#. module: company_payroll
#: model:ir.actions.report,name:company_payroll.payroll_batch_xlsx_report
msgid "Payroll Batch XLSX Report"
msgstr "Reporte de nómina por lote"
#. module: company_payroll
#: model:ir.model,name:company_payroll.model_report_company_payroll_payroll_batch_report
msgid "report.company_payroll.payroll_batch_report"
msgstr ""
如您所见,要翻译的变量(“_("ACCOUNT")"、"_("DEBIT")" 等)没有显示在任何地方。我希望你能帮助我,提前谢谢。
【问题讨论】:
标签: python odoo translation odoo-13 po