Browse Source

[ADD] Initial Commit

pull/90/head
Sreejith P 7 years ago
parent
commit
19bd24a89d
  1. 42
      employee_vehicle_request/README.rst
  2. 23
      employee_vehicle_request/__init__.py
  3. 46
      employee_vehicle_request/__manifest__.py
  4. 17
      employee_vehicle_request/data/data.xml
  5. 3
      employee_vehicle_request/models/__init__.py
  6. 157
      employee_vehicle_request/models/employee_fleet.py
  7. 7
      employee_vehicle_request/security/ir.model.access.csv
  8. 11
      employee_vehicle_request/security/security.xml
  9. BIN
      employee_vehicle_request/static/description/banner.jpg
  10. BIN
      employee_vehicle_request/static/description/cybro_logo.png
  11. BIN
      employee_vehicle_request/static/description/icon.png
  12. 118
      employee_vehicle_request/static/description/index.html
  13. BIN
      employee_vehicle_request/static/description/validation1.png
  14. BIN
      employee_vehicle_request/static/description/validation2.png
  15. BIN
      employee_vehicle_request/static/description/vehicle1.png
  16. BIN
      employee_vehicle_request/static/description/vehicle2.png
  17. 119
      employee_vehicle_request/views/employee_fleet_view.xml

42
employee_vehicle_request/README.rst

@ -0,0 +1,42 @@
Employee Vehicle Request v11
============================
* Manage Vehicle Requests From Employee
Depends
=======
[base] addon Odoo
[hr] addon Odoo
[fleet] addon Odoo
Tech
====
* [Python] - Models
* [XML] - Odoo views
Installation
============
- www.odoo.com/documentation/11.0/setup/install.html
- Install our custom addon
License
=======
GNU Affero General Public License
(http://www.gnu.org/licenses/agpl.html)
Bug Tracker
===========
Contact odoo@cybrosys.com
Authors
-------
* Developer: Nilmar Shereef @ Cybrosys
* Developer v11: Niyas Raphy @ Cybrosys
Maintainer
----------
This module is maintained by Cybrosys Technologies.
For support and more information, please visit https://www.cybrosys.com.

23
employee_vehicle_request/__init__.py

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2018-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# This program is free software: you can modify
# it under the terms of the GNU Affero General Public License (AGPL) as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
##############################################################################
from . import models

46
employee_vehicle_request/__manifest__.py

@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2018-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# This program is free software: you can modify
# it under the terms of the GNU Affero General Public License (AGPL) as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Employee Vehicle Request',
'version': '11.0.1.0.0',
'summary': """Manage Vehicle Requests From Employee""",
'description': """This module is used for manage vehicle requests from employee.
This module also checking the vehicle availability at the requested time slot.""",
'category': "Generic Modules/Human Resources",
'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions',
'website': "https://www.cybrosys.com",
'depends': ['base', 'hr', 'fleet'],
'data': [
'data/data.xml',
'security/security.xml',
'security/ir.model.access.csv',
'views/employee_fleet_view.xml',
],
'images': ['static/description/banner.jpg'],
'license': 'AGPL-3',
'demo': [],
'installable': True,
'auto_install': False,
'application': False,
}

17
employee_vehicle_request/data/data.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="fleet.fleet_rule_vehicle_visibility_user" model="ir.rule">
<field name="name">User can only see his/her vehicle</field>
<field name="model_id" ref="fleet.model_fleet_vehicle"/>
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_unlink" eval="False"/>
<field name="domain_force">[]</field>
</record>
</data>
</odoo>

3
employee_vehicle_request/models/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import employee_fleet

157
employee_vehicle_request/models/employee_fleet.py

