[IMP]l10n_in_hr_payroll:report improved

bzr revid: kbh@tinyerp.com-20120720091634-eyrajix3k2yh9xxg
This commit is contained in:
Khushboo Bhatt (Open ERP) 2012-07-20 14:46:34 +05:30
parent 4b8f5ce491
commit e43a303093
8 changed files with 75 additions and 88 deletions

View File

@ -50,7 +50,7 @@ Indian Payroll Salary Rules.
'security/ir.model.access.csv',
'l10n_in_hr_payroll_report.xml',
'l10n_in_hr_payroll_sequence.xml',
'wizard/salary_rule_bymonth.xml',
'wizard/hr_salary_employee_bymonth.xml',
'report/payment_advice_report_view.xml',
],

View File

@ -17,13 +17,13 @@
name="payroll.advice"
rml="l10n_in_hr_payroll/report/report_payroll_advice.rml"
string="Print Advice" />
<report
auto="False"
id="salary_rule_bymonth"
model="salary.rule.month"
name="salary.rule.bymonth"
rml="l10n_in_hr_payroll/report/report_salary_rule_bymonth.rml"
string="Yearly Salary Report" />
id="hr_salary_employee_bymonth"
model="hr.salary.employee.month"
name="salary.employee.bymonth"
rml="l10n_in_hr_payroll/report/report_hr_salary_employee_bymonth.rml"
string="Salary Register" />
</data>
</openerp>

View File

