Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

New report for employee attendance.

By
charlesraj
on 2/21/14, 12:57 AM 2,089 views

I want to generate a new report for employee attendance(sign in and sign out time ) on monthly basis . In addons/ hr_attendance/reports I create a new .py file , rml file , .sxw file for generating my own custom report the report ( Make this file by referencing attendance_errors.py ,attendance_errors.rml,attendance_errors.sxw) . Then restart Openerp server .It will not create any new report. By looking on the Settings ->Technical -> Action -> reports ,My reports will not appears in the list. But attendance error report will appears in the list .

How can we add my reports to lists.

In my .PY file import time import datetime from openerp.report import report_sxw from openerp.report.interface import report_rml

class attendance_monthly_report(report_sxw.rml_parse):

def __init__(self, cr, uid, name, context):
    super(attendance_monthly_report, self).__init__(cr, uid, name, context)

    self.localcontext.update({
        'time': time,
        'get_employee': self.get_employee,                    
        'get_periods': self.get_periods,            
    })

    self.context = context

def get_periods(self, form):
    self.mnths = []

Get start year-month-date and end year-month-date

    first_year = int(form['date_from'][0:4])
    last_year = int(form['date_to'][0:4])

    first_month = int(form['date_from'][5:7])
    last_month = int(form['date_to'][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(current_year, current_month, 1).strftime('%b')
        mnth_name.append(m)
        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):
    return self.pool.get('hr.employee').browse(self.cr,self.uid, form.get('employee_ids', []), context=self.context)

class report_custom(report_rml):

def create_xml(self, cr, uid, ids, datas, context=None):
    obj_emp = pooler.get_pool(cr.dbname).get('hr.employee')
    if context is None:
        context = {}
    month = datetime(datas['form']['year'], datas['form']['month'], 1)
    emp_ids = datas['active_ids']
    user_xml = ['<month>%s</month>' % _(month2name[month.month]), '<year>%s</year>' % month.year]
    if emp_ids:
        for emp in obj_emp.read(cr, uid, emp_ids, ['name']):
            stop, days_xml = False, []
            total_wh = 0.0
            user_repr = '''
            <user>
              <name>%s</name>
              %%s
            </user>
            ''' % (ustr(toxml(emp['name'])))
            today, tomor = month, month + one_day
            while today.month == month.month:
                #### Work hour calculation
                sql = '''
                select action, att.name
                from hr_employee as emp inner join hr_attendance as att
                     on emp.id = att.employee_id
                where att.name between %s and %s and emp.id = %s
                order by att.name
                '''
                cr.execute(sql, (today.strftime('%Y-%m-%d %H:%M:%S'), tomor.strftime('%Y-%m-%d %H:%M:%S'), emp['id']))
                attendences = cr.dictfetchall()
                wh = 0.0
                # Fake sign ins/outs at week ends, to take attendances across week ends into account
                if attendences and attendences[0]['action'] == 'sign_out':
                    attendences.insert(0, {'name': today.strftime('%Y-%m-%d %H:%M:%S'), 'action':'sign_in'})
                if attendences and attendences[-1]['action'] == 'sign_in':
                    attendences.append({'name': tomor.strftime('%Y-%m-%d %H:%M:%S'), 'action':'sign_out'})
                # sum up the attendances' durations
                ldt = None
                for att in attendences:
                    dt = datetime.strptime(att['name'], '%Y-%m-%d %H:%M:%S')
                    if ldt and att['action'] == 'sign_out':
                        if dt.date() > ldt.date():
                            dt = ldt
                        wh += (float((dt - ldt).seconds)/60/60)
                    else:
                        ldt = dt
                # Week xml representation
                total_wh += wh
                wh = hour2str(wh)
                today_xml = '<day num="%s"><wh>%s</wh></day>' % ((today - month).days+1, (wh))
                dy=(today - month).days+1
                days_xml.append(today_xml)
                today, tomor = tomor, tomor + one_day
            total_wh = hour2str(total_wh)
            today_xml = '<day num="Total"><wh>%s</wh></day>' % (total_wh)
            days_xml.append(today_xml)
            user_xml.append(user_repr % '\n'.join(days_xml))

    rpt_obj = pooler.get_pool(cr.dbname).get('hr.employee')
    rml_obj=report_sxw.rml_parse(cr, uid, rpt_obj._name,context)
    header_xml = '''
    <header>
    <date>%s</date>
    <company>%s</company>
    </header>
    ''' % (str(rml_obj.formatLang(time.strftime("%Y-%m-%d"),date=True))+' ' + str(time.strftime("%H:%M")),to_xml(pooler.get_pool(cr.dbname).get('res.users').browse(cr,uid,uid).company_id.name))

    first_date = str(month)
    som = datetime.strptime(first_date, '%Y-%m-%d %H:%M:%S')
    eom = som + timedelta(int(dy)-1)
    day_diff=eom-som
    date_xml=[]
    cell=1
    date_xml.append('<days>')
    if day_diff.days>=30:
        date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som.replace(day=x).strftime('%a')),x-som.day+1) for x in range(som.day, lengthmonth(som.year, som.month)+1)]
    else:
        if day_diff.days>=(lengthmonth(som.year, som.month)-som.day):
            date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som.replace(day=x).strftime('%a')),x-som.day+1) for x in range(som.day, lengthmonth(som.year, som.month)+1)]
        else:
            date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som.replace(day=x).strftime('%a')),x-som.day+1) for x in range(som.day, eom.day+1)]
    cell=x-som.day+1
    day_diff1=day_diff.days-cell+1
    width_dict={}
    month_dict={}
    i=1
    j=1
    year=som.year
    month=som.month
    month_dict[j]=som.strftime('%B')
    width_dict[j]=cell

    while day_diff1>0:
        if month+i<=12:
            if day_diff1 > lengthmonth(year,i+month): # Not on 30 else you have problems when entering 01-01-2009 for example
                som1=datetime.date(year,month+i,1)
                date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som1.replace(day=x).strftime('%a')),cell+x) for x in range(1, lengthmonth(year,i+month)+1)]
                i=i+1
                j=j+1
                month_dict[j]=som1.strftime('%B')
                cell=cell+x
                width_dict[j]=x
            else:
                som1=datetime.date(year,month+i,1)
                date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som1.replace(day=x).strftime('%a')),cell+x) for x in range(1, eom.day+1)]
                i=i+1
                j=j+1
                month_dict[j]=som1.strftime('%B')
                cell=cell+x
                width_dict[j]=x
            day_diff1=day_diff1-x
        else:
            years=year+1
            year=years
            month=0
            i=1
            if day_diff1>=30:
                som1=datetime.date(years,i,1)
                date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som1.replace(day=x).strftime('%a')),cell+x) for x in range(1, lengthmonth(years,i)+1)]
                i=i+1
                j=j+1
                month_dict[j]=som1.strftime('%B')
                cell=cell+x
                width_dict[j]=x
            else:
                som1=datetime.date(years,i,1)
                i=i+1
                j=j+1
                month_dict[j]=som1.strftime('%B')
                date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, _(som1.replace(day=x).strftime('%a')),cell+x) for x in range(1, eom.day+1)]
                cell=cell+x
                width_dict[j]=x
            day_diff1=day_diff1-x
    date_xml += ['<dayy name="Total" cell="Total"/>']
    date_xml.append('</days>')
    date_xml.append('<cols>3.5cm%s,1.2cm</cols>\n' % (',0.74cm' * (int(dy))))
    xml = '''<?xml version="1.0" encoding="UTF-8" ?>
    <report>
    %s
    <title>%s</title>
    %s
    %s
    </report>
    ''' % (header_xml,_('Daily Attendances by Month'),'\n'.join(user_xml),date_xml)
    return xml

report_sxw.report_sxw('report.employee.attendance.details.monthly', 'hr.attendence', 'addons/hr_attendance/report/report_hr_monthly_attendance_detail.rml', parser=attendance_monthly_report, header='internal') report_custom('report.details.monthly', 'hr.attendance', '', '' )

in my rml file

<?xml version="1.0"?>

<document filename="hr_monthly_attendance_report.pdf">

  <template pageSize="(842.0,595.0)" title="hr_monthly_attendance_report" author="Openerp S.A." allowSplitting="20">
    <pageTemplate id="first">
      <frame id="first" x1="28.0" y1="57.0" width="786" height="481"/>
    </pageTemplate>
  </template>
  <stylesheet>
    <blockTableStyle id="Standard_Outline">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
    </blockTableStyle>
    <blockTableStyle id="Table12">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
    </blockTableStyle>
    <blockTableStyle id="Table2">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
      <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="0,0" stop="0,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#cccccc" start="0,0" stop="0,0"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
      <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="1,0" stop="1,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#cccccc" start="1,0" stop="1,0"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
      <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="2,0" stop="2,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#cccccc" start="2,0" stop="2,0"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/>
      <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="3,0" stop="3,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#cccccc" start="3,0" stop="3,0"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/>
      <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="4,0" stop="4,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#cccccc" start="4,0" stop="4,0"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/>
      <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="5,0" stop="5,-1"/>
      <lineStyle kind="LINEAFTER" colorName="#cccccc" start="5,0" stop="5,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#cccccc" start="5,0" stop="5,0"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="5,-1" stop="5,-1"/>
    </blockTableStyle>
    <blockTableStyle id="Table3">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
      <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="0,0" stop="0,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#cccccc" start="0,0" stop="0,0"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
      <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="1,0" stop="1,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#cccccc" start="1,0" stop="1,0"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
      <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="2,0" stop="2,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#cccccc" start="2,0" stop="2,0"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/>
      <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="3,0" stop="3,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#cccccc" start="3,0" stop="3,0"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/>
      <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="4,0" stop="4,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#cccccc" start="4,0" stop="4,0"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/>
      <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="5,0" stop="5,-1"/>
      <lineStyle kind="LINEAFTER" colorName="#cccccc" start="5,0" stop="5,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#cccccc" start="5,0" stop="5,0"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="5,-1" stop="5,-1"/>
    </blockTableStyle>
    <blockTableStyle id="Table5">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
      <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="0,0" stop="0,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#cccccc" start="0,0" stop="0,0"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
      <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="1,0" stop="1,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#cccccc" start="1,0" stop="1,0"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
      <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="2,0" stop="2,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#cccccc" start="2,0" stop="2,0"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/>
      <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="3,0" stop="3,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#cccccc" start="3,0" stop="3,0"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/>
      <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="4,0" stop="4,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#cccccc" start="4,0" stop="4,0"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/>
      <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="5,0" stop="5,-1"/>
      <lineStyle kind="LINEAFTER" colorName="#cccccc" start="5,0" stop="5,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#cccccc" start="5,0" stop="5,0"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="5,-1" stop="5,-1"/>
    </blockTableStyle>
    <blockTableStyle id="Table4">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="0,0"/>
      <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/>
      <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="2,0" stop="2,0"/>
      <lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="3,0" stop="3,0"/>
      <lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="4,0" stop="4,0"/>
      <lineStyle kind="LINEBELOW" colorName="#000000" start="4,-1" stop="4,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="5,0" stop="5,0"/>
      <lineStyle kind="LINEBELOW" colorName="#000000" start="5,-1" stop="5,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="6,0" stop="6,0"/>
      <lineStyle kind="LINEBELOW" colorName="#000000" start="6,-1" stop="6,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="7,0" stop="7,0"/>
      <lineStyle kind="LINEBELOW" colorName="#000000" start="7,-1" stop="7,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="8,0" stop="8,0"/>
      <lineStyle kind="LINEBELOW" colorName="#000000" start="8,-1" stop="8,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="9,0" stop="9,0"/>
      <lineStyle kind="LINEBELOW" colorName="#000000" start="9,-1" stop="9,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="10,0" stop="10,0"/>
      <lineStyle kind="LINEBELOW" colorName="#000000" start="10,-1" stop="10,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="11,0" stop="11,0"/>
      <lineStyle kind="LINEBELOW" colorName="#000000" start="11,-1" stop="11,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="12,0" stop="12,0"/>
      <lineStyle kind="LINEBELOW" colorName="#000000" start="12,-1" stop="12,-1"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="13,0" stop="13,0"/>
      <lineStyle kind="LINEBELOW" colorName="#000000" start="13,-1" stop="13,-1"/>
    </blockTableStyle>
    <blockTableStyle id="Table7">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
    </blockTableStyle>
    <blockTableStyle id="Table6">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="5,-1" stop="5,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="6,-1" stop="6,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="7,-1" stop="7,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="8,-1" stop="8,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="9,-1" stop="9,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="10,-1" stop="10,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="11,-1" stop="11,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="12,-1" stop="12,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="13,-1" stop="13,-1"/>
    </blockTableStyle>
    <blockTableStyle id="Table10">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
    </blockTableStyle>
    <blockTableStyle id="Table8">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="5,-1" stop="5,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="6,-1" stop="6,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="7,-1" stop="7,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="8,-1" stop="8,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="9,-1" stop="9,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="10,-1" stop="10,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="11,-1" stop="11,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="12,-1" stop="12,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="13,-1" stop="13,-1"/>
    </blockTableStyle>
    <blockTableStyle id="Table11">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
    </blockTableStyle>
    <blockTableStyle id="Table9">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="5,-1" stop="5,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="6,-1" stop="6,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="7,-1" stop="7,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="8,-1" stop="8,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="9,-1" stop="9,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="10,-1" stop="10,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="11,-1" stop="11,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="12,-1" stop="12,-1"/>
      <lineStyle kind="LINEBELOW" colorName="#cccccc" start="13,-1" stop="13,-1"/>
    </blockTableStyle>
    <blockTableStyle id="Table1">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="0,0"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="2,0" stop="2,0"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="3,0" stop="3,0"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="4,0" stop="4,0"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="5,0" stop="5,0"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="6,0" stop="6,0"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="7,0" stop="7,0"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="8,0" stop="8,0"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="9,0" stop="9,0"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="10,0" stop="10,0"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="11,0" stop="11,0"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="12,0" stop="12,0"/>
      <lineStyle kind="LINEABOVE" colorName="#000000" start="13,0" stop="13,0"/>
    </blockTableStyle>
    <initialize>
      <paraStyle name="all" alignment="justify"/>
    </initialize>
    <paraStyle name="Standard" fontName="Helvetica"/>
    <paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
    <paraStyle name="Text body" fontName="Helvetica" fontSize="10.0" leading="13" spaceBefore="0.0" spaceAfter="6.0"/>
    <paraStyle name="List" fontName="Helvetica" fontSize="10.0" leading="13" spaceBefore="0.0" spaceAfter="6.0"/>
    <paraStyle name="Caption" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
    <paraStyle name="Index" fontName="Helvetica"/>
    <paraStyle name="Table Contents" fontName="Helvetica"/>
    <paraStyle name="Table Heading" fontName="Helvetica" alignment="CENTER"/>
    <paraStyle name="Drawing" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
    <paraStyle name="Header" fontName="Helvetica"/>
    <paraStyle name="Endnote" rightIndent="0.0" leftIndent="14.0" fontName="Helvetica" fontSize="10.0" leading="13"/>
    <paraStyle name="Addressee" fontName="Helvetica" spaceBefore="0.0" spaceAfter="3.0"/>
    <paraStyle name="Signature" fontName="Helvetica"/>
    <paraStyle name="Heading 9" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/>
    <paraStyle name="Heading 8" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/>
    <paraStyle name="Heading 7" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/>
    <paraStyle name="Heading 6" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/>
    <paraStyle name="Heading 5" fontName="Helvetica-Bold" fontSize="85%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/>
    <paraStyle name="Heading 4" fontName="Helvetica-BoldOblique" fontSize="85%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/>
    <paraStyle name="Heading 1" fontName="Helvetica-Bold" fontSize="115%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/>
    <paraStyle name="Heading 10" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/>
    <paraStyle name="Heading 2" fontName="Helvetica-BoldOblique" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
    <paraStyle name="First line indent" rightIndent="0.0" leftIndent="0.0" fontName="Helvetica" fontSize="10.0" leading="13" spaceBefore="0.0" spaceAfter="6.0"/>
    <paraStyle name="Hanging indent" rightIndent="0.0" leftIndent="28.0" fontName="Helvetica" fontSize="10.0" leading="13" spaceBefore="0.0" spaceAfter="6.0"/>
    <paraStyle name="Salutation" fontName="Helvetica"/>
    <paraStyle name="Text body indent" rightIndent="0.0" leftIndent="0.0" fontName="Helvetica" fontSize="10.0" leading="13" spaceBefore="0.0" spaceAfter="6.0"/>
    <paraStyle name="Heading 3" fontName="Helvetica-Bold" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
    <paraStyle name="List Indent" rightIndent="0.0" leftIndent="142.0" fontName="Helvetica" fontSize="10.0" leading="13" spaceBefore="0.0" spaceAfter="6.0"/>
    <paraStyle name="Marginalia" rightIndent="0.0" leftIndent="113.0" fontName="Helvetica" fontSize="10.0" leading="13" spaceBefore="0.0" spaceAfter="6.0"/>
    <paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
    <paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
    <paraStyle name="terp_default_Bold_8" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
    <paraStyle name="terp_default_Bold_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
    <paraStyle name="terp_default_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" 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_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
    <paraStyle name="terp_tblheader_Details" rightIndent="0.0" leftIndent="-3.0" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
    <paraStyle name="Footer" fontName="Helvetica"/>
    <paraStyle name="Horizontal Line" fontName="Helvetica" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/>
    <paraStyle name="terp_tblheader_General_Right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
    <paraStyle name="terp_tblheader_Details_Centre" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
    <paraStyle name="terp_tblheader_Details_Right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
    <paraStyle name="terp_default_Right_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
    <paraStyle name="terp_header_Right" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
    <paraStyle name="terp_default_address" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
    <paraStyle name="terp_default_Centre_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
    <paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
    <paraStyle name="terp_default_1" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" 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_8_Italic" fontName="Helvetica-Oblique" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
    <paraStyle name="terp_default_space" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="9.0" spaceAfter="0.0"/>
    <images/>
  </stylesheet>
  <story>
    <para style="terp_default_8">[[ repeatIn(get_employee(data['form']), 'o') ]] </para>
    <blockTable colWidths="785.0" style="Table12">
      <tr>
        <td>
          <para style="terp_default_Centre_9">From <u>[[ formatLang(data['form']['date_from'], date=True) ]]</u> To <u>[[ formatLang(data['form']['date_to'], date=True) ]]</u></para>
        </td>
      </tr>
    </blockTable>
    <para style="terp_default_Centre_9">
      <font color="white"> </font>
    </para>
    <blockTable colWidths="100.0,162.0,92.0,161.0,103.0,167.0" style="Table2">
      <tr>
        <td>
          <para style="terp_tblheader_Details">Employee Code</para>
        </td>
        <td>
          <para style="terp_default_9">[[ o.identification_id ]]</para>
        </td>
        <td>
          <para style="terp_tblheader_Details">Department</para>
        </td>
        <td>
          <para style="terp_default_9">[[ o.department_id and o.department_id.name or '' ]]</para>
        </td>
        <td>
          <para style="terp_tblheader_Details">Bank</para>
        </td>
        <td>
          <para style="terp_default_9">[[ o.bank_account_id and o.bank_account_id.bank.name or '' ]]</para>
        </td>
      </tr>
    </blockTable>
    <blockTable colWidths="100.0,162.0,92.0,161.0,103.0,167.0" style="Table3">
      <tr>
        <td>
          <para style="terp_tblheader_Details">Employee Name</para>
        </td>
        <td>
          <para style="terp_default_9">[[ o.name ]]</para>
        </td>
        <td>
          <para style="terp_tblheader_Details">Other No.</para>
        </td>
        <td>
          <para style="terp_default_9">[[ o.otherid or '' ]]</para>
        </td>
        <td>
          <para style="terp_tblheader_Details">Address</para>
        </td>
        <td>
          <para style="terp_default_9">[[o.address_home_id and o.address_home_id.name or '' ]]</para>
        </td>
      </tr>
    </blockTable>
    <blockTable colWidths="100.0,162.0,92.0,161.0,103.0,167.0" style="Table5">
      <tr>
        <td>
          <para style="terp_tblheader_Details">Designation</para>
        </td>
        <td>
          <para style="terp_default_9">[[ o.job_id and o.job_id.name or '' ]]</para>
        </td>
        <td>
          <para style="terp_tblheader_Details">Phone No.</para>
        </td>
        <td>
          <para style="terp_default_9">[[ o.work_phone or '' ]]</para>
        </td>
        <td>
          <para style="terp_tblheader_Details">E-mail Address</para>
        </td>
        <td>
          <para style="terp_default_9">[[o.work_email or '' ]]</para>
        </td>
      </tr>
    </blockTable>
    <para style="terp_default_space">
      <font color="white"> </font>
    </para>
    <section>
    <para style="terp_default_1">[[ repeatIn(get_periods(data['form']),'m') ]]</para>
      <para style="terp_default_1">[[ get_employee_detail((data['form']),o) ]]</para>
      <blockTable colWidths="195.0,46.0,46.0,46.0,46.0,46.0,46.0,46.0,46.0,46.0,46.0,46.0,46.0,56.0" style="Table4">
        <tr>
          <td>
            <para style="terp_tblheader_Details">Title</para>
          </td>
          <td>
            <para style="terp_tblheader_Details_Right">[[ m[0] != 'None' and m[0] or '' ]]</para>
          </td>
          <td>
            <para style="terp_tblheader_Details_Right">[[ m[1] != 'None' and m[1] or '' ]]</para>
          </td>
          <td>
            <para style="terp_tblheader_Details_Right">[[ m[2] != 'None' and m[2] or '' ]]</para>
          </td>
          <td>
            <para style="terp_tblheader_Details_Right">[[ m[3] != 'None' and m[3] or '' ]]</para>
          </td>
          <td>
            <para style="terp_tblheader_Details_Right">[[ m[4] != 'None' and m[4] or '' ]]</para>
          </td>
          <td>
            <para style="terp_tblheader_Details_Right">[[ m[5] != 'None' and m[5] or '' ]]</para>
          </td>
          <td>
            <para style="terp_tblheader_Details_Right">[[ m[6] != 'None' and m[6] or '' ]]</para>
          </td>
          <td>
            <para style="terp_tblheader_Details_Right">[[ m[7] != 'None' and m[7] or '' ]]</para>
          </td>
          <td>
            <para style="terp_tblheader_Details_Right">[[ m[8] != 'None' and m[8] or '' ]]</para>
          </td>
          <td>
            <para style="terp_tblheader_Details_Right">[[ m[9] != 'None' and m[9] or '' ]]</para>
          </td>
          <td>
            <para style="terp_tblheader_Details_Right">[[ m[10] != 'None' and m[10] or '' ]]</para>
          </td>
          <td>
            <para style="terp_tblheader_Details_Right">[[ m[11] != 'None' and m[11] or '' ]]</para>
          </td>
          <td>
            <para style="terp_tblheader_Details_Right">Total</para>
          </td>
        </tr>
      </blockTable>
      <para style="terp_default_1">
        <font color="white"> </font>
      </para>     
      <para style="terp_default_1">
        <font color="white"> </font>
      </para>
    </section>
    <para style="terp_default_9">
      <font color="white"> </font>
    </para>
  </story>
</document>

in .sxw file...

[[ repeatIn(get_employee(data['form']), 'o') ]]

Employees attendance Details From [[ formatLang(data['form']['date_from'], date=True) ]] To [[ formatLang(data['form']['date_to'], date=True) ]]

Employee Code [[ o.ssnid ]] Department [[ o.company_id and o.company_id.name or '' ]] Bank [[ o.otherid or '' ]] Employee Name [[ o.name ]] Other No. [[ o.otherid or '' ]] Address [[o.address_home_id and o.address_home_id.name or '' ]] Designation [[ o.contract_ids and o.contract_ids[0].job_id.name or '' ]] Phone No. [[ o.work_phone or '' ]] E-mail Address [[o.work_email or '' ]]

[[ repeatIn(get_periods(data['form']),'m') ]] [[ get_employee_detail(o) ]]

Title
[[ m[0] != 'None' and m[0] or ''  ]]
[[ m[1] != 'None' and m[1] or '' ]]
[[ m[2] != 'None' and m[2] or '' ]]
[[ m[3] != 'None' and m[3] or '' ]]
[[ m[4] != 'None' and m[4] or '' ]]
[[ m[5] != 'None' and m[5] or '' ]]
[[ m[6] != 'None' and m[6] or '' ]]
[[ m[7] != 'None' and m[7] or '' ]]
[[ m[8] != 'None' and m[8] or ''  ]]
[[ m[9] != 'None' and m[9] or ''  ]]
[[ m[10] != 'None' and m[10] or ''  ]]
[[ m[11] != 'None' and m[11] or '' ]]
Total

