[MIG,IMP] l10n_fr_hr_payroll : Migrated reports to new API.

This commit is contained in:
Rohan Patel
2016-07-12 09:24:56 +02:00
committed by Yannick Tivisse
parent 2b19b806e1
commit 08f8719985
3 changed files with 40 additions and 52 deletions
+35 -47
View File
@@ -1,57 +1,45 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp.osv import osv
from openerp.report import report_sxw
from odoo import api, models
class fiche_paye_parser(report_sxw.rml_parse):
class FichePayeParser(models.AbstractModel):
_name = 'report.l10n_fr_hr_payroll.report_l10n_fr_fiche_paye'
def __init__(self, cr, uid, name, context):
super(fiche_paye_parser, self).__init__(cr, uid, name, context)
self.localcontext.update({
def get_payslip_lines(self, objs):
res = []
ids = []
for item in objs:
if item.appears_on_payslip is True and not item.salary_rule_id.parent_rule_id:
ids.append(item.id)
if ids:
res = self.env['hr.payslip.line'].browse(ids)
return res
def get_total_by_rule_category(self, obj, code):
category_total = 0
category_id = self.env['hr.salary.rule.category'].search([('code', '=', code)], limit=1).id
if category_id:
line_ids = self.env['hr.payslip.line'].search([('slip_id', '=', obj.id), ('category_id', 'child_of', category_id)])
for line in line_ids:
category_total += line.total
return category_total
def get_employer_line(self, obj, parent_line):
return self.env['hr.payslip.line'].search([('slip_id', '=', obj.id), ('salary_rule_id.parent_rule_id.id', '=', parent_line.salary_rule_id.id)], limit=1)
@api.multi
def render_html(self, data):
payslip = self.env['hr.payslip'].browse(self.ids)
docargs = {
'doc_ids': self.ids,
'doc_model': 'hr.payslip',
'data': data,
'docs': payslip,
'lang': "fr_FR",
'get_payslip_lines': self.get_payslip_lines,
'get_total_by_rule_category': self.get_total_by_rule_category,
'get_employer_line': self.get_employer_line,
})
def get_payslip_lines(self, objs):
payslip_line = self.pool.get('hr.payslip.line')
res = []
ids = []
for item in objs:
if item.appears_on_payslip == True and not item.salary_rule_id.parent_rule_id :
ids.append(item.id)
if ids:
res = payslip_line.browse(self.cr, self.uid, ids)
return res
def get_total_by_rule_category(self, obj, code):
payslip_line = self.pool.get('hr.payslip.line')
rule_cate_obj = self.pool.get('hr.salary.rule.category')
cate_ids = rule_cate_obj.search(self.cr, self.uid, [('code', '=', code)])
category_total = 0
if cate_ids:
line_ids = payslip_line.search(self.cr, self.uid, [('slip_id', '=', obj.id), ('category_id', 'child_of', cate_ids)])
for line in payslip_line.browse(self.cr, self.uid, line_ids):
category_total += line.total
return category_total
def get_employer_line(self, obj, parent_line):
payslip_line = self.pool.get('hr.payslip.line')
line_ids = payslip_line.search(self.cr, self.uid, [('slip_id', '=', obj.id), ('salary_rule_id.parent_rule_id.id', '=', parent_line.salary_rule_id.id )])
res = line_ids and payslip_line.browse(self.cr, self.uid, line_ids[0]) or False
return res
class wrapped_report_fiche_paye(osv.AbstractModel):
_name = 'report.l10n_fr_hr_payroll.report_l10nfrfichepaye'
_inherit = 'report.abstract_report'
_template = 'l10n_fr_hr_payroll.report_l10nfrfichepaye'
_wrapped_report_class = fiche_paye_parser
}
return self.env['report'].render('l10n_fr_hr_payroll.report_l10n_fr_fiche_paye', docargs)
@@ -5,7 +5,7 @@
model="hr.payslip"
string="Fiche de paye"
report_type="qweb-pdf"
name="l10n_fr_hr_payroll.report_l10nfrfichepaye"
file="l10n_fr_hr_payroll.report_l10nfrfichepaye"
name="l10n_fr_hr_payroll.report_l10n_fr_fiche_paye"
file="l10n_fr_hr_payroll.report_l10n_fr_fiche_paye"
/>
</odoo>
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_l10nfrfichepaye">
<template id="report_l10n_fr_fiche_paye">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="report.internal_layout">
<div class="page">
<div class="oe_structure"/>
<div class="row">
<div class="row">
<div class="col-xs-4">
<h2>Bulletin de paie</h2>
<h4>Paie du <span t-esc="formatLang(o.date_from, date=True)"/> au <span t-esc="formatLang(o.date_to, date=True)"/></h4>
<h4>Paie du <span t-field="o.date_from"/> au <span t-field="o.date_to"/></h4>
</div>
<div class="col-xs-4 pull-right">
<table class="table table-bordered" stype="border: 2px solid black;">