@ -24,8 +24,7 @@
import report_payslip_details
import report_payroll_advice
import report_salary_rule_bymonth
import report_hr_salary_employee_bymonth
import payment_advice_report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -23,12 +23,12 @@ import datetime
import time
from report import report_sxw
import pooler
class report_salary_rule_bymonth(report_sxw.rml_parse):
class report_hr_salary_employee_bymonth(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(report_salary_rule_bymonth, self).__init__(cr, uid, name, context)
super(report_hr_salary_employee_bymonth, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
'get_employee': self.get_employee,
@ -37,47 +37,48 @@ class report_salary_rule_bymonth(report_sxw.rml_parse):
'get_total': self.get_total,
})
self.context = context
self.mnths =[]
self.mnths_tol = []
self.mnths_total = []
self.total=0.0
def get_periods(self, form):
# Get start year-month-date and end year-month-date
fy = int(form['start_date'][0:4])
ly = int(form['end_date'][0:4])
first_year = int(form['start_date'][0:4])
last_year = int(form['end_date'][0:4])
fm = int(form['start_date'][5:7])
lm = int(form['end_date'][5:7])
no_months = (ly-fy)*12+lm-fm + 1
cm = fm
cy = fy
first_month = int(form['start_date'][5:7])
last_month = int(form['end_date'][5:7])
no_months = (last_year-first_year) * 12 + last_month - first_month + 1
current_month = first_month
current_year = first_year
# Get name of the months from integer
mnth_name = []
for count in range(0, no_months):
m = datetime.date(cy, cm, 1).strftime('%b')
m = datetime.date(current_year, current_month, 1).strftime('%b')
mnth_name.append(m)
self.mnths.append(str(cm)+'-'+str(cy))
if cm == 12:
cm = 0
cy = ly
cm = cm +1
self.mnths.append(str(current_month)+'-'+str(current_year))
if current_month == 12:
current_month = 0
current_year = last_year
current_month = current_month +1
for c in range(0, (12-no_months)):
mnth_name.append('None')
self.mnths.append('None')
return [mnth_name]
def get_employee(self, form):
ls1=[]
ls = []
tol_mnths=['Total', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
emp = pooler.get_pool(self.cr.dbname).get('hr.employee')
emp_ids = form['employee_ids']
empll = emp.browse(self.cr, self.uid, emp_ids)
list1=[]
list = []
total_mnths=['Total', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
emp_obj = self.pool.get('hr.employee')
emp_ids = form.get('employee_ids', [])
employees = emp_obj.browse(self.cr, self.uid, emp_ids, context=self.context)
cnt = 1
for emp_id in empll:
ls1.append(emp_id.name)
tol = 0.0
for emp_id in employees:
list1.append(emp_id.name)
total = 0.0
for mnth in self.mnths:
if mnth <> 'None':
if len(mnth) != 7:
@ -90,35 +91,35 @@ class report_salary_rule_bymonth(report_sxw.rml_parse):
where pl.code = 'NET' and p.state = 'done' and p.employee_id = '''+str(emp_id.id)+''' \
and to_char(date_to,'mm-yyyy') like '%'''+mnth+'''%'
group by r.name, p.date_to,emp.id''')
sal = self.cr.fetchall()
if sal:
ls1.append(sal[0][0])
tol += sal[0][0]
tol_mnths[cnt] = tol_mnths[cnt] + sal[0][0]
salary = self.cr.fetchall()
if salary:
list1.append(salary[0][0])
total += salary[0][0]
total_mnths[cnt] = total_mnths[cnt] + salary[0][0]
else:
ls1.append(0.00)
list1.append(0.00)
else:
ls1.append('')
tol_mnths[cnt] = ''
list1.append('')
total_mnths[cnt] = ''
cnt = cnt + 1
cnt = 1
ls1.append(tol)
ls.append(ls1)
ls1 = []
self.mnths_tol.append(tol_mnths)
return ls
list1.append(total)
list.append(list1)
list1 = []
self.mnths_total.append(total_mnths)
return list
def get_months_tol(self):
return self.mnths_tol
return self.mnths_total
def get_total(self):
for item in self.mnths_tol:
for item in self.mnths_total:
for count in range(1, len(item)):
if item[count] == '':
continue
self.total += item[count]
return self.total
report_sxw.report_sxw('report.salary.rule.bymonth', 'salary.rule.month', 'l10n_in_hr_payroll/report/report_salary_rule_bymonth.rml', parser=report_salary_rule_bymonth, header='internal')
report_sxw.report_sxw('report.salary.employee.bymonth', 'hr.salary.employee.month', 'l10n_in_hr_payroll/report/report_hr_salary_employee_bymonth.rml', parser=report_hr_salary_employee_bymonth, header='internal')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -2,7 +2,7 @@
<document filename="yearly salary report.pdf">
<template pageSize="(620.0,842.0)" title="Yearly Salary Report" author="OpenERP" allowSplitting="50">
<pageTemplate id="first">
<frame id="first" x1="28.0" y1="28.0" width="400" height="786"/>
<frame id="first" x1="28.0" y1="28.0" width="539" height="772"/>
</pageTemplate>
</template>
<stylesheet>
@ -106,7 +106,7 @@
<paraStyle name="terp_default_9" fontName="Helvetica" fontSize="5.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_Right_8" fontName="Helvetica" fontSize="5.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="7.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_Right_9_Bold" fontName="Helvetica-Bold" fontSize="7.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_Right_9_Bold" fontName="Helvetica-Bold" fontSize="5.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_tblheader_General" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="terp_tblheader_General_Centre" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="terp_tblheader_General_Right" fontName="Helvetica-Bold" fontSize="7.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
@ -117,7 +117,7 @@
<para style="P5">From [[ formatLang(data['form']['start_date'], date=True) ]] To [[ formatLang(data['form']['end_date'], date=True) ]]</para>
<section>
<para style="terp_default_1">[[ repeatIn(get_periods(data['form']),'m') ]]</para>
<blockTable colWidths="53.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,57.0" style="Table1">
<blockTable colWidths="55.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,57.0" style="Table1">
<tr>
<td>
<para style="terp_tblheader_Details">Name</para>
@ -165,7 +165,7 @@
</blockTable>
<section>
<para style="terp_default_1">[[ repeatIn(get_employee(data['form']),'e') ]]</para>
<blockTable colWidths="53.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,57.0" style="Table2">
<blockTable colWidths="55.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,57.0" style="Table2">
<tr>
<td>
<para style="terp_default_9">[[ e[0] ]]</para>
@ -235,17 +235,11 @@
</td>
</tr>
</blockTable>
<para style="P2">
<font color="white"> </font>
</para>
</section>
<para style="P2">
<font color="white"> </font>
</para>
</section>
<section>
<para style="terp_default_1">[[ repeatIn(get_months_tol(),'t') ]]</para>
<blockTable colWidths="53.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,57.0" style="Table6">
<blockTable colWidths="55.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,40.0,57.0" style="Table6">
<tr>
<td>
<para style="terp_tblheader_Details">Total</para>
@ -291,12 +285,6 @@
</td>
</tr>
</blockTable>
<para style="P2">
<font color="white"> </font>
</para>
</section>
<para style="P6">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -19,6 +19,6 @@
#
##############################################################################
import salary_rule_bymonth
import hr_salary_employee_bymonth
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -23,15 +23,14 @@ import time
from osv import osv, fields
class salary_rule_bymonth(osv.osv_memory):
class hr_salary_employee_bymonth(osv.osv_memory):
_name = 'salary.rule.month'
_description = 'Print Monthly Salary Rule Report'
_name = 'hr.salary.employee.month'
_description = 'Print Hr Salary Employee By Month Report'
_columns = {
'start_date': fields.date('Starting Date', required=True),
'end_date': fields.date('Ending Date', required=True),
'employee_ids': fields.many2many('hr.employee', 'payroll_year_rel', 'payroll_year_id', 'emp_id', 'Employees', required=True),
# 'rule_id': fields.many2one('hr.salary.rule.category', 'Rule Category', required=True),
}
_defaults = {
@ -55,13 +54,13 @@ class salary_rule_bymonth(osv.osv_memory):
res = self.read(cr, uid, ids, ['employee_ids', 'start_date', 'end_date'], context=context)
res = res and res[0] or {}
datas['form'] = res
datas['ids'] = res.get('employee_ids', [])
res['employee_ids'] = res.get('employee_ids', [])
return {
'type': 'ir.actions.report.xml',
'report_name': 'salary.rule.bymonth',
'report_name': 'salary.employee.bymonth',
'datas': datas,
}
salary_rule_bymonth()
hr_salary_employee_bymonth()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,30 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_salary_rule_month" model="ir.ui.view">
<field name="name">Salary rule monthly</field>
<field name="model">salary.rule.month</field>
<record id="view_salary_employee_month" model="ir.ui.view">
<field name="name">Hr monthly Employee Salary</field>
<field name="model">hr.salary.employee.month</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Print Salary Rule Monthly" version="7.0">
<form string="Print Hr monthly Employee Salary" version="7.0">
<header>
<button name="print_report" string="Print" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</header>
<group>
<field name="start_date"/>
<field name="end_date"/>
<separator string="Employee" />
<field name="employee_ids" nolabel="1" colspan="4"/>
</group>
</form>
</field>
</record>
<record id="action_yearly_salary_rule" model="ir.actions.act_window">
<record id="action_salary_employee_month" model="ir.actions.act_window">
<field name="name">Salary Register</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">salary.rule.month</field>
<field name="res_model">hr.salary.employee.month</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
@ -33,14 +33,14 @@
<menuitem
name="Reporting"
parent="hr.menu_hr_root"
id="menu_yearly_salary_rule_report" sequence="50"
id="menu_salary_employee_month_report" sequence="50"
/>
<menuitem
name="Yearly Salary Rule Report"
parent="menu_yearly_salary_rule_report"
action="action_yearly_salary_rule"
id="menu_yearly_salary_rule"
name="Salary Register"
parent="menu_salary_employee_month_report"
action="action_salary_employee_month"
id="menu_salary_employee_month"
/>
</data>