Browse Source

[ADD]:Initial Commit

pull/81/head
SHEREEF PT 8 years ago
parent
commit
281e969540
  1. 23
      timesheets_by_employee/__init__.py
  2. 41
      timesheets_by_employee/__openerp__.py
  3. 22
      timesheets_by_employee/report/__init__.py
  4. 84
      timesheets_by_employee/report/report_timesheets.py
  5. 73
      timesheets_by_employee/report/report_timesheets.xml
  6. BIN
      timesheets_by_employee/static/description/banner.jpg
  7. BIN
      timesheets_by_employee/static/description/cybro_logo.png
  8. BIN
      timesheets_by_employee/static/description/icon.png
  9. BIN
      timesheets_by_employee/static/description/image1.png
  10. BIN
      timesheets_by_employee/static/description/image2.png
  11. 53
      timesheets_by_employee/static/description/index.html
  12. 22
      timesheets_by_employee/wizard/__init__.py
  13. 41
      timesheets_by_employee/wizard/timesheet_employee.py
  14. 58
      timesheets_by_employee/wizard/timesheet_wizard.xml

23
timesheets_by_employee/__init__.py

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2009-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import report
import wizard

41
timesheets_by_employee/__openerp__.py

@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2009-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Timesheet PDF Report',
'version': '9.0.1.0.0',
'category': 'Human Resource',
'sequence': 25,
'summary': 'Timesheet PDF Report of Employee',
'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions',
'website': 'www.cybrosys.com',
'depends': ['hr_timesheet_sheet'],
'data': [
'report/report_timesheets.xml',
'wizard/timesheet_wizard.xml',
],
'images': ['static/description/banner.jpg'],
'license': 'AGPL-3',
'installable': True,
'auto_install': False,
'application': False,
}

22
timesheets_by_employee/report/__init__.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2009-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import report_timesheets

84
timesheets_by_employee/report/report_timesheets.py

@ -0,0 +1,84 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2009-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api
class ReportTimesheet(models.AbstractModel):
_name = 'report.timesheets_by_employee.report_timesheets'
def get_timesheets(self, docs):
"""input : name of employee and the starting date and ending date
output: timesheets by that particular employee within that period and the total duration"""
if docs.from_date and docs.to_date:
rec = self.env['account.analytic.line'].search([('user_id', '=', docs.employee[0].user_id.id),
('date', '>=', docs.from_date),('date', '<=', docs.to_date)])
elif docs.from_date:
rec = self.env['account.analytic.line'].search([('user_id', '=', docs.employee[0].user_id.id),
('date', '>=', docs.from_date)])
elif docs.to_date:
rec = self.env['account.analytic.line'].search([('user_id', '=', docs.employee[0].user_id.id),
('date', '<=', docs.to_date)])
else:
rec = self.env['account.analytic.line'].search([('user_id', '=', docs.employee[0].user_id.id)])
records = []
total = 0
for r in rec:
vals = {'project': r.account_id.name,
'user': r.user_id.partner_id.name,
'duration': r.unit_amount,
'date': r.date,
}
total += r.unit_amount
records.append(vals)
return [records, total]
@api.model
def render_html(self, docids, data=None):
"""we are overwriting this function because we need to show values from other models in the report
we pass the objects in the docargs dictionary"""
self.model = self.env.context.get('active_model')
docs = self.env[self.model].browse(self.env.context.get('active_id'))
identification = []
for i in self.env['hr.employee'].search([('user_id', '=', docs.employee[0].user_id.id)]):
if i:
identification.append({'id': i.identification_id, 'name': i.name_related})
timesheets = self.get_timesheets(docs)
period = None
if docs.from_date and docs.to_date:
period = "From " + str(docs.from_date) + " To " + str(docs.to_date)
elif docs.from_date:
period = "From " + str(docs.from_date)
elif docs.from_date:
period = " To " + str(docs.to_date)
docargs = {
'doc_ids': self.ids,
'doc_model': self.model,
'docs': docs,
'timesheets': timesheets[0],
'total': timesheets[1],
'company': docs.employee[0].company_id.name,
'identification': identification,
'period': period,
}
return self.env['report'].render('timesheets_by_employee.report_timesheets', docargs)

73
timesheets_by_employee/report/report_timesheets.xml

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<template id="report_timesheets">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<div class="page">
<t t-call="report.external_layout">
<div class="row">
<div class="mt32 mb32">
<table style="border:1px solid;width:100%;">
<thead>
<tr style="height:35px;border:1px solid">
<th style="vertical-align:middle;text-align:center;border:1px solid">Company Name</th>
<th style="vertical-align:middle;text-align:center;border:1px solid">Employee Number</th>
<th style="vertical-align:middle;text-align:center;border:1px solid">Employee Name</th>
</tr>
</thead>
<tbody>
<tr style="width:100%;height:30px;border:1px solid">
<td style="vertical-align:middle;text-align:center;border:1px solid"><span t-esc="company"/></td>
<th style="vertical-align:middle;text-align:center;border:1px solid"><span t-esc="identification[0]['id']"/></th>
<th style="vertical-align:middle;text-align:center;border:1px solid"><span t-esc="identification[0]['name']"/></th>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="mt32 mb32">
<table style="border:1px solid;width:100%;">
<thead>
<tr style="height:35px;border:1px solid">
<th style="vertical-align:middle;text-align:center;border:1px solid">Timesheet Period</th>
<th style="vertical-align:middle;text-align:center;border:1px solid">Total</th>
</tr>
</thead>
<tbody>
<tr style="height:35px;border:1px solid">
<td style="vertical-align:middle;text-align:center;border:1px solid"><span t-esc="period"/></td>
<td style="vertical-align:middle;text-align:center;border:1px solid"><span t-esc="total"/></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="mt32 mb32">
<table style="border:1px solid;width:100%;">
<thead>
<tr style="height:35px;border:1px solid">
<th style="vertical-align:middle;text-align:center;border:1px solid">Date</th>
<th style="vertical-align:middle;text-align:center;border:1px solid">Account</th>
<th style="vertical-align:middle;text-align:center;border:1px solid">Worked Time</th>
</tr>
</thead>
<tbody>
<tr t-foreach="timesheets" t-as="t" style="height:35px;border:1px solid">
<td style="vertical-align:middle;text-align:center;border:1px solid"><span t-esc="t['date']"/></td>
<td style="vertical-align:middle;text-align:center;border:1px solid"><span t-esc="t['project']"/></td>
<td style="vertical-align:middle;text-align:center;border:1px solid"><span t-esc="t['duration']"/></td>
</tr>
</tbody>
</table>
</div>
</div>
</t></div>
</t>
</t>
</template>
</openerp>