show me your report xml file.

Krupesh Laiya
on 2/21/14, 3:15 AM

Hi Krupesh laiya I update my question..

charlesraj
on 2/22/14, 1:43 AM
1
Krupesh Laiya
On 2/22/14, 7:00 AM

you have to create xml file for this report and put that file in your module directory code of xml file like below:

Note: put new xml file into __openerp__.py

       <?xml version="1.0" encoding="utf-8"?>
          <openerp>
           <data>
          <report auto="False" id="report_sale_order" model="sale.order" name="sale.order"
            rml="sale/report/sale_order.rml" string="Quotation / Order"
            usage="default"/>
  </data>
 </openerp>

Also change this code as per your regarding model name and change path of your rml file name.

Hope this will help you.!!

Hi ., by adding the xml this work. But when i click on the print button The following error will be displayed.. report.hr.attendance

(<type 'exceptions.KeyError'>, KeyError(u'report.hr.attendance',), <traceback object at 0xc511b94>)

charlesraj
on 2/24/14, 1:47 AM

your rml path is wrong either in .py file or xml file which you created at last.

Krupesh Laiya
on 2/24/14, 1:49 AM

Hi i checked the rml file path in xml file and .py file path is wright in both files. Any other way to solve this.

charlesraj
on 2/24/14, 3:07 AM

please checkout carefully one small mistake is there please checkout existing module like sale

Krupesh Laiya
on 2/24/14, 5:41 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 2/21/14, 12:57 AM
Seen: 2089 times
Last updated: 3/16/15, 8:10 AM