@ -0,0 +1,157 @@
# -*- coding: utf-8 -*-
from datetime import datetime
from odoo import models, fields, api, _
from odoo.exceptions import Warning
class FleetReservedTime(models.Model):
_name = "fleet.reserved"
_description = "Reserved Time"
employee = fields.Many2one('hr.employee', string='Employee')
date_from = fields.Datetime(string='Reserved Date From')
date_to = fields.Datetime(string='Reserved Date To')
reserved_obj = fields.Many2one('fleet.vehicle')
class FleetVehicleInherit(models.Model):
_inherit = 'fleet.vehicle'
check_availability = fields.Boolean(default=True, copy=False)
reserved_time = fields.One2many('fleet.reserved', 'reserved_obj', String='Reserved Time', readonly=1,
ondelete='cascade')
class EmployeeFleet(models.Model):
_name = 'employee.fleet'
_description = 'Employee Vehicle Request'
_inherit = 'mail.thread'
@api.model
def create(self, vals):
vals['name'] = self.env['ir.sequence'].next_by_code('employee.fleet')
return super(EmployeeFleet, self).create(vals)
@api.multi
def send(self):
fleet_obj = self.env['fleet.vehicle'].search([])
check_availability = 0
for i in fleet_obj:
for each in i.reserved_time:
if each.date_from <= self.date_from <= each.date_to:
check_availability = 1
elif self.date_from < each.date_from:
if each.date_from <= self.date_to <= each.date_to:
check_availability = 1
elif self.date_to > each.date_to:
check_availability = 1
else:
check_availability = 0
else:
check_availability = 0
if check_availability == 0:
reserved_id = self.fleet.reserved_time.create({'employee': self.employee.id,
'date_from': self.date_from,
'date_to': self.date_to,
'reserved_obj': self.fleet.id,
})
self.write({'reserved_fleet_id': reserved_id.id})
self.state = 'waiting'
else:
raise Warning('Sorry This vehicle is already requested by another employee')
@api.multi
def approve(self):
self.fleet.fleet_status = True
self.state = 'confirm'
mail_content = _('Hi %s,<br>Your vehicle request for the reference %s is approved.') % \
(self.employee.name, self.name)
main_content = {
'subject': _('%s: Approved') % self.name,
'author_id': self.env.user.partner_id.id,
'body_html': mail_content,
'email_to': self.employee.work_email,
}
mail_id = self.env['mail.mail'].create(main_content)
mail_id.mail_message_id.body = mail_content
mail_id.send()
if self.employee.user_id:
mail_id.mail_message_id.write({'needaction_partner_ids': [(4, self.employee.user_id.partner_id.id)]})
mail_id.mail_message_id.write({'partner_ids': [(4, self.employee.user_id.partner_id.id)]})
@api.multi
def reject(self):
self.reserved_fleet_id.unlink()
self.state = 'reject'
mail_content = _('Hi %s,<br>Sorry, Your vehicle request for the reference %s is Rejected.') % \
(self.employee.name, self.name)
main_content = {
'subject': _('%s: Approved') % self.name,
'author_id': self.env.user.partner_id.id,
'body_html': mail_content,
'email_to': self.employee.work_email,
}
mail_id = self.env['mail.mail'].create(main_content)
mail_id.mail_message_id.body = mail_content
mail_id.send()
if self.employee.user_id:
mail_id.mail_message_id.write({'needaction_partner_ids': [(4, self.employee.user_id.partner_id.id)]})
mail_id.mail_message_id.write({'partner_ids': [(4, self.employee.user_id.partner_id.id)]})
@api.multi
def cancel(self):
if self.reserved_fleet_id:
self.reserved_fleet_id.unlink()
self.state = 'cancel'
@api.multi
def returned(self):
self.reserved_fleet_id.unlink()
self.returned_date = fields.datetime.now()
self.state = 'return'
@api.constrains('date_rom', 'date_to')
def onchange_date_to(self):
for each in self:
if each.date_from > each.date_to:
raise Warning('Date To must be greater than Date From')
@api.onchange('date_from', 'date_to')
def check_availability(self):
self.fleet = ''
fleet_obj = self.env['fleet.vehicle'].search([])
for i in fleet_obj:
for each in i.reserved_time:
if each.date_from <= self.date_from <= each.date_to:
i.write({'check_availability': False})
elif self.date_from < each.date_from:
if each.date_from <= self.date_to <= each.date_to:
i.write({'check_availability': False})
elif self.date_to > each.date_to:
i.write({'check_availability': False})
else:
i.write({'check_availability': True})
else:
i.write({'check_availability': True})
reserved_fleet_id = fields.Many2one('fleet.reserved', invisible=1, copy=False)
name = fields.Char(string='Request Number', copy=False)
employee = fields.Many2one('hr.employee', string='Employee', required=1, readonly=True,
states={'draft': [('readonly', False)]})
req_date = fields.Date(string='Requested Date', default=datetime.now(), required=1, readonly=True,
states={'draft': [('readonly', False)]}, help="Requested Date")
fleet = fields.Many2one('fleet.vehicle', string='Vehicle', required=1, readonly=True,
states={'draft': [('readonly', False)]})
date_from = fields.Datetime(string='From', required=1, readonly=True,
states={'draft': [('readonly', False)]})
date_to = fields.Datetime(string='To', required=1, readonly=True,
states={'draft': [('readonly', False)]})
returned_date = fields.Datetime(string='Returned Date', readonly=1)
purpose = fields.Text(string='Purpose', required=1, readonly=True,
states={'draft': [('readonly', False)]}, help="Purpose")
state = fields.Selection([('draft', 'Draft'), ('waiting', 'Waiting for Approval'), ('cancel', 'Cancel'),
('confirm', 'Approved'), ('reject', 'Rejected'), ('return', 'Returned')],
string="State", default="draft")