BIN
timesheets_by_employee/static/description/banner.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

BIN
timesheets_by_employee/static/description/cybro_logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
timesheets_by_employee/static/description/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

BIN
timesheets_by_employee/static/description/image1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

BIN
timesheets_by_employee/static/description/image2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

53
timesheets_by_employee/static/description/index.html

@ -0,0 +1,53 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">Timesheet PDF Report of Employee</h2>
<h3 class="oe_slogan">..Print timesheets of selected employees..</h3>
<h4 class="oe_slogan">Author : Cybrosys Techno Solutions , www.cybrosys.com</h4>
</div>
<div class="oe_row oe_spaced oe_dark">
<div>
<p class='oe_mt32'>
This module by Cybrosys Technologies allows to print the timesheets of selected employee. It will group all timesheet lines
of selected employee in wizard by period.
</p>
</div>
</div>
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h3 class="oe_slogan">Generate Timesheet Report Wizard With Dates:</h3>
<div>
<img class="oe_demo oe_picture oe_screenshot" src="image1.png">
</div>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h3 class="oe_slogan">PDF Report Of Employee Timesheet:</h3>
<div>
<img class="oe_demo oe_picture oe_screenshot" src="image2.png">
</div>
</div>
</div>
</section>
<section class="oe_container">
<h2 class="oe_slogan" style="margin-top:20px;" >Need Any Help?</h2>
<div class="oe_slogan" style="margin-top:10px !important;">
<a class="btn btn-primary btn-lg mt8"
style="color: #FFFFFF !important;" href="http://www.cybrosys.com"><i
class="fa fa-envelope"></i> Email </a> <a
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;"
href="http://www.cybrosys.com/contact/"><i
class="fa fa-phone"></i> Contact Us </a> <a
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;"
href="http://www.cybrosys.com/odoo-customization-and-installation/"><i
class="fa fa-check-square"></i> Request Customization </a>
</div>
<img src="cybro_logo.png" style="width: 190px; margin-bottom: 20px;" class="center-block">
</section>

22
timesheets_by_employee/wizard/__init__.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2009-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import timesheet_employee

41
timesheets_by_employee/wizard/timesheet_employee.py

@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2009-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api
class EmployeeTimesheet(models.TransientModel):
_name = 'timesheet.wizard'
employee = fields.Many2one('hr.employee', string="Employee", required=True)
from_date = fields.Date(string="Starting Date")
to_date = fields.Date(string="Ending Date")
@api.model
def print_timesheet(self, data):
"""Redirects to the report with the values obtained from the wizard
'data['form']': name of employee and the date duration"""
rec = self.browse(data)
data = {}
data['form'] = rec.read(['employee', 'from_date', 'to_date'])
return self.env['report'].get_action(self.browse(data), 'timesheets_by_employee.report_timesheets', data=data)

58
timesheets_by_employee/wizard/timesheet_wizard.xml

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8" ?>
<openerp>
<data>
<record id="timesheets_report_view" model="ir.ui.view">
<field name="name">Timesheets Wizard</field>
<field name="model">timesheet.wizard</field>
<field name="arch" type="xml">
<form>
<group>
<group string="Select Employee">
<div>
<label for="employee" string="Employee" />
<field name="employee"/>
</div>
</group>
<group>
<div>
<label for="from_date" string="Starting Date" />
<field name="from_date"/>
<label for="to_date" string="Ending Date" />
<field name="to_date"/>
</div>
</group>
<footer>
<button string="Print Timesheet" name="print_timesheet" type="object" class="btn-primary"/>
<button string="Discard" class="btn-default" special="cancel"/>
</footer>
</group>
</form>
</field>
</record>
<record id="action_print_timesheet_wizard" model="ir.actions.act_window">
<field name="name">Generate Timesheet Report</field>
<field name="res_model">timesheet.wizard</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="timesheets_report_view"/>
<field name="target">new</field>
</record>
<menuitem name="Print Timesheets" id="print_timesheets" action="action_print_timesheet_wizard" parent="hr_timesheet.menu_timesheets_reports"/>
<report
id="action_report_print_timesheets"
model="timesheet.wizard"
report_type="qweb-pdf"
string="Timesheets"
name="timesheets_by_employee.report_timesheets"
file="timesheets_by_employee.report_timesheets"
menu="False"
/>
</data>
</openerp>
Loading…
Cancel
Save