Commit 458f8fcf authored by Edward Lim's avatar Edward Lim

Added addon module files

parents
Pipeline #150 failed with stages
Custom Backend Theme
=====================
This is a customized Backend Theme.
Credits
=======
Contributors
------------
* Edward Allen L. Lim <e@eal.im>
# -*- encoding: utf-8 -*-
import controllers
\ No newline at end of file
# -*- encoding: utf-8 -*-
{
# Module information
'name': 'Responsive Backend Theme',
'sequence': -4,
'version': '3.0',
'category': 'Themes/Backend',
# Your information
'author': 'Edward Allen L. Lim',
'website': 'e@eal.im',
'license': 'AGPL-3',
'summary': 'Responsive Backend Theme',
'images': [
'images/screen.png'
],
# Dependencies
'depends': [
'web',
],
# Views templates, pages, menus, options and snippets
'data': [
'views/backend.xml',
],
# Qweb templates
'qweb': [
'static/src/xml/backend.xml',
],
# Technical options
'installable': True,
'auto_install': True,
}
# -*- coding: utf-8 -*-
from . import main
# -*- coding: utf-8 -*-
import functools
import jinja2
import logging
import os
import simplejson
import sys
import werkzeug.utils
import werkzeug.wrappers
try:
import xlwt
except ImportError:
xlwt = None
import openerp
import openerp.modules.registry
from openerp.addons.web.controllers.main import Database
from openerp.tools import topological_sort
from openerp import http
from openerp.http import request, serialize_exception as _serialize_exception
_logger = logging.getLogger(__name__)
if hasattr(sys, 'frozen'):
# When running on compiled windows binary, we don't have access to package loader.
path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'views'))
loader = jinja2.FileSystemLoader(path)
else:
loader = jinja2.PackageLoader('openerp.addons.responsive_backend_theme', "views")
env = jinja2.Environment(loader=loader, autoescape=True)
env.filters["json"] = simplejson.dumps
# 1 week cache for asset bundles as advised by Google Page Speed
BUNDLE_MAXAGE = 60 * 60 * 24 * 7
#----------------------------------------------------------
# OpenERP Web helpers
#----------------------------------------------------------
db_list = http.db_list
db_monodb = http.db_monodb
def serialize_exception(f):
@functools.wraps(f)
def wrap(*args, **kwargs):
try:
return f(*args, **kwargs)
except Exception, e:
_logger.exception("An exception occured during an http request")
se = _serialize_exception(e)
error = {
'code': 200,
'message': "ERP Server Error",
'data': se
}
return werkzeug.exceptions.InternalServerError(simplejson.dumps(error))
return wrap
def module_boot(db=None):
server_wide_modules = openerp.conf.server_wide_modules or ['web']
serverside = []
dbside = []
for i in server_wide_modules:
if i in http.addons_manifest:
serverside.append(i)
monodb = db or db_monodb()
if monodb:
dbside = module_installed_bypass_session(monodb)
dbside = [i for i in dbside if i not in serverside]
addons = serverside + dbside
return addons
def module_installed_bypass_session(dbname):
loadable = http.addons_manifest.keys()
modules = {}
try:
registry = openerp.modules.registry.RegistryManager.get(dbname)
with registry.cursor() as cr:
m = registry.get('ir.module.module')
# TODO The following code should move to ir.module.module.list_installed_modules()
domain = [('state','=','installed'), ('name','in', loadable)]
ids = m.search(cr, 1, [('state','=','installed'), ('name','in', loadable)])
for module in m.read(cr, 1, ids, ['name', 'dependencies_id']):
modules[module['name']] = []
deps = module.get('dependencies_id')
if deps:
deps_read = registry.get('ir.module.module.dependency').read(cr, 1, deps, ['name'])
dependencies = [i['name'] for i in deps_read]
modules[module['name']] = dependencies
except:
pass
sorted_modules = topological_sort(modules)
return sorted_modules
class DatabaseBackend(Database):
@http.route('/web/database/selector', type='http', auth="none")
def selector(self, **kw):
try:
dbs = http.db_list()
if not dbs:
return http.local_redirect('/web/database/manager')
except openerp.exceptions.AccessDenied:
dbs = False
return env.get_template("database_selector_backend.html").render({
'databases': dbs,
'debug': request.debug,
'error': kw.get('error')
})
@http.route('/web/database/manager', type='http', auth="none")
def manager(self, **kw):
print("OKAY")
# TODO: migrate the webclient's database manager to server side views
request.session.logout()
return env.get_template("database_manager_backend.html").render({
'modules': simplejson.dumps(module_boot()),
})
<section class="oe_container">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan" style="color:#875A7B;">Responsive Backend Theme</h2>
<div class="oe_demo oe_picture oe_screenshot">
<img src="screen.png">
</div>
<div>
<div class="oe_demo oe_picture oe_screenshot">
<img src="apps.png">
</div>
<div>
<div class="oe_demo oe_picture oe_screenshot">
<img src="treesale.png">
</div>
<div>
<div class="oe_demo oe_picture oe_screenshot">
<img src="formsale.png">
</div>
</div>
</div>
</section>
<section class="oe_container oe_separator">
</section>
<section class="oe_container oe_dark">
<div class="oe_row">
<div class="oe_span12 oe_centeralign">
<br/>
<h3>Help & Support</h3>
<br/> Contact: <a href="e@eal.im" subject="Responsive Backend Theme">Email Support</a><br/>
<br/>
</div>
</div>
</section>
/*
# -*- encoding: utf-8 -*-
/* Extra small devices (phones, less than 768px) */
/* No media query since this is the default in Bootstrap */
/* PRIMARY COLOR: #875A7B*/
/* SOCONDARY COLOR: #593e52*/
/* BUTTON COLOR: #3a9630*/
/* BUTTON COLOR HOVER: #6fc765*/
.openerp .oe_form_sheet_width {
max-width: 95%;
}
.openerp .oe_leftbar {
background-color: #fff;
border-right: 1px solid #D1D1D1;
}
#oe_main_menu_navbar .oe_systray #oe_topbar_imbutton_icon,
#oe_main_menu_navbar .oe_systray #oe_attendance_sign_in_out_icon {
color: white;
}
.openerp .oe_form header,
.openerp .oe_view_manager_current > .oe_view_manager_header {
border-bottom: 1px solid #D1D1D1;
background: #d4dae1;
box-shadow: none;
}
.openerp .oe_horizontal_separator,
.openerp .oe_button.oe_link span,
.openerp .oe_application a,
.openerp .ui-widget-content a,
.openerp .oe_view_manager table.oe_view_manager_header h2 a,
.openerp .oe_secondary_menu_section {
color: #1D559D;
}
.openerp .nav-pills > li.active > a,
.openerp a.list-group-item.active > a {
background-color: #1D559D;
}
.openerp .nav-pills > li.active a:hover,
.openerp .nav-pills > li.active a:focus,
.openerp a.list-group-item.active a:hover,
.openerp a.list-group-item.active a:focus {
background-color: #446b9d;
}
.navbar-inverse {
background-color: #1D559D;
border-color: #D1D1D1;
}
.navbar-inverse .navbar-collapse,
.navbar-inverse .navbar-form {
border-color: #D1D1D1;
}
.navbar-inverse .navbar-nav > li > a {
color: white;
line-height: 21px !important;
}
.openerp .nav-pills li > a{
color: black;
}
/* Small devices (tablets, 768px and up) */
@media (min-width: 768px) {
}
/* Medium devices (desktops, 992px and up) */
@media (min-width: 992px) {
}
/* Large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
}
#######################################################
#oe_main_menu_navbar.navbar {
background-color: #875A7B !important;
border-color:#875A7B !important;
color: #ffffff !important;
}
#oe_main_menu_navbar .navbar-header {
margin-right: 15px !important;
}
.navbar-inverse .navbar-collapse, .navbar-inverse .navbar-form {
padding: 0px !important;
background-color: #875A7B !important;
border-color: #875A7B !important;
}
#fa_fa_th_menu {
margin-left: 10px !important;
margin-right: 10px !important;
}
#oe_main_menu_navbar li a.oe_menu_toggler {
color: #ffff !important;
}
.openerp .nav-pills > li.active > a, .openerp a.list-group-item.active > a {
background-color: transparent !important;
}
.openerp .oe_loading {
display: none;
z-index: 1001;
position: fixed;
top: 97% !important;
bottom: 0 !important;
right: 0 !important;
padding: 4px 12px;
background: #875A7B;
border-color:#875A7B !important;
color: white;
text-align: center;
border: 1px solid #6d315d;
border-top: none;
-moz-border-radius-bottomright: 0px;
-moz-border-radius-bottomleft: 0px;
border-bottom-right-radius: 0px;
border-bottom-left-radius: 0px;
}
.openerp .oe_leftbar > div {
background-color: #593e52 !important;
}
.openerp .nav-pills li > a {
padding: 15px !important;
border-radius: 0px;
color: #fff;
}
.openerp .nav-pills li {
display: block;
margin: 0;
padding: 0;
border: 0px;
background: linear-gradient(to right,#875A7B 50%, #593e52 50%);
background-size: 200% 100%;
background-position: right bottom;
transition: all 0.2s ease-out;
}
.openerp .nav-pills li:hover {
background-position: left bottom;
}
.openerp .nav-pills li > a, .openerp .nav-pills > li.active > a, .openerp a.list-group-item.active > a {
background-color: transparent !important;
display: block;
position: relative;
margin: 0;
width: 220px;
border: 0px;
padding: 8px 15px;
text-decoration: none;
font-weight: 300;
overflow: hidden;
text-overflow: ellipsis;
color: #FFFFFF;
transition: all 0.2s ease-out;
}
.openerp .oe_secondary_menu_section {
color: #ffffff !important;
margin-left: 0px !important;
padding-left: 8px !important;
padding-top: 8px !important;
padding-bottom: 8px !important;
text-transform: uppercase !important;
background-color: #875A7B !important;
}
.navbar-inverse .navbar-toggle {
background-color: transparent !important;
}
.navbar-inverse {
background-color: #875A7B !important;
border-color: #875A7B !important;
}
.oe_module_desc button {
padding-left: 30px !important;
padding-right: 30px !important;
padding-top: 10px !important;
padding-bottom: 10px !important;
}
.openerp .oe_kanban_view .oe_kanban_action_button {
padding-left: 30px !important;
padding-right: 30px !important;
padding-top: 10px !important;
padding-bottom: 10px !important;
height: auto !important;
background-color:#3a9630 !important;
border-color:#3a9630 !important;
}
.openerp .oe_kanban_view .oe_kanban_action_button:hover {
background-color:#6fc765 !important;
border-color:#6fc765 !important;
}
.openerp button.oe_button, button.oe_dropdown_toggle, .openerp button.oe_highlight {
padding-left: 30px !important;
padding-right: 30px !important;
padding-top: 10px !important;
padding-bottom: 10px !important;
background-color:#3a9630 !important;
border-color:#3a9630 !important;
}
.openerp button.oe_button:hover, button.oe_dropdown_toggle:hover, .openerp button.oe_highlight:hover {
background-color:#6fc765 !important;
border-color:#6fc765 !important;
}
.openerp button.oe_dropdown_toggle, .openerp button.oe_highlight {
padding-left: 30px !important;
padding-right: 30px !important;
padding-top: 10px !important;
padding-bottom: 10px !important;
background-color:#3a9630 !important;
border-color:#3a9630 !important;
}
.openerp button.oe_dropdown_toggle:hover, .openerp button.oe_highlight:hover {
background-color:#6fc765 !important;
border-color:#6fc765 !important;
}
@media (max-width: 768px) {
#leftbar_toggle {
display: none !important;
}
.navbar-inverse .navbar-collapse, .navbar-inverse .navbar-form {
text-align: center !important;
}
.navbar-nav .open .dropdown-menu {
text-align: center !important;
}
}
@media (max-width: 767px) {
#leftbar_toggle {
display: none !important;
}
.navbar-inverse .navbar-collapse, .navbar-inverse .navbar-form {
text-align: center !important;
}
.navbar-nav .open .dropdown-menu {
text-align: center !important;
}
}
.navbar-left > li {
}
#oe_main_menu_navbar li a, #oe_main_menu_navbar li button {
padding: 13px !important;
}
.navbar-nav > li:hover {
background: #593e52 !important;
}
.navbar-inverse .navbar-nav > .open > a, .navbar-inverse .navbar-nav > .open > a:hover, .navbar-inverse .navbar-nav > .open > a:focus, .navbar-inverse .navbar-nav > .active > a, .navbar-inverse .navbar-nav > .active > a:hover, .navbar-inverse .navbar-nav > .active > a:focus {
color: #fff;
background-color: #593e52 !important;
}
#oe_main_menu_navbar li a, #oe_main_menu_navbar li button {
margin-top: 0px !important;
}
#oe_main_menu_navbar #menu_more li a.oe_menu_toggler {
color: black !important;
}
.openerp .oe_sidebar_suggestion .oe_suggest_items .oe_suggested_item_content button, .openerp .oe_followers button.oe_follower {
padding-left: 30px !important;
padding-right: 30px !important;
padding-top: 10px !important;
padding-bottom: 10px !important;
background-color:#3a9630 !important;
border-color:#3a9630 !important;
}
.openerp .oe_sidebar_suggestion .oe_suggest_items .oe_suggested_item_content button:hover, .openerp .oe_followers button.oe_follower:hover {
background-color:#6fc765 !important;
border-color:#6fc765 !important;
}
.openerp .oe_form input[type="text"], .openerp .oe_form input[type="password"], .openerp .oe_form input[type="file"], .openerp .oe_form select, .openerp .oe_form textarea {
min-height: 30px !important;
}
body.oe_single_form .oe_single_form_container {
background-color: #875A7B !important;
color: white !important;
}
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
box-shadow: inset 0 0 5px grey;
border-radius: 10px;
}
::-webkit-scrollbar-thumb {
background: #875A7B;
border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
background: #875A7B;
}
.pace {
-webkit-pointer-events: none;
pointer-events: none;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.pace-inactive {
display: none;
}
.pace .pace-progress {
background: #ffffff;
position: fixed;
z-index: 2000;
top: 0;
right: 100%;
width: 100%;
height: 4px;
}
/*
# -*- encoding: utf-8 -*-
*/
.openerp .oe_list_content th.oe_sortable div {
position: relative;
display:inline-table;
}
.openerp .oe_list_content th
{
vertical-align:top;
}
.openerp .oe_dropdown_menu
{
z-index: 100 !important;
}
div.graph_widget {
padding-top:10px !important;
padding-left:50px !important;
padding-bottom: 10px !important;
padding-right: 10px !important;
}
.openerp.openerp_webclient_container {
height: calc(100% - 55px);
}
.openerp td {
vertical-align: middle;
}
oe_main_menu_navbar .dropdown-menu li a,
oe_main_menu_navbar .dropdown-menu li button {
padding: 13px 15px!important;
}
#oe_main_menu_navbar .navbar-nav.navbar-right:last-child {
float: right!important;
}
.navbar .oe_topbar_name {
height: 15px!important;
}
.openerp .oe_leftbar {
border-right: 1px solid #bfbfc6;
}
.oe_leftbar {
background: 0!important;
padding: 0!important;
}
.oe_leftbar li a {
padding: 10px 30px!important;
}
.navbar-collapse {
padding-right: 10px;
padding-left: 10px;
}
.openerp .oe_leftbar.show {
display: table-cell !important;
}
.openerp .oe_leftbar.hide {
display: none !important;
}
@media (max-width: 767px) {
.openerp .oe_leftbar {
display: none !important;
}
}
@media (min-width: 767px) {
.openerp .oe_leftbar {
display: table-cell !important;
}
}
.navbar-toggle {
border: none!important;
margin-top: 10px!important;
}
.navbar-inverse .navbar-toggle:hover,
.navbar-inverse .navbar-toggle:focus {
}
.navbar-toggle.left {
display: block;
float: left;
margin-left: 15px;
padding: 2px 2px;
}
@media (max-width: 600px) {
.openerp .oe_searchview {
min-width: 300px;
}
}
.navbar-inverse .navbar-toggle .icon-bar{
background-color: white!important;
}
.openerp .nav-pills li > a {
padding: 6px 4px 6px 18px !important;
}
.navbar-inverse .navbar-toggle {
background-color: #1D559D!important;
}
.oe_kanban_groups {
background-color: #e5e5e4 !important;
}
.oe_employee_vignette,
.openerp .oe_module_vignette,
.openerp .oe_kanban_view .oe_kanban_vignette {
padding: 8px;
background-color: #fff;
min-height: 122px !important;
border: 1px solid #D1D1D1 !important;
border-radius: 5px;
}
/*Comment Line 355 in web/../base.css*/
.openerp .oe_kanban_view .oe_kanban_column,
.openerp .oe_kanban_view {
background: #e5e5e4 !important;
}
.openerp .oe_kanban_column_cards {
text-align: center;
}
.oe_employee_details,
.openerp .oe_kanban_details,
.openerp .oe_module_desc {
text-align: left!important;
}
.openerp .oe_view_manager table.oe_view_manager_header .oe_header_row:last-child td,
.openerp .oe_view_manager table.oe_view_manager_header .oe_header_row:first-child td {
background: white;
}
/* .openerp .oe_kanban_view.oe_kanban_ungrouped .oe_kanban_column .oe_kanban_record {
padding: 8px!important;
} */
.openerp .oe_searchview{
background: white!important;
border: none!important;
border-bottom: #D1D1D1 2px solid!important;
border-radius: 0!important;
box-shadow: none!important;
height: 30px;
padding: 10px!important;
}
.openerp .oe_searchview .oe_searchview_facets {
margin-top: -8px!important;
}
.openerp .oe_breadcrumb_title span {
color: #1D559D!important;
font-size: 30px!important;
}
.openerp .oe_tag_dark {
background: none!important;
}
.openerp .oe_searchview .oe_searchview_facets .oe_searchview_facet .oe_facet_category {
color: #1D559D!important;
}
.openerp .oe_facet_values {
font-weight: 700!important;
}
.openerp .oe_view_manager table.oe_view_manager_header {
border-collapse: separate;
background: white;
}
.openerp .oe_view_manager_current > .oe_view_manager_header {
padding: 20px 0 10px 0;
}
.oe_breadcrumb_title a.oe_breadcrumb_item {
color: #888!important;
font-size: 18px!important;
}
.openerp .oe_fade {
color: #888!important;
}
.openerp .oe_breadcrumb_item {
font-weight: 400!important;
}
.openerp .oe_form select,
.openerp .oe_form textarea,
.openerp .oe_form input[type="text"] {
border-top: none;
border-left: none;
border-right: none;
border-bottom: #ccc 2px solid;
border-radius: 0;
outline: none;
}
.openerp .oe_searchview.oe_focused {
border-bottom: #1D559D 3px solid!important;
}
.openerp select:focus,
.openerp input[type="text"]:focus {
border-color: #1D559D;
}
.openerp .oe_view_manager table.oe_view_manager_header .oe_header_row h2 {
font-weight: 400;
color: #1D559D!important;
font-size: 34px!important;
}
.openerp .oe_view_manager table.oe_view_manager_header .oe_button_group li,
.openerp .oe_view_manager table.oe_view_manager_header .oe_button_group {
border: none!important;
margin: 0 5px!important;
}
.openerp .oe_view_manager table.oe_view_manager_header .oe_button_group .active a {
color: #1D559D!important;
background: none!important;
text-shadow: none!important;
box-shadow: none!important;
}
.openerp .oe_view_manager table.oe_view_manager_header .oe_button_group .active {
background: none!important;
text-shadow: none!important;
box-shadow: none!important;
}
.openerp .oe_e {
font-size: 48px;
}
.openerp .oe_pager_group li {
height: 23px!important;
}
.openerp .oe_pager_group a.oe_i {
display: block;
margin-top: -2px;
font-size: 18px;
}
.openerp .oe_button.oe_link {
color: #1D559D!important;
font-weight: bold;
background: none!important;
}
.openerp .oe_button.oe_link:hover {
background: none!important;
}
.openerp button.oe_button {
background: #176CC9!important;
border: none!important;
color: white;
}
.openerp a.button:hover,
.openerp button:hover,
.openerp .oe_button:hover,
.openerp input[type='submit']:hover
.openerp button.oe_button:hover {
background: #1D559D!important;
}
.openerp button.oe_dropdown_toggle,
.openerp button.oe_highlight {
color: white!important;
background: #1D559D!important;
border: none!important;
padding: 5px 10px!important;
text-shadow: none!important;
box-shadow: none!important;
}
.openerp button.oe_dropdown_toggle:hover,
.openerp button.oe_highlight:hover {
background: #093B6D!important;
}
.openerp .oe_button {
text-shadow: none!important;
padding: 5px 10px!important;
box-shadow: none!important;
}
/*Edit on module web/../base.css - line 2185*/
.openerp .oe_form .oe_form_required input:not([disabled]):not([readonly]),
.openerp textarea:focus {
background: none !important;
border-color: red;
}
.openerp .oe_form .oe_form_required textarea:not([disabled]):not([readonly]):focus,
.openerp .oe_form .oe_form_required select:not([disabled]):not([readonly]):focus,
.openerp .oe_form .oe_form_required input:not([disabled]):not([readonly]):focus {
border-color: #1D559D!important;
}
.openerp .oe_application .oe_form_sheet {
border: none!important;
box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .24)!important;
border-radius: 2px;
}
.openerp .oe_application .oe_form_sheetbg {
background: white !important;
}
.openerp .oe_form_sheet_width {
max-width: none !important;
}
.openerp .oe_form_sheetbg {
padding: 0 0 10px 0 !important;
}
.openerp .oe_form > :not(.oe_form_nosheet) header {
padding-left: 2px;
}
.openerp .oe_form header {
padding: 8px;
}
.oe_form_field_status li span {
border: none!important;
text-shadow: none!important;
background: none!important;
}
.openerp ul.oe_form_status li > .label {
color: black;
padding: 7px;
display: inline-block;
margin: 0;
position: relative;
line-height: normal;
font-size: 100%;
font-weight: normal;
}
.oe_form_field_status .label {
margin-right: 5px!important;
}
.openerp ul.oe_form_status li:first-child > .label {
padding-left: 14px;
}
.openerp ul.oe_form_status li,
.openerp ul.oe_form_status li.oe_active {
background-image: none!important;
background-color: transparent!important;
margin: 0 -18px 0 0;
}
.openerp ul.oe_form_status li.oe_active > .label {
color: #1D559D!important;
}
.openerp ul.oe_form_status li:last-child {
border-right: none!important;
}
.oe_msg {
background: #fff!important;
box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .24)!important;
}
.openerp .oe_form div.oe_chatter {
max-width: none!important;
padding: 8px;
}
.oe_thread {
margin: 10px 0 15px;
}
.openerp .oe_mail .oe_msg.oe_msg_nobody, .oe_msg_comment {
margin: 10px 0!important;
padding: 10px!important;
}
.openerp .oe_kanban_view .oe_kanban_action_button,
.btn.btn-default.dropdown-toggle,
.openerp .oe_followers button.oe_follower.oe_following {
background-color: transparent!important;
background-image: none!important;
background: #176CC9!important;
border: none;
box-shadow: none;
text-shadow: none;
padding: 5px 10px;
color: white!important;
}
.openerp .oe_kanban_view .oe_kanban_action_button:hover,
.oe_followers button.btn.btn-default.dropdown-toggle:hover,
.openerp .oe_followers button.oe_follower.oe_following:hover {
background: #1D559D!important;
}
.openerp .oe_kanban_view .oe_kanban_footer_left > span {
background: none;
padding: 0;
border: none;
}
.openerp .oe_sidebar_suggestion .oe_suggest_items .oe_suggested_item_content button,
.openerp .oe_followers button.oe_follower {
border: none;
box-shadow: none;
background: #176CC9;
color: white;
}
.openerp .oe_list_content > thead,
.openerp .oe_list_content > tfoot {
background: #FAFAFA !important;
}
.openerp .oe_list_content th,
.openerp .oe_list_content td,
.openerp .oe_list_content > tbody > tr > td.oe_list_field_cell {
padding: 8px!important;
}
.openerp thead th {
border-left: 0px solid #dfdfdf !important;
}
.openerp .oe_list_content td.oe_number {
text-align: right !important;
}
.openerp .oe_list_content > tbody > tr:nth-child(2n+1) {
background-color: #FFF!important;
background-image: linear-gradient(to bottom, #FFF, #FFF)!important;
}
.openerp .oe_list_content > tbody > tr {
height: 40px !important;
}
input[type="radio"],
input[type="checkbox"] {
margin: 0px -2px 0 !important;
-webkit-appearance: none;
margin-top: 1px !important;
line-height: normal !important;
border: none!important;
position: relative;
}
input[type="checkbox"]:after,
.checkbox input[type="checkbox"]:after,
.checkbox-inline input[type="checkbox"]:after {
content: "";
display: block;
width: 18px;
height: 18px;
margin-top: -2px;
margin-right: 5px;
border: 2px solid #666666;
border-radius: 2px;
transition: 240ms;
}
input[type="checkbox"]:checked:after {
background-color: #1d559d;
border-color: #1d559d;
}
input[type="checkbox"]:checked:before,
.checkbox input[type="checkbox"]:checked:before,
.checkbox-inline input[type="checkbox"]:checked:before {
content: "";
position: absolute;
left: 10px;
display: table;
width: 6px;
height: 12px;
border: 2px solid #fff;
border-top-width: 0;
border-left-width: 0;
transform: rotate(45deg);
}
.openerp .oe_list .oe_list_content .oe_group_header {
background-image: linear-gradient(to bottom, #fcfcfc, #dedede)!important;
}
.openerp .oe_list .oe_list_content .oe_group_header:hover {
background-image: linear-gradient(to bottom, #FFF, #FFF)!important;
}
input[type="radio"] {
/* margin: 0px -2px 0 !important;
margin-top: 1px !important;
line-height: normal !important; */
border: none!important;
padding: 0px;
}
input[type="radio"]:before {
position: absolute;
/* left: 0;
top: -3px; */
background-color: #1d559d;
transform: scale(0);
}
input[type="radio"]:before,
input[type="radio"]:after {
content: "";
display: block;
width: 18px;
height: 18px;
border-radius: 50%;
transition: 240ms;
}
input[type="radio"]:checked:before {
transform: scale(0.5);
}
input[type="radio"]:checked:after {
border-color: #1d559d;
}
input[type="radio"]:after {
position: relative;
/* top: -3px; */
border: 2px solid #666666;
}
*:before {
box-sizing: border-box;
}
.openerp .oe_form_field_radio.oe_form_required .oe_radio_input {
border: 0 !important;
}
.oe_form_field>span>div {
margin-bottom: 5px;
}
.openerp .oe_form_field_radio.oe_vertical label {
margin-left: 10px !important;
}
\ No newline at end of file
/*
# -*- encoding: utf-8 -*-
*/
// Check jQuery available
if (typeof jQuery === 'undefined') { throw new Error('Theme JavaScript requires jQuery') }
+function ($) {
'use strict';
openerp.reponsive_backend_theme = function(instance, local) {
var _t = instance.web._t,
_lt = instance.web._lt;
var QWeb = instance.web.qweb;
}
}(jQuery);
/*
# -*- encoding: utf-8 -*-
*/
openerp.responsive_backend_theme = function(instance, local) {
var _t = instance.web._t;
openerp_FieldMany2ManyTagsMultiSelection(instance);
openerp_listview_html_widget(instance);
web_listview_sticky(instance);
var QWeb = instance.web.qweb;
instance.web.Client.include({
show_annoucement_bar : function() {
return;
},
bind_events : function() {
var self = this;
this._super();
var root = self.$el.parents();
$("#oe_main_menu_navbar.navbar").css("padding-left", "220px");
var elem_sm = $("<button id='leftbar_toggle' type='button' class='navbar-toggle left'><span class='fa fa-th' style='color:#ffffff;font-size: 25px;'></span></button>");
elem_sm.prependTo(root.find('.navbar-header'));
$(document).ready(function() {
$('.page-loading').show();
});
self.$el.on('click', '#leftbar_toggle', function() {
var leftbar = root.find('.oe_leftbar');
if (leftbar.css('display') == 'none') {
leftbar.removeClass("hide");
$("#oe_main_menu_navbar.navbar").css("padding-left", "220px");
leftbar.addClass("show");
} else {
$("#oe_main_menu_navbar.navbar").css("padding-left", "0px");
leftbar.removeClass("show");
leftbar.addClass("hide");
}
});
$('.oe_application').click(function () {
var leftbar = root.find('.oe_leftbar');
$("#oe_main_menu_navbar.navbar").css("padding-left", "0px");
leftbar.removeClass("show");
leftbar.addClass("hide");
});
$('ul.nav.navbar-nav.navbar-left.oe_application_menu_placeholder li a').click(function () {
var leftbar = root.find('.oe_leftbar');
if (leftbar.css('display') == 'none') {
leftbar.removeClass("hide");
$("#oe_main_menu_navbar.navbar").css("padding-left", "220px");
leftbar.addClass("show");
}
});
}
});
instance.web.Menu.include({
reflow : function(behavior) {
var self = this;
var $more_container = this.$('#menu_more_container').hide();
var $more = this.$('#menu_more');
var $systray = this.$el.parents().find('.oe_systray');
$more.children('li').insertBefore($more_container);
// Pull all the items out of the more menu
// 'all_outside' beahavior should display all the items, so hide the more menu and exit
if (behavior === 'all_outside') {
// Show list of menu items
self.$el.show();
this.$el.find('li').show();
$more_container.hide();
return;
}
// Hide all menu items
var $toplevel_items = this.$el.find('li').not($more_container).not($systray.find('li')).hide();
// Show list of menu items (which is empty for now since all menu items are hidden)
self.$el.show();
$toplevel_items.each(function() {
var remaining_space = self.$el.parent().width() - $more_container.outerWidth() - 75;
self.$el.parent().children(':visible').each(function() {
remaining_space -= $(this).outerWidth();
});
if ($(this).width() >= remaining_space) {
return false;
// the current item will be appended in more_container
}
$(this).show();
// show the current item in menu bar
});
$more.append($toplevel_items.filter(':hidden').show());
$more_container.toggle(!!$more.children().length);
// Hide toplevel item if there is only one
var $toplevel = self.$el.children("li:visible");
if ($toplevel.length === 1) {
$toplevel.hide();
}
},
open_menu : function(id) {
var self = this;
var root = self.$el.parents();
var oe_main_menu_placeholder = root.find('#oe_main_menu_placeholder');
if (oe_main_menu_placeholder.hasClass("in")) {
oe_main_menu_placeholder.removeClass("in");
}
this._super(id);
}
});
};
/*
# -*- encoding: utf-8 -*-
*/
openerp_listview_html_widget= function(instance) {
var _t = instance.web._t;
instance.web.list.columns.map['field.html'] = 'instance.web.list.HtmlColumn';
instance.web.list.HtmlColumn = instance.web.list.Column.extend({
_format: function (row_data, options) {
return instance.web.format_value(
row_data[this.id].value, this, options.value_if_empty);
}
});
};
/*
# -*- encoding: utf-8 -*-
*/
web_listview_sticky = function (instance) {
var _t = instance.web._t,
_lt = instance.web._lt;
var QWeb = instance.web.qweb;
//Sticky Table Header
instance.web.ListView.include({
load_list: function () {
var self = this;
self._super.apply(this, arguments);
var one2many_length = self.$el.parents('.oe_form_field.oe_form_field_one2many').length;
var scrollArea = self.$el.parents('.oe_view_manager.oe_view_manager_current').find('.oe_view_manager_wrapper .oe_view_manager_body')[0];
if(scrollArea && one2many_length == 0){
self.$el.find('table.oe_list_content').each(function(){
$(this).stickyTableHeaders({scrollableArea: scrollArea});
});
}
},
});
};
\ No newline at end of file
/*---------------------------------------------------------
* OpenERP Web chrome
*---------------------------------------------------------*/
(function() {
var instance = openerp;
openerp.web.chrome = {};
var QWeb = instance.web.qweb,
_t = instance.web._t;
instance.web.Notification = instance.web.Widget.extend({
template: 'Notification',
init: function() {
this._super.apply(this, arguments);
instance.web.notification = this;
},
start: function() {
this._super.apply(this, arguments);
this.$el.notify({
speed: 500,
expires: 2500
});
},
notify: function(title, text, sticky) {
sticky = !!sticky;
var opts = {};
if (sticky) {
opts.expires = false;
}
return this.$el.notify('create', {
title: title,
text: text
}, opts);
},
warn: function(title, text, sticky) {
sticky = !!sticky;
var opts = {};
if (sticky) {
opts.expires = false;
}
return this.$el.notify('create', 'oe_notification_alert', {
title: title,
text: text
}, opts);
}
});
var opened_modal = [];
instance.web.action_notify = function(element, action) {
element.do_notify(action.params.title, action.params.text, action.params.sticky);
};
instance.web.client_actions.add("action_notify", "instance.web.action_notify");
instance.web.action_warn = function(element, action) {
element.do_warn(action.params.title, action.params.text, action.params.sticky);
};
instance.web.client_actions.add("action_warn", "instance.web.action_warn");
/**
A useful class to handle dialogs.
Attributes:
- $buttons: A jQuery element targeting a dom part where buttons can be added. It always exists
during the lifecycle of the dialog.
*/
instance.web.Dialog = instance.web.Widget.extend({
dialog_title: "",
/**
Constructor.
@param {Widget} parent
@param {dictionary} options A dictionary that will be forwarded to jQueryUI Dialog. Additionaly, that
dictionary can contain the following keys:
- size: one of the following: 'large', 'medium', 'small'
- dialogClass: class to add to the body of dialog
- buttons: Deprecated. The buttons key is not propagated to jQueryUI Dialog. It must be a dictionary (key = button
label, value = click handler) or a list of dictionaries (each element in the dictionary is send to the
corresponding method of a jQuery element targeting the <button> tag). It is deprecated because all dialogs
in OpenERP must be personalized in some way (button in red, link instead of button, ...) and this
feature does not allow that kind of personalization.
- destroy_on_close: Default true. If true and the dialog is closed, it is automatically destroyed.
@param {jQuery object} content Some content to replace this.$el .
*/
init: function (parent, options, content) {
var self = this;
this._super(parent);
this.content_to_set = content;
this.dialog_options = {
destroy_on_close: true,
size: 'large', //'medium', 'small'
buttons: null,
};
if (options) {
_.extend(this.dialog_options, options);
}
this.on("closing", this, this._closing);
this.$buttons = $('<div class="modal-footer"><span class="oe_dialog_custom_buttons"/></div>');
},
renderElement: function() {
if (this.content_to_set) {
this.setElement(this.content_to_set);
} else if (this.template) {
this._super();
}
},
/**
Opens the popup. Inits the dialog if it is not already inited.
@return this
*/
open: function() {
if (!this.dialog_inited) {
this.init_dialog();
}
this.$buttons.insertAfter(this.$dialog_box.find(".modal-body"));
$('.tooltip').remove(); //remove open tooltip if any to prevent them staying when modal is opened
//add to list of currently opened modal
opened_modal.push(this.$dialog_box);
return this;
},
_add_buttons: function(buttons) {
var self = this;
var $customButons = this.$buttons.find('.oe_dialog_custom_buttons').empty();
_.each(buttons, function(fn, text) {
// buttons can be object or array
var oe_link_class = fn.oe_link_class;
if (!_.isFunction(fn)) {
text = fn.text;
fn = fn.click;
}
var $but = $(QWeb.render('WidgetButton', { widget : { string: text, node: { attrs: {'class': oe_link_class} }}}));
$customButons.append($but);
$but.on('click', function(ev) {
fn.call(self.$el, ev);
});
});
},
/**
Initializes the popup.
@return The result returned by start().
*/
init_dialog: function() {
var self = this;
var options = _.extend({}, this.dialog_options);
options.title = options.title || this.dialog_title;
if (options.buttons) {
this._add_buttons(options.buttons);
delete(options.buttons);
}
this.renderElement();
this.$dialog_box = $(QWeb.render('Dialog', options)).appendTo("body");
this.$el.modal({
'backdrop': false,
'keyboard': true,
});
if (options.size !== 'large'){
var dialog_class_size = this.$dialog_box.find('.modal-lg').removeClass('modal-lg');
if (options.size === 'small'){
dialog_class_size.addClass('modal-sm');
}
}
this.$el.appendTo(this.$dialog_box.find(".modal-body"));
var $dialog_content = this.$dialog_box.find('.modal-content');
if (options.dialogClass){
$dialog_content.find(".modal-body").addClass(options.dialogClass);
}
$dialog_content.openerpClass();
this.$dialog_box.on('hidden.bs.modal', this, function() {
self.close();
});
this.$dialog_box.modal('show');
this.dialog_inited = true;
var res = this.start();
return res;
},
/**
Closes (hide) the popup, if destroy_on_close was passed to the constructor, it will be destroyed instead.
*/
close: function(reason) {
if (this.dialog_inited && !this.__tmp_dialog_hiding) {
$('.tooltip').remove(); //remove open tooltip if any to prevent them staying when modal has disappeared
if (this.$el.is(":data(bs.modal)")) { // may have been destroyed by closing signal
this.__tmp_dialog_hiding = true;
this.$dialog_box.modal('hide');
this.__tmp_dialog_hiding = undefined;
}
this.trigger("closing", reason);
}
},
_closing: function() {
if (this.__tmp_dialog_destroying)
return;
if (this.dialog_options.destroy_on_close) {
this.__tmp_dialog_closing = true;
this.destroy();
this.__tmp_dialog_closing = undefined;
}
},
/**
Destroys the popup, also closes it.
*/
destroy: function (reason) {
this.$buttons.remove();
var self = this;
_.each(this.getChildren(), function(el) {
el.destroy();
});
if (! this.__tmp_dialog_closing) {
this.__tmp_dialog_destroying = true;
this.close(reason);
this.__tmp_dialog_destroying = undefined;
}
if (this.dialog_inited && !this.isDestroyed() && this.$el.is(":data(bs.modal)")) {
//we need this to put the instruction to remove modal from DOM at the end
//of the queue, otherwise it might already have been removed before the modal-backdrop
//is removed when pressing escape key
var $element = this.$dialog_box;
setTimeout(function () {
//remove modal from list of opened modal since we just destroy it
var modal_list_index = $.inArray($element, opened_modal);
if (modal_list_index > -1){
opened_modal.splice(modal_list_index,1)[0].remove();
}
if (opened_modal.length > 0){
//we still have other opened modal so we should focus it
opened_modal[opened_modal.length-1].focus();
//keep class modal-open (deleted by bootstrap hide fnct) on body
//to allow scrolling inside the modal
$('body').addClass('modal-open');
}
},0);
}
this._super();
}
});
instance.web.CrashManager = instance.web.Class.extend({
init: function() {
this.active = true;
},
rpc_error: function(error) {
if (!this.active) {
return;
}
var handler = instance.web.crash_manager_registry.get_object(error.data.name, true);
if (handler) {
new (handler)(this, error).display();
return;
}
if (error.data.name === "openerp.http.SessionExpiredException" || error.data.name === "werkzeug.exceptions.Forbidden") {
this.show_warning({type: "Session Expired", data: { message: _t("Your ERP session expired. Please refresh the current web page.") }});
return;
}
if (error.data.exception_type === "except_osv" || error.data.exception_type === "warning" || error.data.exception_type === "access_error") {
this.show_warning(error);
} else {
this.show_error(error);
}
},
show_warning: function(error) {
if (!this.active) {
return;
}
if (error.data.exception_type === "except_osv") {
error = _.extend({}, error, {data: _.extend({}, error.data, {message: error.data.arguments[0] + "\n\n" + error.data.arguments[1]})});
}
new instance.web.Dialog(this, {
size: 'medium',
title: "ERP " + (_.str.capitalize(error.type) || "Warning"),
buttons: [
{text: _t("Ok"), click: function() { this.parents('.modal').modal('hide'); }}
],
}, $('<div>' + QWeb.render('CrashManager.warning', {error: error}) + '</div>')).open();
},
show_error: function(error) {
if (!this.active) {
return;
}
var buttons = {};
buttons[_t("Ok")] = function() {
this.parents('.modal').modal('hide');
};
new instance.web.Dialog(this, {
title: "ERP " + _.str.capitalize(error.type),
buttons: buttons
}, QWeb.render('CrashManager.error', {session: instance.session, error: error})).open();
},
show_message: function(exception) {
this.show_error({
type: _t("Client Error"),
message: exception,
data: {debug: ""}
});
},
});
/**
An interface to implement to handle exceptions. Register implementation in instance.web.crash_manager_registry.
*/
instance.web.ExceptionHandler = {
/**
@param parent The parent.
@param error The error object as returned by the JSON-RPC implementation.
*/
init: function(parent, error) {},
/**
Called to inform to display the widget, if necessary. A typical way would be to implement
this interface in a class extending instance.web.Dialog and simply display the dialog in this
method.
*/
display: function() {},
};
/**
The registry to handle exceptions. It associate a fully qualified python exception name with a class implementing
instance.web.ExceptionHandler.
*/
instance.web.crash_manager_registry = new instance.web.Registry();
/**
* Handle redirection warnings, which behave more or less like a regular
* warning, with an additional redirection button.
*/
instance.web.RedirectWarningHandler = instance.web.Dialog.extend(instance.web.ExceptionHandler, {
init: function(parent, error) {
this._super(parent);
this.error = error;
},
display: function() {
var self = this;
error = this.error;
error.data.message = error.data.arguments[0];
new instance.web.Dialog(this, {
size: 'medium',
title: "ERP " + (_.str.capitalize(error.type) || "Warning"),
buttons: [
{text: _t("Ok"), click: function() { self.$el.parents('.modal').modal('hide'); self.destroy();}},
{text: error.data.arguments[2],
oe_link_class: 'oe_link',
click: function() {
window.location.href='#action='+error.data.arguments[1];
self.destroy();
}}
],
}, QWeb.render('CrashManager.warning', {error: error})).open();
}
});
instance.web.crash_manager_registry.add('openerp.exceptions.RedirectWarning', 'instance.web.RedirectWarningHandler');
instance.web.Loading = instance.web.Widget.extend({
template: _t("Loading"),
init: function(parent) {
this._super(parent);
this.count = 0;
this.blocked_ui = false;
this.session.on("request", this, this.request_call);
this.session.on("response", this, this.response_call);
this.session.on("response_failed", this, this.response_call);
},
destroy: function() {
this.on_rpc_event(-this.count);
this._super();
},
request_call: function() {
this.on_rpc_event(1);
},
response_call: function() {
this.on_rpc_event(-1);
},
on_rpc_event : function(increment) {
var self = this;
if (!this.count && increment === 1) {
// Block UI after 3s
this.long_running_timer = setTimeout(function () {
self.blocked_ui = true;
instance.web.blockUI();
}, 3000);
}
// DEBUT CODE LOADING
(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X=[].slice,Y={}.hasOwnProperty,Z=function(a,b){function c(){this.constructor=a}for(var d in b)Y.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},$=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};for(u={catchupTime:100,initialRate:.03,minTime:250,ghostTime:100,maxProgressPerFrame:20,easeFactor:1.25,startOnPageLoad:!0,restartOnPushState:!0,restartOnRequestAfter:500,target:"body",elements:{checkInterval:100,selectors:["body"]},eventLag:{minSamples:10,sampleCount:3,lagThreshold:3},ajax:{trackMethods:["GET"],trackWebSockets:!0,ignoreURLs:[]}},C=function(){var a;return null!=(a="undefined"!=typeof performance&&null!==performance&&"function"==typeof performance.now?performance.now():void 0)?a:+new Date},E=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,t=window.cancelAnimationFrame||window.mozCancelAnimationFrame,null==E&&(E=function(a){return setTimeout(a,50)},t=function(a){return clearTimeout(a)}),G=function(a){var b,c;return b=C(),(c=function(){var d;return d=C()-b,d>=33?(b=C(),a(d,function(){return E(c)})):setTimeout(c,33-d)})()},F=function(){var a,b,c;return c=arguments[0],b=arguments[1],a=3<=arguments.length?X.call(arguments,2):[],"function"==typeof c[b]?c[b].apply(c,a):c[b]},v=function(){var a,b,c,d,e,f,g;for(b=arguments[0],d=2<=arguments.length?X.call(arguments,1):[],f=0,g=d.length;g>f;f++)if(c=d[f])for(a in c)Y.call(c,a)&&(e=c[a],null!=b[a]&&"object"==typeof b[a]&&null!=e&&"object"==typeof e?v(b[a],e):b[a]=e);return b},q=function(a){var b,c,d,e,f;for(c=b=0,e=0,f=a.length;f>e;e++)d=a[e],c+=Math.abs(d),b++;return c/b},x=function(a,b){var c,d,e;if(null==a&&(a="options"),null==b&&(b=!0),e=document.querySelector("[data-pace-"+a+"]")){if(c=e.getAttribute("data-pace-"+a),!b)return c;try{return JSON.parse(c)}catch(f){return d=f,"undefined"!=typeof console&&null!==console?console.error("Error parsing inline pace options",d):void 0}}},g=function(){function a(){}return a.prototype.on=function(a,b,c,d){var e;return null==d&&(d=!1),null==this.bindings&&(this.bindings={}),null==(e=this.bindings)[a]&&(e[a]=[]),this.bindings[a].push({handler:b,ctx:c,once:d})},a.prototype.once=function(a,b,c){return this.on(a,b,c,!0)},a.prototype.off=function(a,b){var c,d,e;if(null!=(null!=(d=this.bindings)?d[a]:void 0)){if(null==b)return delete this.bindings[a];for(c=0,e=[];c<this.bindings[a].length;)e.push(this.bindings[a][c].handler===b?this.bindings[a].splice(c,1):c++);return e}},a.prototype.trigger=function(){var a,b,c,d,e,f,g,h,i;if(c=arguments[0],a=2<=arguments.length?X.call(arguments,1):[],null!=(g=this.bindings)?g[c]:void 0){for(e=0,i=[];e<this.bindings[c].length;)h=this.bindings[c][e],d=h.handler,b=h.ctx,f=h.once,d.apply(null!=b?b:this,a),i.push(f?this.bindings[c].splice(e,1):e++);return i}},a}(),j=window.Pace||{},window.Pace=j,v(j,g.prototype),D=j.options=v({},u,window.paceOptions,x()),U=["ajax","document","eventLag","elements"],Q=0,S=U.length;S>Q;Q++)K=U[Q],D[K]===!0&&(D[K]=u[K]);i=function(a){function b(){return V=b.__super__.constructor.apply(this,arguments)}return Z(b,a),b}(Error),b=function(){function a(){this.progress=0}return a.prototype.getElement=function(){var a;if(null==this.el){if(a=document.querySelector(D.target),!a)throw new i;this.el=document.createElement("div"),this.el.className="pace pace-active",document.body.className=document.body.className.replace(/pace-done/g,""),document.body.className+=" pace-running",this.el.innerHTML='<div class="pace-progress">\n <div class="pace-progress-inner"></div>\n</div>\n<div class="pace-activity"></div>',null!=a.firstChild?a.insertBefore(this.el,a.firstChild):a.appendChild(this.el)}return this.el},a.prototype.finish=function(){var a;return a=this.getElement(),a.className=a.className.replace("pace-active",""),a.className+=" pace-inactive",document.body.className=document.body.className.replace("pace-running",""),document.body.className+=" pace-done"},a.prototype.update=function(a){return this.progress=a,this.render()},a.prototype.destroy=function(){try{this.getElement().parentNode.removeChild(this.getElement())}catch(a){i=a}return this.el=void 0},a.prototype.render=function(){var a,b,c,d,e,f,g;if(null==document.querySelector(D.target))return!1;for(a=this.getElement(),d="translate3d("+this.progress+"%, 0, 0)",g=["webkitTransform","msTransform","transform"],e=0,f=g.length;f>e;e++)b=g[e],a.children[0].style[b]=d;return(!this.lastRenderedProgress||this.lastRenderedProgress|0!==this.progress|0)&&(a.children[0].setAttribute("data-progress-text",""+(0|this.progress)+"%"),this.progress>=100?c="99":(c=this.progress<10?"0":"",c+=0|this.progress),a.children[0].setAttribute("data-progress",""+c)),this.lastRenderedProgress=this.progress},a.prototype.done=function(){return this.progress>=100},a}(),h=function(){function a(){this.bindings={}}return a.prototype.trigger=function(a,b){var c,d,e,f,g;if(null!=this.bindings[a]){for(f=this.bindings[a],g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(c.call(this,b));return g}},a.prototype.on=function(a,b){var c;return null==(c=this.bindings)[a]&&(c[a]=[]),this.bindings[a].push(b)},a}(),P=window.XMLHttpRequest,O=window.XDomainRequest,N=window.WebSocket,w=function(a,b){var c,d,e,f;f=[];for(d in b.prototype)try{e=b.prototype[d],f.push(null==a[d]&&"function"!=typeof e?a[d]=e:void 0)}catch(g){c=g}return f},A=[],j.ignore=function(){var a,b,c;return b=arguments[0],a=2<=arguments.length?X.call(arguments,1):[],A.unshift("ignore"),c=b.apply(null,a),A.shift(),c},j.track=function(){var a,b,c;return b=arguments[0],a=2<=arguments.length?X.call(arguments,1):[],A.unshift("track"),c=b.apply(null,a),A.shift(),c},J=function(a){var b;if(null==a&&(a="GET"),"track"===A[0])return"force";if(!A.length&&D.ajax){if("socket"===a&&D.ajax.trackWebSockets)return!0;if(b=a.toUpperCase(),$.call(D.ajax.trackMethods,b)>=0)return!0}return!1},k=function(a){function b(){var a,c=this;b.__super__.constructor.apply(this,arguments),a=function(a){var b;return b=a.open,a.open=function(d,e){return J(d)&&c.trigger("request",{type:d,url:e,request:a}),b.apply(a,arguments)}},window.XMLHttpRequest=function(b){var c;return c=new P(b),a(c),c};try{w(window.XMLHttpRequest,P)}catch(d){}if(null!=O){window.XDomainRequest=function(){var b;return b=new O,a(b),b};try{w(window.XDomainRequest,O)}catch(d){}}if(null!=N&&D.ajax.trackWebSockets){window.WebSocket=function(a,b){var d;return d=null!=b?new N(a,b):new N(a),J("socket")&&c.trigger("request",{type:"socket",url:a,protocols:b,request:d}),d};try{w(window.WebSocket,N)}catch(d){}}}return Z(b,a),b}(h),R=null,y=function(){return null==R&&(R=new k),R},I=function(a){var b,c,d,e;for(e=D.ajax.ignoreURLs,c=0,d=e.length;d>c;c++)if(b=e[c],"string"==typeof b){if(-1!==a.indexOf(b))return!0}else if(b.test(a))return!0;return!1},y().on("request",function(b){var c,d,e,f,g;return f=b.type,e=b.request,g=b.url,I(g)?void 0:j.running||D.restartOnRequestAfter===!1&&"force"!==J(f)?void 0:(d=arguments,c=D.restartOnRequestAfter||0,"boolean"==typeof c&&(c=0),setTimeout(function(){var b,c,g,h,i,k;if(b="socket"===f?e.readyState<2:0<(h=e.readyState)&&4>h){for(j.restart(),i=j.sources,k=[],c=0,g=i.length;g>c;c++){if(K=i[c],K instanceof a){K.watch.apply(K,d);break}k.push(void 0)}return k}},c))}),a=function(){function a(){var a=this;this.elements=[],y().on("request",function(){return a.watch.apply(a,arguments)})}return a.prototype.watch=function(a){var b,c,d,e;return d=a.type,b=a.request,e=a.url,I(e)?void 0:(c="socket"===d?new n(b):new o(b),this.elements.push(c))},a}(),o=function(){function a(a){var b,c,d,e,f,g,h=this;if(this.progress=0,null!=window.ProgressEvent)for(c=null,a.addEventListener("progress",function(a){return h.progress=a.lengthComputable?100*a.loaded/a.total:h.progress+(100-h.progress)/2},!1),g=["load","abort","timeout","error"],d=0,e=g.length;e>d;d++)b=g[d],a.addEventListener(b,function(){return h.progress=100},!1);else f=a.onreadystatechange,a.onreadystatechange=function(){var b;return 0===(b=a.readyState)||4===b?h.progress=100:3===a.readyState&&(h.progress=50),"function"==typeof f?f.apply(null,arguments):void 0}}return a}(),n=function(){function a(a){var b,c,d,e,f=this;for(this.progress=0,e=["error","open"],c=0,d=e.length;d>c;c++)b=e[c],a.addEventListener(b,function(){return f.progress=100},!1)}return a}(),d=function(){function a(a){var b,c,d,f;for(null==a&&(a={}),this.elements=[],null==a.selectors&&(a.selectors=[]),f=a.selectors,c=0,d=f.length;d>c;c++)b=f[c],this.elements.push(new e(b))}return a}(),e=function(){function a(a){this.selector=a,this.progress=0,this.check()}return a.prototype.check=function(){var a=this;return document.querySelector(this.selector)?this.done():setTimeout(function(){return a.check()},D.elements.checkInterval)},a.prototype.done=function(){return this.progress=100},a}(),c=function(){function a(){var a,b,c=this;this.progress=null!=(b=this.states[document.readyState])?b:100,a=document.onreadystatechange,document.onreadystatechange=function(){return null!=c.states[document.readyState]&&(c.progress=c.states[document.readyState]),"function"==typeof a?a.apply(null,arguments):void 0}}return a.prototype.states={loading:0,interactive:50,complete:100},a}(),f=function(){function a(){var a,b,c,d,e,f=this;this.progress=0,a=0,e=[],d=0,c=C(),b=setInterval(function(){var g;return g=C()-c-50,c=C(),e.push(g),e.length>D.eventLag.sampleCount&&e.shift(),a=q(e),++d>=D.eventLag.minSamples&&a<D.eventLag.lagThreshold?(f.progress=100,clearInterval(b)):f.progress=100*(3/(a+3))},50)}return a}(),m=function(){function a(a){this.source=a,this.last=this.sinceLastUpdate=0,this.rate=D.initialRate,this.catchup=0,this.progress=this.lastProgress=0,null!=this.source&&(this.progress=F(this.source,"progress"))}return a.prototype.tick=function(a,b){var c;return null==b&&(b=F(this.source,"progress")),b>=100&&(this.done=!0),b===this.last?this.sinceLastUpdate+=a:(this.sinceLastUpdate&&(this.rate=(b-this.last)/this.sinceLastUpdate),this.catchup=(b-this.progress)/D.catchupTime,this.sinceLastUpdate=0,this.last=b),b>this.progress&&(this.progress+=this.catchup*a),c=1-Math.pow(this.progress/100,D.easeFactor),this.progress+=c*this.rate*a,this.progress=Math.min(this.lastProgress+D.maxProgressPerFrame,this.progress),this.progress=Math.max(0,this.progress),this.progress=Math.min(100,this.progress),this.lastProgress=this.progress,this.progress},a}(),L=null,H=null,r=null,M=null,p=null,s=null,j.running=!1,z=function(){return D.restartOnPushState?j.restart():void 0},null!=window.history.pushState&&(T=window.history.pushState,window.history.pushState=function(){return z(),T.apply(window.history,arguments)}),null!=window.history.replaceState&&(W=window.history.replaceState,window.history.replaceState=function(){return z(),W.apply(window.history,arguments)}),l={ajax:a,elements:d,document:c,eventLag:f},(B=function(){var a,c,d,e,f,g,h,i;for(j.sources=L=[],g=["ajax","elements","document","eventLag"],c=0,e=g.length;e>c;c++)a=g[c],D[a]!==!1&&L.push(new l[a](D[a]));for(i=null!=(h=D.extraSources)?h:[],d=0,f=i.length;f>d;d++)K=i[d],L.push(new K(D));return j.bar=r=new b,H=[],M=new m})(),j.stop=function(){return j.trigger("stop"),j.running=!1,r.destroy(),s=!0,null!=p&&("function"==typeof t&&t(p),p=null),B()},j.restart=function(){return j.trigger("restart"),j.stop(),j.start()},j.go=function(){var a;return j.running=!0,r.render(),a=C(),s=!1,p=G(function(b,c){var d,e,f,g,h,i,k,l,n,o,p,q,t,u,v,w;for(l=100-r.progress,e=p=0,f=!0,i=q=0,u=L.length;u>q;i=++q)for(K=L[i],o=null!=H[i]?H[i]:H[i]=[],h=null!=(w=K.elements)?w:[K],k=t=0,v=h.length;v>t;k=++t)g=h[k],n=null!=o[k]?o[k]:o[k]=new m(g),f&=n.done,n.done||(e++,p+=n.tick(b));return d=p/e,r.update(M.tick(b,d)),r.done()||f||s?(r.update(100),j.trigger("done"),setTimeout(function(){return r.finish(),j.running=!1,j.trigger("hide")},Math.max(D.ghostTime,Math.max(D.minTime-(C()-a),0)))):c()})},j.start=function(a){v(D,a),j.running=!0;try{r.render()}catch(b){i=b}return document.querySelector(".pace")?(j.trigger("start"),j.go()):setTimeout(j.start,50)},"function"==typeof define&&define.amd?define(function(){return j}):"object"==typeof exports?module.exports=j:D.startOnPageLoad&&j.start()}).call(this);
// FIN CODE LOADING
this.count += increment;
if (this.count > 0) {
if (instance.session.debug) {
this.$el.text(_.str.sprintf( _t("Loading (%d)"), this.count));
} else {
this.$el.text(_t("Loading"));
}
this.$el.show();
this.getParent().$el.addClass('oe_wait');
} else {
this.count = 0;
clearTimeout(this.long_running_timer);
// Don't unblock if blocked by somebody else
if (self.blocked_ui) {
this.blocked_ui = false;
instance.web.unblockUI();
}
this.$el.fadeOut();
this.getParent().$el.removeClass('oe_wait');
}
}
});
instance.web.DatabaseManager = instance.web.Widget.extend({
init: function(parent) {
this._super(parent);
this.unblockUIFunction = instance.web.unblockUI;
$.validator.addMethod('matches', function (s, _, re) {
return new RegExp(re).test(s);
}, _t("Invalid database name"));
},
start: function() {
var self = this;
$('.oe_secondary_menus_container,.oe_user_menu_placeholder').empty();
var fetch_db = this.rpc("/web/database/get_list", {}).then(
function(result) {
self.db_list = result;
},
function (_, ev) {
ev.preventDefault();
self.db_list = null;
});
var fetch_langs = this.rpc("/web/session/get_lang_list", {}).done(function(result) {
self.lang_list = result;
});
return $.when(fetch_db, fetch_langs).always(self.do_render);
},
do_render: function() {
var self = this;
instance.webclient.toggle_bars(true);
self.$el.html(QWeb.render("DatabaseManager", { widget : self }));
$('.oe_user_menu_placeholder').append(QWeb.render("DatabaseManager.user_menu",{ widget : self }));
$('.oe_secondary_menus_container').append(QWeb.render("DatabaseManager.menu",{ widget : self }));
$('ul.oe_secondary_submenu > li:first').addClass('active');
$('ul.oe_secondary_submenu > li').bind('click', function (event) {
var menuitem = $(this);
menuitem.addClass('active').siblings().removeClass('active');
var form_id =menuitem.find('a').attr('href');
$(form_id).show().siblings().hide();
event.preventDefault();
});
$('#back-to-login').click(self.do_exit);
self.$el.find("td").addClass("oe_form_group_cell");
self.$el.find("tr td:first-child").addClass("oe_form_group_cell_label");
self.$el.find("label").addClass("oe_form_label");
self.$el.find("form[name=create_db_form]").validate({ submitHandler: self.do_create });
self.$el.find("form[name=duplicate_db_form]").validate({ submitHandler: self.do_duplicate });
self.$el.find("form[name=drop_db_form]").validate({ submitHandler: self.do_drop });
self.$el.find("form[name=backup_db_form]").validate({ submitHandler: self.do_backup });
self.$el.find("form[name=restore_db_form]").validate({ submitHandler: self.do_restore });
self.$el.find("form[name=change_pwd_form]").validate({
messages: {
old_pwd: _t("Please enter your previous password"),
new_pwd: _t("Please enter your new password"),
confirm_pwd: {
required: _t("Please confirm your new password"),
equalTo: _t("The confirmation does not match the password")
}
},
submitHandler: self.do_change_password
});
},
destroy: function () {
this.$el.find('#db-create, #db-drop, #db-backup, #db-restore, #db-change-password, #back-to-login').unbind('click').end().empty();
this._super();
},
/**
* Blocks UI and replaces $.unblockUI by a noop to prevent third parties
* from unblocking the UI
*/
blockUI: function () {
instance.web.blockUI();
instance.web.unblockUI = function () {};
},
/**
* Reinstates $.unblockUI so third parties can play with blockUI, and
* unblocks the UI
*/
unblockUI: function () {
instance.web.unblockUI = this.unblockUIFunction;
instance.web.unblockUI();
},
/**
* Displays an error dialog resulting from the various RPC communications
* failing over themselves
*
* @param {Object} error error description
* @param {String} error.title title of the error dialog
* @param {String} error.error message of the error dialog
*/
display_error: function (error) {
return new instance.web.Dialog(this, {
size: 'medium',
title: error.title,
buttons: [
{text: _t("Ok"), click: function() { this.parents('.modal').modal('hide'); }}
]
}, $('<div>').html(error.error)).open();
},
do_create: function(form) {
var self = this;
var fields = $(form).serializeArray();
self.rpc("/web/database/create", {'fields': fields}).done(function(result) {
if (result) {
instance.web.redirect('/web');
} else {
alert("Failed to create database");
}
});
},
do_duplicate: function(form) {
var self = this;
var fields = $(form).serializeArray();
self.rpc("/web/database/duplicate", {'fields': fields}).then(function(result) {
if (result.error) {
self.display_error(result);
return;
}
self.do_notify(_t("Duplicating database"), _t("The database has been duplicated."));
self.start();
});
},
do_drop: function(form) {
var self = this;
var $form = $(form),
fields = $form.serializeArray(),
$db_list = $form.find('[name=drop_db]'),
db = $db_list.val();
if (!db || !confirm(_.str.sprintf(_t("Do you really want to delete the database: %s ?"), db))) {
return;
}
self.rpc("/web/database/drop", {'fields': fields}).done(function(result) {
if (result.error) {
self.display_error(result);
return;
}
self.do_notify(_t("Dropping database"), _.str.sprintf(_t("The database %s has been dropped"), db));
self.start();
});
},
do_backup: function(form) {
var self = this;
self.blockUI();
self.session.get_file({
form: form,
success: function () {
self.do_notify(_t("Backed"), _t("Database backed up successfully"));
},
error: function(error){
if (error && error[1]) {
self.display_error(error[1][0]);
}
},
complete: function() {
self.unblockUI();
}
});
},
do_restore: function(form) {
var self = this;
self.blockUI();
$(form).ajaxSubmit({
url: '/web/database/restore',
type: 'POST',
resetForm: true,
success: function (body) {
// If empty body, everything went fine
if (!body) { return; }
if (body.indexOf('403 Forbidden') !== -1) {
self.display_error({
title: _t("Access Denied"),
error: _t("Incorrect super-administrator password")
});
} else {
self.display_error({
title: _t("Restore Database"),
error: _t("Could not restore the database")
});
}
},
complete: function() {
self.unblockUI();
self.do_notify(_t("Restored"), _t("Database restored successfully"));
}
});
},
do_change_password: function(form) {
var self = this;
self.rpc("/web/database/change_password", {
'fields': $(form).serializeArray()
}).done(function(result) {
if (result.error) {
self.display_error(result);
return;
}
self.unblockUI();
self.do_notify(_t("Changed Password"), _t("Password has been changed successfully"));
});
},
do_exit: function () {
this.$el.remove();
instance.web.redirect('/web');
}
});
instance.web.client_actions.add("database_manager", "instance.web.DatabaseManager");
instance.web.login = function() {
instance.web.redirect('/web/login');
};
instance.web.client_actions.add("login", "instance.web.login");
instance.web.logout = function() {
instance.web.redirect('/web/session/logout');
};
instance.web.client_actions.add("logout", "instance.web.logout");
/**
* Redirect to url by replacing window.location
* If wait is true, sleep 1s and wait for the server i.e. after a restart.
*/
instance.web.redirect = function(url, wait) {
// Dont display a dialog if some xmlhttprequest are in progress
if (instance.client && instance.client.crashmanager) {
instance.client.crashmanager.active = false;
}
var load = function() {
var old = "" + window.location;
var old_no_hash = old.split("#")[0];
var url_no_hash = url.split("#")[0];
location.assign(url);
if (old_no_hash === url_no_hash) {
location.reload(true);
}
};
var wait_server = function() {
instance.session.rpc("/web/webclient/version_info", {}).done(load).fail(function() {
setTimeout(wait_server, 250);
});
};
if (wait) {
setTimeout(wait_server, 1000);
} else {
load();
}
};
/**
* Client action to reload the whole interface.
* If params.menu_id, it opens the given menu entry.
* If params.wait, reload will wait the openerp server to be reachable before reloading
*/
instance.web.Reload = function(parent, action) {
var params = action.params || {};
var menu_id = params.menu_id || false;
var l = window.location;
var sobj = $.deparam(l.search.substr(1));
if (params.url_search) {
sobj = _.extend(sobj, params.url_search);
}
var search = '?' + $.param(sobj);
var hash = l.hash;
if (menu_id) {
hash = "#menu_id=" + menu_id;
}
var url = l.protocol + "//" + l.host + l.pathname + search + hash;
instance.web.redirect(url, params.wait);
};
instance.web.client_actions.add("reload", "instance.web.Reload");
/**
* Client action to refresh the session context (making sure
* HTTP requests will have the right one) then reload the
* whole interface.
*/
instance.web.ReloadContext = function(parent, action) {
// side-effect of get_session_info is to refresh the session context
instance.session.rpc("/web/session/get_session_info", {}).then(function() {
instance.web.Reload(parent, action);
});
}
instance.web.client_actions.add("reload_context", "instance.web.ReloadContext");
/**
* Client action to go back in breadcrumb history.
* If can't go back in history stack, will go back to home.
*/
instance.web.HistoryBack = function(parent) {
if (!parent.history_back()) {
instance.web.Home(parent);
}
};
instance.web.client_actions.add("history_back", "instance.web.HistoryBack");
/**
* Client action to go back home.
*/
instance.web.Home = function(parent, action) {
var url = '/' + (window.location.search || '');
instance.web.redirect(url, action && action.params && action.params.wait);
};
instance.web.client_actions.add("home", "instance.web.Home");
instance.web.ChangePassword = instance.web.Widget.extend({
template: "ChangePassword",
start: function() {
var self = this;
this.getParent().dialog_title = _t("Change Password");
var $button = self.$el.find('.oe_form_button');
$button.appendTo(this.getParent().$buttons);
$button.eq(2).click(function(){
self.$el.parents('.modal').modal('hide');
});
$button.eq(0).click(function(){
self.rpc("/web/session/change_password",{
'fields': $("form[name=change_password_form]").serializeArray()
}).done(function(result) {
if (result.error) {
self.display_error(result);
return;
} else {
instance.webclient.on_logout();
}
});
});
},
display_error: function (error) {
return new instance.web.Dialog(this, {
size: 'medium',
title: error.title,
buttons: [
{text: _t("Ok"), click: function() { this.parents('.modal').modal('hide'); }}
]
}, $('<div>').html(error.error)).open();
},
});
instance.web.client_actions.add("change_password", "instance.web.ChangePassword");
instance.web.Menu = instance.web.Widget.extend({
init: function() {
var self = this;
this._super.apply(this, arguments);
this.is_bound = $.Deferred();
this.maximum_visible_links = 'auto'; // # of menu to show. 0 = do not crop, 'auto' = algo
this.data = {data:{children:[]}};
this.on("menu_bound", this, function() {
// launch the fetch of needaction counters, asynchronous
var $all_menus = self.$el.parents('body').find('.oe_webclient').find('[data-menu]');
var all_menu_ids = _.map($all_menus, function (menu) {return parseInt($(menu).attr('data-menu'), 10);});
if (!_.isEmpty(all_menu_ids)) {
this.do_load_needaction(all_menu_ids);
}
});
},
start: function() {
this._super.apply(this, arguments);
return this.bind_menu();
},
do_reload: function() {
var self = this;
self.bind_menu();
},
bind_menu: function() {
var self = this;
this.$secondary_menus = this.$el.parents().find('.oe_secondary_menus_container')
this.$secondary_menus.on('click', 'a[data-menu]', this.on_menu_click);
this.$el.on('click', 'a[data-menu]', this.on_top_menu_click);
// Hide second level submenus
this.$secondary_menus.find('.oe_menu_toggler').siblings('.oe_secondary_submenu').hide();
if (self.current_menu) {
self.open_menu(self.current_menu);
}
this.trigger('menu_bound');
var lazyreflow = _.debounce(this.reflow.bind(this), 200);
instance.web.bus.on('resize', this, function() {
if (parseInt(self.$el.parent().css('width')) <= 768 ) {
lazyreflow('all_outside');
} else {
lazyreflow();
}
});
instance.web.bus.trigger('resize');
this.is_bound.resolve();
},
do_load_needaction: function (menu_ids) {
var self = this;
menu_ids = _.compact(menu_ids);
if (_.isEmpty(menu_ids)) {
return $.when();
}
return this.rpc("/web/menu/load_needaction", {'menu_ids': menu_ids}).done(function(r) {
self.on_needaction_loaded(r);
});
},
on_needaction_loaded: function(data) {
var self = this;
this.needaction_data = data;
_.each(this.needaction_data, function (item, menu_id) {
var $item = self.$secondary_menus.find('a[data-menu="' + menu_id + '"]');
$item.find('.badge').remove();
if (item.needaction_counter && item.needaction_counter > 0) {
$item.append(QWeb.render("Menu.needaction_counter", { widget : item }));
}
});
},
/**
* Reflow the menu items and dock overflowing items into a "More" menu item.
* Automatically called when 'menu_bound' event is triggered and on window resizing.
*
* @param {string} behavior If set to 'all_outside', all the items are displayed. If set to
* 'all_inside', all the items are hidden under the more item. If not set, only the
* overflowing items are hidden.
*/
reflow: function(behavior) {
var self = this;
var $more_container = this.$('#menu_more_container').hide();
var $more = this.$('#menu_more');
var $systray = this.$el.parents().find('.oe_systray');
$more.children('li').insertBefore($more_container); // Pull all the items out of the more menu
// 'all_outside' beahavior should display all the items, so hide the more menu and exit
if (behavior === 'all_outside') {
this.$el.find('li').show();
$more_container.hide();
return;
}
var $toplevel_items = this.$el.find('li').not($more_container).not($systray.find('li')).hide();
$toplevel_items.each(function() {
// In all inside mode, we do not compute to know if we must hide the items, we hide them all
if (behavior === 'all_inside') {
return false;
}
var remaining_space = self.$el.parent().width() - $more_container.outerWidth();
self.$el.parent().children(':visible').each(function() {
remaining_space -= $(this).outerWidth();
});
if ($(this).width() > remaining_space) {
return false;
}
$(this).show();
});
$more.append($toplevel_items.filter(':hidden').show());
$more_container.toggle(!!$more.children().length || behavior === 'all_inside');
// Hide toplevel item if there is only one
var $toplevel = this.$el.children("li:visible");
if ($toplevel.length === 1 && behavior != 'all_inside') {
$toplevel.hide();
}
},
/**
* Opens a given menu by id, as if a user had browsed to that menu by hand
* except does not trigger any event on the way
*
* @param {Number} id database id of the terminal menu to select
*/
open_menu: function (id) {
this.current_menu = id;
this.session.active_id = id;
var $clicked_menu, $sub_menu, $main_menu;
$clicked_menu = this.$el.add(this.$secondary_menus).find('a[data-menu=' + id + ']');
this.trigger('open_menu', id, $clicked_menu);
if (this.$secondary_menus.has($clicked_menu).length) {
$sub_menu = $clicked_menu.parents('.oe_secondary_menu');
$main_menu = this.$el.find('a[data-menu=' + $sub_menu.data('menu-parent') + ']');
} else {
$sub_menu = this.$secondary_menus.find('.oe_secondary_menu[data-menu-parent=' + $clicked_menu.attr('data-menu') + ']');
$main_menu = $clicked_menu;
}
// Activate current main menu
this.$el.find('.active').removeClass('active');
$main_menu.parent().addClass('active');
// Show current sub menu
this.$secondary_menus.find('.oe_secondary_menu').hide();
$sub_menu.show();
// Hide/Show the leftbar menu depending of the presence of sub-items
this.$secondary_menus.parent('.oe_leftbar').toggle(!!$sub_menu.children().length);
// Activate current menu item and show parents
this.$secondary_menus.find('.active').removeClass('active');
if ($main_menu !== $clicked_menu) {
$clicked_menu.parents().show();
if ($clicked_menu.is('.oe_menu_toggler')) {
$clicked_menu.toggleClass('oe_menu_opened').siblings('.oe_secondary_submenu:first').toggle();
} else {
$clicked_menu.parent().addClass('active');
}
}
// add a tooltip to cropped menu items
this.$secondary_menus.find('.oe_secondary_submenu li a span').each(function() {
$(this).tooltip(this.scrollWidth > this.clientWidth ? {title: $(this).text().trim(), placement: 'right'} :'destroy');
});
},
/**
* Call open_menu with the first menu_item matching an action_id
*
* @param {Number} id the action_id to match
*/
open_action: function (id) {
var $menu = this.$el.add(this.$secondary_menus).find('a[data-action-id="' + id + '"]');
var menu_id = $menu.data('menu');
if (menu_id) {
this.open_menu(menu_id);
}
},
/**
* Process a click on a menu item
*
* @param {Number} id the menu_id
* @param {Boolean} [needaction=false] whether the triggered action should execute in a `needs action` context
*/
menu_click: function(id, needaction) {
if (!id) { return; }
// find back the menuitem in dom to get the action
var $item = this.$el.find('a[data-menu=' + id + ']');
if (!$item.length) {
$item = this.$secondary_menus.find('a[data-menu=' + id + ']');
}
var action_id = $item.data('action-id');
// If first level menu doesnt have action trigger first leaf
if (!action_id) {
if(this.$el.has($item).length) {
var $sub_menu = this.$secondary_menus.find('.oe_secondary_menu[data-menu-parent=' + id + ']');
var $items = $sub_menu.find('a[data-action-id]').filter('[data-action-id!=""]');
if($items.length) {
action_id = $items.data('action-id');
id = $items.data('menu');
}
}
}
if (action_id) {
this.trigger('menu_click', {
action_id: action_id,
needaction: needaction,
id: id,
previous_menu_id: this.current_menu // Here we don't know if action will fail (in which case we have to revert menu)
}, $item);
} else {
console.log('Menu no action found web test 04 will fail');
}
this.open_menu(id);
},
do_reload_needaction: function () {
var self = this;
if (self.current_menu) {
self.do_load_needaction([self.current_menu]).then(function () {
self.trigger("need_action_reloaded");
});
}
},
/**
* Jquery event handler for menu click
*
* @param {Event} ev the jquery event
*/
on_top_menu_click: function(ev) {
ev.preventDefault();
var self = this;
var id = $(ev.currentTarget).data('menu');
// Fetch the menu leaves ids in order to check if they need a 'needaction'
var $secondary_menu = this.$el.parents().find('.oe_secondary_menu[data-menu-parent=' + id + ']');
var $menu_leaves = $secondary_menu.children().find('.oe_menu_leaf');
var menu_ids = _.map($menu_leaves, function (leave) {return parseInt($(leave).attr('data-menu'), 10);});
self.do_load_needaction(menu_ids).then(function () {
self.trigger("need_action_reloaded");
});
this.$el.parents().find(".oe_secondary_menus_container").scrollTop(0,0);
this.on_menu_click(ev);
},
on_menu_click: function(ev) {
ev.preventDefault();
var needaction = $(ev.target).is('div#menu_counter');
this.menu_click($(ev.currentTarget).data('menu'), needaction);
},
});
instance.web.UserMenu = instance.web.Widget.extend({
template: "UserMenu",
init: function(parent) {
this._super(parent);
this.update_promise = $.Deferred().resolve();
},
start: function() {
var self = this;
this._super.apply(this, arguments);
this.$el.on('click', '.dropdown-menu li a[data-menu]', function(ev) {
ev.preventDefault();
var f = self['on_menu_' + $(this).data('menu')];
if (f) {
f($(this));
}
});
this.$el.parent().show()
},
do_update: function () {
var self = this;
var fct = function() {
var $avatar = self.$el.find('.oe_topbar_avatar');
$avatar.attr('src', $avatar.data('default-src'));
if (!self.session.uid)
return;
var func = new instance.web.Model("res.users").get_func("read");
return self.alive(func(self.session.uid, ["name", "company_id"])).then(function(res) {
var topbar_name = res.name;
if(instance.session.debug)
topbar_name = _.str.sprintf("%s (%s)", topbar_name, instance.session.db);
if(res.company_id[0] > 1)
topbar_name = _.str.sprintf("%s (%s)", topbar_name, res.company_id[1]);
self.$el.find('.oe_topbar_name').text(topbar_name);
if (!instance.session.debug) {
topbar_name = _.str.sprintf("%s (%s)", topbar_name, instance.session.db);
}
var avatar_src = self.session.url('/web/binary/image', {model:'res.users', field: 'image_small', id: self.session.uid});
$avatar.attr('src', avatar_src);
openerp.web.bus.trigger('resize'); // Re-trigger the reflow logic
});
};
this.update_promise = this.update_promise.then(fct, fct);
},
on_menu_help: function() {
window.open('http://help.eal.im', '_blank');
},
on_menu_logout: function() {
this.trigger('user_logout');
},
on_menu_settings: function() {
var self = this;
if (!this.getParent().has_uncommitted_changes()) {
self.rpc("/web/action/load", { action_id: "base.action_res_users_my" }).done(function(result) {
result.res_id = instance.session.uid;
self.getParent().action_manager.do_action(result);
});
}
},
on_menu_account: function() {
var self = this;
if (!this.getParent().has_uncommitted_changes()) {
var P = new instance.web.Model('ir.config_parameter');
P.call('get_param', ['database.uuid']).then(function(dbuuid) {
var state = {
'd': instance.session.db,
'u': window.location.protocol + '//' + window.location.host,
};
var params = {
response_type: 'token',
client_id: dbuuid || '',
state: JSON.stringify(state),
scope: 'userinfo',
};
instance.web.redirect('https://accounts.eal.im/oauth2/auth?'+$.param(params));
}).fail(function(result, ev){
ev.preventDefault();
instance.web.redirect('https://accounts.eal.im/account');
});
}
},
on_menu_about: function() {
var self = this;
self.rpc("/web/webclient/version_info", {}).done(function(res) {
var $help = $(QWeb.render("UserMenu.about", {version_info: res}));
$help.find('a.oe_activate_debug_mode').click(function (e) {
e.preventDefault();
window.location = $.param.querystring( window.location.href, 'debug');
});
new instance.web.Dialog(this, {
size: 'medium',
dialogClass: 'oe_act_window',
title: _t("About"),
}, $help).open();
});
},
});
instance.web.FullscreenWidget = instance.web.Widget.extend({
/**
* Widgets extending the FullscreenWidget will be displayed fullscreen,
* and will have a fixed 1:1 zoom level on mobile devices.
*/
start: function(){
if(!$('#oe-fullscreenwidget-viewport').length){
$('head').append('<meta id="oe-fullscreenwidget-viewport" name="viewport" content="initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">');
}
instance.webclient.set_content_full_screen(true);
return this._super();
},
destroy: function(){
instance.webclient.set_content_full_screen(false);
$('#oe-fullscreenwidget-viewport').remove();
return this._super();
},
});
instance.web.Client = instance.web.Widget.extend({
init: function(parent, origin) {
instance.client = instance.webclient = this;
this.client_options = {};
this._super(parent);
this.origin = origin;
},
start: function() {
var self = this;
return instance.session.session_bind(this.origin).then(function() {
self.bind_events();
return self.show_common();
});
},
bind_events: function() {
var self = this;
$('.oe_systray').show();
this.$el.on('mouseenter', '.oe_systray > div:not([data-toggle=tooltip])', function() {
$(this).attr('data-toggle', 'tooltip').tooltip().trigger('mouseenter');
});
this.$el.on('click', '.oe_dropdown_toggle', function(ev) {
ev.preventDefault();
var $toggle = $(this);
var doc_width = $(document).width();
var $menu = $toggle.siblings('.oe_dropdown_menu');
$menu = $menu.size() >= 1 ? $menu : $toggle.find('.oe_dropdown_menu');
var state = $menu.is('.oe_opened');
setTimeout(function() {
// Do not alter propagation
$toggle.add($menu).toggleClass('oe_opened', !state);
if (!state) {
// Move $menu if outside window's edge
var offset = $menu.offset();
var menu_width = $menu.width();
var x = doc_width - offset.left - menu_width - 2;
if (x < 0) {
$menu.offset({ left: offset.left + x }).width(menu_width);
}
}
}, 0);
});
instance.web.bus.on('click', this, function(ev) {
$('.tooltip').remove();
if (!$(ev.target).is('input[type=file]')) {
self.$el.find('.oe_dropdown_menu.oe_opened, .oe_dropdown_toggle.oe_opened').removeClass('oe_opened');
}
});
},
show_common: function() {
var self = this;
this.crashmanager = new instance.web.CrashManager();
instance.session.on('error', this.crashmanager, this.crashmanager.rpc_error);
self.notification = new instance.web.Notification(this);
self.notification.appendTo(self.$el.find('.openerp'));
self.loading = new instance.web.Loading(self);
self.loading.appendTo(self.$('.openerp_webclient_container'));
self.action_manager = new instance.web.ActionManager(self);
self.action_manager.appendTo(self.$('.oe_application'));
},
toggle_bars: function(value) {
this.$('tr:has(td.navbar),.oe_leftbar').toggle(value);
},
has_uncommitted_changes: function() {
return false;
},
});
instance.web.WebClient = instance.web.Client.extend({
init: function(parent, client_options) {
this._super(parent);
if (client_options) {
_.extend(this.client_options, client_options);
}
this._current_state = null;
this.menu_dm = new instance.web.DropMisordered();
this.action_mutex = new $.Mutex();
this.set('title_part', {"zopenerp": "ERP"});
},
start: function() {
var self = this;
this.on("change:title_part", this, this._title_changed);
this._title_changed();
return $.when(this._super()).then(function() {
if (jQuery.deparam !== undefined && jQuery.deparam(jQuery.param.querystring()).kitten !== undefined) {
self.to_kitten();
}
if (self.session.session_is_valid()) {
self.show_application();
}
if (self.client_options.action) {
self.action_manager.do_action(self.client_options.action);
delete(self.client_options.action);
}
instance.web.cordova.ready();
instance.web.cordova.on('back', self, function() {
self.do_action('history_back');
});
});
},
to_kitten: function() {
this.kitten = true;
$("body").addClass("kitten-mode-activated");
$("body").css("background-image", "url(" + instance.session.origin + "/web/static/src/img/back-enable.jpg" + ")");
if ($.blockUI) {
var imgkit = Math.floor(Math.random() * 2 + 1);
$.blockUI.defaults.message = '<img src="/web/static/src/img/k-waiting' + imgkit + '.gif" class="loading-kitten">';
}
},
/**
Sets the first part of the title of the window, dedicated to the current action.
*/
set_title: function(title) {
this.set_title_part("action", title);
},
/**
Sets an arbitrary part of the title of the window. Title parts are identified by strings. Each time
a title part is changed, all parts are gathered, ordered by alphabetical order and displayed in the
title of the window separated by '-'.
*/
set_title_part: function(part, title) {
var tmp = _.clone(this.get("title_part"));
tmp[part] = title;
this.set("title_part", tmp);
},
_title_changed: function() {
var parts = _.sortBy(_.keys(this.get("title_part")), function(x) { return x; });
var tmp = "";
_.each(parts, function(part) {
var str = this.get("title_part")[part];
if (str) {
tmp = tmp ? tmp + " - " + str : str;
}
}, this);
document.title = tmp;
},
show_common: function() {
var self = this;
this._super();
window.onerror = function (message, file, line) {
self.crashmanager.show_error({
type: _t("Client Error"),
message: message,
data: {debug: file + ':' + line}
});
};
},
show_application: function() {
var self = this;
self.toggle_bars(true);
self.update_logo();
this.$('.oe_logo_edit_admin').click(function(ev) {
self.logo_edit(ev);
});
// Menu is rendered server-side thus we don't want the widget to create any dom
self.menu = new instance.web.Menu(self);
self.menu.setElement(this.$el.parents().find('.oe_application_menu_placeholder'));
self.menu.start();
self.menu.on('menu_click', this, this.on_menu_action);
self.user_menu = new instance.web.UserMenu(self);
self.user_menu.appendTo(this.$el.parents().find('.oe_user_menu_placeholder'));
self.user_menu.on('user_logout', self, self.on_logout);
self.user_menu.do_update();
self.bind_hashchange();
self.set_title();
self.check_timezone();
if (self.client_options.action_post_login) {
self.action_manager.do_action(self.client_options.action_post_login);
delete(self.client_options.action_post_login);
}
/* Do not forward port! */
if ($.browser.chrome) {
var chrome_version = $.browser.version.split('.')[0];
if (parseInt(chrome_version, 10) >= 50) {
openerp.loadCSS('/web/static/src/css/chrome50.css');
}
}
},
update_logo: function() {
var company = this.session.company_id;
var img = this.session.url('/web/binary/company_logo' + '?db=' + this.session.db + (company ? '&company=' + company : ''));
this.$('.oe_logo img').attr('src', '').attr('src', img);
this.$('.oe_logo_edit').toggleClass('oe_logo_edit_admin', this.session.uid === 1);
},
logo_edit: function(ev) {
var self = this;
ev.preventDefault();
self.alive(new instance.web.Model("res.users").get_func("read")(this.session.uid, ["company_id"])).then(function(res) {
self.rpc("/web/action/load", { action_id: "base.action_res_company_form" }).done(function(result) {
result.res_id = res['company_id'][0];
result.target = "new";
result.views = [[false, 'form']];
result.flags = {
action_buttons: true,
};
self.action_manager.do_action(result);
var form = self.action_manager.dialog_widget.views.form.controller;
form.on("on_button_cancel", self.action_manager, self.action_manager.dialog_stop);
form.on('record_saved', self, function() {
self.action_manager.dialog_stop();
self.update_logo();
});
});
});
return false;
},
check_timezone: function() {
var self = this;
return self.alive(new instance.web.Model('res.users').call('read', [[this.session.uid], ['tz_offset']])).then(function(result) {
var user_offset = result[0]['tz_offset'];
var offset = -(new Date().getTimezoneOffset());
// _.str.sprintf()'s zero front padding is buggy with signed decimals, so doing it manually
var browser_offset = (offset < 0) ? "-" : "+";
browser_offset += _.str.sprintf("%02d", Math.abs(offset / 60));
browser_offset += _.str.sprintf("%02d", Math.abs(offset % 60));
if (browser_offset !== user_offset) {
var $icon = $(QWeb.render('WebClient.timezone_systray'));
$icon.on('click', function() {
var notification = self.do_warn(_t("Timezone Mismatch"), QWeb.render('WebClient.timezone_notification', {
user_timezone: instance.session.user_context.tz || 'UTC',
user_offset: user_offset,
browser_offset: browser_offset,
}), true);
notification.element.find('.oe_webclient_timezone_notification').on('click', function() {
notification.close();
}).find('a').on('click', function() {
notification.close();
self.user_menu.on_menu_settings();
return false;
});
});
$icon.prependTo(window.$('.oe_systray'));
}
});
},
destroy_content: function() {
_.each(_.clone(this.getChildren()), function(el) {
el.destroy();
});
this.$el.children().remove();
},
do_reload: function() {
var self = this;
return this.session.session_reload().then(function () {
instance.session.load_modules(true).then(
self.menu.proxy('do_reload')); });
},
do_notify: function() {
var n = this.notification;
return n.notify.apply(n, arguments);
},
do_warn: function() {
var n = this.notification;
return n.warn.apply(n, arguments);
},
on_logout: function() {
var self = this;
if (!this.has_uncommitted_changes()) {
instance.web.cordova.logout();
self.action_manager.do_action('logout');
}
},
bind_hashchange: function() {
var self = this;
$(window).bind('hashchange', this.on_hashchange);
var state = $.bbq.getState(true);
if (_.isEmpty(state) || state.action == "login") {
self.menu.is_bound.done(function() {
new instance.web.Model("res.users").call("read", [self.session.uid, ["action_id"]]).done(function(data) {
if(data.action_id) {
self.action_manager.do_action(data.action_id[0]);
self.menu.open_action(data.action_id[0]);
} else {
var first_menu_id = self.menu.$el.find("a:first").data("menu");
if(first_menu_id) {
self.menu.menu_click(first_menu_id);
} }
});
});
} else {
$(window).trigger('hashchange');
}
},
on_hashchange: function(event) {
var self = this;
var stringstate = event.getState(false);
if (!_.isEqual(this._current_state, stringstate)) {
var state = event.getState(true);
if(!state.action && state.menu_id) {
self.menu.is_bound.done(function() {
self.menu.menu_click(state.menu_id);
});
} else {
state._push_me = false; // no need to push state back...
this.action_manager.do_load_state(state, !!this._current_state);
}
}
this._current_state = stringstate;
},
do_push_state: function(state) {
this.set_title(state.title);
delete state.title;
var url = '#' + $.param(state);
this._current_state = $.deparam($.param(state), false); // stringify all values
$.bbq.pushState(url);
this.trigger('state_pushed', state);
},
on_menu_action: function(options) {
var self = this;
return this.menu_dm.add(this.rpc("/web/action/load", { action_id: options.action_id }))
.then(function (result) {
return self.action_mutex.exec(function() {
if (options.needaction) {
result.context = new instance.web.CompoundContext(result.context, {
search_default_message_unread: true,
search_disable_custom_filters: true,
});
}
var completed = $.Deferred();
$.when(self.action_manager.do_action(result, {
clear_breadcrumbs: true,
action_menu_id: self.menu.current_menu,
})).fail(function() {
self.menu.open_menu(options.previous_menu_id);
}).always(function() {
completed.resolve();
});
setTimeout(function() {
completed.resolve();
}, 2000);
// We block the menu when clicking on an element until the action has correctly finished
// loading. If something crash, there is a 2 seconds timeout before it's unblocked.
return completed;
});
});
},
set_content_full_screen: function(fullscreen) {
$(document.body).css('overflow-y', fullscreen ? 'hidden' : 'scroll');
this.$('.oe_webclient').toggleClass(
'oe_content_full_screen', fullscreen);
},
has_uncommitted_changes: function() {
var $e = $.Event('clear_uncommitted_changes');
instance.web.bus.trigger('clear_uncommitted_changes', $e);
if ($e.isDefaultPrevented()) {
return true;
} else {
return this._super.apply(this, arguments);
}
},
});
instance.web.EmbeddedClient = instance.web.Client.extend({
_template: 'EmbedClient',
init: function(parent, origin, dbname, login, key, action_id, options) {
this._super(parent, origin);
this.bind_credentials(dbname, login, key);
this.action_id = action_id;
this.options = options || {};
},
start: function() {
var self = this;
return $.when(this._super()).then(function() {
return self.authenticate().then(function() {
if (!self.action_id) {
return;
}
return self.rpc("/web/action/load", { action_id: self.action_id }).done(function(result) {
var action = result;
action.flags = _.extend({
//views_switcher : false,
search_view : false,
action_buttons : false,
sidebar : false
//pager : false
}, self.options, action.flags || {});
self.do_action(action);
});
});
});
},
do_action: function(/*...*/) {
var am = this.action_manager;
return am.do_action.apply(am, arguments);
},
authenticate: function() {
var s = instance.session;
if (s.session_is_valid() && s.db === this.dbname && s.login === this.login) {
return $.when();
}
return instance.session.session_authenticate(this.dbname, this.login, this.key);
},
bind_credentials: function(dbname, login, key) {
this.dbname = dbname;
this.login = login;
this.key = key;
},
});
instance.web.embed = function (origin, dbname, login, key, action, options) {
$('head').append($('<link>', {
'rel': 'stylesheet',
'type': 'text/css',
'href': origin +'/web/css/web.assets_webclient'
}));
var currentScript = document.currentScript;
if (!currentScript) {
var sc = document.getElementsByTagName('script');
currentScript = sc[sc.length-1];
}
var client = new instance.web.EmbeddedClient(null, origin, dbname, login, key, action, options);
client.insertAfter(currentScript);
};
/*
* The Android/iPhone App is a JS/HTML app that launches the
* ERP webclient in an iframe, using the Cordova framework.
*
* This class acts as a link between the webclient and the
* ERP Android/iPhone App implemented with cordova.
*/
instance.web.Cordova = instance.web.Class.extend({}, instance.web.PropertiesMixin, {
init: function(parent) {
var self = this;
instance.web.PropertiesMixin.init.call(this, parent);
window.addEventListener('message', function(event) {
self.receive(event);
}, false);
},
// odoo.send('foobar') in cordova will call messages.foobar()
messages: {
// launch the POS !
pos: function() {
if (window.location.href.indexOf('/pos/web') < 0) {
window.location.href = "/pos/web";
}
},
},
// what happens when we receive an event from cordova
// -> call messages[event.data]()
// -> selfs trigger(event.data)
receive: function(event) {
if (event.origin !== 'file://') {
return;
}
if (typeof event.data === 'string') {
this.trigger(event.data);
if (this.messages[event.data]) {
this.messages[event.data].call(this);
}
}
},
// send a message to cordova
send: function(message) {
function inIframe(){
try {
return window.self !== window.top;
} catch (e) {
return true;
}
}
if (inIframe()) {
window.parent.postMessage(message,'file://');
}
},
// notifies cordova that the webclient is ready.
ready: function() { this.send('ready'); },
// notifies cordova that we want to exit the app.
logout: function() { this.send('logout'); },
// asks cordova to emit a beep.
beep: function() { this.send('beep'); },
// ask cordova to vibrate the phone.
vibrate: function() { this.send('vibrate'); },
});
instance.web.cordova = new instance.web.Cordova();
})();
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:
/*
# -*- encoding: utf-8 -*-
*/
openerp_FieldMany2ManyTagsMultiSelection = function(instance) {
var _t = instance.web._t;
instance.web.form.CompletionFieldMixin._search_create_popup = function(view, ids, context) {
var self = this;
var pop = new instance.web.form.SelectCreatePopup(this);
var domain = self.build_domain();
if (self.field.type == 'many2many') {
var selected_ids = self.get_search_blacklist();
if (selected_ids.length > 0) {
domain = new instance.web.CompoundDomain(domain, ["!", ["id", "in", selected_ids]]);
}
}
pop.select_element(self.field.relation, {
title : (view === 'search' ? _t("Search: ") : _t("Create: ")) + this.string,
initial_ids : ids ? _.map(ids, function(x) {
return x[0];
}) : undefined,
initial_view : view,
disable_multiple_selection : this.field.type != 'many2many',
}, domain, new instance.web.CompoundContext(self.build_context(), context || {}));
pop.on("elements_selected", self, function(element_ids) {
for (var i = 0,
len = element_ids.length; i < len; i++) {
self.add_id(element_ids[i]);
if (self.field.type != 'many2many') {
break;
}
}
self.focus();
});
};
};
/*
# -*- encoding: utf-8 -*-
*/
/*! */
;(function ($, window, undefined) {
'use strict';
var name = 'stickyTableHeaders',
id = 0,
defaults = {
fixedOffset: 0,
leftOffset: 0,
marginTop: 0,
objDocument: document,
objHead: 'head',
objWindow: window,
scrollableArea: window
};
function Plugin (el, options) {
// To avoid scope issues, use 'base' instead of 'this'
// to reference this class from internal events and functions.
var base = this;
// Access to jQuery and DOM versions of element
base.$el = $(el);
base.el = el;
base.id = id++;
// Listen for destroyed, call teardown
base.$el.bind('destroyed',
$.proxy(base.teardown, base));
// Cache DOM refs for performance reasons
base.$clonedHeader = null;
base.$originalHeader = null;
// Keep track of state
base.isSticky = false;
base.hasBeenSticky = false;
base.leftOffset = null;
base.topOffset = null;
base.init = function () {
base.setOptions(options);
base.$el.each(function () {
var $this = $(this);
// remove padding on <table> to fix issue #7
$this.css('padding', 0);
base.$originalHeader = $('thead:first', this);
base.$clonedHeader = base.$originalHeader.clone();
$this.trigger('clonedHeader.' + name, [base.$clonedHeader]);
base.$clonedHeader.addClass('tableFloatingHeader');
base.$clonedHeader.css('display', 'none');
base.$originalHeader.addClass('tableFloatingHeaderOriginal');
base.$originalHeader.after(base.$clonedHeader);
base.$printStyle = $('<style type="text/css" media="print">' +
'.tableFloatingHeader{display:none !important;}' +
'.tableFloatingHeaderOriginal{position:static !important;}' +
'</style>');
base.$head.append(base.$printStyle);
});
base.updateWidth();
base.toggleHeaders();
base.bind();
};
base.destroy = function (){
base.$el.unbind('destroyed', base.teardown);
base.teardown();
};
base.teardown = function(){
if (base.isSticky) {
base.$originalHeader.css('position', 'static');
}
$.removeData(base.el, 'plugin_' + name);
base.unbind();
base.$clonedHeader.remove();
base.$originalHeader.removeClass('tableFloatingHeaderOriginal');
base.$originalHeader.css('visibility', 'visible');
base.$printStyle.remove();
base.el = null;
base.$el = null;
};
base.bind = function(){
base.$scrollableArea.on('scroll.' + name, base.toggleHeaders);
if (!base.isWindowScrolling) {
base.$window.on('scroll.' + name + base.id, base.setPositionValues);
base.$window.on('resize.' + name + base.id, base.toggleHeaders);
base.$window.on('resize.' + name + base.id, base.updateWidth);
}
base.$scrollableArea.on('resize.' + name, base.toggleHeaders);
base.$scrollableArea.on('resize.' + name, base.updateWidth);
};
base.unbind = function(){
// unbind window events by specifying handle so we don't remove too much
base.$scrollableArea.off('.' + name, base.toggleHeaders);
if (!base.isWindowScrolling) {
base.$window.off('.' + name + base.id, base.setPositionValues);
base.$window.off('.' + name + base.id, base.toggleHeaders);
}
base.$scrollableArea.off('.' + name, base.updateWidth);
};
base.toggleHeaders = function () {
if (base.$el) {
base.$el.each(function () {
var $this = $(this),
newLeft,
newTopOffset = base.isWindowScrolling ? (
isNaN(base.options.fixedOffset) ?
base.options.fixedOffset.outerHeight() :
base.options.fixedOffset
) :
base.$scrollableArea.offset().top + (!isNaN(base.options.fixedOffset) ? base.options.fixedOffset : 0),
offset = $this.offset(),
scrollTop = base.$scrollableArea.scrollTop(),
scrollLeft = base.$scrollableArea.scrollLeft(),
scrolledPastTop = base.isWindowScrolling ?
scrollTop > offset.top :
newTopOffset > offset.top,
notScrolledPastBottom = (base.isWindowScrolling ? scrollTop : 0) <
(offset.top + $this.height() - base.$clonedHeader.height() - (base.isWindowScrolling ? 0 : newTopOffset));
if (scrolledPastTop && notScrolledPastBottom) {
newLeft = 0;
base.$originalHeader.css({
'position': 'absolute',
'margin-top': base.options.marginTop,
'left': newLeft,
'z-index': 3 // #18: opacity bug
});
base.leftOffset = newLeft;
base.topOffset = scrollTop;
base.$clonedHeader.css('display', '');
if (!base.isSticky) {
base.isSticky = true;
// make sure the width is correct: the user might have resized the browser while in static mode
base.updateWidth();
$this.trigger('enabledStickiness.' + name);
}
base.setPositionValues();
} else if (base.isSticky) {
base.$originalHeader.css('position', 'static');
base.$clonedHeader.css('display', 'none');
base.isSticky = false;
base.resetWidth($('td,th', base.$clonedHeader), $('td,th', base.$originalHeader));
$this.trigger('disabledStickiness.' + name);
}
});
}
};
base.setPositionValues = function () {
var winScrollTop = base.$window.scrollTop(),
winScrollLeft = base.$window.scrollLeft();
if (!base.isSticky ||
winScrollTop < 0 || winScrollTop + base.$window.height() > base.$document.height() ||
winScrollLeft < 0 || winScrollLeft + base.$window.width() > base.$document.width()) {
return;
}
base.$originalHeader.css({
'top': base.topOffset,
'left': base.leftOffset - (base.isWindowScrolling ? 0 : winScrollLeft)
});
};
base.updateWidth = function () {
if (!base.isSticky) {
return;
}
// Copy cell widths from clone
if (!base.$originalHeaderCells) {
base.$originalHeaderCells = $('th,td', base.$originalHeader);
}
if (!base.$clonedHeaderCells) {
base.$clonedHeaderCells = $('th,td', base.$clonedHeader);
}
var cellWidths = base.getWidth(base.$clonedHeaderCells);
base.setWidth(cellWidths, base.$clonedHeaderCells, base.$originalHeaderCells);
// Copy row width from whole table
base.$originalHeader.css('width', base.$clonedHeader.width());
};
base.getWidth = function ($clonedHeaders) {
var widths = [];
$clonedHeaders.each(function (index) {
var width, $this = $(this);
if ($this.css('box-sizing') === 'border-box') {
var boundingClientRect = $this[0].getBoundingClientRect();
if(boundingClientRect.width) {
width = boundingClientRect.width; // #39: border-box bug
} else {
width = boundingClientRect.right - boundingClientRect.left; // ie8 bug: getBoundingClientRect() does not have a width property
}
} else {
var $origTh = $('th', base.$originalHeader);
if ($origTh.css('border-collapse') === 'collapse') {
if (window.getComputedStyle) {
width = parseFloat(window.getComputedStyle(this, null).width);
} else {
// ie8 only
var leftPadding = parseFloat($this.css('padding-left'));
var rightPadding = parseFloat($this.css('padding-right'));
// Needs more investigation - this is assuming constant border around this cell and it's neighbours.
var border = parseFloat($this.css('border-width'));
width = $this.outerWidth() - leftPadding - rightPadding - border;
}
} else {
width = $this.width();
}
}
widths[index] = width;
});
return widths;
};
base.setWidth = function (widths, $clonedHeaders, $origHeaders) {
$clonedHeaders.each(function (index) {
var width = widths[index];
$origHeaders.eq(index).css({
'min-width': width,
'max-width': width
});
});
};
base.resetWidth = function ($clonedHeaders, $origHeaders) {
$clonedHeaders.each(function (index) {
var $this = $(this);
$origHeaders.eq(index).css({
'min-width': $this.css('min-width'),
'max-width': $this.css('max-width')
});
});
};
base.setOptions = function (options) {
base.options = $.extend({}, defaults, options);
base.$window = $(base.options.objWindow);
base.$head = $(base.options.objHead);
base.$document = $(base.options.objDocument);
base.$scrollableArea = $(base.options.scrollableArea);
base.isWindowScrolling = base.$scrollableArea[0] === base.$window[0];
};
base.updateOptions = function (options) {
base.setOptions(options);
// scrollableArea might have changed
base.unbind();
base.bind();
base.updateWidth();
base.toggleHeaders();
};
// Run initializer
base.init();
}
// A plugin wrapper around the constructor,
// preventing against multiple instantiations
$.fn[name] = function ( options ) {
return this.each(function () {
var instance = $.data(this, 'plugin_' + name);
if (instance) {
if (typeof options === 'string') {
instance[options].apply(instance);
} else {
instance.updateOptions(options);
}
} else if(options !== 'destroy') {
$.data(this, 'plugin_' + name, new Plugin( this, options ));
}
});
};
})(jQuery, window);
<?xml version="1.0" encoding="utf-8"?>
<!-- Author: e@eal.im -->
<templates>
<!-- Qweb templates for Backend -->
<t t-extend="UserMenu">
<t t-jquery="ul" t-operation="replace">
<ul class="dropdown-menu">
<li><a href="#" data-menu="settings">Preferences</a></li>
<li><a href="#" data-menu="about">About Development</a></li>
<li><a href="#" data-menu="logout">Log out</a></li>
</ul>
</t>
</t>
</templates>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Author: e@eal.im -->
<openerp>
<data>
<!-- Setting theme favicon -->
<template id="layout" inherit_id="web.layout" name="Setting favicon" priority="20">
<xpath expr="//link[@rel='shortcut icon']" position="replace">
<link rel="shortcut icon" href="/responsive_backend_theme/static/src/img/favicon.ico" type="image/x-icon"/>
</xpath>
</template>
<!-- Add theme CSS and Javascript -->
<template id="assets_backend" inherit_id="web.assets_backend" name="Custom CSS and JS">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/responsive_backend_theme/static/src/css/backend.css"/>
<script type="text/javascript" src="/responsive_backend_theme/static/src/js/backend.js"></script>
<script type="text/javascript"
src="/responsive_backend_theme/static/src/js/sticky_table_headers.js"></script>
<script type="text/javascript" src="/responsive_backend_theme/static/src/js/base.js"></script>
<script type="text/javascript"
src="/responsive_backend_theme/static/src/js/many2many_tags_multi_selection.js"></script>
<script type="text/javascript"
src="/responsive_backend_theme/static/src/js/listview_html_widget.js"></script>
<script type="text/javascript" src="/responsive_backend_theme/static/src/js/listview_sticky.js"></script>
<script type="text/javascript" src="/responsive_backend_theme/static/src/js/loading.js"></script>
<style>
@keyframes page-load {
from {
width:0;
}
to {
width:100%;
}
}
.page-loading::before {
content:" ";
display:block;
position:fixed;
z-index:10;
height:2px;
width:100%;
top:0;
left:0;
background-color:#06D;
animation: page-load ease-out 2s;
}
</style>
</xpath>
</template>
<template id="customizing_css_id" inherit_id="web.assets_common" name="customizing_css_name">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/responsive_backend_theme/static/src/css/list_view.css"/>
<style>
@keyframes page-load {
from {
width:0;
}
to {
width:100%;
}
}
.page-loading::before {
content:" ";
display:block;
position:fixed;
z-index:10;
height:2px;
width:100%;
top:0;
left:0;
background-color:#06D;
animation: page-load ease-out 2s;
}
</style>
</xpath>
</template>
<!-- Remove login footer and change logo -->
<!-- Priority 10 to be applied before website.login_layout if installed -->
<template id="login_layout" inherit_id="web.login_layout" name="Remove login footer and change logo"
priority="10">
<xpath expr="//div[@class='oe_single_form_footer']" position="replace">
<div></div>
</xpath>
</template>
<template id="menu_secondary" inherit_id="web.menu_secondary" name="Force logo in backend" priority="20">
<xpath expr="//a[@class='oe_logo']" position="replace">
<a class="test" t-att-href="'/web'">
<center>
<img src='/web/binary/company_logo' style="border-radius: 5px;margin:10px;"/>
</center>
</a>
</xpath>
<xpath expr="//div[@class='oe_footer']" position="replace">
<div></div>
</xpath>
</template>
</data>
</openerp>
<!DOCTYPE html>
<html style="height: 100%;">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Odoo</title>
<link rel="shortcut icon" href="/web/static/src/img/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" href="/web/static/src/css/full.css"/>
<script src="/web/static/lib/es5-shim/es5-shim.min.js" type="text/javascript"></script>
<script src="/web/static/lib/underscore/underscore.js" type="text/javascript"></script>
<script src="/web/static/lib/underscore.string/lib/underscore.string.js" type="text/javascript"></script>
<script src="/web/static/lib/datejs/globalization/en-US.js" type="text/javascript"></script>
<script src="/web/static/lib/spinjs/spin.js" type="text/javascript"></script>
<script src="/web/static/lib/jquery/jquery.js" type="text/javascript"></script>
<script src="/web/static/lib/jquery.blockUI/jquery.blockUI.js" type="text/javascript"></script>
<script src="/web/static/lib/jquery.hotkeys/jquery.hotkeys.js" type="text/javascript"></script>
<script src="/web/static/lib/jquery.placeholder/jquery.placeholder.js" type="text/javascript"></script>
<script src="/web/static/lib/jquery.timeago/jquery.timeago.js" type="text/javascript"></script>
<script src="/web/static/lib/jquery.form/jquery.form.js" type="text/javascript"></script>
<script src="/web/static/lib/jquery.ba-bbq/jquery.ba-bbq.js" type="text/javascript"></script>
<script src="/web/static/lib/datejs/core.js" type="text/javascript"></script>
<script src="/web/static/lib/datejs/parser.js" type="text/javascript"></script>
<script src="/web/static/lib/datejs/sugarpak.js" type="text/javascript"></script>
<script src="/web/static/lib/datejs/extras.js" type="text/javascript"></script>
<script src="/web/static/lib/jquery.validate/jquery.validate.js" type="text/javascript"></script>
<script src="/web/static/lib/jquery.autosize/jquery.autosize.js" type="text/javascript"></script>
<script src="/web/static/lib/jquery.scrollTo/jquery.scrollTo-min.js" type="text/javascript"></script>
<script src="/web/static/lib/cleditor/jquery.cleditor.js" type="text/javascript"></script>
<script src="/web/static/lib/jquery.textext/jquery.textext.js" type="text/javascript"></script>
<script src="/web/static/lib/select2/select2.js" type="text/javascript"></script>
<script src="/web/static/lib/jquery.ui/js/jquery-ui-1.9.1.custom.js" type="text/javascript"></script>
<script src="/web/static/lib/jquery.ui.timepicker/js/jquery-ui-timepicker-addon.js" type="text/javascript"></script>
<script src="/web/static/lib/jquery.ui.notify/js/jquery.notify.js" type="text/javascript"></script>
<script src="/web/static/lib/bootstrap/js/bootstrap.js" type="text/javascript"></script>
<script src="/web/static/lib/backbone/backbone.js" type="text/javascript"></script>
<script src="/web/static/lib/qweb/qweb2.js" type="text/javascript"></script>
<script src="/web/static/src/js/openerpframework.js" type="text/javascript"></script>
<script src="/web/static/lib/py.js/lib/py.js" type="text/javascript"></script>
<script src="/web/static/src/js/boot.js" type="text/javascript"></script>
<script src="/web/static/src/js/testing.js" type="text/javascript"></script>
<script src="/web/static/src/js/pyeval.js" type="text/javascript"></script>
<script src="/web/static/src/js/core.js" type="text/javascript"></script>
<script src="/web/static/src/js/formats.js" type="text/javascript"></script>
<script src="/web/static/src/js/chrome.js" type="text/javascript"></script>
<script src="/web/static/src/js/views.js" type="text/javascript"></script>
<script src="/web/static/src/js/data.js" type="text/javascript"></script>
<script src="/web/static/src/js/data_export.js" type="text/javascript"></script>
<script src="/web/static/src/js/search.js" type="text/javascript"></script>
<script src="/web/static/src/js/view_list.js" type="text/javascript"></script>
<script src="/web/static/src/js/view_form.js" type="text/javascript"></script>
<script src="/web/static/src/js/view_list_editable.js" type="text/javascript"></script>
<script src="/web/static/src/js/view_tree.js" type="text/javascript"></script>
<script src="/base/static/src/js/apps.js" type="text/javascript"></script>
<script src="/web/static/src/js/tour.js" type="text/javascript"></script>
<link href="/web/static/lib/fontawesome/css/font-awesome.css" rel="stylesheet"/>
<link href="/web/static/lib/cleditor/jquery.cleditor.css" rel="stylesheet"/>
<link href="/web/static/lib/jquery.textext/jquery.textext.css" rel="stylesheet"/>
<link href="/web/static/lib/select2/select2.css" rel="stylesheet"/>
<link href="/web/static/lib/jquery.ui.bootstrap/css/custom-theme/jquery-ui-1.9.0.custom.css" rel="stylesheet"/>
<link href="/web/static/lib/jquery.ui.timepicker/css/jquery-ui-timepicker-addon.css" rel="stylesheet"/>
<link href="/web/static/lib/jquery.ui.notify/css/ui.notify.css" rel="stylesheet"/>
<link href="/web/static/lib/bootstrap/css/bootstrap.css" rel="stylesheet"/>
<link href="/web/static/src/css/base.css" rel="stylesheet"/>
<link href="/web/static/src/css/data_export.css" rel="stylesheet"/>
<link href="/base/static/src/css/modules.css" rel="stylesheet"/>
<link rel="stylesheet" href="/responsive_backend_theme/static/src/css/backend.css"/>
<script type="text/javascript" src="/responsive_backend_theme/static/src/js/loading.js"></script>
<script type="text/javascript">
$(function () {
/* Do not forward port this block! */
if ($.browser.chrome) {
var chrome_version = $.browser.version.split('.')[0];
if (parseInt(chrome_version, 10) >= 50) {
openerp.loadCSS('/web/static/src/css/chrome50.css');
}
}
var s = new openerp.init({{ modules|safe }});
var wc = new s.web.WebClient(null, {action: 'database_manager'});
wc.setElement($(document.body));
wc.start();
});
</script>
</head>
<body>
<nav id="oe_main_menu_navbar" class="navbar navbar-inverse" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="oe_main_menu_placeholder">
<ul class="nav navbar-nav navbar-right oe_user_menu_placeholder"></ul>
</div>
</nav>
<div class="openerp openerp_webclient_container">
<table class="oe_webclient">
<tr>
<td class="oe_leftbar" valign="top">
<div>
<a class="oe_logo">
<span class="oe_logo_edit">Edit Company data</span>
<img src='/web/binary/company_logo'/>
</a>
<div>
<div>
<div class="oe_secondary_menus_container"></div>
</div>
</div>
<div class="oe_footer">
Powered by <a href="http://www.eal.im" target="_blank"><span>eal.im</span></a>
</div>
</div>
</td>
<td class="oe_application">
</td>
</tr>
</table>
</div>
<!--[if lte IE 8]>
<script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script>
<script>CFInstall.check({mode: "overlay"});</script>
<![endif]-->
</body>
</html>
<!DOCTYPE html>
<html style="height: 100%">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>ERP</title>
<link rel="shortcut icon" href="/web/static/src/img/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="/web/static/src/css/full.css">
<link rel="stylesheet" href="/web/static/lib/fontawesome/css/font-awesome.css">
<link rel="stylesheet" href="/web/static/lib/bootstrap/css/bootstrap.css">
<link rel="stylesheet" href="/web/static/src/css/base.css">
<link rel="stylesheet" href="/responsive_backend_theme/static/src/css/backend.css"/>
<script type="text/javascript" src="/responsive_backend_theme/static/src/js/loading.js"></script>
<script type="text/javascript">
function dbchanged() {
document.getElementById('dbselector').submit();
}
</script>
<body class="oe_single_form">
<div class="oe_single_form_container modal-content">
<form class="oe_dbselector_form" id="dbselector" role="form" action="/web" method="get">
<div class="oe_single_form_logo">
<img src="/web/static/src/img/logo2.png"/>
</div>
<hr/>
{% if error %}
<p class="alert alert-danger">
{{ error }}
</p>
{% endif %}
<div class="form-group field-db">
<label for="db" class="control-label">Select database</label>
{% if databases %}
<select name="db" id="db" class="form-control" required="required" autofocus="autofocus"
onchange="dbchanged()">
<option></option>
{% for db in databases %}
<option value="{{ db }}">{{ db }}</option>
{% endfor %}
</select>
{% else %}
<input type="text" name="db" id="db" class="form-control" required="required" autofocus="autofocus"/>
{% endif %}
</div>
{% if debug %}
<input type="hidden" name="debug" value=""/>
{% endif %}
<noscript>
<hr/>
<input type="submit" value="Continue" class="btn btn-primary pull-right"/>
</noscript>
<div class="oe_single_form_footer">
<a class="oe_login_manage_db" href="/web/database/manager{% if debug %}?debug{% endif %}">Manage
Databases</a> |
<a href="http://www.eal.im" target="_blank">Powered by <span>eal.im</span></a>
</div>
</form>
</div>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment