This question has been flagged
2102 Views

i am using odoo 9 and i want to print a detailed payroll but i noticed that in the Details by salary Rule Category it shows twice each content of fields "code", "rule_category" and "total " I tried to edit the report_payslipdetails.xml file but still the same problem. Any help please??? How to modify it to print "Base",Brut", "Net", .. one time ??

report_payslipdetails.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_payslipdetails">
<t t-call="report.html_container">
    <t t-foreach="docs" t-as="o">
        <t t-call="report.external_layout">
        .......
        <h3>Details by Salary Rule Category</h3>
                <table class="table table-condensed mb32">
                    <thead>
                        <tr>
                            <th>Code</th>
                            <th>Salary Rule Category</th>
                            <th>Total</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr t-foreach="get_details_by_rule_category(o.details_by_salary_rule_category)" t-as="h">
                            <td>
                                <span t-esc="h['code']"/>
                            </td>
                            <td>
                              <span t-esc="h['rule_category']"/>
                            </td>
                            <td>
                                <span t-esc="formatLang(h['total'], currency_obj=o.company_id.currency_id)"/>
                            </td>
                        </tr>
                    </tbody>
                </table>

                <h3>Payslip Lines by Contribution Register</h3>
                <table class="table table-condensed mt32">
                    <thead>
                        <tr>
                            <th>Code</th>
                            <th>Name</th>
                            <th>Quantity/rate</th>
                            <th>Amount</th>
                            <th>Total</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr t-foreach="get_lines_by_contribution_register(o.line_ids)" t-as="p">
                            <td><span t-esc="p.get('code', '')"/></td>
                            <td><span t-esc="p.get('name', '')"/></td>
                            <td><span t-esc="p.get('quantity', '')"/></td>
                            <td><span t-esc="formatLang(p.get('amount', 0))"/></td>
                            <td><span t-esc="formatLang(p.get('total', 0), currency_obj=o.company_id.currency_id)"/></td>
                        </tr>
                    </tbody>
                </table>
            <p class="text-right"><strong>Authorized signature</strong></p>
            </div>
        </t>
    </t>
</t>
 </template>
 </data>
</openerp>

report_payslip_details.py

  def get_details_by_rule_category(self, obj):
    payslip_line = self.pool.get('hr.payslip.line')
    rule_cate_obj = self.pool.get('hr.salary.rule.category')

 def get_lines_by_contribution_register(self, obj):
    payslip_line = self.pool.get('hr.payslip.line')
    result = {}
    res = []

    for id in range(len(obj)):
        if obj[id].register_id:
            result.setdefault(obj[id].register_id.name, [])
            result[obj[id].register_id.name].append(obj[id].id)
    for key, value in result.iteritems():
        register_total = 0
        for line in payslip_line.browse(self.cr, self.uid, value):
            register_total += line.total
        res.append({
            'register_name': key,
            'total': register_total,
        })
        for line in payslip_line.browse(self.cr, self.uid, value):
            res.append({
                'name': line.name,
                'code': line.code,
                'quantity': line.quantity,
                'amount': line.amount,
                'total': line.total,
            })
    return res


Avatar
Discard

have you done any customizations on payslip on is that a default behaviour?

Author

No