7
employee_vehicle_request/security/ir.model.access.csv

@ -0,0 +1,7 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_fleet_reserved_employee,access.fleet.reserved.employee,model_fleet_reserved,base.group_user,1,1,1,0
access_fleet_reserved_hr,access.fleet.reserved.hr,model_fleet_reserved,hr.group_hr_manager,1,1,1,1
access_fleet_reserved_hr_user,access.fleet.reserved.hr.user,model_fleet_reserved,hr.group_hr_user,1,1,1,0
access_employee_fleet_employee,access.employee.fleet.employee,model_employee_fleet,base.group_user,1,1,1,0
access_employee_fleet_hr,access.employee.fleet.hr,model_employee_fleet,hr.group_hr_manager,1,1,1,1
access_employee_fleet_hr_user,access.employee.fleet.hr.user,model_employee_fleet,hr.group_hr_user,1,1,1,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_fleet_reserved_employee access.fleet.reserved.employee model_fleet_reserved base.group_user 1 1 1 0
3 access_fleet_reserved_hr access.fleet.reserved.hr model_fleet_reserved hr.group_hr_manager 1 1 1 1
4 access_fleet_reserved_hr_user access.fleet.reserved.hr.user model_fleet_reserved hr.group_hr_user 1 1 1 0
5 access_employee_fleet_employee access.employee.fleet.employee model_employee_fleet base.group_user 1 1 1 0
6 access_employee_fleet_hr access.employee.fleet.hr model_employee_fleet hr.group_hr_manager 1 1 1 1
7 access_employee_fleet_hr_user access.employee.fleet.hr.user model_employee_fleet hr.group_hr_user 1 1 1 0

11
employee_vehicle_request/security/security.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record model="res.groups" id="base.group_user">
<field name="implied_ids" eval="[(4, ref('fleet.fleet_group_user'))]"/>
</record>
<record model="res.groups" id="hr.group_hr_manager">
<field name="implied_ids" eval="[(4, ref('fleet.fleet_group_manager'))]"/>
</record>
</data>
</odoo>

BIN
employee_vehicle_request/static/description/banner.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

BIN
employee_vehicle_request/static/description/cybro_logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
employee_vehicle_request/static/description/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

118
employee_vehicle_request/static/description/index.html

