You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Odoo工资单自定义打印选项不显示问题排查求助

Odoo自定义工资单报表未显示在打印按钮中

我在Odoo中创建自定义工资单报表,想要添加到工资单表单视图的打印按钮里。已经完成模块创建、报表定义并绑定hr.payslip模型,但新的打印选项没在界面显示。

操作详情

1. 清单文件(manifest.py)

'depends': ['account', 'sale_management', 'hr_contract','hr_holiday',],

2. XML文件(wcm_pay_slip_report.xml)

模板代码:

<?xml version="1.0" encoding="utf-8"?>
<template id="wcm_pay_slip_report">
   <t t-call="web.html_container">
        <t t-foreach="docs" t-as="doc">
            <t t-call="hr_payroll.report_payslipdocument"/>
        <main>
            <div class="page">
                <h2 class="text-center" style="background-color: #336699; color: white; padding: 10px;">FICHE DE
                    PAIE
                </h2>

                <table class="table table-sm mt32" style="width: 100%; border: 1px solid #336699;">
                    <tr>
                        <td style="padding: 10px;">
                            <strong>Employeur</strong>
                            <br/>
                            Num Emplé:

                        </td>
                        <td class="text-right" style="padding: 10px;">
                            Mois:

                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" style="padding: 10px; text-align: center;">
                            <img t-att-src="" alt="Logo" style="width: 150px;"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding: 10px;">
                            Raison Sociale:

                            Adresse:

                        </td>
                    </tr>
                </table>

                <table class="table table-sm mt32" style="width: 100%; border: 1px solid #336699;">
                    <tr>
                        <td style="padding: 10px;">
                            <strong>Salarié</strong>
                            <br/>
                            Nom:

                            Date de naissance:

                        </td>
                        <td style="padding: 10px;">
                            Salaire de base:

                            Nº de compte:

                            Mode de paiement:

                        </td>
                    </tr>
                </table>

                <table class="table table-sm mt32" style="width: 100%; border: 1px solid #336699;">
                    <thead style="background-color: #336699; color: white;">
                        <tr>
                            <th style="padding: 5px;">Code</th>
                            <th style="padding: 5px;">Désignation</th>
                            <th style="padding: 5px;">Nbre/Taux</th>
                            <th style="padding: 5px;">Montant</th>
                            <th style="padding: 5px;">Gains</th>
                            <th style="padding: 5px;">Retenues</th>
                        </tr>
                    </thead>
                    <!--<tbody>
                      <tr t-foreach="payslip.details_by_salary_rule_category" t-as="line">
                           <td style="padding: 5px;"><t t-esc="line.code"/></td>
                           <td style="padding: 5px;"><t t-esc="line.name"/></td>
                           <td style="padding: 5px;"><t t-esc="line.quantity"/></td>
                           <td style="padding: 5px;"><t t-esc="line.amount"/></td>
                           <td style="padding: 5px;"><t t-esc="line.total"/></td>
                           <td style="padding: 5px;"><t t-esc="line.total_deduction"/></td>
                       </tr>
                   </tbody>!-->
                </table>

                <table class="table table-sm mt32" style="width: 100%; border: 1px solid #336699;">
                    <tr>
                        <td style="padding: 10px;">
                            <strong>SALAIRE IMPOSABLE</strong>
                        </td>
                        <td class="text-right" style="padding: 10px;">

                        </td>
                    </tr>
                    <tr>
                        <td style="padding: 10px;">
                            <strong>TOTAL GAINS</strong>
                        </td>
                        <td class="text-right" style="padding: 10px;">

                        </td>
                    </tr>
                    <tr>
                        <td style="padding: 10px;">
                            <strong>TOTAL RETENUES</strong>
                        </td>
                        <td class="text-right" style="padding: 10px;">

                        </td>
                    </tr>
                    <tr>
                        <td style="padding: 10px;">
                            <strong>NET A PAYER</strong>
                        </td>
                        <td class="text-right" style="padding: 10px;">

                        </td>
                    </tr>
                </table>
            </div>
        </main>
     </t>
    </t>
</template>

报表动作代码:

<record id="wcm_pay_slip_report_action" model="ir.actions.report">
    <field name="name">Fiche de Paie</field>
    <field name="model">hr.payslip</field>
    <field name="report_type">qweb-pdf</field>
    <field name="report_name">wsl_wcm_report.wcm_pay_slip_report</field>
    <field name="report_file">wsl_wcm_report.wcm_pay_slip_report</field>
    <field name="print_report_name">('Fiche de Paie- %s' % (object.employee_id.name))</field>
    <field name="binding_model_id" ref="hr_holiday.model_hr_payslip"/>
    <field name="binding_type">report</field>
</record>

问题排查点及解决步骤

  • 依赖模块缺失:模板中调用了hr_payroll.report_payslipdocument,且hr.payslip模型属于hr_payroll模块,需在manifest.py中添加该依赖:

    'depends': ['account', 'sale_management', 'hr_contract','hr_holiday', 'hr_payroll'],
    
  • 绑定模型引用错误:报表动作里的binding_model_id引用了错误的模块,hr.payslip模型的正确引用是hr_payroll.model_hr_payslip,修改如下:

    <field name="binding_model_id" ref="hr_payroll.model_hr_payslip"/>
    
  • XML文件未加载:检查manifest.py的data或qweb字段是否包含当前XML文件,示例:

    'data': [
        'wcm_pay_slip_report.xml',
    ],
    
  • 权限与缓存问题:

    1. 确认当前用户拥有该报表的访问权限,可在模块安全文件中配置对应权限组
    2. 进入后台设置 -> 技术 -> 动作 -> 报表,确认报表动作是否存在
    3. 清除浏览器缓存,升级自定义模块后刷新页面
  • 模板语法错误:检查模板循环结构,确保<t t-foreach="docs" t-as="doc">内的代码结构正确,避免未闭合的标签或逻辑错误导致报表无法加载。

内容的提问来源于stack exchange,提问作者Rahma Begag

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 17:39:53