Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

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

Subscriure's

Get notified when there's activity on this post

This question has been flagged
2 Respostes
5539 Vistes
Avatar
charlesraj

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

0
Avatar
Descartar
Avatar
René Schuster
Best Answer

'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).

1
Avatar
Descartar
charlesraj
Autor

<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'

charlesraj
Autor

<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'

charlesraj
Autor

please explain what this mean KeyError: 'form'

René Schuster

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

charlesraj
Autor

how can i add this to the directory.

charlesraj
Autor

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

charlesraj
Autor

Here form is an object..

René Schuster

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

charlesraj
Autor

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

charlesraj
Autor

will u check my py file and .mako file

René Schuster

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

This call statement might use a parameter data or datas,

charlesraj
Autor

the py file and the .mako file...

Avatar
charlesraj
Autor Best Answer

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)
    self.localcontext.update({
        'time': time,
        'cr':cr,
        '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):
        res.append(employee_rec)
    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":
            days.append("F")
        else:
            days.append(i)
        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:
            att_type.append("F")
        elif attendance_type == "present":
            att_type.append("P")
        else:
            att_type.append("A")
        overtime.append(overtime_hrs)
    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; }

th{
    font-size: 15px;
    text-align: center; 
}

</style>

<% setLang('en_US') %>

</head>

<body>

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

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

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

<tr>
    <th>S/n.</th>
    <th>Name</th>
    <th>Designation</th>
    <th>Date</th>
    <%cnt = 0%> 
    %for i in get_days(data['form']['period_id']):
        %if i == "F":       
            <th style="background-color:grey;">${i}</th>
        %else:
            <th>${i}</th>           
        %endif
    <%cnt += 1%>
    %endfor
    <th>Total</th>  
</tr>

<%sr_no=0%>
%for emp in get_emp_data(data['form']['employee_ids']):
    <%sr_no+=1%>        
    <tr> 
        <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']:              
            <td>${att}</td>
        %endfor
        <td>${cnt}</td> 
    </tr>       
    <tr>        
        <%total = 0.0%>
        <td>Overtime</td>
        %for att in res['overtime']:                
            <%total += att%>                
            <td>${formatLang(att)}</td>
        %endfor
        <td>${total}</td>
    </tr>
%endfor

</table>

</body>

</html>

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

0
Avatar
Descartar
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now