[MERGE] merge upstream + code adaptation to revid:al@openerp.com-20110927001435-vttw23epyru5gm0b
bzr revid: chs@openerp.com-20110927085435-pipko7w752conp3a
This commit is contained in:
commit
1d2d17a365
|
@ -10,15 +10,14 @@ class Options(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def wsgi_postload():
|
def wsgi_postload():
|
||||||
import openerp.wsgi
|
import openerp
|
||||||
import openerp.tools
|
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
_logger.info("embedded mode")
|
_logger.info("embedded mode")
|
||||||
o = Options()
|
o = Options()
|
||||||
o.dbfilter = openerp.tools.config['dbfilter']
|
o.dbfilter = openerp.tools.config['dbfilter']
|
||||||
o.session_storage = os.path.join(tempfile.gettempdir(), "oe-sessions")
|
o.session_storage = os.path.join(tempfile.gettempdir(), "oe-sessions")
|
||||||
o.addons_path = os.path.dirname(os.path.dirname(__file__))
|
o.addons_path = openerp.modules.module.ad_paths
|
||||||
o.serve_static = True
|
o.serve_static = True
|
||||||
o.backend = 'local'
|
o.backend = 'local'
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
"name" : "web",
|
"name" : "web",
|
||||||
"depends" : [],
|
"depends" : [],
|
||||||
'active': True,
|
'active': True,
|
||||||
'web_auto_load': True,
|
'post_load' : 'wsgi_postload',
|
||||||
|
'web_preload' : True,
|
||||||
'js' : [
|
'js' : [
|
||||||
"static/lib/datejs/globalization/en-US.js",
|
"static/lib/datejs/globalization/en-US.js",
|
||||||
"static/lib/datejs/core.js",
|
"static/lib/datejs/core.js",
|
||||||
|
@ -49,5 +50,4 @@
|
||||||
"static/src/css/data_export.css",
|
"static/src/css/data_export.css",
|
||||||
"static/src/css/data_import.css",
|
"static/src/css/data_import.css",
|
||||||
],
|
],
|
||||||
'post_load' : 'wsgi_postload',
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ _logger = logging.getLogger(__name__)
|
||||||
# Globals (wont move into a pool)
|
# Globals (wont move into a pool)
|
||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
|
|
||||||
applicationsession = {}
|
|
||||||
addons_module = {}
|
addons_module = {}
|
||||||
addons_manifest = {}
|
addons_manifest = {}
|
||||||
controllers_class = {}
|
controllers_class = {}
|
||||||
|
@ -52,10 +51,6 @@ class WebRequest(object):
|
||||||
:type request: :class:`werkzeug.wrappers.BaseRequest`
|
:type request: :class:`werkzeug.wrappers.BaseRequest`
|
||||||
:param config: configuration object
|
:param config: configuration object
|
||||||
|
|
||||||
.. attribute:: applicationsession
|
|
||||||
|
|
||||||
an application-wide :class:`~collections.Mapping`
|
|
||||||
|
|
||||||
.. attribute:: httprequest
|
.. attribute:: httprequest
|
||||||
|
|
||||||
the original :class:`werkzeug.wrappers.Request` object provided to the
|
the original :class:`werkzeug.wrappers.Request` object provided to the
|
||||||
|
@ -94,7 +89,6 @@ class WebRequest(object):
|
||||||
``bool``, indicates whether the debug mode is active on the client
|
``bool``, indicates whether the debug mode is active on the client
|
||||||
"""
|
"""
|
||||||
def __init__(self, request, config):
|
def __init__(self, request, config):
|
||||||
self.applicationsession = applicationsession
|
|
||||||
self.httprequest = request
|
self.httprequest = request
|
||||||
self.httpresponse = None
|
self.httpresponse = None
|
||||||
self.httpsession = request.session
|
self.httpsession = request.session
|
||||||
|
@ -381,20 +375,21 @@ class Root(object):
|
||||||
static URLs to the corresponding directories
|
static URLs to the corresponding directories
|
||||||
"""
|
"""
|
||||||
statics = {}
|
statics = {}
|
||||||
addons_path = self.config.addons_path
|
for addons_path in self.config.addons_path:
|
||||||
if addons_path not in sys.path:
|
if addons_path not in sys.path:
|
||||||
sys.path.insert(0, addons_path)
|
sys.path.insert(0, addons_path)
|
||||||
for module in os.listdir(addons_path):
|
for module in os.listdir(addons_path):
|
||||||
if module not in addons_module:
|
if module not in addons_module:
|
||||||
manifest_path = os.path.join(addons_path, module, '__openerp__.py')
|
manifest_path = os.path.join(addons_path, module, '__openerp__.py')
|
||||||
path_static = os.path.join(addons_path, module, 'static')
|
path_static = os.path.join(addons_path, module, 'static')
|
||||||
if os.path.isfile(manifest_path) and os.path.isdir(path_static):
|
if os.path.isfile(manifest_path) and os.path.isdir(path_static):
|
||||||
manifest = ast.literal_eval(open(manifest_path).read())
|
manifest = ast.literal_eval(open(manifest_path).read())
|
||||||
_logger.info("Loading %s", module)
|
manifest['addons_path'] = addons_path
|
||||||
m = __import__(module)
|
_logger.info("Loading %s", module)
|
||||||
addons_module[module] = m
|
m = __import__(module)
|
||||||
addons_manifest[module] = manifest
|
addons_module[module] = m
|
||||||
statics['/%s/static' % module] = path_static
|
addons_manifest[module] = manifest
|
||||||
|
statics['/%s/static' % module] = path_static
|
||||||
for k, v in controllers_class.items():
|
for k, v in controllers_class.items():
|
||||||
if k not in controllers_object:
|
if k not in controllers_object:
|
||||||
o = v()
|
o = v()
|
||||||
|
|
|
@ -68,15 +68,30 @@ class Xml2Json:
|
||||||
# OpenERP Web web Controllers
|
# OpenERP Web web Controllers
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
|
|
||||||
def manifest_glob(addons_path, addons, key):
|
def manifest_preload():
|
||||||
|
modules = [k for k,v in openerpweb.addons_manifest.items() if v.get('web_preload')]
|
||||||
|
return modules
|
||||||
|
|
||||||
|
def manifest_addons(addons):
|
||||||
|
if addons is None:
|
||||||
|
addons = manifest_preload()
|
||||||
|
else:
|
||||||
|
addons = addons.split(',')
|
||||||
|
return addons
|
||||||
|
|
||||||
|
def manifest_glob(addons, key):
|
||||||
|
addons = manifest_addons(addons)
|
||||||
files = []
|
files = []
|
||||||
for addon in addons:
|
for addon in addons:
|
||||||
globlist = openerpweb.addons_manifest.get(addon, {}).get(key, [])
|
manifest = openerpweb.addons_manifest.get(addon, {})
|
||||||
|
addons_path = manifest['addons_path']
|
||||||
|
globlist = manifest.get(key, [])
|
||||||
for pattern in globlist:
|
for pattern in globlist:
|
||||||
for path in glob.glob(os.path.join(addons_path, addon, pattern)):
|
for path in glob.glob(os.path.join(addons_path, addon, pattern)):
|
||||||
files.append(path[len(addons_path):])
|
files.append(path[len(addons_path):])
|
||||||
return files
|
return files
|
||||||
|
|
||||||
|
# TODO change into concat_file(addons,key) taking care of addons_path
|
||||||
def concat_files(addons_path, file_list):
|
def concat_files(addons_path, file_list):
|
||||||
""" Concatenate file content
|
""" Concatenate file content
|
||||||
return (concat,timestamp)
|
return (concat,timestamp)
|
||||||
|
@ -117,49 +132,45 @@ class WebClient(openerpweb.Controller):
|
||||||
_cp_path = "/web/webclient"
|
_cp_path = "/web/webclient"
|
||||||
|
|
||||||
@openerpweb.jsonrequest
|
@openerpweb.jsonrequest
|
||||||
def csslist(self, req, mods='web'):
|
def csslist(self, req, mods=None):
|
||||||
return manifest_glob(req.config.addons_path, mods.split(','), 'css')
|
return manifest_glob(mods, 'css')
|
||||||
|
|
||||||
@openerpweb.jsonrequest
|
@openerpweb.jsonrequest
|
||||||
def jslist(self, req, mods='web'):
|
def jslist(self, req, mods=None):
|
||||||
return manifest_glob(req.config.addons_path, mods.split(','), 'js')
|
return manifest_glob(mods, 'js')
|
||||||
|
|
||||||
@openerpweb.httprequest
|
@openerpweb.httprequest
|
||||||
def css(self, req, mods='web'):
|
def css(self, req, mods=None):
|
||||||
files = manifest_glob(req.config.addons_path, mods.split(','), 'css')
|
files = manifest_glob(mods, 'css')
|
||||||
content,timestamp = concat_files(req.config.addons_path, files)
|
content,timestamp = concat_files(req.config.addons_path, files)
|
||||||
# TODO request set the Date of last modif and Etag
|
# TODO request set the Date of last modif and Etag
|
||||||
return req.make_response(content, [('Content-Type', 'text/css')])
|
return req.make_response(content, [('Content-Type', 'text/css')])
|
||||||
|
|
||||||
@openerpweb.httprequest
|
@openerpweb.httprequest
|
||||||
def js(self, req, mods='web'):
|
def js(self, req, mods=None):
|
||||||
files = manifest_glob(req.config.addons_path, mods.split(','), 'js')
|
files = manifest_glob(mods, 'js')
|
||||||
content,timestamp = concat_files(req.config.addons_path, files)
|
content,timestamp = concat_files(req.config.addons_path, files)
|
||||||
# TODO request set the Date of last modif and Etag
|
# TODO request set the Date of last modif and Etag
|
||||||
return req.make_response(content, [('Content-Type', 'application/javascript')])
|
return req.make_response(content, [('Content-Type', 'application/javascript')])
|
||||||
|
|
||||||
@openerpweb.httprequest
|
@openerpweb.httprequest
|
||||||
def home(self, req, s_action=None, **kw):
|
def home(self, req, s_action=None, **kw):
|
||||||
modules = [a for a, m in openerpweb.addons_manifest.iteritems() if m.get('web_auto_load')]
|
|
||||||
assert 'web' in modules
|
|
||||||
cs_mods = ','.join(modules)
|
|
||||||
|
|
||||||
# script tags
|
# script tags
|
||||||
jslist = ['/web/webclient/js?mods='+cs_mods]
|
jslist = ['/web/webclient/js']
|
||||||
if req.debug:
|
if req.debug:
|
||||||
jslist = [i + '?debug=' + str(time.time()) for i in manifest_glob(req.config.addons_path, modules, 'js')]
|
jslist = [i + '?debug=' + str(time.time()) for i in manifest_glob(None, 'js')]
|
||||||
js = "\n ".join(['<script type="text/javascript" src="%s"></script>'%i for i in jslist])
|
js = "\n ".join(['<script type="text/javascript" src="%s"></script>'%i for i in jslist])
|
||||||
|
|
||||||
# css tags
|
# css tags
|
||||||
csslist = ['/web/webclient/css?mods='+cs_mods]
|
csslist = ['/web/webclient/css']
|
||||||
if req.debug:
|
if req.debug:
|
||||||
csslist = [i + '?debug=' + str(time.time()) for i in manifest_glob(req.config.addons_path, modules, 'css')]
|
csslist = [i + '?debug=' + str(time.time()) for i in manifest_glob(None, 'css')]
|
||||||
css = "\n ".join(['<link rel="stylesheet" href="%s">'%i for i in csslist])
|
css = "\n ".join(['<link rel="stylesheet" href="%s">'%i for i in csslist])
|
||||||
|
|
||||||
r = home_template % {
|
r = home_template % {
|
||||||
'javascript': js,
|
'javascript': js,
|
||||||
'css': css,
|
'css': css,
|
||||||
'modules': repr(modules), # XXX good js-ification ?
|
'modules': repr(manifest_preload()), # XXX good js-ification ?
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
@ -185,7 +196,8 @@ class WebClient(openerpweb.Controller):
|
||||||
transl = {"messages":[]}
|
transl = {"messages":[]}
|
||||||
transs[addon_name] = transl
|
transs[addon_name] = transl
|
||||||
for l in langs:
|
for l in langs:
|
||||||
f_name = os.path.join(req.config.addons_path, addon_name, "po", l + ".po")
|
addons_path = openerpweb.addons_manifest[addon_name]['addons_path']
|
||||||
|
f_name = os.path.join(addons_path, addon_name, "po", l + ".po")
|
||||||
if not os.path.exists(f_name):
|
if not os.path.exists(f_name):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
|
@ -305,6 +317,7 @@ class Session(openerpweb.Controller):
|
||||||
"context": ctx,
|
"context": ctx,
|
||||||
"db": req.session._db
|
"db": req.session._db
|
||||||
}
|
}
|
||||||
|
|
||||||
@openerpweb.jsonrequest
|
@openerpweb.jsonrequest
|
||||||
def get_session_info(self, req):
|
def get_session_info(self, req):
|
||||||
req.session.assert_valid(force=True)
|
req.session.assert_valid(force=True)
|
||||||
|
@ -313,6 +326,7 @@ class Session(openerpweb.Controller):
|
||||||
"context": req.session.get_context() if req.session._uid else False,
|
"context": req.session.get_context() if req.session._uid else False,
|
||||||
"db": req.session._db
|
"db": req.session._db
|
||||||
}
|
}
|
||||||
|
|
||||||
@openerpweb.jsonrequest
|
@openerpweb.jsonrequest
|
||||||
def change_password (self,req,fields):
|
def change_password (self,req,fields):
|
||||||
old_password, new_password,confirm_password = operator.itemgetter('old_pwd', 'new_password','confirm_pwd')(
|
old_password, new_password,confirm_password = operator.itemgetter('old_pwd', 'new_password','confirm_pwd')(
|
||||||
|
@ -328,6 +342,7 @@ class Session(openerpweb.Controller):
|
||||||
except:
|
except:
|
||||||
return {'error': 'Original password incorrect, your password was not changed.', 'title': 'Change Password'}
|
return {'error': 'Original password incorrect, your password was not changed.', 'title': 'Change Password'}
|
||||||
return {'error': 'Error, password not changed !', 'title': 'Change Password'}
|
return {'error': 'Error, password not changed !', 'title': 'Change Password'}
|
||||||
|
|
||||||
@openerpweb.jsonrequest
|
@openerpweb.jsonrequest
|
||||||
def sc_list(self, req):
|
def sc_list(self, req):
|
||||||
return req.session.model('ir.ui.view_sc').get_sc(
|
return req.session.model('ir.ui.view_sc').get_sc(
|
||||||
|
@ -348,7 +363,8 @@ class Session(openerpweb.Controller):
|
||||||
# TODO query server for installed web modules
|
# TODO query server for installed web modules
|
||||||
mods = []
|
mods = []
|
||||||
for name, manifest in openerpweb.addons_manifest.items():
|
for name, manifest in openerpweb.addons_manifest.items():
|
||||||
if not manifest.get('web_auto_load') and manifest.get('active', True):
|
# TODO replace by ir.module.module installed web
|
||||||
|
if not manifest.get('web_preload') and manifest.get('active', True):
|
||||||
mods.append(name)
|
mods.append(name)
|
||||||
return mods
|
return mods
|
||||||
|
|
||||||
|
|
|
@ -608,15 +608,23 @@ openerp.web.BufferedDataSet = openerp.web.DataSetStatic.extend({
|
||||||
init: function() {
|
init: function() {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
this.reset_ids([]);
|
this.reset_ids([]);
|
||||||
|
this.last_default_get = {};
|
||||||
|
},
|
||||||
|
default_get: function(fields, callback) {
|
||||||
|
return this._super(fields).then(this.on_default_get).then(callback);
|
||||||
|
},
|
||||||
|
on_default_get: function(res) {
|
||||||
|
this.last_default_get = res;
|
||||||
},
|
},
|
||||||
create: function(data, callback, error_callback) {
|
create: function(data, callback, error_callback) {
|
||||||
var cached = {id:_.uniqueId(this.virtual_id_prefix), values: data};
|
var cached = {id:_.uniqueId(this.virtual_id_prefix), values: data,
|
||||||
|
defaults: this.last_default_get};
|
||||||
this.to_create.push(cached);
|
this.to_create.push(cached);
|
||||||
this.cache.push(cached);
|
this.cache.push(cached);
|
||||||
this.on_change();
|
this.on_change();
|
||||||
var to_return = $.Deferred().then(callback);
|
var prom = $.Deferred().then(callback);
|
||||||
to_return.resolve({result: cached.id});
|
setTimeout(function() {prom.resolve({result: cached.id});}, 0);
|
||||||
return to_return.promise();
|
return prom.promise();
|
||||||
},
|
},
|
||||||
write: function (id, data, options, callback) {
|
write: function (id, data, options, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -676,7 +684,8 @@ openerp.web.BufferedDataSet = openerp.web.DataSetStatic.extend({
|
||||||
var cached = _.detect(self.cache, function(x) {return x.id === id;});
|
var cached = _.detect(self.cache, function(x) {return x.id === id;});
|
||||||
var created = _.detect(self.to_create, function(x) {return x.id === id;});
|
var created = _.detect(self.to_create, function(x) {return x.id === id;});
|
||||||
if (created) {
|
if (created) {
|
||||||
_.each(fields, function(x) {if (cached.values[x] === undefined) cached.values[x] = false;});
|
_.each(fields, function(x) {if (cached.values[x] === undefined)
|
||||||
|
cached.values[x] = created.defaults[x] || false;});
|
||||||
} else {
|
} else {
|
||||||
if (!cached || !_.all(fields, function(x) {return cached.values[x] !== undefined}))
|
if (!cached || !_.all(fields, function(x) {return cached.values[x] !== undefined}))
|
||||||
to_get.push(id);
|
to_get.push(id);
|
||||||
|
@ -716,6 +725,10 @@ openerp.web.BufferedDataSet = openerp.web.DataSetStatic.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
openerp.web.ReadOnlyDataSetSearch = openerp.web.DataSetSearch.extend({
|
openerp.web.ReadOnlyDataSetSearch = openerp.web.DataSetSearch.extend({
|
||||||
|
default_get: function(fields, callback) {
|
||||||
|
return this._super(fields, callback).then(this.on_default_get);
|
||||||
|
},
|
||||||
|
on_default_get: function(result) {},
|
||||||
create: function(data, callback, error_callback) {
|
create: function(data, callback, error_callback) {
|
||||||
this.on_create(data);
|
this.on_create(data);
|
||||||
var to_return = $.Deferred().then(callback);
|
var to_return = $.Deferred().then(callback);
|
||||||
|
|
|
@ -345,7 +345,7 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
|
||||||
do_save: function(success, prepend_on_create) {
|
do_save: function(success, prepend_on_create) {
|
||||||
var self = this;
|
var self = this;
|
||||||
if (!this.ready) {
|
if (!this.ready) {
|
||||||
return false;
|
return $.Deferred().reject();
|
||||||
}
|
}
|
||||||
var form_dirty = false,
|
var form_dirty = false,
|
||||||
form_invalid = false,
|
form_invalid = false,
|
||||||
|
@ -367,17 +367,17 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
|
||||||
if (form_invalid) {
|
if (form_invalid) {
|
||||||
first_invalid_field.focus();
|
first_invalid_field.focus();
|
||||||
this.on_invalid();
|
this.on_invalid();
|
||||||
return false;
|
return $.Deferred().reject();
|
||||||
} else {
|
} else {
|
||||||
console.log("About to save", values);
|
console.log("About to save", values);
|
||||||
if (!this.datarecord.id) {
|
if (!this.datarecord.id) {
|
||||||
return this.dataset.create(values, function(r) {
|
return this.dataset.create(values).pipe(function(r) {
|
||||||
self.on_created(r, success, prepend_on_create);
|
return self.on_created(r, undefined, prepend_on_create);
|
||||||
});
|
}).then(success);
|
||||||
} else {
|
} else {
|
||||||
return this.dataset.write(this.datarecord.id, values, {}, function(r) {
|
return this.dataset.write(this.datarecord.id, values, {}).pipe(function(r) {
|
||||||
self.on_saved(r, success);
|
return self.on_saved(r);
|
||||||
});
|
}).then(success);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -402,11 +402,10 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
|
||||||
on_saved: function(r, success) {
|
on_saved: function(r, success) {
|
||||||
if (!r.result) {
|
if (!r.result) {
|
||||||
// should not happen in the server, but may happen for internal purpose
|
// should not happen in the server, but may happen for internal purpose
|
||||||
|
return $.Deferred().reject();
|
||||||
} else {
|
} else {
|
||||||
if (success) {
|
|
||||||
success(r);
|
|
||||||
}
|
|
||||||
this.reload();
|
this.reload();
|
||||||
|
return $.Deferred().then(success).resolve(r);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
@ -425,6 +424,7 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
|
||||||
on_created: function(r, success, prepend_on_create) {
|
on_created: function(r, success, prepend_on_create) {
|
||||||
if (!r.result) {
|
if (!r.result) {
|
||||||
// should not happen in the server, but may happen for internal purpose
|
// should not happen in the server, but may happen for internal purpose
|
||||||
|
return $.Deferred().reject();
|
||||||
} else {
|
} else {
|
||||||
this.datarecord.id = r.result;
|
this.datarecord.id = r.result;
|
||||||
if (!prepend_on_create) {
|
if (!prepend_on_create) {
|
||||||
|
@ -439,10 +439,8 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
|
||||||
this.sidebar.attachments.do_update();
|
this.sidebar.attachments.do_update();
|
||||||
}
|
}
|
||||||
console.debug("The record has been created with id #" + this.datarecord.id);
|
console.debug("The record has been created with id #" + this.datarecord.id);
|
||||||
if (success) {
|
|
||||||
success(_.extend(r, {created: true}));
|
|
||||||
}
|
|
||||||
this.reload();
|
this.reload();
|
||||||
|
return $.Deferred().then(success).resolve(_.extend(r, {created: true}));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
do_search: function (domains, contexts, groupbys) {
|
do_search: function (domains, contexts, groupbys) {
|
||||||
|
@ -472,6 +470,13 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
|
||||||
get_selected_ids: function() {
|
get_selected_ids: function() {
|
||||||
var id = this.dataset.ids[this.dataset.index];
|
var id = this.dataset.ids[this.dataset.index];
|
||||||
return id ? [id] : [];
|
return id ? [id] : [];
|
||||||
|
},
|
||||||
|
recursive_save: function() {
|
||||||
|
var self = this;
|
||||||
|
return $.when(this.do_save()).pipe(function(res) {
|
||||||
|
if (self.dataset.parent_view)
|
||||||
|
return self.dataset.parent_view.recursive_save();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
openerp.web.FormDialog = openerp.web.Dialog.extend({
|
openerp.web.FormDialog = openerp.web.Dialog.extend({
|
||||||
|
@ -830,30 +835,31 @@ openerp.web.form.WidgetButton = openerp.web.form.Widget.extend({
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
this.$element.click(this.on_click);
|
this.$element.click(this.on_click);
|
||||||
},
|
},
|
||||||
on_click: function(saved) {
|
on_click: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
if ((!this.node.attrs.special && this.view.dirty_for_user && saved !== true) || !this.view.datarecord.id) {
|
var exec_action = function() {
|
||||||
this.view.do_save(function() {
|
if (self.node.attrs.confirm) {
|
||||||
self.on_click(true);
|
var dialog = $('<div>' + self.node.attrs.confirm + '</div>').dialog({
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (this.node.attrs.confirm) {
|
|
||||||
var dialog = $('<div>' + this.node.attrs.confirm + '</div>').dialog({
|
|
||||||
title: 'Confirm',
|
title: 'Confirm',
|
||||||
modal: true,
|
modal: true,
|
||||||
buttons: {
|
buttons: {
|
||||||
Ok: function() {
|
Ok: function() {
|
||||||
self.on_confirmed();
|
self.on_confirmed();
|
||||||
$(this).dialog("close");
|
$(self).dialog("close");
|
||||||
},
|
},
|
||||||
Cancel: function() {
|
Cancel: function() {
|
||||||
$(this).dialog("close");
|
$(self).dialog("close");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.on_confirmed();
|
self.on_confirmed();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
if ((!this.node.attrs.special && this.view.dirty_for_user) || !this.view.datarecord.id) {
|
||||||
|
this.view.recursive_save().then(exec_action);
|
||||||
|
} else {
|
||||||
|
exec_action();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
on_confirmed: function() {
|
on_confirmed: function() {
|
||||||
|
@ -1945,11 +1951,7 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({
|
||||||
var view = this.viewmanager.views[this.viewmanager.active_view].controller;
|
var view = this.viewmanager.views[this.viewmanager.active_view].controller;
|
||||||
if (this.viewmanager.active_view === "form") {
|
if (this.viewmanager.active_view === "form") {
|
||||||
var res = $.when(view.do_save());
|
var res = $.when(view.do_save());
|
||||||
if (res === false) {
|
if (!res.isResolved() && !res.isRejected()) {
|
||||||
// ignore
|
|
||||||
} else if (res.isRejected()) {
|
|
||||||
throw "Save or create on one2many dataset is not supposed to fail.";
|
|
||||||
} else if (!res.isResolved()) {
|
|
||||||
throw "Asynchronous get_value() is not supported in form view.";
|
throw "Asynchronous get_value() is not supported in form view.";
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
@ -2002,6 +2004,7 @@ openerp.web.form.One2ManyListView = openerp.web.ListView.extend({
|
||||||
} else {
|
} else {
|
||||||
var self = this;
|
var self = this;
|
||||||
var pop = new openerp.web.form.SelectCreatePopup(this);
|
var pop = new openerp.web.form.SelectCreatePopup(this);
|
||||||
|
pop.on_default_get.add(self.dataset.on_default_get);
|
||||||
pop.select_element(self.o2m.field.relation,{
|
pop.select_element(self.o2m.field.relation,{
|
||||||
initial_view: "form",
|
initial_view: "form",
|
||||||
alternative_form_view: self.o2m.field.views ? self.o2m.field.views["form"] : undefined,
|
alternative_form_view: self.o2m.field.views ? self.o2m.field.views["form"] : undefined,
|
||||||
|
@ -2163,6 +2166,7 @@ openerp.web.form.SelectCreatePopup = openerp.web.OldWidget.extend(/** @lends ope
|
||||||
this.dataset = new openerp.web.ReadOnlyDataSetSearch(this, this.model,
|
this.dataset = new openerp.web.ReadOnlyDataSetSearch(this, this.model,
|
||||||
this.context);
|
this.context);
|
||||||
this.dataset.parent_view = this.options.parent_view;
|
this.dataset.parent_view = this.options.parent_view;
|
||||||
|
this.dataset.on_default_get.add(this.on_default_get);
|
||||||
if (this.options.initial_view == "search") {
|
if (this.options.initial_view == "search") {
|
||||||
this.setup_search_view();
|
this.setup_search_view();
|
||||||
} else { // "form"
|
} else { // "form"
|
||||||
|
@ -2285,7 +2289,8 @@ openerp.web.form.SelectCreatePopup = openerp.web.OldWidget.extend(/** @lends ope
|
||||||
this.on_select_elements(this.created_elements);
|
this.on_select_elements(this.created_elements);
|
||||||
}
|
}
|
||||||
this.stop();
|
this.stop();
|
||||||
}
|
},
|
||||||
|
on_default_get: function(res) {}
|
||||||
});
|
});
|
||||||
|
|
||||||
openerp.web.form.SelectCreateListView = openerp.web.ListView.extend({
|
openerp.web.form.SelectCreateListView = openerp.web.ListView.extend({
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
import controllers
|
|
|
@ -1 +0,0 @@
|
||||||
import main
|
|
|
@ -1,11 +0,0 @@
|
||||||
from web.controllers.main import View
|
|
||||||
import web.common as openerpweb
|
|
||||||
|
|
||||||
class GraphView(View):
|
|
||||||
_cp_path = "/web_graph/graphview"
|
|
||||||
|
|
||||||
@openerpweb.jsonrequest
|
|
||||||
def load(self, req, model, view_id):
|
|
||||||
fields_view = self.fields_view_get(req, model, view_id, 'graph')
|
|
||||||
all_fields = req.session.model(model).fields_get()
|
|
||||||
return {'fields_view': fields_view, 'all_fields':all_fields}
|
|
|
@ -33,8 +33,20 @@ openerp.web_graph.GraphView = openerp.web.View.extend({
|
||||||
this.$element.hide();
|
this.$element.hide();
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
|
var self = this;
|
||||||
this._super();
|
this._super();
|
||||||
return this.rpc("/web_graph/graphview/load", {"model": this.model, "view_id": this.view_id}, this.on_loaded);
|
return $.when(
|
||||||
|
new openerp.web.DataSet(this, this.model).call('fields_get', []),
|
||||||
|
this.rpc('/web/view/load', {
|
||||||
|
model: this.model,
|
||||||
|
view_id: this.view_id,
|
||||||
|
view_type: 'graph'
|
||||||
|
})).then(function (fields_result, view_result) {
|
||||||
|
self.on_loaded({
|
||||||
|
all_fields: fields_result[0],
|
||||||
|
fields_view: view_result[0]
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
on_loaded: function(data) {
|
on_loaded: function(data) {
|
||||||
this.all_fields = data.all_fields;
|
this.all_fields = data.all_fields;
|
||||||
|
@ -49,8 +61,6 @@ openerp.web_graph.GraphView = openerp.web.View.extend({
|
||||||
this.operator = [];
|
this.operator = [];
|
||||||
this.group_field = [];
|
this.group_field = [];
|
||||||
this.orientation = this.fields_view.arch.attrs.orientation || '';
|
this.orientation = this.fields_view.arch.attrs.orientation || '';
|
||||||
this.elem_id = this.$element[0]['id'];
|
|
||||||
|
|
||||||
_.each(this.fields_view.arch.children, function (field) {
|
_.each(this.fields_view.arch.children, function (field) {
|
||||||
if (field.attrs.operator) {
|
if (field.attrs.operator) {
|
||||||
this.operator.push(field.attrs.name);
|
this.operator.push(field.attrs.name);
|
||||||
|
@ -98,7 +108,7 @@ openerp.web_graph.GraphView = openerp.web.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
schedule_chart: function(results) {
|
schedule_chart: function(results) {
|
||||||
this.$element.html(QWeb.render("GraphView", {"fields_view": this.fields_view, "chart": this.chart,'elem_id': this.elem_id}));
|
this.$element.html(QWeb.render("GraphView", {"fields_view": this.fields_view, "chart": this.chart,'element_id': this.element_id}));
|
||||||
|
|
||||||
_.each(results, function (result) {
|
_.each(results, function (result) {
|
||||||
_.each(result, function (field_value, field_name) {
|
_.each(result, function (field_value, field_name) {
|
||||||
|
@ -304,7 +314,7 @@ openerp.web_graph.GraphView = openerp.web.View.extend({
|
||||||
|
|
||||||
var bar_chart = new dhtmlXChart({
|
var bar_chart = new dhtmlXChart({
|
||||||
view: view_chart,
|
view: view_chart,
|
||||||
container: self.elem_id+"-barchart",
|
container: self.element_id+"-barchart",
|
||||||
value:"#"+group_list[0]+"#",
|
value:"#"+group_list[0]+"#",
|
||||||
gradient: "3d",
|
gradient: "3d",
|
||||||
border: false,
|
border: false,
|
||||||
|
@ -374,7 +384,7 @@ openerp.web_graph.GraphView = openerp.web.View.extend({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
bar_chart.parse(_.values(abscissa_data), "json");
|
bar_chart.parse(_.values(abscissa_data), "json");
|
||||||
jQuery("#"+self.elem_id+"-barchart").height(jQuery("#"+self.elem_id+"-barchart").height()+50);
|
jQuery("#"+self.element_id+"-barchart").height(jQuery("#"+self.element_id+"-barchart").height()+50);
|
||||||
bar_chart.attachEvent("onItemClick", function(id) {
|
bar_chart.attachEvent("onItemClick", function(id) {
|
||||||
self.open_list_view(bar_chart.get(id));
|
self.open_list_view(bar_chart.get(id));
|
||||||
});
|
});
|
||||||
|
@ -383,7 +393,7 @@ openerp.web_graph.GraphView = openerp.web.View.extend({
|
||||||
var self = this;
|
var self = this;
|
||||||
var chart = new dhtmlXChart({
|
var chart = new dhtmlXChart({
|
||||||
view:"pie3D",
|
view:"pie3D",
|
||||||
container:self.elem_id+"-piechart",
|
container:self.element_id+"-piechart",
|
||||||
value:"#"+self.operator_field+"#",
|
value:"#"+self.operator_field+"#",
|
||||||
pieInnerText:function(obj) {
|
pieInnerText:function(obj) {
|
||||||
var sum = chart.sum("#"+self.operator_field+"#");
|
var sum = chart.sum("#"+self.operator_field+"#");
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<template>
|
<template>
|
||||||
<div t-name="GraphView" t-att-id="elem_id+'-'+chart+'chart'"
|
<div t-name="GraphView" t-att-id="element_id+'-'+chart+'chart'"
|
||||||
style="height:300px;position:relative;"/>
|
style="height:300px;position:relative;"/>
|
||||||
</template>
|
</template>
|
|
@ -5,5 +5,5 @@
|
||||||
"js": ["static/*/*.js", "static/*/js/*.js"],
|
"js": ["static/*/*.js", "static/*/js/*.js"],
|
||||||
"css": [],
|
"css": [],
|
||||||
'active': False,
|
'active': False,
|
||||||
'web_auto_load': True,
|
'web_preload': True,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,21 @@
|
||||||
.openerp .oe_kanban_view .oe_column {
|
.openerp .oe_kanban_view .oe_column {
|
||||||
float: left;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.openerp .oe_vertical_text {
|
||||||
|
writing-mode:tb-rl;
|
||||||
|
-webkit-transform:rotate(90deg);
|
||||||
|
-moz-transform:rotate(90deg);
|
||||||
|
-o-transform: rotate(90deg);
|
||||||
|
-ms-transform: rotate(90deg);
|
||||||
|
transform: rotate(90deg);
|
||||||
|
display:block;
|
||||||
|
width:30px;
|
||||||
|
height:20px;
|
||||||
|
align:center;
|
||||||
|
font-size:24px;
|
||||||
|
}
|
||||||
|
|
||||||
.openerp .oe_kanban_view .ui-sortable-placeholder {
|
.openerp .oe_kanban_view .ui-sortable-placeholder {
|
||||||
border: 1px dotted black;
|
border: 1px dotted black;
|
||||||
visibility: visible !important;
|
visibility: visible !important;
|
||||||
|
@ -14,6 +27,10 @@
|
||||||
font-size: 1.5em;
|
font-size: 1.5em;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
.openerp .oe_kanban_view .fold-columns-icon {
|
||||||
|
float: left;
|
||||||
|
padding: 2px 2px 0 0;
|
||||||
|
}
|
||||||
.openerp .oe_kanban_action_button {
|
.openerp .oe_kanban_action_button {
|
||||||
height: 22px;
|
height: 22px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
@ -200,4 +217,3 @@
|
||||||
.openerp .oe_kanban_color_alert .oe_kanban_color_border {
|
.openerp .oe_kanban_color_alert .oe_kanban_color_border {
|
||||||
border-color: #c00 !important;
|
border-color: #c00 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 761 B |
|
@ -18,6 +18,8 @@ openerp.web_kanban.KanbanView = openerp.web.View.extend({
|
||||||
this.all_display_data = false;
|
this.all_display_data = false;
|
||||||
this.groups = [];
|
this.groups = [];
|
||||||
this.qweb = new QWeb2.Engine();
|
this.qweb = new QWeb2.Engine();
|
||||||
|
this.aggregates = {};
|
||||||
|
this.NO_OF_COLUMNS = 3;
|
||||||
if (this.options.action_views_ids.form) {
|
if (this.options.action_views_ids.form) {
|
||||||
this.form_dialog = new openerp.web.FormDialog(this, {}, this.options.action_views_ids.form, dataset).start();
|
this.form_dialog = new openerp.web.FormDialog(this, {}, this.options.action_views_ids.form, dataset).start();
|
||||||
this.form_dialog.on_form_dialog_saved.add_last(this.on_record_saved);
|
this.form_dialog.on_form_dialog_saved.add_last(this.on_record_saved);
|
||||||
|
@ -36,8 +38,17 @@ openerp.web_kanban.KanbanView = openerp.web.View.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
add_qweb_template: function() {
|
add_qweb_template: function() {
|
||||||
|
var group_operator = ["avg", "max", "min", "sum", "count"]
|
||||||
for (var i=0, ii=this.fields_view.arch.children.length; i < ii; i++) {
|
for (var i=0, ii=this.fields_view.arch.children.length; i < ii; i++) {
|
||||||
var child = this.fields_view.arch.children[i];
|
var child = this.fields_view.arch.children[i];
|
||||||
|
if (child.tag === "field") {
|
||||||
|
for(j=0, jj=group_operator.length; j < jj; j++) {
|
||||||
|
if (child.attrs[group_operator[j]]) {
|
||||||
|
this.aggregates[child.attrs.name] = child.attrs[group_operator[j]];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (child.tag === "templates") {
|
if (child.tag === "templates") {
|
||||||
this.transform_qweb_template(child);
|
this.transform_qweb_template(child);
|
||||||
this.qweb.add_template(openerp.web.json_node_to_xml(child));
|
this.qweb.add_template(openerp.web.json_node_to_xml(child));
|
||||||
|
@ -118,14 +129,33 @@ openerp.web_kanban.KanbanView = openerp.web.View.extend({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
on_show_data: function(data) {
|
sort_group: function (first, second) {
|
||||||
|
if (first.header && second.header)
|
||||||
|
{
|
||||||
|
first = first.header.toLowerCase();
|
||||||
|
second = second.header.toLowerCase();
|
||||||
|
if (first > second) return 1;
|
||||||
|
else if (first < second) return -1;
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
else return 0;
|
||||||
|
},
|
||||||
|
on_show_data: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.$element.html(QWeb.render("KanbanView", {"data": data}));
|
if (!this.group_by.length) {
|
||||||
|
this.do_record_group();
|
||||||
|
}
|
||||||
|
self.all_display_data.sort(this.sort_group);
|
||||||
|
this.$element.html(QWeb.render("KanbanView", {"data": self.all_display_data}));
|
||||||
this.on_reload_kanban();
|
this.on_reload_kanban();
|
||||||
|
this.$element.find(".oe_vertical_text").hide();
|
||||||
var drag_handel = false;
|
var drag_handel = false;
|
||||||
if (this.$element.find(".oe_kanban_draghandle").length > 0) {
|
if (this.$element.find(".oe_kanban_draghandle").length > 0) {
|
||||||
drag_handel = ".oe_kanban_draghandle";
|
drag_handel = ".oe_kanban_draghandle";
|
||||||
}
|
}
|
||||||
|
if (!this.group_by.length) {
|
||||||
|
drag_handel = true;
|
||||||
|
}
|
||||||
this.$element.find(".oe_column").sortable({
|
this.$element.find(".oe_column").sortable({
|
||||||
connectWith: ".oe_column",
|
connectWith: ".oe_column",
|
||||||
handle : drag_handel,
|
handle : drag_handel,
|
||||||
|
@ -134,36 +164,44 @@ openerp.web_kanban.KanbanView = openerp.web.View.extend({
|
||||||
self.source_index['column'] = ui.item.parent().attr('id');
|
self.source_index['column'] = ui.item.parent().attr('id');
|
||||||
},
|
},
|
||||||
stop: self.on_receive_record,
|
stop: self.on_receive_record,
|
||||||
|
scroll: false
|
||||||
});
|
});
|
||||||
this.$element.find(".oe_column").disableSelection()
|
this.$element.find(".oe_column").disableSelection()
|
||||||
this.$element.find('button.oe_kanban_button_new').click(this.do_add_record);
|
this.$element.find('button.oe_kanban_button_new').click(this.do_add_record);
|
||||||
|
this.$element.find(".fold-columns-icon").click(function(event) {
|
||||||
|
self.do_fold_unfold_columns(event, this.id);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
on_button_click: function (button_attrs, record_id) {
|
do_fold_unfold_columns: function(event, element_id) {
|
||||||
var self = this;
|
var column_id = "column_" + element_id;
|
||||||
if (this.groups.length) {
|
var column_element = this.$element.find("#" + column_id + " .oe_fold_column");
|
||||||
_.each(this.groups, function (group) {
|
if (column_element.is(":hidden")) {
|
||||||
group.list([],
|
this.$element.find("#" + column_id).find("img.fold-columns-icon").attr('src', '/web_kanban/static/src/img/minus-icon.png');
|
||||||
function (groups) {},
|
column_element.show();
|
||||||
function (dataset) {
|
this.$element.find("#" + column_id + ".oe_table_column").css("width",Math.round(99 / this.all_display_data.length) + "%");
|
||||||
dataset.read_slice([], {}, function(records) {
|
this.$element.find("#" + column_id + ".oe_vertical_text").hide();
|
||||||
var index = parseInt(_.indexOf(dataset.ids, record_id));
|
}
|
||||||
if(index >= 0) {
|
else{
|
||||||
self.on_confirm_click(dataset, button_attrs, index, record_id);
|
this.$element.find("#" + column_id).find("img.fold-columns-icon").attr('src', '/web_kanban/static/src/img/plus-icon.png');
|
||||||
}
|
column_element.hide();
|
||||||
});
|
this.$element.find("#" + column_id + ".oe_table_column").css("width","0.5%");
|
||||||
}
|
this.$element.find("#" + column_id + ".oe_vertical_text").show();
|
||||||
);
|
}
|
||||||
});
|
|
||||||
} else {
|
},
|
||||||
var index = parseInt(_.indexOf(self.dataset.ids, record_id));
|
do_record_group: function() {
|
||||||
if (index >= 0) {
|
if (this.NO_OF_COLUMNS && this.all_display_data.length > 0) {
|
||||||
_.extend(self.dataset, {domain: self.domain, context: self.context});
|
var records = this.all_display_data[0].records;
|
||||||
self.on_confirm_click(self.dataset, button_attrs, index, record_id);
|
var record_per_group = Math.round((records).length / this.NO_OF_COLUMNS);
|
||||||
|
this.all_display_data = [];
|
||||||
|
for (var i=0, ii=this.NO_OF_COLUMNS; i < ii; i++) {
|
||||||
|
this.all_display_data.push({'records': records.slice(0,record_per_group), 'value':i, 'header' : false, 'ids':[]});
|
||||||
|
records.splice(0,record_per_group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
on_confirm_click: function (dataset, button_attrs, index, record_id) {
|
on_button_click: function (button_attrs, record_id) {
|
||||||
this.on_execute_button_click(dataset, button_attrs, record_id);
|
this.on_execute_button_click(this.dataset, button_attrs, record_id);
|
||||||
},
|
},
|
||||||
do_add_record: function() {
|
do_add_record: function() {
|
||||||
this.dataset.index = null;
|
this.dataset.index = null;
|
||||||
|
@ -199,11 +237,37 @@ openerp.web_kanban.KanbanView = openerp.web.View.extend({
|
||||||
data[$e.data('name')] = $(this).data('color');
|
data[$e.data('name')] = $(this).data('color');
|
||||||
self.dataset.write(id, data, {}, function() {
|
self.dataset.write(id, data, {}, function() {
|
||||||
// TODO fme: reload record instead of all. need refactoring
|
// TODO fme: reload record instead of all. need refactoring
|
||||||
self.do_actual_search();
|
self.on_reload_record(id, data);
|
||||||
});
|
});
|
||||||
$cpicker.remove();
|
$cpicker.remove();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
Reload one record in view.
|
||||||
|
record_id : reload record id.
|
||||||
|
data : change value in particular record.
|
||||||
|
*/
|
||||||
|
on_reload_record: function (record_id, data){
|
||||||
|
var self = this;
|
||||||
|
for (var i=0, ii=this.all_display_data.length; i < ii; i++) {
|
||||||
|
for(j=0, jj=this.all_display_data[i].records.length; j < jj; j++) {
|
||||||
|
if (this.all_display_data[i].records[j].id == record_id) {
|
||||||
|
_.extend(this.all_display_data[i].records[j], data);
|
||||||
|
this.$element.find("#main_" + record_id).children().remove();
|
||||||
|
this.$element.find("#main_" + record_id).append(this.qweb.render('kanban-box', {
|
||||||
|
record: this.do_transform_record(this.all_display_data[i].records[j]),
|
||||||
|
kanban_color: this.kanban_color,
|
||||||
|
kanban_gravatar: this.kanban_gravatar
|
||||||
|
}));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.$element.find("#main_" + record_id + " .oe_kanban_action").click(this.on_action_clicked);
|
||||||
|
this.$element.find("#main_" + record_id + " .oe_kanban_box_show_onclick_trigger").click(function() {
|
||||||
|
$(this).parent("#main_" + record_id + " .oe_kanban_box").find(".oe_kanban_box_show_onclick").toggle();
|
||||||
|
});
|
||||||
|
},
|
||||||
do_delete: function (id) {
|
do_delete: function (id) {
|
||||||
var self = this;
|
var self = this;
|
||||||
return $.when(this.dataset.unlink([id])).then(function () {
|
return $.when(this.dataset.unlink([id])).then(function () {
|
||||||
|
@ -228,16 +292,7 @@ openerp.web_kanban.KanbanView = openerp.web.View.extend({
|
||||||
this.do_execute_action(
|
this.do_execute_action(
|
||||||
button_attrs, dataset,
|
button_attrs, dataset,
|
||||||
record_id, function () {
|
record_id, function () {
|
||||||
var count = 1;
|
self.do_actual_search();
|
||||||
_.each(self.all_display_data, function(data, index) {
|
|
||||||
self.dataset.read_ids( data.ids, [], function(records){
|
|
||||||
self.all_display_data[index].records = records;
|
|
||||||
if(self.all_display_data.length == count) {
|
|
||||||
self.do_actual_search();
|
|
||||||
}
|
|
||||||
count++;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -250,8 +305,8 @@ openerp.web_kanban.KanbanView = openerp.web.View.extend({
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// TODO fme: check what was this sequence
|
// TODO fme: check what was this sequence
|
||||||
if (self.fields_view.fields.sequence && (self.source_index.index >= 0 && self.source_index.index != from) ||
|
if (self.fields_view.fields.sequence != undefined && ((self.source_index.index >= 0 && self.source_index.index != from) ||
|
||||||
(self.source_index.column && self.source_index.column != ui.item.parent().attr('id'))) {
|
(self.source_index.column && self.source_index.column != ui.item.parent().attr('id')))) {
|
||||||
var child_record = ui.item.parent().children();
|
var child_record = ui.item.parent().children();
|
||||||
var data, sequence = 1, index = to;
|
var data, sequence = 1, index = to;
|
||||||
child_record.splice(0, to);
|
child_record.splice(0, to);
|
||||||
|
@ -338,9 +393,6 @@ openerp.web_kanban.KanbanView = openerp.web.View.extend({
|
||||||
kanban_gravatar: self.kanban_gravatar
|
kanban_gravatar: self.kanban_gravatar
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
self.$element.find("#column_" + data.value).remove();
|
|
||||||
self.all_display_data.splice(index, 1);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.$element.find('.oe_kanban_action').click(this.on_action_clicked);
|
this.$element.find('.oe_kanban_action').click(this.on_action_clicked);
|
||||||
|
@ -377,8 +429,8 @@ openerp.web_kanban.KanbanView = openerp.web.View.extend({
|
||||||
do_search: function (domains, contexts, group_by) {
|
do_search: function (domains, contexts, group_by) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.rpc('/web/session/eval_domain_and_context', {
|
this.rpc('/web/session/eval_domain_and_context', {
|
||||||
domains: domains,
|
domains: [this.dataset.get_domain()].concat(domains),
|
||||||
contexts: contexts,
|
contexts: [this.dataset.get_context()].concat(contexts),
|
||||||
group_by_seq: group_by
|
group_by_seq: group_by
|
||||||
}, function (results) {
|
}, function (results) {
|
||||||
self.domain = results.domain;
|
self.domain = results.domain;
|
||||||
|
@ -392,23 +444,27 @@ openerp.web_kanban.KanbanView = openerp.web.View.extend({
|
||||||
group_by = self.group_by;
|
group_by = self.group_by;
|
||||||
if (!group_by.length && this.fields_view.arch.attrs.default_group_by) {
|
if (!group_by.length && this.fields_view.arch.attrs.default_group_by) {
|
||||||
group_by = [this.fields_view.arch.attrs.default_group_by];
|
group_by = [this.fields_view.arch.attrs.default_group_by];
|
||||||
|
self.group_by = group_by;
|
||||||
}
|
}
|
||||||
self.datagroup = new openerp.web.DataGroup(self, self.model, self.domain, self.context, group_by);
|
self.datagroup = new openerp.web.DataGroup(self, self.model, self.domain, self.context, group_by);
|
||||||
self.dataset.context = self.context;
|
self.datagroup.list(_.keys(self.fields_view.fields),
|
||||||
self.dataset.domain = self.domain;
|
|
||||||
self.datagroup.list([],
|
|
||||||
function (groups) {
|
function (groups) {
|
||||||
self.groups = groups;
|
self.groups = groups;
|
||||||
self.do_render_group(groups);
|
if (groups.length) {
|
||||||
|
self.do_render_group(groups);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self.all_display_data = [];
|
||||||
|
self.on_show_data();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
function (dataset) {
|
function (dataset) {
|
||||||
self.domain = dataset.domain;
|
|
||||||
self.context = dataset.context;
|
|
||||||
self.groups = [];
|
self.groups = [];
|
||||||
self.dataset.read_slice([], {}, function(records) {
|
self.dataset.read_slice([], {'domain': self.domain, 'context': self.context}, function(records) {
|
||||||
self.all_display_data = [{'records': records, 'value':false, 'header' : false, 'ids': self.dataset.ids}];
|
if (records.length) self.all_display_data = [{'records': records, 'value':false, 'header' : false, 'ids': self.dataset.ids}];
|
||||||
|
else self.all_display_data = [];
|
||||||
self.$element.find(".oe_kanban_view").remove();
|
self.$element.find(".oe_kanban_view").remove();
|
||||||
self.on_show_data(self.all_display_data);
|
self.on_show_data();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -417,8 +473,6 @@ openerp.web_kanban.KanbanView = openerp.web.View.extend({
|
||||||
this.all_display_data = [];
|
this.all_display_data = [];
|
||||||
var self = this;
|
var self = this;
|
||||||
_.each(datagroups, function (group) {
|
_.each(datagroups, function (group) {
|
||||||
self.dataset.context = group.context;
|
|
||||||
self.dataset.domain = group.domain;
|
|
||||||
var group_name = group.value;
|
var group_name = group.value;
|
||||||
var group_value = group.value;
|
var group_value = group.value;
|
||||||
if (!group.value) {
|
if (!group.value) {
|
||||||
|
@ -428,11 +482,15 @@ openerp.web_kanban.KanbanView = openerp.web.View.extend({
|
||||||
group_name = group.value[1];
|
group_name = group.value[1];
|
||||||
group_value = group.value[0];
|
group_value = group.value[0];
|
||||||
}
|
}
|
||||||
self.dataset.read_slice([], {}, function(records) {
|
var group_aggregates = {};
|
||||||
self.all_display_data.push({"value" : group_value, "records": records, 'header':group_name, 'ids': self.dataset.ids});
|
_.each(self.aggregates, function(value, key) {
|
||||||
|
group_aggregates[value] = group.aggregates[key];
|
||||||
|
});
|
||||||
|
self.dataset.read_slice([], {'domain': group.domain, 'context': group.context}, function(records) {
|
||||||
|
self.all_display_data.push({"value" : group_value, "records": records, 'header':group_name, 'ids': self.dataset.ids, 'aggregates': group_aggregates});
|
||||||
if (datagroups.length == self.all_display_data.length) {
|
if (datagroups.length == self.all_display_data.length) {
|
||||||
self.$element.find(".oe_kanban_view").remove();
|
self.$element.find(".oe_kanban_view").remove();
|
||||||
self.on_show_data(self.all_display_data);
|
self.on_show_data();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,15 +9,20 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td t-foreach="data" t-as="columns" class="oe_table_column oe_column_heading" t-att-id="'column_' + columns.value">
|
<td t-foreach="data" t-as="columns" class="oe_table_column" t-att-id="'column_' + columns.value">
|
||||||
<t t-if="columns.value" t-esc="columns.header"/>
|
<img t-att-id="columns.value" class="fold-columns-icon" src="/web_kanban/static/src/img/minus-icon.png"/>
|
||||||
|
<div class="oe_fold_column oe_column_heading" t-att-id="'column_' + columns.value">
|
||||||
|
<t t-if="columns.value and columns.header" t-esc="columns.header"/>
|
||||||
|
</div>
|
||||||
|
<div t-foreach="columns.aggregates" t-as="aggregate">
|
||||||
|
<i><u><t t-esc="aggregate"/>:</u> <t t-esc="aggregate_value"/></i>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td t-foreach="data" t-as="columns" class="oe_table_column" t-att-id="'column_' + columns.value" t-attf-style="width: #{Math.round(99 / data.length)}%">
|
<td t-foreach="data" t-as="columns" class="oe_column oe_table_column" t-att-id="'column_' + columns.value" t-attf-style="width: #{Math.round(99 / data.length)}%">
|
||||||
<div class="oe_column" t-att-id="'column_' + columns.value">
|
<p class="oe_vertical_text" t-att-id="'column_' + columns.value"><t t-esc="columns.header"/></p>
|
||||||
<div t-foreach="columns.records" t-as="record" class="oe_kanban_record" t-att-id="'main_' + record.id"/>
|
<div t-foreach="columns.records" t-as="record" class="oe_fold_column oe_kanban_record" t-att-id="'main_' + record.id"/>
|
||||||
</div>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -24,7 +24,7 @@ optparser.add_option("--server-port", dest="server_port", default=8069,
|
||||||
help="OpenERP server port", type="int", metavar="NUMBER")
|
help="OpenERP server port", type="int", metavar="NUMBER")
|
||||||
optparser.add_option("--db-filter", dest="dbfilter", default='.*',
|
optparser.add_option("--db-filter", dest="dbfilter", default='.*',
|
||||||
help="Filter listed database", metavar="REGEXP")
|
help="Filter listed database", metavar="REGEXP")
|
||||||
optparser.add_option('--addons-path', dest='addons_path', default=path_addons,
|
optparser.add_option('--addons-path', dest='addons_path', default=[path_addons], action='append',
|
||||||
help="Path do addons directory", metavar="PATH")
|
help="Path do addons directory", metavar="PATH")
|
||||||
|
|
||||||
server_options = optparse.OptionGroup(optparser, "Server configuration")
|
server_options = optparse.OptionGroup(optparser, "Server configuration")
|
||||||
|
|
Loading…
Reference in New Issue