Odoo Help


${get_month(data['form']['period_id'])} What the form means ?.

on 2/24/14, 6:20 AM 2,079 views

hi ..

Any one please explain what this line mean.,

Attendance Sheet for the month of ${get_month(data['form']['period_id'])} ..

This is a line in .mako file . I don't know what the form actually means in the code ${get_month(data['form']['period_id'])}

Can anyone please help. me..


René Schuster

--René Schuster--
| 5 5 8
Weinheim, Germany
--René Schuster--

Challenge Everything!

René Schuster
On 2/24/14, 7:12 AM

'form' is a keyword for the data dictionary.

This dictionary is commonly used when creating a report using a wizard.

Compare this http://help.openerp.com/question/22334/how-to-generate-a-report-from-a-wizard/ (related Question).

<th colspan="36" style="text-align: center; font-size: 20px;"> Attendance Sheet for the month of ${get_month(data['form']['period_id'])} </th> KeyError: 'form'

on 2/24/14, 7:49 AM

<th colspan="36" style="text-align: center; font-size: 20px;"> Attendance Sheet for the month of ${get_month(data['form']['period_id'])} </th> KeyError: 'form'

on 2/24/14, 7:50 AM

please explain what this mean KeyError: 'form'

on 2/24/14, 7:50 AM

KeyError means that the requested key is not in the dictionary. https://wiki.python.org/moin/KeyError

René Schuster
on 2/24/14, 8:01 AM

how can i add this to the directory.

on 2/24/14, 8:08 AM

I dont know how to add this into the directory please help me. What it actuall mean (form)..

on 2/24/14, 8:15 AM

Here form is an object..

on 2/24/14, 8:18 AM

Give more details to your question. What are you trying to do? When does the error occur? Have you edited/created modules or functionality?

René Schuster
on 2/24/14, 8:18 AM

Hi i add my .py file and .mako file please check..

on 2/24/14, 8:53 AM

will u check my py file and .mako file

on 2/25/14, 12:22 AM

Which code is actually triggering the report and using the .mako file?

This call statement might use a parameter data or datas,

René Schuster
on 2/25/14, 5:14 AM

the py file and the .mako file...

on 2/26/14, 1:05 AM
On 2/24/14, 8:52 AM

from openerp.osv import osv import pooler

class employee_attendance_webkit_report(report_sxw.rml_parse):

def __init__(self, cr, uid, name, context):
    super(employee_attendance_webkit_report, self).__init__(cr, uid, name, context=context)
        'time': time,
        'uid': uid,
        'get_month' : self.get_month,
        'get_emp_data' : self.get_emp_data,
        'get_days' : self.get_days,
        'get_emp_timesheet' : self.get_emp_timesheet,

def get_emp_data(self, emp_ids):
    res = []
    for employee_rec in self.pool.get('hr.employee').browse(self.cr, self.uid, emp_ids):
    return res

def get_month(self, id):
    acnt_rec = self.pool.get('account.period').browse(self.cr, self.uid, id)
    dt = acnt_rec.name
    dt = datetime.strptime(dt.__str__(),"%m/%Y")
    return datetime.strptime((dt.date().__str__()), "%Y-%m-%d").strftime("%B") + "-" + datetime.strptime((dt.date().__str__()), "%Y-%m-%d").strftime("%Y") 

def get_days(self, id):
    days = []
    acnt_rec = self.pool.get('account.period').browse(self.cr, self.uid, id)
    dt = (acnt_rec.name).__str__()
    month = int(datetime.strptime(dt,"%m/%Y").strftime("%m"))
    year = int(datetime.strptime(dt,"%m/%Y").strftime("%Y"))

    for i in range(1,monthrange(year, month)[1]+1):
        temp_dt = i.__str__() + "/" + dt
        if datetime.strptime(temp_dt,"%d/%m/%Y").strftime("%a") == "Fri":
        temp_dt = "" 
    return days

def get_emp_timesheet(self, emp_id, date_id):
    res = {}
    att_type = []
    overtime = []
    hr_analytic_timesheet_obj = self.pool.get('hr.analytic.timesheet')
    acnt_rec = self.pool.get('account.period').browse(self.cr, self.uid, date_id)
    dt = (acnt_rec.name).__str__()
    month = datetime.strptime(dt,"%m/%Y").strftime("%m")
    year = datetime.strptime(dt,"%m/%Y").strftime("%Y")
    self.cr.execute("""select id from hr_analytic_timesheet where employee_id=%s 
                        and to_char(timesheet_date, 'MM')='%s' and to_char(timesheet_date, 'YYYY')='%s'
                        order by timesheet_date"""%(emp_id, month, year))
    for r in self.cr.fetchall():
        rec = hr_analytic_timesheet_obj.browse(self.cr, self.uid, r[0])
        attendance_type = rec.att_type
        overtime_hrs = rec.overtime_hours
        if datetime.strptime(rec.timesheet_date,"%Y-%m-%d").strftime("%a") == "Fri" and overtime_hrs <= 0:
        elif attendance_type == "present":
    res.update({'attendance' : att_type, 'overtime': overtime})
    return res

report_sxw.report_sxw('report.webkit.emp_attendance', 'hr.attendance', 'hr_attendance/report/employee_attendance.mako', parser=employee_attendance_webkit_report)

In my .mako file.

<html> <%from datetime import date%>

<head> <style type="text/css"> td{ font-size: 15px; text-align: center; }

    font-size: 15px;
    text-align: center; 


<% setLang('en_US') %>



<table border="1" cellspacing="0">

    <th colspan="36" style="text-align: center; font-size: 25px;">New Line Group</th>   

    <th colspan="36" style="text-align: center; font-size: 20px;"> Attendance Sheet for the month of ${get_month(data['form']['period_id'])} </th> 

    <%cnt = 0%> 
    %for i in get_days(data['form']['period_id']):
        %if i == "F":       
            <th style="background-color:grey;">${i}</th>
    <%cnt += 1%>

%for emp in get_emp_data(data['form']['employee_ids']):
        <td rowspan="2">${sr_no}</td>           
        <td rowspan="2">${emp.name}</td> 
        <td rowspan="2">${emp.job_id.name}</td>
        <td> Attendance </td>   
        <%res = get_emp_timesheet(emp.id, data['form']['period_id'])%>
        %for att in res['attendance']:              
        <%total = 0.0%>
        %for att in res['overtime']:                
            <%total += att%>                




I need to generate a report for attendance report for employee this .mako file will generate the error.

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 2/24/14, 6:20 AM
Seen: 2079 times
Last updated: 3/16/15, 8:10 AM