Skip to content

Commit

Permalink
[ADD] website_hr_department
Browse files Browse the repository at this point in the history
New module to display the departments in the website
  • Loading branch information
lmignon committed Feb 26, 2015
1 parent 93c6535 commit f7e9ab1
Show file tree
Hide file tree
Showing 11 changed files with 462 additions and 0 deletions.
31 changes: 31 additions & 0 deletions website_hr_department/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Our Departments Page
====================

This module was written to extend the functionality of the website by adding
a new page displaying the departments. Departments can be displayed with or
without:

* A breadcrumb,
* The departments tree,
* The employees members of a department as a list or as a grid.

Credits
=======

Contributors
------------

* Laurent Mignon <[email protected]>

Maintainer
----------

.. image:: http://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

To contribute to this module, please visit http://odoo-community.org.
3 changes: 3 additions & 0 deletions website_hr_department/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import controllers
from . import models
43 changes: 43 additions & 0 deletions website_hr_department/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This file is part of website_hr_department, an Odoo module.
#
# Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)
#
# website_hr_department is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# website_hr_department 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 website_hr_department.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': "Departments Page",
'summary': """
Display the structure of your departments and their members.
""",
'author': "ACSONE SA/NV",
'website': "http://acsone.eu",
'category': 'Website',
'version': '0.1',
'license': 'AGPL-3',
'depends': [
'website_hr',
],
'data': [
'security/ir.model.access.csv',
'security/website_hr_department.xml',
'data/websiste_hr_department_data.xml',
'views/website_hr_department.xml',
],
}
58 changes: 58 additions & 0 deletions website_hr_department/controllers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This file is part of website_hr_department, an Odoo module.
#
# Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)
#
# website_hr_department is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# website_hr_department 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 website_hr_department.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from openerp import http
from openerp.addons.website_hr.controllers.main import website_hr


class WebsiteHr(website_hr):

@http.route(['/page/departments',
'/page/departments/<model("hr.department"):department>'
], type='http', auth="public", website=True)
def departments(self, department=None, **post):
request = http.request
hr_department = request.env['hr.department']
departments = hr_department.search([('parent_id', '=', False)])

hr_employee = request.env['hr.employee']
employees = []
breadcrumb = []
if department:
employees = hr_employee.search(
[('department_id', '=', department.id)])
breadcrumb.append(department)
parent = department.parent_id
while parent:
breadcrumb.append(parent)
parent = parent.parent_id
breadcrumb.reverse()
values = {
'employees': employees,
'departments': departments,
'department': department,
'breadcrumb': breadcrumb,
}
return request.website.render(
'website_hr_department.departments', values)
22 changes: 22 additions & 0 deletions website_hr_department/data/websiste_hr_department_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">

<record id="menu_departments" model="website.menu">
<field name="name">Departments</field>
<field name="url">/page/departments</field>
<field name="parent_id" ref="website.main_menu"/>
<field name="sequence" type="int">40</field>
</record>
<record id="action_open_website" model="ir.actions.act_url">
<field name="name">Website Departments</field>
<field name="target">self</field>
<field name="url">/page/departments</field>
</record>
<record id="base.open_menu" model="ir.actions.todo">
<field name="action_id" ref="action_open_website"/>
<field name="state">open</field>
</record>

</data>
</openerp>
33 changes: 33 additions & 0 deletions website_hr_department/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This file is part of website_hr_department, an Odoo module.
#
# Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)
#
# website_hr_department is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# website_hr_department 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 website_hr_department.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from openerp import models, fields


class hr_department(models.Model):
_inherit = 'hr.department'

website_published = fields.Boolean(
'Available in the website', copy=False, default=False)
public_info = fields.Html('Public Info')
2 changes: 2 additions & 0 deletions website_hr_department/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_hr_department_public,hr.department.public,hr.model_hr_department,base.group_public,1,0,0,0
15 changes: 15 additions & 0 deletions website_hr_department/security/website_hr_department.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="hr_department_public" model="ir.rule">
<field name="name">hr_department: Public</field>
<field name="model_id" ref="hr.model_hr_department"/>
<field name="domain_force">[('website_published', '=', True)]</field>
<field name="groups" eval="[(4, ref('base.group_public'))]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
</record>
</data>
</openerp>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 84 additions & 0 deletions website_hr_department/static/src/css/website_hr_department.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
.employees h2 {
text-align: center;
}

/* ---- Employees grid styles---- */
.employee.oe_grid {
text-align: center;
}

.employee.oe_grid .employee_image img{
display: inline;
}

/* ---- Employees list styles ---- */
.employee.oe_list {
border: 1px solid rgba(100, 100, 100, 0.2);
}

.employee.oe_list {
position: relative;
}
.employee.oe_list .employee_image {
position: absolute;
left: 15px;
right: 15px;
top: 15px;
bottom: 55px;
text-align: center;
}
.employee.oe_list .employee_image img {
max-width: 100%;
max-height: 100%;
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: 4;
}
.employee.oe_list section {
position: absolute;
left: 0;
right: 0;
bottom: 0;
overflow: hidden;
padding: 0 15px 24px 10px;
min-height: 56px;
border-top: 1px solid rgba(255, 255, 255, 0.2);
background: rgba(255, 255, 255, 0.75);
z-index: 5;
}

.employee.oe_list .oe_subdescription {
font-size: 0.8em;
overflow: hidden;
margin-bottom: 10px;
}

@media (min-width: 400px) {
.employee.oe_list {
border: none;
border-bottom: 1px solid rgba(100, 100, 100, 0.2);
width: 100%;
min-height: 100px;
position: relative;
padding-bottom: 5px;
}
.employee.oe_list .employee_image {
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 170px;
}
.employee.oe_list section {
position: relative;
border: 0;
top: 0;
bottom: auto;
left: 180px;
background: transparent;
}
}
Loading

0 comments on commit f7e9ab1

Please sign in to comment.