[MERGE] Merge with trunk upto revision no 672.

bzr revid: ysa@tinyerp.com-20110725054610-2fkhv81amdhsqz44
This commit is contained in:
Yogesh (OpenERP) 2011-07-25 11:16:10 +05:30
commit d657a3dff2
13 changed files with 271 additions and 162 deletions

View File

@ -3,4 +3,38 @@
"version" : "2.0",
"depends" : [],
'active': True,
'js' : [
"static/lib/datejs/date-en-US.js",
"static/lib/jquery/jquery-1.5.2.js",
"static/lib/jquery.ba-bbq/jquery.ba-bbq.js",
"static/lib/jquery.contextmenu/jquery.contextmenu.r2.packed.js",
"static/lib/jquery.superfish/js/hoverIntent.js",
"static/lib/jquery.superfish/js/superfish.js",
"static/lib/jquery.ui/js/jquery-ui-1.8.9.custom.min.js",
"static/lib/jquery.ui/js/jquery-ui-timepicker-addon.js",
"static/lib/jquery.ui.notify/js/jquery.notify.js",
"static/lib/json/json2.js",
"static/lib/qweb/qweb2.js",
"static/lib/underscore/underscore.js",
"static/lib/underscore/underscore.string.js",
"static/src/js/base.js",
"static/src/js/chrome.js",
"static/src/js/controller.js",
"static/src/js/views.js",
"static/src/js/data.js",
"static/src/js/dates.js",
"static/src/js/form.js",
"static/src/js/list.js",
"static/src/js/list-editable.js",
"static/src/js/search.js",
"static/src/js/view_tree.js",
"static/src/js/export.js",
],
'css' : [
"static/lib/jquery.superfish/css/superfish.css",
"static/lib/jquery.ui/css/smoothness/jquery-ui-1.8.9.custom.css",
"static/lib/jquery.ui.notify/css/ui.notify.css",
"static/src/css/base.css",
"static/src/css/export.css",
],
}

View File