@ -0,0 +1,118 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">Employee Vehicle Request</h2>
<h3 class="oe_slogan">This Module Helps You To Manage Vehicle Requests From Employee</h3>
<h4 class="oe_slogan"><a href="https://www.cybrosys.com">Cybrosys Technologies</a> </h4>
</div>
<div class="oe_row oe_spaced" style="padding-left:65px;">
<h4>Features:</h4>
<div>
<span style="color:green;"> &#9745; </span> Employee can request for any vehicle.<br/>
<span style="color:green;"> &#9745; </span> Checking availability of vehicles.<br/>
<span style="color:green;"> &#9745; </span> Validation for send request.<br/>
<span style="color:green;"> &#9745; </span> Validation for requested dates.<br/>
<span style="color:green;"> &#9745; </span> Advanced search view.<br/>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_picture">
<h3 class="oe_slogan">Overview</h3>
<p class="oe_mt32" style="text-align: center;">
This module is used to manage vehicle requests from each employee. According to this module
two employees can't request the same vehicle at same time. Because this module will check
the vehicle availability. Also this module gives the validation for send request and requested dates.
</p>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h3 class="oe_slogan">Vehicle Request</h3>
<div style="text-align: center">
<p>
<h4>Employee -> Vehicle Request -> Vehicle Request</h4>
<p>
</div>
<div style="text-align: center">
<a href="https://www.cybrosys.com">
<div class="oe_demo oe_picture oe_screenshot">
<img style="border:10px solid white;height: 400px;" src="vehicle1.png">
</div>
</a>
<span style="text-align: center;padding-left:65px;">&#9755; Here any employee can request available vehicle for a time period.
He should mention the time period and purpose. Then he can send this request to hr manager. Here also
module checking the availability of vehicle.</span>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<h3 class="oe_slogan">Approval</h3>
<div class="" style="text-align: center">
<div class="oe_demo oe_picture oe_screenshot">
<img style="border:10px solid white;height: 400px;" src="vehicle2.png">
</div>
</div>
<br>
<div class="" style="text-align: center">
<div class="" style="text-align: center;padding-left:65px;">
<p>
Here Hr Manager can approve the vehicle request. Or she can refuse the request. Also Employee
can cancel this request from this stage before approval or rejection.
<p>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h3 class="oe_slogan">Validation Messages</h3>
<div style="text-align: center">
<div class="oe_demo oe_picture oe_screenshot">
<img style="border:10px solid white;" src="validation1.png">
</div>
<span style="text-align: center">&#9755; Requested Period Validation</span>
</div>
<div style="text-align: center">
<div class="oe_demo oe_picture oe_screenshot">
<img style="border:10px solid white;" src="validation2.png">
</div>
<span style="text-align: center">&#9755;Checking the availability of vehicle</span>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<h2 class="oe_slogan" style="margin-top:20px;" >Need Any Help?</h2>
<div class="oe_slogan" style="margin-top:10px !important;">
<div>
<a class="btn btn-primary btn-lg mt8"
style="color: #FFFFFF !important;border-radius: 0;" href="https://www.cybrosys.com"><i
class="fa fa-envelope"></i> Email </a> <a
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;"
href="https://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;border-radius: 0;"
href="https://www.cybrosys.com/odoo-customization-and-installation/"><i
class="fa fa-check-square"></i> Request Customization </a>
</div>
<br>
<img src="cybro_logo.png" style="width: 190px; margin-bottom: 20px;" class="center-block">
<div>
<a href="https://twitter.com/cybrosys" target="_blank"><i class="fa fa-2x fa-twitter" style="color:white;background: #00a0d1;width:35px;"></i></a></td>
<a href="https://www.linkedin.com/company/cybrosys-technologies-pvt-ltd" target="_blank"><i class="fa fa-2x fa-linkedin" style="color:white;background: #31a3d6;width:35px;padding-left: 3px;"></i></a></td>
<a href="https://www.facebook.com/cybrosystechnologies" target="_blank"><i class="fa fa-2x fa-facebook" style="color:white;background: #3b5998;width:35px;padding-left: 8px;"></i></a></td>
<a href="https://plus.google.com/106641282743045431892/about" target="_blank"><i class="fa fa-2x fa-google-plus" style="color:white;background: #c53c2c;width:35px;padding-left: 3px;"></i></a></td>
<a href="https://in.pinterest.com/cybrosys" target="_blank"><i class="fa fa-2x fa-pinterest" style="color:white;background: #ac0f18;width:35px;padding-left: 3px;"></i></a></td>
</div>
</div>
</section>

BIN
employee_vehicle_request/static/description/validation1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

BIN
employee_vehicle_request/static/description/validation2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

BIN
employee_vehicle_request/static/description/vehicle1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

BIN
employee_vehicle_request/static/description/vehicle2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

119
employee_vehicle_request/views/employee_fleet_view.xml

@ -0,0 +1,119 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="sequence_employee_fleet" model="ir.sequence">
<field name="name">Vehicle Request Code</field>
<field name="code">employee.fleet</field>
<field eval="4" name="padding" />
<field name="prefix">VR</field>
</record>
<record model="ir.ui.view" id="fleet_vehicle_inherit_form_view">
<field name="name">fleet.vehicle.form.inherit.view</field>
<field name="model">fleet.vehicle</field>
<field name="inherit_id" ref="fleet.fleet_vehicle_view_form"/>
<field name="arch" type="xml">
<field name="car_value" position="after">
<field name="check_availability" invisible="1"/>
<field name="reserved_time" invisible="1"/>
</field>
</field>
</record>
<record model='ir.ui.view' id='employee_fleet_form_view'>
<field name="name">employee.fleet.form</field>
<field name="model">employee.fleet</field>
<field name="arch" type="xml">
<form string="Employee Fleet Request">
<header>
<button name='send' string="Send Request" type="object" class='oe_highlight' states="draft"/>
<button name='approve' string="Approve" type="object" class='oe_highlight'
states="waiting" groups="hr.group_hr_manager,hr.group_hr_user"/>
<button name='reject' string="Reject" type="object" states="waiting" groups="hr.group_hr_manager,hr.group_hr_user"/>
<button name='cancel' string="Cancel" type="object" states="draft,waiting"/>
<button name='returned' string="Return" type="object" class='oe_highlight'
states="confirm" groups="hr.group_hr_manager,hr.group_hr_user"/>
<field name="state" widget="statusbar" statusbar_visible="draft,waiting,confirm,return"/>
</header>
<sheet>
<h1>
<field name="name" readonly="1"/>
</h1>
<group>
<group>
<field name="employee" options="{'no_create': True}"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="returned_date" attrs="{'invisible': [('state','!=','return')]}"/>
</group>
<group>
<field name="req_date"/>
<field name="fleet" domain="[('check_availability','=',True)]" options="{'no_create': True}"/>
<field name="purpose"/>
</group>
</group>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
</field>
</record>
<record model='ir.ui.view' id='employee_fleet_tree_view'>
<field name="name">employee.fleet.tree</field>
<field name="model">employee.fleet</field>
<field name="arch" type="xml">
<tree decoration-info="state == 'draft'" colors="grey:state == 'cancel';green:state == 'confirm';
red:state == 'reject';grey:state == 'return';">
<field name="name"/>
<field name="employee"/>
<field name="fleet"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="state"/>
</tree>
</field>
</record>
<record model='ir.ui.view' id='employee_fleet_search_view'>
<field name="name">employee.fleet.search</field>
<field name="model">employee.fleet</field>
<field name="arch" type="xml">
<search string="Custody">
<field name="name"/>
<field name="employee"/>
<field name="fleet"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="state"/>
<separator/>
<group expand="0" string="Group By">
<filter string="Status" domain="[]" context="{'group_by':'state'}"/>
<filter string="Employee" domain="[]" context="{'group_by':'employee'}"/>
<filter string="Vehicle" domain="[]" context="{'group_by':'fleet'}"/>
</group>
</search>
</field>
</record>
<record id="action_employee_fleet" model="ir.actions.act_window">
<field name="name">Vehicle Request</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">employee.fleet</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="employee_fleet_search_view"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a New Vehicle Request.
</p>
</field>
</record>
<menuitem id="employee_fleet_menu" name="Vehicle Request" parent="hr.menu_hr_root" sequence="4"/>
<menuitem id="employee_fleet_sub_menu" name="Vehicle Request" parent="employee_fleet_menu" sequence="1"
action="action_employee_fleet"/>
</data>
</odoo>
Loading…
Cancel
Save