@ -56,6 +56,99 @@ class Xml2Json:
# OpenERP Web base Controllers
#----------------------------------------------------------
def manifest_glob(addons, key):
files = []
for addon in addons:
globlist = openerpweb.addons_manifest.get(addon, {}).get(key, [])
print globlist
for pattern in globlist:
for path in glob.glob(os.path.join(openerpweb.path_addons, addon, pattern)):
files.append(path[len(openerpweb.path_addons):])
return files
def concat_files(file_list):
""" Concatenate file content
return (concat,timestamp)
concat: concatenation of file content
timestamp: max(os.path.getmtime of file_list)
"""
root = openerpweb.path_root
files_content = []
files_timestamp = 0
for i in file_list:
fname = os.path.join(root, i)
ftime = os.path.getmtime(fname)
if ftime > files_timestamp:
files_timestamp = ftime
files_content = open(fname).read()
files_concat = "".join(files_content)
return files_concat
class WebClient(openerpweb.Controller):
_cp_path = "/base/webclient"
@openerpweb.jsonrequest
def csslist(self, req, mods='base'):
return manifest_glob(mods.split(','), 'css')
@openerpweb.jsonrequest
def jslist(self, req, mods='base'):
return manifest_glob(mods.split(','), 'js')
@openerpweb.httprequest
def css(self, req, mods='base'):
cherrypy.response.headers['Content-Type'] = 'text/css'
files = manifest_glob(mods.split(','), 'css')
concat = concat_files(files)[0]
# TODO request set the Date of last modif and Etag
return concat
@openerpweb.httprequest
def js(self, req, mods='base'):
cherrypy.response.headers['Content-Type'] = 'application/javascript'
files = manifest_glob(mods.split(','), 'js')
concat = concat_files(files)[0]
# TODO request set the Date of last modif and Etag
return concat
@openerpweb.httprequest
def home(self, req):
template ="""<!DOCTYPE html>
<html style="height: 100%%">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>OpenERP</title>
%s
<script type="text/javascript">
$(function() {
QWeb = new QWeb2.Engine();
openerp.init().base.webclient("oe");
});
</script>
<link rel="shortcut icon" href="/base/static/src/img/favicon.ico" type="image/x-icon"/>
%s
<!--[if lte IE 7]>
<link rel="stylesheet" href="/base/static/src/css/base-ie7.css" type="text/css"/>
<![endif]-->
</head>
<body id="oe" class="openerp"></body>
</html>
""".replace('\n'+' '*8,'\n')
# script tags
jslist = ['/base/webclient/js']
if 1: # debug == 1
jslist = manifest_glob(['base'], 'js')
js = "\n ".join(['<script type="text/javascript" src="%s"></script>'%i for i in jslist])
# css tags
csslist = ['/base/webclient/css']
if 1: # debug == 1
csslist = manifest_glob(['base'], 'css')
css = "\n ".join(['<link rel="stylesheet" href="%s">'%i for i in csslist])
r = template % (js, css)
return r
class Database(openerpweb.Controller):
_cp_path = "/base/database"
@ -73,37 +166,6 @@ class Database(openerpweb.Controller):
class Session(openerpweb.Controller):
_cp_path = "/base/session"
def manifest_glob(self, addons, key):
files = []
for addon in addons:
globlist = openerpweb.addons_manifest.get(addon, {}).get(key, [])
files.extend([
resource_path[len(openerpweb.path_addons):]
for pattern in globlist
for resource_path in glob.glob(os.path.join(
openerpweb.path_addons, addon, pattern))
])
return files
def concat_files(self, file_list):
""" Concatenate file content
return (concat,timestamp)
concat: concatenation of file content
timestamp: max(os.path.getmtime of file_list)
"""
root = openerpweb.path_root
files_content = []
files_timestamp = 0
for i in file_list:
fname = os.path.join(root, i)
ftime = os.path.getmtime(fname)
if ftime > files_timestamp:
files_timestamp = ftime
files_content = open(fname).read()
files_concat = "".join(files_content)
return files_concat
@openerpweb.jsonrequest
def login(self, req, db, login, password):
req.session.login(db, login, password)
@ -120,31 +182,12 @@ class Session(openerpweb.Controller):
@openerpweb.jsonrequest
def modules(self, req):
return {"modules": [name
for name, manifest in openerpweb.addons_manifest.iteritems()
if manifest.get('active', True)]}
@openerpweb.jsonrequest
def csslist(self, req, mods='base'):
return {'files': self.manifest_glob(mods.split(','), 'css')}
@openerpweb.jsonrequest
def jslist(self, req, mods='base'):
return {'files': self.manifest_glob(mods.split(','), 'js')}
def css(self, req, mods='base'):
files = self.manifest_glob(mods.split(','), 'css')
concat = self.concat_files(files)[0]
# TODO request set the Date of last modif and Etag
return concat
css.exposed = True
def js(self, req, mods='base'):
files = self.manifest_glob(mods.split(','), 'js')
concat = self.concat_files(files)[0]
# TODO request set the Date of last modif and Etag
return concat
js.exposed = True
# TODO query server for installed web modules
mods = []
for name, manifest in openerpweb.addons_manifest.items():
if name != 'base' and manifest.get('active', True):
mods.append(name)
return mods
@openerpweb.jsonrequest
def eval_domain_and_context(self, req, contexts, domains,
@ -723,6 +766,15 @@ class SearchView(View):
if field.get('context'):
field["context"] = self.parse_domain(field["context"], req.session)
return {'fields': fields}
@openerpweb.jsonrequest
def get_filters(self, req, model):
Model = req.session.model("ir.filters")
filters = Model.get_filters(model)
for filter in filters:
filter["context"] = req.session.eval_context(self.parse_context(filter["context"], req.session))
filter["domain"] = req.session.eval_domain(self.parse_domain(filter["domain"], req.session))
return filters
class Binary(openerpweb.Controller):
_cp_path = "/base/binary"

View File

@ -1,5 +0,0 @@
/*! LAB.js (LABjs :: Loading And Blocking JavaScript)
v1.2.0 (c) Kyle Simpson
MIT License
*/
(function(p){var q="string",w="head",L="body",M="script",u="readyState",j="preloaddone",x="loadtrigger",N="srcuri",E="preload",Z="complete",y="done",z="which",O="preserve",F="onreadystatechange",ba="onload",P="hasOwnProperty",bb="script/cache",Q="[object ",bw=Q+"Function]",bx=Q+"Array]",e=null,h=true,i=false,k=p.document,bc=p.location,bd=p.ActiveXObject,A=p.setTimeout,be=p.clearTimeout,R=function(a){return k.getElementsByTagName(a)},S=Object.prototype.toString,G=function(){},r={},T={},bf=/^[^?#]*\//.exec(bc.href)[0],bg=/^\w+\:\/\/\/?[^\/]+/.exec(bf)[0],by=R(M),bh=p.opera&&S.call(p.opera)==Q+"Opera]",bi=("MozAppearance"in k.documentElement.style),bj=(k.createElement(M).async===true),v={cache:!(bi||bh),order:bi||bh||bj,xhr:h,dupe:h,base:"",which:w};v[O]=i;v[E]=h;r[w]=k.head||R(w);r[L]=R(L);function B(a){return S.call(a)===bw}function U(a,b){var c=/^\w+\:\/\//,d;if(typeof a!=q)a="";if(typeof b!=q)b="";d=((/^\/\//.test(a))?bc.protocol:"")+a;d=(c.test(d)?"":b)+d;return((c.test(d)?"":(d.charAt(0)==="/"?bg:bf))+d)}function bz(a){return(U(a).indexOf(bg)===0)}function bA(a){var b,c=-1;while(b=by[++c]){if(typeof b.src==q&&a===U(b.src)&&b.type!==bb)return h}return i}function H(t,l){t=!(!t);if(l==e)l=v;var bk=i,C=t&&l[E],bl=C&&l.cache,I=C&&l.order,bm=C&&l.xhr,bB=l[O],bC=l.which,bD=l.base,bn=G,J=i,D,s=h,m={},K=[],V=e;C=bl||bm||I;function bo(a,b){if((a[u]&&a[u]!==Z&&a[u]!=="loaded")||b[y]){return i}a[ba]=a[F]=e;return h}function W(a,b,c){c=!(!c);if(!c&&!(bo(a,b)))return;b[y]=h;for(var d in m){if(m[P](d)&&!(m[d][y]))return}bk=h;bn()}function bp(a){if(B(a[x])){a[x]();a[x]=e}}function bE(a,b){if(!bo(a,b))return;b[j]=h;A(function(){r[b[z]].removeChild(a);bp(b)},0)}function bF(a,b){if(a[u]===4){a[F]=G;b[j]=h;A(function(){bp(b)},0)}}function X(b,c,d,g,f,n){var o=b[z];A(function(){if("item"in r[o]){if(!r[o][0]){A(arguments.callee,25);return}r[o]=r[o][0]}var a=k.createElement(M);if(typeof d==q)a.type=d;if(typeof g==q)a.charset=g;if(B(f)){a[ba]=a[F]=function(){f(a,b)};a.src=c;if(bj){a.async=i}}r[o].insertBefore(a,(o===w?r[o].firstChild:e));if(typeof n==q){a.text=n;W(a,b,h)}},0)}function bq(a,b,c,d){T[a[N]]=h;X(a,b,c,d,W)}function br(a,b,c,d){var g=arguments;if(s&&a[j]==e){a[j]=i;X(a,b,bb,d,bE)}else if(!s&&a[j]!=e&&!a[j]){a[x]=function(){br.apply(e,g)}}else if(!s){bq.apply(e,g)}}function bs(a,b,c,d){var g=arguments,f;if(s&&a[j]==e){a[j]=i;f=a.xhr=(bd?new bd("Microsoft.XMLHTTP"):new p.XMLHttpRequest());f[F]=function(){bF(f,a)};f.open("GET",b);f.send("")}else if(!s&&a[j]!=e&&!a[j]){a[x]=function(){bs.apply(e,g)}}else if(!s){T[a[N]]=h;X(a,b,c,d,e,a.xhr.responseText);a.xhr=e}}function bt(a){if(typeof a=="undefined"||!a)return;if(a.allowDup==e)a.allowDup=l.dupe;var b=a.src,c=a.type,d=a.charset,g=a.allowDup,f=U(b,bD),n,o=bz(f);if(typeof d!=q)d=e;g=!(!g);if(!g&&((T[f]!=e)||(s&&m[f])||bA(f))){if(m[f]!=e&&m[f][j]&&!m[f][y]&&o){W(e,m[f],h)}return}if(m[f]==e)m[f]={};n=m[f];if(n[z]==e)n[z]=bC;n[y]=i;n[N]=f;J=h;if(!I&&bm&&o)bs(n,f,c,d);else if(!I&&bl)br(n,f,c,d);else bq(n,f,c,d)}function Y(a){if(t&&!I)K.push(a);if(!t||C)a()}function bu(a){var b=[],c;for(c=-1;++c<a.length;){if(S.call(a[c])===bx)b=b.concat(bu(a[c]));else b[b.length]=a[c]}return b}D={script:function(){be(V);var a=bu(arguments),b=D,c;if(bB){for(c=-1;++c<a.length;){if(B(a[c]))a[c]=a[c]();if(c===0){Y(function(){bt((typeof a[0]==q)?{src:a[0]}:a[0])})}else b=b.script(a[c]);b=b.wait()}}else{for(c=-1;++c<a.length;){if(B(a[c]))a[c]=a[c]()}Y(function(){for(c=-1;++c<a.length;){bt((typeof a[c]==q)?{src:a[c]}:a[c])}})}V=A(function(){s=i},5);return b},wait:function(a){be(V);s=i;if(!B(a))a=G;var b=H(t||J,l),c=b.trigger,d=function(){try{a()}catch(err){}c()};delete b.trigger;var g=function(){if(J&&!bk)bn=d;else d()};if(t&&!J)K.push(g);else Y(g);return b}};if(t){D.trigger=function(){var a,b=-1;while(a=K[++b])a();K=[]}}else D.trigger=G;return D}function bv(a){var b,c={},d={"UseCachePreload":"cache","UseLocalXHR":"xhr","UsePreloading":E,"AlwaysPreserveOrder":O,"AllowDuplicates":"dupe"},g={"AppendTo":z,"BasePath":"base"};for(b in d)g[b]=d[b];c.order=!(!v.order);for(b in g){if(g[P](b)&&v[g[b]]!=e)c[g[b]]=(a[b]!=e)?a[b]:v[g[b]]}for(b in d){if(d[P](b))c[d[b]]=!(!c[d[b]])}if(!c[E])c.cache=c.order=c.xhr=i;c.which=(c.which===w||c.which===L)?c.which:w;return c}p.$LAB={setGlobalDefaults:function(a){v=bv(a)},setOptions:function(a){return H(i,bv(a))},script:function(){return H().script.apply(e,arguments)},wait:function(){return H().wait.apply(e,arguments)}};(function(a,b,c){if(k[u]==e&&k[a]){k[u]="loading";k[a](b,c=function(){k.removeEventListener(b,c,i);k[u]=Z},i)}})("addEventListener","DOMContentLoaded")})(window);

View File

@ -1,58 +0,0 @@
<!DOCTYPE html>
<html style="height: 100%">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>OpenERP</title>
<link rel="shortcut icon" href="/base/static/src/img/favicon.ico" type="image/x-icon"/>
<script type="text/javascript" src="/base/static/lib/LABjs/LAB.js"></script>
<script type="text/javascript" src="/base/static/lib/underscore/underscore.js"></script>
<script type="text/javascript" src="/base/static/lib/underscore/underscore.string.js"></script>
<script type="text/javascript" src="/base/static/lib/qweb/qweb2.js"></script>
<!-- Uncomment in order to use legacy QWeb
<script type="text/javascript" src="/base/static/lib/qweb/qweb.js"></script>
-->
<script type="text/javascript" src="/base/static/lib/jquery/jquery-1.5.2.js"></script>
<script type="text/javascript" src="/base/static/lib/jquery.ui/js/jquery-ui-1.8.9.custom.min.js"></script>
<script type="text/javascript" src="/base/static/lib/jquery.ui/js/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="/base/static/lib/jquery.ui.notify/js/jquery.notify.js"></script>
<script type="text/javascript" src="/base/static/lib/jquery.superfish/js/hoverIntent.js"></script>
<script type="text/javascript" src="/base/static/lib/jquery.superfish/js/superfish.js"></script>
<script type="text/javascript" src="/base/static/lib/jquery.ba-bbq/jquery.ba-bbq.js"></script>
<script type="text/javascript" src="/base/static/lib/jquery.contextmenu/jquery.contextmenu.r2.packed.js"></script>
<script type="text/javascript" src="/base/static/lib/datejs/date-en-US.js"></script>
<script type="text/javascript" src="/base/static/lib/json/json2.js"></script>
<script type="text/javascript" src="/base/static/src/js/base.js"></script>
<script type="text/javascript" src="/base/static/src/js/controller.js"></script>
<script type="text/javascript" src="/base/static/src/js/dates.js"></script>
<script type="text/javascript" src="/base/static/src/js/chrome.js"></script>
<script type="text/javascript" src="/base/static/src/js/data.js"></script>
<script type="text/javascript" src="/base/static/src/js/export.js"></script>
<script type="text/javascript" src="/base/static/src/js/views.js"></script>
<script type="text/javascript" src="/base/static/src/js/form.js"></script>
<script type="text/javascript" src="/base/static/src/js/list.js"></script>
<script type="text/javascript" src="/base/static/src/js/list-editable.js"></script>
<script type="text/javascript" src="/base/static/src/js/search.js"></script>
<script type="text/javascript" src="/base/static/src/js/view_tree.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="/base/static/lib/jquery.ui/css/smoothness/jquery-ui-1.8.9.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/base/static/lib/jquery.ui.notify/css/ui.notify.css" />
<link rel="stylesheet" type="text/css" href="/base/static/lib/jquery.superfish/css/superfish.css" media="screen">
<link rel="stylesheet" href="/base/static/src/css/base.css" type="text/css"/>
<link rel="stylesheet" href="/base/static/src/css/export.css" type="text/css"/>
<!--[if lte IE 7]>
<link rel="stylesheet" href="/base/static/src/css/base-ie7.css" type="text/css"/>
<![endif]-->
<script type="text/javascript">
$(function() {
QWeb = window.QWeb || new QWeb2.Engine();
var oe = openerp.init();
oe.base.webclient("oe");
});
</script>
</head>
<body id="oe" class="openerp">
</body>
</html>

View File

@ -234,6 +234,7 @@ openerp.base.BaseWidget = openerp.base.Controller.extend({
if(this.$element != null) {
this.$element.remove();
}
this._super();
}
});
@ -451,15 +452,20 @@ openerp.base.Session = openerp.base.Controller.extend( /** @lends openerp.base.S
load_modules: function() {
var self = this;
this.rpc('/base/session/modules', {}, function(result) {
self.module_list = result['modules'];
self.module_list = result;
var modules = self.module_list.join(',');
self.rpc('/base/session/csslist', {mods: modules}, self.do_load_css);
self.rpc('/base/session/jslist', {"mods": modules}, self.debug ? self.do_load_modules_debug : self.do_load_modules_prod);
if(self.debug || true) {
self.rpc('/base/webclient/csslist', {"mods": modules}, self.do_load_css);
self.rpc('/base/webclient/jslist', {"mods": modules}, self.do_load_js);
} else {
self.do_load_css(["/base/webclient/css?mods="+modules]);
self.do_load_js(["/base/webclient/js?mods="+modules]);
}
openerp._modules_loaded = true;
});
},
do_load_css: function (result) {
_.each(result.files, function (file) {
do_load_css: function (files) {
_.each(files, function (file) {
$('head').append($('<link>', {
'href': file,
'rel': 'stylesheet',
@ -467,16 +473,23 @@ openerp.base.Session = openerp.base.Controller.extend( /** @lends openerp.base.S
}));
});
},
do_load_modules_debug: function(result) {
$LAB.setOptions({AlwaysPreserveOrder: true})
.script(result.files)
.wait(this.on_modules_loaded);
},
do_load_modules_prod: function() {
// load merged ones
// /base/session/css?mod=mod1,mod2,mod3
// /base/session/js?mod=mod1,mod2,mod3
// use $.getScript(your_3rd_party-script.js); ? i want to keep lineno !
do_load_js: function(files) {
var self = this;
if(files.length != 0) {
var file = files.shift();
var tag = document.createElement('script');
tag.type = 'text/javascript';
tag.src = file;
tag.onload = tag.onreadystatechange = function() {
if ( (tag.readyState && tag.readyState != "loaded" && tag.readyState != "complete") || tag.onload_done )
return;
tag.onload_done = true;
self.do_load_js(files);
};
document.head.appendChild(tag);
} else {
this.on_modules_loaded();
}
},
on_modules_loaded: function() {
for(var j=0; j<this.module_list.length; j++) {
@ -845,7 +858,7 @@ openerp.base.WebClient = openerp.base.Controller.extend({
init: function(element_id) {
this._super(null, element_id);
QWeb.add_template("xml/base.xml");
QWeb.add_template("/base/static/src/xml/base.xml");
var params = {};
if(jQuery.param != undefined && jQuery.deparam(jQuery.param.querystring()).kitten != undefined) {
this.$element.addClass("kitten-mode-activated");

View File

@ -200,6 +200,12 @@ instance.base.Controller = instance.base.Class.extend( /** @lends instance.base.
return $.Deferred().done().promise();
},
stop: function() {
if (this.parent && this.parent.children) {
this.parent.children = _.without(this.parent.children, this);
this.parent.controller_children = this.parent.children;
}
this.parent = null;
this.controller_parent = null;
},
log: function() {
var args = Array.prototype.slice.call(arguments);

View File

@ -240,11 +240,12 @@ openerp.base.DataSet = openerp.base.Controller.extend( /** @lends openerp.base.
* @constructs
* @extends openerp.base.Controller
*
* @param {openerp.base.Session} session current OpenERP session
* @param {String} model the OpenERP model this dataset will manage
*/
init: function(parent, model, context) {
this._super(parent);
init: function(source_controller, model, context) {
// we don't want the dataset to be a child of anything!
this._super(null);
this.session = source_controller ? source_controller.session : undefined;
this.model = model;
this.context = context || {};
this.index = null;

View File

@ -407,20 +407,19 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormV
this.notification.notify("Cancelling form");
},
do_update_sidebar: function() {
if (this.flags.sidebar === false) {
if (this.flags.sidebar === false || this.view_manager.sidebar === undefined) {
return;
}
if (!this.datarecord.id) {
this.on_attachments_loaded([]);
} else {
// TODO fme: modify this so it doesn't try to load attachments when there is not sidebar
/*(new openerp.base.DataSetSearch(
(new openerp.base.DataSetSearch(
this, 'ir.attachment', this.dataset.get_context(),
[['res_model', '=', this.dataset.model],
['res_id', '=', this.datarecord.id],
['type', 'in', ['binary', 'url']]])).read_slice(
['name', 'url', 'type'], false, false,
this.on_attachments_loaded);*/
this.on_attachments_loaded);
}
},
on_attachments_loaded: function(attachments) {
@ -2219,8 +2218,10 @@ openerp.base.form.widgets = new openerp.base.Registry({
'url' : 'openerp.base.form.FieldUrl',
'text' : 'openerp.base.form.FieldText',
'text_wiki' : 'openerp.base.form.FieldText',
'date' : 'openerp.base.form.FieldDate',
'datetime' : 'openerp.base.form.FieldDatetime',
// 'date' : 'openerp.base.form.FieldDate',
// 'datetime' : 'openerp.base.form.FieldDatetime',
'date' : 'openerp.base.form.FieldChar',
'datetime' : 'openerp.base.form.FieldChar',
'selection' : 'openerp.base.form.FieldSelection',
'many2one' : 'openerp.base.form.FieldMany2One',
'many2many' : 'openerp.base.form.FieldMany2Many',

View File

@ -1086,6 +1086,45 @@ openerp.base.ListView.Groups = openerp.base.Class.extend( /** @lends openerp.bas
});
return d.promise();
},
setup_resequence_rows: function (list, dataset) {
// drag and drop enabled if list is not sorted and there is a
// "sequence" column in the view.
if ((dataset.sort && dataset.sort())
|| !_(this.columns).any(function (column) {
return column.name === 'sequence'; })) {
return;
}
// ondrop, move relevant record & fix sequences
list.$current.sortable({
stop: function (event, ui) {
var from = ui.item.data('index'),
to = ui.item.prev().data('index') || 0;
if (from === to) { return; }
list.rows.splice(to, 0, list.rows.splice(from, 1)[0]);
ui.item.parent().children().each(function (i, e) {
// reset record-index accelerators on rows and even/odd
var even = i%2 === 0;
$(e).data('index', i)
.toggleClass('even', even)
.toggleClass('odd', !even);
});
// resequencing time!
var data, index = to,
// if drag to 1st row (to = 0), start sequencing from 0
// (exclusive lower bound)
seq = to ? list.rows[to - 1].data.sequence.value : 0;
while (++seq, data = list.rows[index++].data) {
data.sequence.value = seq;
// write are independent from one another, so we can just
// launch them all at the same time and we don't really
// give a fig about when they're done
dataset.write(data.id.value, {sequence: seq});
}
}
});
},
render: function (post_render) {
var self = this;
var $element = $('<tbody>');
@ -1104,6 +1143,7 @@ openerp.base.ListView.Groups = openerp.base.Class.extend( /** @lends openerp.bas
self.children[null] = list;
self.elements =
[list.$current.replaceAll($element)[0]];
self.setup_resequence_rows(list, dataset);
if (post_render) { post_render(); }
});
});

View File

@ -140,30 +140,42 @@ openerp.base.SearchView = openerp.base.Controller.extend({
return widget.start();
}).value();
// filters management
this.$element.find(".oe_search-view-filters-management").change(this.on_filters_management);
var self = this;
$.when.apply(null, widget_starts).then(function () {
self.ready.resolve();
});
// filters management
var self = this;
return this.rpc('/base/searchview/get_filters', {
model: this.dataset.model
}).then(function(result) {
self.managed_filters = result;
var filters = self.$element.find(".oe_search-view-filters-management");
filters.html(QWeb.render("SearchView.managed-filters", {filters: result}));
filters.change(self.on_filters_management);
});
},
/**
* Handle event when the user make a selection in the filters management select box.
*/
on_filters_management: function(e) {
var select = this.$element.find(".oe_search-view-filters-management"),
val = select.val();
select.val("_filters");
var select = this.$element.find(".oe_search-view-filters-management");
var val = select.val();
if (val.slice(0,1) == "_") // useless action
if (val.slice(0,1) == "_") { // useless action
select.val("_filters");
return;
}
if (val.slice(0, "get:".length) == "get:") {
val = val.slice("get:".length);
//TODO niv
val = parseInt(val);
var filter = this.managed_filters[val];
this.on_search([filter.domain], [filter.context], []);
} else if (val == "save_filter") {
select.val("_filters");
//TODO niv
} else { // manage_filters
select.val("_filters");
//TODO niv
}
},
@ -179,6 +191,10 @@ openerp.base.SearchView = openerp.base.Controller.extend({
* @param e jQuery event object coming from the "Search" button
*/
do_search: function (e) {
// reset filters management
var select = this.$element.find(".oe_search-view-filters-management");
select.val("_filters");
if (e && e.preventDefault) { e.preventDefault(); }
var domains = [],
@ -847,7 +863,9 @@ openerp.base.search.ExtendedSearch = openerp.base.BaseWidget.extend({
},
check_last_element: function() {
_.each(this.children, function(x) {x.set_last_group(false);});
this.children[this.children.length - 1].set_last_group(true);
if (this.children.length >= 1) {
this.children[this.children.length - 1].set_last_group(true);
}
}
});

View File

@ -11,7 +11,7 @@ openerp.base.ActionManager = openerp.base.Controller.extend({
this.viewmanager = null;
this.current_dialog = null;
// Temporary linking view_manager to session.
// Will use controller_parent to find it when implementation will be done.
// Will use parent to find it when implementation will be done.
this.session.action_manager = this;
},
/**

View File

@ -62,7 +62,7 @@
<td><label for="db">Database:</label></td>
<td>
<t t-if="!db_list">
<input type="text" name="db" value="trunk" autofocus="true"/>
<input type="text" name="db" value="" autofocus="true"/>
</t>
<t t-if="db_list">
<select name="db">
@ -664,14 +664,21 @@
<input type="reset" value="Clear"/>
<button class="oe_search-view-custom-filter-btn"><span>Advanced Filter</span></button>
<select class="oe_search-view-filters-management">
<option value="_filters">-- Filters --</option>
<option value="_actions">-- Actions --</option>
<option value="save_filter">Save Filter</option>
<option value="manage_filters">Manage Filters</option>
</select>
</div>
</form>
</t>
<t t-name="SearchView.managed-filters">
<option value="_filters">-- Filters --</option>
<t t-set="i" t-value="0"/>
<t t-foreach="filters" t-as="filter">
<option t-att-value="'get:' + i"><t t-esc="filter.name"/></option>
<t t-set="i" t-value="i+1"/>
</t>
<option value="_actions">-- Actions --</option>
<option value="save_filter">Save Filter</option>
<option value="manage_filters">Manage Filters</option>
</t>
<t t-name="SearchView.render_lines">
<table class="oe-searchview-render-line" border="0" cellspacing="0" cellpadding="0"
t-foreach="lines" t-as="line">

View File

@ -407,7 +407,7 @@ class Root(object):
if path_addons not in sys.path:
sys.path.insert(0, path_addons)
for i in os.listdir(path_addons):
if i not in sys.modules:
if i not in addons_module:
manifest_path = os.path.join(path_addons, i, '__openerp__.py')
if os.path.isfile(manifest_path):
manifest = eval(open(manifest_path).read())
@ -445,7 +445,7 @@ class Root(object):
#for the mobile web client we are supposed to use a different url to just add '/mobile'
raise cherrypy.HTTPRedirect('/web_mobile/static/src/web_mobile.html', 301)
else:
raise cherrypy.HTTPRedirect('/base/static/src/base.html', 301)
raise cherrypy.HTTPRedirect('/base/webclient/home', 301)
default.exposed = True
def main(argv):