From 972e0ff71cc881683e9d6a27a9504c946f840f53 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 15 Sep 2011 17:58:37 +0530 Subject: [imp]improve code for creating object of xml for tree view. bzr revid: vme@tinyerp.com-20110915122837-4v344b0g0lsrq9u9 --- addons/web/static/src/js/view_editor.js | 58 +++++++++++++++++++-------------- addons/web/static/src/js/views.js | 2 +- 2 files changed, 35 insertions(+), 25 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 22800facf9b..c2d8404a2dd 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -1,5 +1,6 @@ openerp.web.view_editor = function(openerp) { -openerp.web.ViewEditor = openerp.web.Widget.extend({ +var QWeb = openerp.web.qweb; +openerp.web.ViewEditor = openerp.web.Widget.extend({ init: function(parent, element_id, dataset, view, options) { this._super(parent); this.element_id = element_id @@ -56,8 +57,6 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ this.dialog.open(); action_manager.appendTo(this.dialog); action_manager.do_action(action); - - }, check_attr:function(xml,tag){ var obj = new Object(); @@ -76,25 +75,29 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ obj.name = name1; return obj; }, - recursiveFunction : function(main_object,parent_id,child_id){ + save_object : function(val,parent_list,child_obj_list){ var self = this; - var check = false; - var main_object = _.detect(main_object , function(node){ - if(node.id == parent_id){ - node.child_id = child_id; - check = true; - } - return main_object; - }); - if(check){ - return main_object; - }else{ - //todo recursion for saving object into objects + var check_id = parent_list[0]; + var p_list = parent_list.slice(1); + if(val.child_id.length != 0){ + $.each(val.child_id, function(key,val) { + if(val.id==check_id){ + if(p_list.length!=0){ + self.save_object(val,p_list,child_obj_list); + }else{ + val.child_id = child_obj_list; + return; + } + } + }); + }else{ + val.child_id = child_obj_list; } }, - children_function : function(xml,root,main_object,parent_id){ + children_function : function(xml,root,parent_list,parent_id,main_object){ var self = this; var child_obj_list = []; + var parent_list = parent_list; var main_object = main_object; var children_list = $(xml).filter(root).children(); _.each(children_list, function(child_node){ @@ -102,15 +105,23 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ child_obj_list.push(string); }); if(children_list.length != 0){ - main_object = self.recursiveFunction(main_object,parent_id,child_obj_list); + var parents = $(children_list[0]).parents().get(); + if(parents.length <= parent_list.length){ + parent_list.splice(parents.length-1);} + parent_list.push(parent_id); + $.each(main_object, function(key,val) { + self.save_object(val,parent_list.slice(1),child_obj_list); + }); } for(var i=0;i' + openerp.base.json_node_to_xml(this.fields_view.arch, true) + '').dialog({ width: '95%', height: 600}); - var view_editor = new openerp.base.ViewEditor(this, this.$element, this.dataset, this.fields_view.arch) + var view_editor = new openerp.web.ViewEditor(this, this.$element, this.dataset, this.fields_view.arch) view_editor.start(); } else { this.notification.warn("Manage Views", "Could not find current view declaration"); -- cgit v1.2.3 From 28a13263c9c109d4a2c04831291308992b0b4c6e Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Fri, 16 Sep 2011 18:54:11 +0530 Subject: [imp]render object of xml in view editor with all data. bzr revid: vme@tinyerp.com-20110916132411-4o787cega0nnxr33 --- addons/web/static/src/css/base.css | 3 ++ addons/web/static/src/js/view_editor.js | 75 +++++++++++++++++++-------------- addons/web/static/src/xml/base.xml | 23 ++++++++++ 3 files changed, 69 insertions(+), 32 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index cc8b596e6f5..2cdeb9e89d5 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1315,3 +1315,6 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after { border-color: rgba(0,0,0,0); border-left-color: #CFCCCC; } +.openerp .view_editor{ + border-bottom: 1px solid #CFCCCC; +} diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index c2d8404a2dd..28b13aa1930 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -44,8 +44,9 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }, "Edit": function(){ - self.xml_id=0; - self.edit_view(); + self.xml_id = 0 ; + self.get_data(); + }, "Close": function(){ $(this).dialog('destroy'); @@ -58,10 +59,12 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ action_manager.appendTo(this.dialog); action_manager.do_action(action); }, - check_attr:function(xml,tag){ + + check_attr:function(xml,tag,level){ var obj = new Object(); obj.child_id = []; obj.id = this.xml_id++; + obj.level = level; var att_list = []; var name1 = "<" + tag; $(xml).each(function() { @@ -75,6 +78,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ obj.name = name1; return obj; }, + save_object : function(val,parent_list,child_obj_list){ var self = this; var check_id = parent_list[0]; @@ -94,14 +98,16 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ val.child_id = child_obj_list; } }, + children_function : function(xml,root,parent_list,parent_id,main_object){ var self = this; var child_obj_list = []; var parent_list = parent_list; var main_object = main_object; var children_list = $(xml).filter(root).children(); + var parents = $(children_list[0]).parents().get(); _.each(children_list, function(child_node){ - var string = self.check_attr(child_node,child_node.tagName.toLowerCase()); + var string = self.check_attr(child_node,child_node.tagName.toLowerCase(),parents.length); child_obj_list.push(string); }); if(children_list.length != 0){ @@ -115,42 +121,47 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } for(var i=0;i + + + +
+
+ + + + + + + + + + + + + + + + Export @@ -1295,6 +1317,7 @@ + -- cgit v1.2.3 From e34c9b01a50c4377982986c1d0cdecb9e87121ef Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Mon, 19 Sep 2011 12:35:59 +0530 Subject: [FIX]Rename openerp to db. bzr revid: vme@tinyerp.com-20110919070559-l703ghrpnv4bmehn --- addons/web/static/src/js/views.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 5f06297cbbb..fa27e59c0af 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -850,7 +850,7 @@ db.web.View = db.web.Widget.extend(/** @lends db.web.View# */{ }, on_sidebar_manage_view: function() { if (this.fields_view && this.fields_view.arch) { - var view_editor = new openerp.web.ViewEditor(this, this.$element, this.dataset, this.fields_view.arch); + var view_editor = new db.web.ViewEditor(this, this.$element, this.dataset, this.fields_view.arch); view_editor.start(); } else { this.notification.warn("Manage Views", "Could not find current view declaration"); -- cgit v1.2.3 From e0724b4c339b1da080cea7d8dc5e3b671fd07701 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Tue, 20 Sep 2011 18:13:02 +0530 Subject: [IMP]improve code for edit dialog box in manager view. bzr revid: vme@tinyerp.com-20110920124302-0nxmhgb0u6tomi37 --- addons/web/static/src/css/base.css | 10 ++++++-- addons/web/static/src/js/view_editor.js | 29 +++++++++++++++++++---- addons/web/static/src/xml/base.xml | 41 +++++++++++++++++++++------------ 3 files changed, 58 insertions(+), 22 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index a66bb20d8de..5d4da8175dd 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1369,6 +1369,12 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after { border-color: rgba(0,0,0,0); border-left-color: #CFCCCC; } -.openerp .view_editor{ - border-bottom: 1px solid #CFCCCC; +.openerp .view_editor{ + font-size: 90%; + font-weight: normal; + height : 10%; + padding: 0; + border-bottom: 1px solid #CFCCCC; } + + diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 28b13aa1930..6f9fd059066 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -70,9 +70,14 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ $(xml).each(function() { att_list = this.attributes; att_list = _.select(att_list, function(attrs){ - if(attrs.nodeName == "string" || attrs.nodeName == "name" || attrs.nodeName == "index"){ - name1 += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';} - }); + if (tag != 'button'){ + if(attrs.nodeName == "string" || attrs.nodeName == "name" || attrs.nodeName == "index"){ + name1 += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';} + }else{ + if(attrs.nodeName == "name"){ + name1 += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';} + } + }); name1+= ">"; }); obj.name = name1; @@ -138,7 +143,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ return self.edit_view(one_object); }); }, - edit_view : function(o){ + edit_view : function(one_object){ var self = this; this.dialog = new openerp.web.Dialog(this,{ modal: true, @@ -160,9 +165,23 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ this.dialog.start().open(); this.dialog.$element.html(QWeb.render('view_editor', { - 'data': o, + 'data': one_object, })); + + $("tr[id^='viewedit-']").click(function() { + $("tr[id^='viewedit-']").removeClass('ui-selected'); + $(this).addClass('ui-selected'); + }); + + $("img[id^='parentimg-']").click(function() { + if ($(this).attr('src') == '/web/static/src/img/collapse.gif'){ + $(this).attr('src', '/web/static/src/img/expand.gif'); + }else{ + $(this).attr('src', '/web/static/src/img/collapse.gif'); + } + }); } + }); }; diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 6251b5ba339..5f91ab46047 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1263,28 +1263,39 @@ -
+
- - - - - - - - - + + + + + + + +
+ + + +
+ + + + + + + + + + +
+ - - - - + Export -- cgit v1.2.3 From f6a7de7e113222186c4ef712f3936f4247fc5908 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Tue, 20 Sep 2011 19:09:11 +0530 Subject: [IMP]created object key,value for parent,child. bzr revid: vme@tinyerp.com-20110920133911-7jcdqs6sdcwl7bvk --- addons/web/static/src/js/view_editor.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 6f9fd059066..f5f1766b119 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -104,9 +104,10 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }, - children_function : function(xml,root,parent_list,parent_id,main_object){ + children_function : function(xml,root,parent_list,parent_id,main_object,parent_child_id){ var self = this; var child_obj_list = []; + var parent_child_id = parent_child_id; var parent_list = parent_list; var main_object = main_object; var children_list = $(xml).filter(root).children(); @@ -116,6 +117,8 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ child_obj_list.push(string); }); if(children_list.length != 0){ + parent_child_id.push({key: parent_id, value: child_obj_list}); + var parents = $(children_list[0]).parents().get(); if(parents.length <= parent_list.length){ parent_list.splice(parents.length-1);} @@ -126,11 +129,12 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } for(var i=0;i Date: Thu, 22 Sep 2011 14:30:27 +0530 Subject: [IMP]Implement code for show-hide child node in tree view. bzr revid: kch@tinyerp.com-20110922090027-9eku05pk3okq26hh --- addons/web/static/src/js/view_editor.js | 109 +++++++++++++++++++------------- addons/web/static/src/xml/base.xml | 11 ++-- 2 files changed, 71 insertions(+), 49 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index f5f1766b119..c86f9993856 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -41,12 +41,12 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ height: 500, buttons: { "Create": function(){ - + }, "Edit": function(){ self.xml_id = 0 ; self.get_data(); - + }, "Close": function(){ $(this).dialog('destroy'); @@ -54,7 +54,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }, }); - this.dialog.start(); + this.dialog.start(); this.dialog.open(); action_manager.appendTo(this.dialog); action_manager.do_action(action); @@ -72,14 +72,14 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ att_list = _.select(att_list, function(attrs){ if (tag != 'button'){ if(attrs.nodeName == "string" || attrs.nodeName == "name" || attrs.nodeName == "index"){ - name1 += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';} + name1 += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';} }else{ if(attrs.nodeName == "name"){ - name1 += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';} + name1 += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';} } - }); + }); name1+= ">"; - }); + }); obj.name = name1; return obj; }, @@ -117,14 +117,14 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ child_obj_list.push(string); }); if(children_list.length != 0){ - parent_child_id.push({key: parent_id, value: child_obj_list}); - + var child_ids = _.map(child_obj_list ,function(num){return num.id;}); + parent_child_id.push({'key': parent_id, 'value': child_ids}); var parents = $(children_list[0]).parents().get(); if(parents.length <= parent_list.length){ parent_list.splice(parents.length-1);} parent_list.push(parent_id); $.each(main_object, function(key,val) { - self.save_object(val,parent_list.slice(1),child_obj_list); + self.save_object(val,parent_list.slice(1),child_obj_list); }); } for(var i=0;i level){ + cur_tr = nxt_tr; + nxt_tr.hide(); + }else break; + } + }, + on_collapse: function(self,parent_child_id){ + var id = self.id.split('-')[1]; + var datas = _.detect(parent_child_id,function(res){ + return res.key == id; + }); + _.each(datas.value,function(rec){ + var tr = $("tr[id='viewedit-"+rec+"']"); + tr.find("img[id='parentimg-"+rec+"']").attr('src','/web/static/src/img/expand.gif'); + tr.show(); + }); + } }); }; diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 5f91ab46047..a0b4505155a 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -640,8 +640,8 @@
- - + + - - + +
@@ -1280,7 +1280,7 @@
- + @@ -1296,6 +1296,7 @@ + Export -- cgit v1.2.3 From 3e11ca62990fde34e537e233e3b099d22f8c8373 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 22 Sep 2011 15:15:13 +0530 Subject: [IMP]implement code for side images in view editor and up-down tag. bzr revid: vme@tinyerp.com-20110922094513-bhvlvfm9q5bw9dq9 --- addons/web/static/src/js/view_editor.js | 25 +++++++++++++++++++++++++ addons/web/static/src/xml/base.xml | 29 ++++++++++++++++++++--------- 2 files changed, 45 insertions(+), 9 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index c86f9993856..7f1ac017ff3 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -116,6 +116,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var string = self.check_attr(child_node,child_node.tagName.toLowerCase(),parents.length); child_obj_list.push(string); }); + if(children_list.length != 0){ var child_ids = _.map(child_obj_list ,function(num){return num.id;}); parent_child_id.push({'key': parent_id, 'value': child_ids}); @@ -184,6 +185,30 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ self.on_collapse(this,one_object['parent_child_id']); } }); + $("img[id^='side-']").click(function() { + var side = $(this).closest("'tr[id^='viewedit-']'"); + switch (this.id) + { + case "side-add": + break; + case "side-remove": + break; + case "side-edit": + break; + case "side-up": + if(side.prev().attr('level') == side.attr('level')){ + console.log(); + $(side.prev()).before(side); + } + break; + case "side-down": + if(side.next().attr('level') == side.attr('level')){ + var v = side.next().next().attr('level') + $(side.next()).after(side); + } + break; + } + }); }, on_expand: function(self){ var level = $(self).closest("tr[id^='viewedit-']").attr('level'); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index a0b4505155a..4d4efbed2a3 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1267,12 +1267,13 @@
- - + +
- + @@ -1280,14 +1281,24 @@
- + - - - - - + + + + +
+ + + + + + + + + +
-- cgit v1.2.3 From d558fa620e175dced3ba29f946dda4663aad61fb Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Fri, 23 Sep 2011 18:34:06 +0530 Subject: [IMP]include main xml tag in main_object for up down posisition of node. bzr revid: vme@tinyerp.com-20110923130406-3h1r41v6z768zkqt --- addons/web/static/src/js/view_editor.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 7f1ac017ff3..824227174ef 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -65,11 +65,14 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ obj.child_id = []; obj.id = this.xml_id++; obj.level = level; + var vidhin = xml; var att_list = []; var name1 = "<" + tag; + var xml_tag = "<" + tag; $(xml).each(function() { att_list = this.attributes; att_list = _.select(att_list, function(attrs){ + xml_tag += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"'; if (tag != 'button'){ if(attrs.nodeName == "string" || attrs.nodeName == "name" || attrs.nodeName == "index"){ name1 += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';} @@ -79,7 +82,9 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }); name1+= ">"; + xml_tag+= ">"; }); + obj.main_xml = xml_tag; obj.name = name1; return obj; }, @@ -134,17 +139,24 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } return {"main_object":main_object,"parent_child_id":parent_child_id}; }, + parse_xml :function(arch){ + var self = this; + var root = $(arch).filter(":first")[0]; + var tag = root.tagName.toLowerCase(); + var root_object = self.check_attr(root,tag,0); + var one_object = self.children_function(arch,tag,[],0,[root_object],[]); + return self.edit_view(one_object); + }, get_data : function(){ var self = this; var view_id =(($("input[name='radiogroup']:checked").parent()).parent()).attr('data-id'); + dataset = new openerp.web.DataSetSearch(this,'ir.ui.view', null, null); + dataset.read_slice([],{domain : [['inherit_id','=',parseInt(view_id)]]},function (result) { + _.each(result ,function(num){console.log(result);}); + }); var ve_dataset = new openerp.web.DataSet(this,'ir.ui.view'); ve_dataset.read_ids([parseInt(view_id)],['arch'],function (arch){ - var arch = arch[0].arch; - var root = $(arch).filter(":first")[0]; - var tag = root.tagName.toLowerCase(); - var root_object = self.check_attr(root,tag,0); - var one_object = self.children_function(arch,tag,[],0,[root_object],[]); - return self.edit_view(one_object); + self.parse_xml(arch[0].arch); }); }, edit_view : function(one_object){ @@ -197,18 +209,19 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ break; case "side-up": if(side.prev().attr('level') == side.attr('level')){ - console.log(); $(side.prev()).before(side); } break; case "side-down": if(side.next().attr('level') == side.attr('level')){ - var v = side.next().next().attr('level') $(side.next()).after(side); } break; } }); + }, + search_object:function(main_object){ + }, on_expand: function(self){ var level = $(self).closest("tr[id^='viewedit-']").attr('level'); -- cgit v1.2.3 From 145694cc60f0ebe10925f1bfc0baa582e31a78be Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Mon, 26 Sep 2011 17:05:01 +0530 Subject: [IMP]implement code for down image with moving its all children. bzr revid: vme@tinyerp.com-20110926113501-5oed41l0miehjsgx --- addons/web/static/src/js/view_editor.js | 42 ++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 8 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 824227174ef..a7ceb682a2c 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -198,7 +198,8 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }); $("img[id^='side-']").click(function() { - var side = $(this).closest("'tr[id^='viewedit-']'"); + var side = $(this).closest("'tr[id^='viewedit-']'") + var id_tr = (side.attr('id')).split('-')[1]; switch (this.id) { case "side-add": @@ -213,15 +214,40 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } break; case "side-down": - if(side.next().attr('level') == side.attr('level')){ - $(side.next()).after(side); + var img = side.find("img[id='parentimg-"+id_tr+"']").attr('src'); + var level = side.attr('level'); + var list_shift =[]; + var last_tr; + list_shift.push(side); + if(img){ + while(1){ + var next_tr = side.next(); + if(next_tr.attr('level') <= level || next_tr.length==0){ + last_tr = next_tr; + break; + }else{ + list_shift.push(next_tr); + side = next_tr; + } + } + }else{last_tr = side.next();} + var last_tr_id = (last_tr.attr('id')).split('-')[1]; + img = last_tr.find("img[id='parentimg-"+last_tr_id+"']").attr('src'); + if(img){ + while(1){ + var nxt_tr = last_tr.next(); + if (nxt_tr.attr('level') <= level || nxt_tr.length==0){break;} + last_tr = nxt_tr; + } + list_shift.reverse() + } + _.each(list_shift,function(rec){ + $(last_tr).after(rec); + }); break; } }); - }, - search_object:function(main_object){ - }, on_expand: function(self){ var level = $(self).closest("tr[id^='viewedit-']").attr('level'); @@ -231,10 +257,10 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ if (nxt_tr.attr('level') > level){ cur_tr = nxt_tr; nxt_tr.hide(); - }else break; + }else return nxt_tr; } }, - on_collapse: function(self,parent_child_id){ + on_collapse: function(self,parent_child_id,id){ var id = self.id.split('-')[1]; var datas = _.detect(parent_child_id,function(res){ return res.key == id; -- cgit v1.2.3 From bdf4274f2bdf0085ecf7960529959ffa383d7feb Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Tue, 27 Sep 2011 10:35:03 +0530 Subject: [IMP]up-down tag throght image with its all chidren. bzr revid: vme@tinyerp.com-20110927050503-nw9rg581n8im0vwz --- addons/web/static/src/js/view_editor.js | 73 ++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 19 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index a7ceb682a2c..fd4fcde9ee3 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -152,7 +152,9 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var view_id =(($("input[name='radiogroup']:checked").parent()).parent()).attr('data-id'); dataset = new openerp.web.DataSetSearch(this,'ir.ui.view', null, null); dataset.read_slice([],{domain : [['inherit_id','=',parseInt(view_id)]]},function (result) { - _.each(result ,function(num){console.log(result);}); + _.each(result ,function(num){ + // todo xpath + }); }); var ve_dataset = new openerp.web.DataSet(this,'ir.ui.view'); ve_dataset.read_ids([parseInt(view_id)],['arch'],function (arch){ @@ -209,42 +211,75 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ case "side-edit": break; case "side-up": - if(side.prev().attr('level') == side.attr('level')){ - $(side.prev()).before(side); - } - break; - case "side-down": - var img = side.find("img[id='parentimg-"+id_tr+"']").attr('src'); + var img = side.find("img[id='parentimg-"+id_tr+"']").attr('src'); var level = side.attr('level'); var list_shift =[]; var last_tr; + var next_tr; list_shift.push(side); + var cur_tr = side; + while(1){ + var prev_tr = cur_tr.prev(); + if(level >= prev_tr.attr('level') || prev_tr.length==0){ + last_tr = prev_tr; + break; + } + cur_tr = prev_tr; + } if(img){ while(1){ var next_tr = side.next(); if(next_tr.attr('level') <= level || next_tr.length==0){ - last_tr = next_tr; break; }else{ list_shift.push(next_tr); side = next_tr; } } - }else{last_tr = side.next();} - var last_tr_id = (last_tr.attr('id')).split('-')[1]; - img = last_tr.find("img[id='parentimg-"+last_tr_id+"']").attr('src'); + } + if(last_tr.length!=0 && last_tr.attr('level') == level){ + _.each(list_shift,function(rec){ + $(last_tr).before(rec); + }); + } + break; + case "side-down": + var img = side.find("img[id='parentimg-"+id_tr+"']").attr('src'); + var level = side.attr('level'); + var list_shift =[]; + var last_tr; + var next_tr; + var cur_tr = side; + list_shift.push(side); if(img){ while(1){ - var nxt_tr = last_tr.next(); - if (nxt_tr.attr('level') <= level || nxt_tr.length==0){break;} - last_tr = nxt_tr; + var next_tr = cur_tr.next(); + if(next_tr.attr('level') <= level || next_tr.length==0){ + last_tr = next_tr; + break; + }else{ + list_shift.push(next_tr); + cur_tr = next_tr; + } } - list_shift.reverse() - + }else{last_tr = cur_tr.next();} + if(last_tr.length != 0 && last_tr.attr('level')==level){ + var last_tr_id = (last_tr.attr('id')).split('-')[1]; + img = last_tr.find("img[id='parentimg-"+last_tr_id+"']").attr('src'); + if(img){ + $("img[id='parentimg-"+last_tr_id+"']").attr('src', '/web/static/src/img/expand.gif'); + while(1){ + var next_tr = last_tr.next(); + if (next_tr.attr('level') <= level || next_tr.length==0){break;} + next_tr.hide(); + last_tr = next_tr; + } + } + list_shift.reverse(); + _.each(list_shift,function(rec){ + $(last_tr).after(rec); + }); } - _.each(list_shift,function(rec){ - $(last_tr).after(rec); - }); break; } }); -- cgit v1.2.3 From 0d9bd77377f55d488db572fc5d0c1bb084408d67 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Tue, 27 Sep 2011 12:34:13 +0530 Subject: [FIX]side_id not define bzr revid: vme@tinyerp.com-20110927070413-qjhjmc853141i4so --- addons/web/static/src/js/view_editor.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index fd4fcde9ee3..3194a8aef03 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -121,7 +121,6 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var string = self.check_attr(child_node,child_node.tagName.toLowerCase(),parents.length); child_obj_list.push(string); }); - if(children_list.length != 0){ var child_ids = _.map(child_obj_list ,function(num){return num.id;}); parent_child_id.push({'key': parent_id, 'value': child_ids}); @@ -144,22 +143,23 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var root = $(arch).filter(":first")[0]; var tag = root.tagName.toLowerCase(); var root_object = self.check_attr(root,tag,0); - var one_object = self.children_function(arch,tag,[],0,[root_object],[]); - return self.edit_view(one_object); + return self.children_function(arch,tag,[],0,[root_object],[]); }, get_data : function(){ var self = this; + var inherited_view =[]; + var result; var view_id =(($("input[name='radiogroup']:checked").parent()).parent()).attr('data-id'); - dataset = new openerp.web.DataSetSearch(this,'ir.ui.view', null, null); + var ve_dataset = new openerp.web.DataSet(this,'ir.ui.view'); + dataset = new openerp.web.DataSetSearch(self,'ir.ui.view', null, null); dataset.read_slice([],{domain : [['inherit_id','=',parseInt(view_id)]]},function (result) { - _.each(result ,function(num){ - // todo xpath - }); + return result; }); - var ve_dataset = new openerp.web.DataSet(this,'ir.ui.view'); ve_dataset.read_ids([parseInt(view_id)],['arch'],function (arch){ - self.parse_xml(arch[0].arch); - }); + var one_object = self.parse_xml(arch[0].arch); + return self.edit_view(one_object); + }); + }, edit_view : function(one_object){ var self = this; @@ -200,7 +200,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }); $("img[id^='side-']").click(function() { - var side = $(this).closest("'tr[id^='viewedit-']'") + var side = $(this).closest("tr[id^='viewedit-']") var id_tr = (side.attr('id')).split('-')[1]; switch (this.id) { -- cgit v1.2.3 From 889cff8a19e289568a855c950e65cc07ff36b075 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Tue, 27 Sep 2011 12:47:53 +0530 Subject: [IMP]removed unnecessary variables bzr revid: vme@tinyerp.com-20110927071753-hp5qwox2wgt1bws5 --- addons/web/static/src/js/view_editor.js | 1 - 1 file changed, 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 3194a8aef03..b8ceec94845 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -65,7 +65,6 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ obj.child_id = []; obj.id = this.xml_id++; obj.level = level; - var vidhin = xml; var att_list = []; var name1 = "<" + tag; var xml_tag = "<" + tag; -- cgit v1.2.3 From 654478b811b3f2e42aba489b0f70d71497ff66ea Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Fri, 30 Sep 2011 18:19:32 +0530 Subject: [IMP]developed code for @ sign inherit view with xpath. bzr revid: vme@tinyerp.com-20110930124932-78pdg9o6o450rnur --- addons/web/static/src/js/view_editor.js | 381 +++++++++++++++++++------------- 1 file changed, 225 insertions(+), 156 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index b8ceec94845..46e83576eb2 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -1,6 +1,7 @@ openerp.web.view_editor = function(openerp) { var QWeb = openerp.web.qweb; openerp.web.ViewEditor = openerp.web.Widget.extend({ + init: function(parent, element_id, dataset, view, options) { this._super(parent); this.element_id = element_id @@ -9,55 +10,55 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ this.model = dataset.model; this.xml_id = 0; }, + start: function() { this.View_editor(); }, - View_editor : function(){ - var self = this; - var action = { - name:'ViewEditor', - context:this.session.user_context, - domain: [["model", "=", this.dataset.model]], - res_model: 'ir.ui.view', - views : [[false, 'list']], - type: 'ir.actions.act_window', - target: "current", - limit : 80, - auto_search : true, - flags: { - sidebar: false, - views_switcher: false, - action_buttons:false, - search_view:false, - pager:false, - radio:true - }, - }; - var action_manager = new openerp.web.ActionManager(this); - this.dialog = new openerp.web.Dialog(this,{ - modal: true, - title: 'ViewEditor', - width: 750, - height: 500, - buttons: { - "Create": function(){ - }, - "Edit": function(){ - self.xml_id = 0 ; - self.get_data(); - - }, - "Close": function(){ - $(this).dialog('destroy'); - } - }, - - }); - this.dialog.start(); - this.dialog.open(); - action_manager.appendTo(this.dialog); - action_manager.do_action(action); + View_editor : function(){ + var self = this; + var action = { + name:'ViewEditor', + context:this.session.user_context, + domain: [["model", "=", this.dataset.model]], + res_model : 'ir.ui.view', + views : [[false, 'list']], + type: 'ir.actions.act_window', + target: "current", + limit : 80, + auto_search : true, + flags: { + sidebar: false, + views_switcher: false, + action_buttons:false, + search_view:false, + pager:false, + radio:true + }, + }; + var action_manager = new openerp.web.ActionManager(this); + this.dialog = new openerp.web.Dialog(this,{ + modal: true, + title: 'ViewEditor', + width: 750, + height: 500, + buttons: { + "Create": function(){ + //to do + }, + "Edit": function(){ + self.xml_id = 0 ; + self.get_data(); + }, + "Close": function(){ + $(this).dialog('destroy'); + } + }, + }); + this.dialog.start(); + this.dialog.open(); + action_manager.appendTo(this.dialog); + action_manager.do_action(action); }, check_attr:function(xml,tag,level){ @@ -66,25 +67,25 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ obj.id = this.xml_id++; obj.level = level; var att_list = []; - var name1 = "<" + tag; + var render_name = "<" + tag; var xml_tag = "<" + tag; $(xml).each(function() { att_list = this.attributes; att_list = _.select(att_list, function(attrs){ - xml_tag += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"'; - if (tag != 'button'){ - if(attrs.nodeName == "string" || attrs.nodeName == "name" || attrs.nodeName == "index"){ - name1 += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';} - }else{ - if(attrs.nodeName == "name"){ - name1 += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';} - } - }); - name1+= ">"; - xml_tag+= ">"; - }); + xml_tag += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"'; + if (tag != 'button'){ + if(attrs.nodeName == "string" || attrs.nodeName == "name" || attrs.nodeName == "index"){ + render_name += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';} + }else{ + if(attrs.nodeName == "name"){ + render_name += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';} + } + }); + render_name+= ">"; + xml_tag+= ">"; + }); obj.main_xml = xml_tag; - obj.name = name1; + obj.name = render_name; return obj; }, @@ -93,13 +94,13 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var check_id = parent_list[0]; var p_list = parent_list.slice(1); if(val.child_id.length != 0){ - $.each(val.child_id, function(key,val) { + $.each(val.child_id, function(key,val) { if(val.id==check_id){ if(p_list.length!=0){ self.save_object(val,p_list,child_obj_list); }else{ val.child_id = child_obj_list; - return; + return; } } }); @@ -116,49 +117,121 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var main_object = main_object; var children_list = $(xml).filter(root).children(); var parents = $(children_list[0]).parents().get(); - _.each(children_list, function(child_node){ + _.each(children_list, function(child_node){ var string = self.check_attr(child_node,child_node.tagName.toLowerCase(),parents.length); child_obj_list.push(string); }); + if(children_list.length != 0){ var child_ids = _.map(child_obj_list ,function(num){return num.id;}); parent_child_id.push({'key': parent_id, 'value': child_ids}); var parents = $(children_list[0]).parents().get(); if(parents.length <= parent_list.length){ - parent_list.splice(parents.length-1);} + parent_list.splice(parents.length-1); + } parent_list.push(parent_id); $.each(main_object, function(key,val) { self.save_object(val,parent_list.slice(1),child_obj_list); }); } + for(var i=0;i= prev_tr.attr('level') || prev_tr.length==0){ - last_tr = prev_tr; - break; - } - cur_tr = prev_tr; - } - if(img){ + case "side-add": + break; + case "side-remove": + break; + case "side-edit": + break; + case "side-up": while(1){ - var next_tr = side.next(); + var prev_tr = cur_tr.prev(); + if(level >= prev_tr.attr('level') || prev_tr.length==0){ + last_tr = prev_tr; + break; + } + cur_tr = prev_tr; + } + if(img){ + while(1){ + next_tr = side.next(); if(next_tr.attr('level') <= level || next_tr.length==0){ break; }else{ - list_shift.push(next_tr); - side = next_tr; + list_shift.push(next_tr); + side = next_tr; } + } } - } - if(last_tr.length!=0 && last_tr.attr('level') == level){ - _.each(list_shift,function(rec){ - $(last_tr).before(rec); - }); - } - break; + if(last_tr.length!=0 && last_tr.attr('level') == level){ + _.each(list_shift,function(rec){ + $(last_tr).before(rec); + }); + } + break; case "side-down": - var img = side.find("img[id='parentimg-"+id_tr+"']").attr('src'); - var level = side.attr('level'); - var list_shift =[]; - var last_tr; - var next_tr; - var cur_tr = side; - list_shift.push(side); if(img){ while(1){ - var next_tr = cur_tr.next(); - if(next_tr.attr('level') <= level || next_tr.length==0){ - last_tr = next_tr; - break; - }else{ + next_tr = cur_tr.next(); + if(next_tr.attr('level') <= level || next_tr.length==0){ + last_tr = next_tr; + break; + }else{ list_shift.push(next_tr); cur_tr = next_tr; - } - } - }else{last_tr = cur_tr.next();} + } + } + } + else{ + last_tr = cur_tr.next(); + } if(last_tr.length != 0 && last_tr.attr('level')==level){ var last_tr_id = (last_tr.attr('id')).split('-')[1]; img = last_tr.find("img[id='parentimg-"+last_tr_id+"']").attr('src'); @@ -270,16 +339,16 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ while(1){ var next_tr = last_tr.next(); if (next_tr.attr('level') <= level || next_tr.length==0){break;} - next_tr.hide(); - last_tr = next_tr; + next_tr.hide(); + last_tr = next_tr; } - } + } list_shift.reverse(); _.each(list_shift,function(rec){ - $(last_tr).after(rec); - }); + $(last_tr).after(rec); + }); } - break; + break; } }); }, -- cgit v1.2.3 From 5e07d121a63e959b22e0982a4473e9104c46d211 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Mon, 3 Oct 2011 15:19:31 +0530 Subject: [IMP]hide and show of inherited view and reduce code. bzr revid: vme@tinyerp.com-20111003094931-4jsh8rwmum4ak0z1 --- addons/web/static/src/js/view_editor.js | 67 +++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 29 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 46e83576eb2..2650f966c7e 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -143,7 +143,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ return {"main_object":main_object,"parent_child_id":parent_child_id}; }, - parse_xml :function(arch){ + parse_xml :function(arch,view_id){ var self = this; var root = $(arch).filter(":first")[0]; var tag = root.tagName.toLowerCase(); @@ -156,7 +156,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var view_id =(($("input[name='radiogroup']:checked").parent()).parent()).attr('data-id'); var ve_dataset = new openerp.web.DataSet(this,'ir.ui.view'); ve_dataset.read_ids([parseInt(view_id)],['arch'],function (arch){ - one_object = self.parse_xml(arch[0].arch); + one_object = self.parse_xml(arch[0].arch,view_id); one_object.arch = arch[0].arch; dataset = new openerp.web.DataSetSearch(self,'ir.ui.view', null, null); dataset.read_slice([],{domain : [['inherit_id','=',parseInt(view_id)]]},function (result) { @@ -181,7 +181,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ xpath_list.push(root[0]); } _.each(xpath_list,function(element){ - var xpath_object = self.parse_xml(element); + var xpath_object = self.parse_xml(element,result.id); var expr = $(element).attr('expr'); var position = $(element).attr('position'); part_expr = expr.split("/"); @@ -192,39 +192,47 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } if(part_expr[part_expr.length-1].search("@")!=-1){ var part = part_expr[part_expr.length-1]; - var pp = $.trim(part.replace(/[^a-zA-Z 0-9 _]+/g,' ')).split(" "); + var xpath_list = $.trim(part.replace(/[^a-zA-Z 0-9 _]+/g,' ')).split(" "); + one_object['parent_child_id'].push(xpath_object['parent_child_id'][0]); $.each(one_object['main_object'], function(key,val) { - self.search_object(val,pp,[],position,xpath_object['main_object']); + var id = self.search_object(val,xpath_list,[],position,xpath_object['main_object'],[]); + _.detect(one_object['parent_child_id'],function(res){ + if(res.key==id){ + res.value.push(xpath_object['main_object'][0].id); + } + }); }); } }); }, - search_object:function(val,list,p_list,position,xpath_object){ + search_object:function(val,list,p_list,position,xpath_object,r_list){ var self = this; - var pp = $.trim(val.name.replace(/[^a-zA-Z 0-9 _]+/g,' ')).split(" "); - var insert = _.intersection(pp,list); - if(insert.length == list.length){ - var level = val.level; - $.each(xpath_object, function(key,val) { - self.increase_level(val,level) - }); - var index = _.indexOf(p_list.child_id,val); - if(position == "before"){ - if(index!=0){index--;} - }else if(position == "after"){ - index++; - } - var check = _.indexOf(p_list.child_id,xpath_object[0]); - if(check == -1){ + var return_list = r_list; + var main_list = $.trim(val.name.replace(/[^a-zA-Z 0-9 _]+/g,' ')).split(" "); + var insert = _.intersection(main_list,list); + var check = _.indexOf(p_list.child_id,xpath_object[0]); + if(check == -1){ + if(insert.length == list.length){ + var level = val.level; + $.each(xpath_object, function(key,val) { + self.increase_level(val,level) + }); + var index = _.indexOf(p_list.child_id,val); + if(position == "before"){ + if(index!=0){index--;} + }else if(position == "after"){ + index++; + } p_list.child_id.splice(index,0,xpath_object[0]); - return val.id; + return_list.push(p_list.id); + }else{ + if(val.child_id.length!=0){p_list = val;} + $.each(val.child_id, function(key,val) { + self.search_object(val,list,p_list,position,xpath_object,return_list); + }); } - }else{ - if(val.child_id.length!=0){p_list = val;} - $.each(val.child_id, function(key,val) { - self.search_object(val,list,p_list,position,xpath_object); - }); } + return return_list; }, increase_level :function(val,level){ var self = this; @@ -268,7 +276,8 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ self.on_expand(this); }else{ $(this).attr('src', '/web/static/src/img/collapse.gif'); - self.on_collapse(this,one_object['parent_child_id']); + var id = this.id.split('-')[1]; + self.on_collapse(this,one_object['parent_child_id'],one_object['main_object']); } }); $("img[id^='side-']").click(function() { @@ -363,7 +372,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }else return nxt_tr; } }, - on_collapse: function(self,parent_child_id,id){ + on_collapse: function(self,parent_child_id,id,main_object){ var id = self.id.split('-')[1]; var datas = _.detect(parent_child_id,function(res){ return res.key == id; -- cgit v1.2.3 From 58c3f5c93ebad356f4e5d652cfc001f2177f48b3 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Tue, 4 Oct 2011 09:48:42 +0200 Subject: [imp] be more coherent to send widget as usual as form template data. This can be used in mobile version or other templates that would like to subclass the main FormView class. bzr revid: valentin.lab@kalysto.org-20111004074842-txpar1ph0utc2eqd --- addons/web/static/src/js/view_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 11ebad8d093..d10c6989ff8 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -85,7 +85,7 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView# this.fields_view = data; var frame = new (this.registry.get_object('frame'))(this, this.fields_view.arch); - this.rendered = QWeb.render(this.form_template, { 'frame': frame, 'view': this }); + this.rendered = QWeb.render(this.form_template, { 'frame': frame, 'view': this, 'widget': this }); } this.$element.html(this.rendered); _.each(this.widgets, function(w) { -- cgit v1.2.3 From 59ef6514220f2e1d6a69024688abb0479e914dab Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Tue, 4 Oct 2011 16:15:50 +0530 Subject: [IMP] code refactore in view editor. bzr revid: ysa@tinyerp.com-20111004104550-abxppmgpbbqedv1k --- addons/web/static/src/js/view_editor.js | 440 ++++++++++++++++---------------- 1 file changed, 218 insertions(+), 222 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 2650f966c7e..4bed60d67cd 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -16,52 +16,52 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }, View_editor : function(){ - var self = this; - var action = { - name:'ViewEditor', - context:this.session.user_context, - domain: [["model", "=", this.dataset.model]], - res_model : 'ir.ui.view', - views : [[false, 'list']], - type: 'ir.actions.act_window', - target: "current", - limit : 80, - auto_search : true, - flags: { - sidebar: false, - views_switcher: false, - action_buttons:false, - search_view:false, - pager:false, - radio:true - }, - }; - var action_manager = new openerp.web.ActionManager(this); - this.dialog = new openerp.web.Dialog(this,{ - modal: true, - title: 'ViewEditor', - width: 750, - height: 500, - buttons: { - "Create": function(){ - //to do - }, - "Edit": function(){ - self.xml_id = 0 ; - self.get_data(); + var self = this; + var action = { + name:'ViewEditor', + context:this.session.user_context, + domain: [["model", "=", this.dataset.model]], + res_model : 'ir.ui.view', + views : [[false, 'list']], + type: 'ir.actions.act_window', + target: "current", + limit : 80, + auto_search : true, + flags: { + sidebar: false, + views_switcher: false, + action_buttons:false, + search_view:false, + pager:false, + radio:true + }, + }; + var action_manager = new openerp.web.ActionManager(this); + this.dialog = new openerp.web.Dialog(this,{ + modal: true, + title: 'ViewEditor', + width: 750, + height: 500, + buttons: { + "Create": function(){ + //to do + }, + "Edit": function(){ + self.xml_id = 0 ; + self.get_data(); + }, + "Close": function(){ + $(this).dialog('destroy'); + } }, - "Close": function(){ - $(this).dialog('destroy'); - } - }, - }); - this.dialog.start(); - this.dialog.open(); - action_manager.appendTo(this.dialog); - action_manager.do_action(action); + }); + this.dialog.start(); + this.dialog.open(); + action_manager.appendTo(this.dialog); + action_manager.do_action(action); }, - check_attr:function(xml,tag,level){ + check_attr: function(xml, tag, level) { var obj = new Object(); obj.child_id = []; obj.id = this.xml_id++; @@ -71,45 +71,45 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var xml_tag = "<" + tag; $(xml).each(function() { att_list = this.attributes; - att_list = _.select(att_list, function(attrs){ - xml_tag += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"'; - if (tag != 'button'){ - if(attrs.nodeName == "string" || attrs.nodeName == "name" || attrs.nodeName == "index"){ - render_name += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';} - }else{ - if(attrs.nodeName == "name"){ - render_name += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';} - } - }); - render_name+= ">"; - xml_tag+= ">"; + att_list = _.select(att_list, function(attrs) { + xml_tag += ' ' + attrs.nodeName + '=' + '"' + attrs.nodeValue + '"'; + if (tag != 'button') { + if (attrs.nodeName == "string" || attrs.nodeName == "name" || attrs.nodeName == "index") { + render_name += ' ' + attrs.nodeName + '=' + '"' + attrs.nodeValue + '"'; + } + } else { + if (attrs.nodeName == "name") render_name += ' ' + attrs.nodeName + '=' + '"' + attrs.nodeValue + '"'; + } + }); + render_name += ">"; + xml_tag += ">"; }); obj.main_xml = xml_tag; obj.name = render_name; return obj; }, - save_object : function(val,parent_list,child_obj_list){ + save_object : function(val, parent_list, child_obj_list) { var self = this; var check_id = parent_list[0]; var p_list = parent_list.slice(1); - if(val.child_id.length != 0){ - $.each(val.child_id, function(key,val) { - if(val.id==check_id){ - if(p_list.length!=0){ - self.save_object(val,p_list,child_obj_list); - }else{ + if (val.child_id.length != 0) { + _.each(val.child_id, function(val, key) { + if (val.id==check_id) { + if (p_list.length!=0) { + self.save_object(val, p_list, child_obj_list); + } else { val.child_id = child_obj_list; - return; + return false; } } }); - }else{ + } else { val.child_id = child_obj_list; } }, - children_function : function(xml,root,parent_list,parent_id,main_object,parent_child_id){ + children_function : function(xml, root, parent_list, parent_id, main_object, parent_child_id) { var self = this; var child_obj_list = []; var parent_child_id = parent_child_id; @@ -117,128 +117,125 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var main_object = main_object; var children_list = $(xml).filter(root).children(); var parents = $(children_list[0]).parents().get(); - _.each(children_list, function(child_node){ + _.each(children_list, function (child_node) { var string = self.check_attr(child_node,child_node.tagName.toLowerCase(),parents.length); child_obj_list.push(string); }); - - if(children_list.length != 0){ - var child_ids = _.map(child_obj_list ,function(num){return num.id;}); + if (children_list.length != 0) { + var child_ids = _.map(child_obj_list, function (num) { return num.id; }); parent_child_id.push({'key': parent_id, 'value': child_ids}); var parents = $(children_list[0]).parents().get(); - if(parents.length <= parent_list.length){ - parent_list.splice(parents.length-1); + if (parents.length <= parent_list.length) { + parent_list.splice(parents.length - 1); } parent_list.push(parent_id); - $.each(main_object, function(key,val) { - self.save_object(val,parent_list.slice(1),child_obj_list); + _.each(main_object, function (val, key) { + self.save_object(val, parent_list.slice(1), child_obj_list); }); } - for(var i=0;i= prev_tr.attr('level') || prev_tr.length==0){ - last_tr = prev_tr; - break; + $("img[id^='parentimg-']").click(function() { + if ($(this).attr('src') == '/web/static/src/img/collapse.gif') { + $(this).attr('src', '/web/static/src/img/expand.gif'); + self.on_expand(this); + } else { + $(this).attr('src', '/web/static/src/img/collapse.gif'); + var id = this.id.split('-')[1]; + self.on_collapse(this,one_object['parent_child_id'], one_object['main_object']); + } + }); + $("img[id^='side-']").click(function() { + var side = $(this).closest("tr[id^='viewedit-']") + var id_tr = (side.attr('id')).split('-')[1]; + var img = side.find("img[id='parentimg-"+id_tr+"']").attr('src'); ; + var level = side.attr('level'); + var list_shift =[]; + var last_tr; + var cur_tr = side; + list_shift.push(side); + var next_tr; + switch (this.id) { + case "side-add": + break; + case "side-remove": + break; + case "side-edit": + break; + case "side-up": + while (1) { + var prev_tr = cur_tr.prev(); + if(level >= prev_tr.attr('level') || prev_tr.length == 0) { + last_tr = prev_tr; + break; + } + cur_tr = prev_tr; } - cur_tr = prev_tr; - } - if(img){ - while(1){ - next_tr = side.next(); - if(next_tr.attr('level') <= level || next_tr.length==0){ + if (img) { + while (1) { + next_tr = side.next(); + if (next_tr.attr('level') <= level || next_tr.length == 0) { + break; + } else { + list_shift.push(next_tr); + side = next_tr; + } + } + } + if (last_tr.length != 0 && last_tr.attr('level') == level) { + _.each(list_shift, function(rec) { + $(last_tr).before(rec); + }); + } + break; + case "side-down": + if (img) { + while (1) { + next_tr = cur_tr.next(); + if (next_tr.attr('level') <= level || next_tr.length == 0) { + last_tr = next_tr; break; - }else{ + } else { list_shift.push(next_tr); - side = next_tr; - } - } + cur_tr = next_tr; + } + } } - if(last_tr.length!=0 && last_tr.attr('level') == level){ - _.each(list_shift,function(rec){ - $(last_tr).before(rec); - }); + else { + last_tr = cur_tr.next(); } - break; - case "side-down": - if(img){ - while(1){ - next_tr = cur_tr.next(); - if(next_tr.attr('level') <= level || next_tr.length==0){ - last_tr = next_tr; - break; - }else{ - list_shift.push(next_tr); - cur_tr = next_tr; - } - } - } - else{ - last_tr = cur_tr.next(); - } - if(last_tr.length != 0 && last_tr.attr('level')==level){ - var last_tr_id = (last_tr.attr('id')).split('-')[1]; - img = last_tr.find("img[id='parentimg-"+last_tr_id+"']").attr('src'); - if(img){ - $("img[id='parentimg-"+last_tr_id+"']").attr('src', '/web/static/src/img/expand.gif'); - while(1){ - var next_tr = last_tr.next(); - if (next_tr.attr('level') <= level || next_tr.length==0){break;} - next_tr.hide(); - last_tr = next_tr; + if (last_tr.length != 0 && last_tr.attr('level') == level) { + var last_tr_id = (last_tr.attr('id')).split('-')[1]; + img = last_tr.find("img[id='parentimg-" + last_tr_id + "']").attr('src'); + if (img) { + $("img[id='parentimg-" + last_tr_id + "']").attr('src', '/web/static/src/img/expand.gif'); + while (1) { + var next_tr = last_tr.next(); + if (next_tr.attr('level') <= level || next_tr.length == 0) break; + next_tr.hide(); + last_tr = next_tr; + } } + list_shift.reverse(); + _.each(list_shift, function(rec) { + $(last_tr).after(rec); + }); } - list_shift.reverse(); - _.each(list_shift,function(rec){ - $(last_tr).after(rec); - }); + break; } - break; - } - }); + }); }, on_expand: function(self){ var level = $(self).closest("tr[id^='viewedit-']").attr('level'); var cur_tr = $(self).closest("tr[id^='viewedit-']"); - while (1){ + while (1) { var nxt_tr = cur_tr.next(); - if (nxt_tr.attr('level') > level){ + if (nxt_tr.attr('level') > level) { cur_tr = nxt_tr; nxt_tr.hide(); - }else return nxt_tr; + } else return nxt_tr; } }, - on_collapse: function(self,parent_child_id,id,main_object){ + on_collapse: function(self, parent_child_id, id, main_object) { var id = self.id.split('-')[1]; - var datas = _.detect(parent_child_id,function(res){ + var datas = _.detect(parent_child_id,function(res) { return res.key == id; }); - _.each(datas.value,function(rec){ + _.each(datas.value, function(rec) { var tr = $("tr[id='viewedit-"+rec+"']"); tr.find("img[id='parentimg-"+rec+"']").attr('src','/web/static/src/img/expand.gif'); tr.show(); -- cgit v1.2.3 From 5bffa6a13542874ca61a2b1633f7ce0e57de845a Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Wed, 5 Oct 2011 16:51:27 +0530 Subject: [IMP]reduce code and implement for field position. bzr revid: vme@tinyerp.com-20111005112127-wihc38e3a5iipea7 --- addons/web/static/src/js/view_editor.js | 190 ++++++++++++++++---------------- 1 file changed, 98 insertions(+), 92 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 2650f966c7e..1e5aef495c8 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -1,7 +1,6 @@ openerp.web.view_editor = function(openerp) { var QWeb = openerp.web.qweb; openerp.web.ViewEditor = openerp.web.Widget.extend({ - init: function(parent, element_id, dataset, view, options) { this._super(parent); this.element_id = element_id @@ -61,44 +60,38 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ action_manager.do_action(action); }, - check_attr:function(xml,tag,level){ + check_attr: function(xml ,tag,level) { var obj = new Object(); obj.child_id = []; obj.id = this.xml_id++; - obj.level = level; - var att_list = []; + obj.level = level+1; var render_name = "<" + tag; - var xml_tag = "<" + tag; $(xml).each(function() { - att_list = this.attributes; - att_list = _.select(att_list, function(attrs){ - xml_tag += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"'; - if (tag != 'button'){ - if(attrs.nodeName == "string" || attrs.nodeName == "name" || attrs.nodeName == "index"){ + _.each(this.attributes, function(attrs){ + if (tag != 'button') { + if (attrs.nodeName == "string" || attrs.nodeName == "name" || attrs.nodeName == "index") { render_name += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';} - }else{ - if(attrs.nodeName == "name"){ + } else { + if (attrs.nodeName == "name") { render_name += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';} } }); render_name+= ">"; - xml_tag+= ">"; }); - obj.main_xml = xml_tag; obj.name = render_name; return obj; }, - save_object : function(val,parent_list,child_obj_list){ + save_object: function(val, parent_list, child_obj_list){ var self = this; var check_id = parent_list[0]; var p_list = parent_list.slice(1); - if(val.child_id.length != 0){ - $.each(val.child_id, function(key,val) { - if(val.id==check_id){ - if(p_list.length!=0){ - self.save_object(val,p_list,child_obj_list); - }else{ + if (val.child_id.length != 0) { + $.each(val.child_id, function(key, val) { + if (val.id == check_id) { + if (p_list.length!=0) { + self.save_object(val, p_list, child_obj_list); + } else { val.child_id = child_obj_list; return; } @@ -109,56 +102,58 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }, - children_function : function(xml,root,parent_list,parent_id,main_object,parent_child_id){ + children_function: function(xml, root, parent_list, parent_id, main_object){ var self = this; var child_obj_list = []; - var parent_child_id = parent_child_id; - var parent_list = parent_list; - var main_object = main_object; var children_list = $(xml).filter(root).children(); var parents = $(children_list[0]).parents().get(); _.each(children_list, function(child_node){ var string = self.check_attr(child_node,child_node.tagName.toLowerCase(),parents.length); child_obj_list.push(string); }); - - if(children_list.length != 0){ - var child_ids = _.map(child_obj_list ,function(num){return num.id;}); - parent_child_id.push({'key': parent_id, 'value': child_ids}); + if (children_list.length != 0) { var parents = $(children_list[0]).parents().get(); - if(parents.length <= parent_list.length){ + if (parents.length <= parent_list.length) { parent_list.splice(parents.length-1); } parent_list.push(parent_id); - $.each(main_object, function(key,val) { - self.save_object(val,parent_list.slice(1),child_obj_list); + $.each(main_object, function(key, val) { + self.save_object(val, parent_list.slice(1), child_obj_list); }); } - - for(var i=0;i" + var root_object = self.check_attr(root,tag,0); + f_obj = self.children_function(arch, tag, [], this.xml_id-1, [root_object], []) + obj.child_id.push(f_obj[0]); + f_obj.pop(); + f_obj.push(obj); + return f_obj; }, - get_data : function(){ + get_data: function() { var self = this; var view_id =(($("input[name='radiogroup']:checked").parent()).parent()).attr('data-id'); var ve_dataset = new openerp.web.DataSet(this,'ir.ui.view'); - ve_dataset.read_ids([parseInt(view_id)],['arch'],function (arch){ + ve_dataset.read_ids([parseInt(view_id)], ['arch'], function (arch) { one_object = self.parse_xml(arch[0].arch,view_id); one_object.arch = arch[0].arch; - dataset = new openerp.web.DataSetSearch(self,'ir.ui.view', null, null); + dataset = new openerp.web.DataSetSearch(self, 'ir.ui.view', null, null); dataset.read_slice([],{domain : [['inherit_id','=',parseInt(view_id)]]},function (result) { _.each(result,function(res){ self.inherit_view(one_object,res); @@ -167,80 +162,91 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }); }); }, - inherit_view : function(one_object,result){ + + inherit_view: function(one_object, result){ var self = this; var root = $(result.arch).filter('*'); - var xpath_list = []; - var part_expr = []; - var position ; - if(root[0].tagName.toLowerCase() == "data"){ - _.each($(root).find('xpath'),function(xpath){ - xpath_list.push(xpath); - }); - } else if(root[0].tagName.toLowerCase() == "xpath"){ - xpath_list.push(root[0]); + var xml_list = []; + var xpath_object ; + if (root[0].tagName.toLowerCase() == "data") { + xml_list = $(root[0]).children(); + } else { + xml_list.push(root[0]); } - _.each(xpath_list,function(element){ - var xpath_object = self.parse_xml(element,result.id); - var expr = $(element).attr('expr'); - var position = $(element).attr('position'); - part_expr = expr.split("/"); - if(part_expr[0]=="" && part_expr[1]==""){ - part_expr = part_expr.splice(2); - }else if(part_expr[0]==""){ - part_expr = part_expr.splice(1); - } - if(part_expr[part_expr.length-1].search("@")!=-1){ - var part = part_expr[part_expr.length-1]; - var xpath_list = $.trim(part.replace(/[^a-zA-Z 0-9 _]+/g,' ')).split(" "); - one_object['parent_child_id'].push(xpath_object['parent_child_id'][0]); - $.each(one_object['main_object'], function(key,val) { - var id = self.search_object(val,xpath_list,[],position,xpath_object['main_object'],[]); - _.detect(one_object['parent_child_id'],function(res){ - if(res.key==id){ - res.value.push(xpath_object['main_object'][0].id); - } - }); - }); + _.each(xml_list , function(xml){ + var parent_id; + var check_list = []; + var position = $(xml).attr('position'); + if (xml.tagName.toLowerCase() == "xpath") { + var part_expr = _.without($(xml).attr('expr').split("/"),"");; + xpath_object = self.parse_xml(xml,result.id); + if (part_expr[part_expr.length-1].search("@")!=-1) { + check_list = $.trim(part_expr[part_expr.length-1].replace(/[^a-zA-Z 0-9 _]+/g,' ')).split(" "); + + }else{ + //search full path... + } + } else { + var xml_child = $(xml).children(); + check_list.push(xml.tagName.toLowerCase()); + if ($(root[0]).attr('name')){ + check_list.push($(root[0]).attr('name')); + check_list.push("name"); + } + xpath_object = self.parse_xml(xml,result.id); } + $.each(function(){ + }); + self.search_object(val,check_list,[],position,xpath_object['main_object'],[]); }); }, - search_object:function(val,list,p_list,position,xpath_object,r_list){ + search_object: function(val ,list ,p_list ,position, xpath_object){ var self = this; - var return_list = r_list; var main_list = $.trim(val.name.replace(/[^a-zA-Z 0-9 _]+/g,' ')).split(" "); var insert = _.intersection(main_list,list); var check = _.indexOf(p_list.child_id,xpath_object[0]); if(check == -1){ if(insert.length == list.length){ - var level = val.level; - $.each(xpath_object, function(key,val) { - self.increase_level(val,level) + var level = val.level; + $.each(xpath_object, function(key, val) { + self.increase_level(val, level) }); var index = _.indexOf(p_list.child_id,val); - if(position == "before"){ - if(index!=0){index--;} - }else if(position == "after"){ - index++; + switch (position) + { + case "before": + if (index != 0) { index--; } + p_list.child_id.splice(index,0,xpath_object[0]); + break; + case "after": + index++; + p_list.child_id.splice(index,0,xpath_object[0]); + break; + case "inside": + val.child_id.push(xpath_object[0]); + break; + case "replace": + break; } - p_list.child_id.splice(index,0,xpath_object[0]); - return_list.push(p_list.id); + }else{ - if(val.child_id.length!=0){p_list = val;} - $.each(val.child_id, function(key,val) { - self.search_object(val,list,p_list,position,xpath_object,return_list); + if ( val.child_id.length != 0) { p_list = val; } + $.each(val.child_id, function(key, val) { + self.search_object(val, list, p_list, position, xpath_object); }); } } return return_list; }, - increase_level :function(val,level){ + + increase_level :function(val, level){ var self = this; val.level = level; - $.each(val.child_id, function(key,val) { + $.each(val.child_id, function(key, val) { self.increase_level(val,level+1); }); }, + edit_view : function(one_object){ var self = this; this.dialog = new openerp.web.Dialog(this,{ @@ -262,7 +268,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }); this.dialog.start().open(); this.dialog.$element.html(QWeb.render('view_editor', { - 'data': one_object['main_object'], + 'data': one_object, })); $("tr[id^='viewedit-']").click(function() { -- cgit v1.2.3 From c36d4ddea4732e8d936fcf3805bee72b8d08cf99 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Fri, 7 Oct 2011 11:46:04 +0530 Subject: [IMP]create parent-child list after inherit view. bzr revid: vme@tinyerp.com-20111007061604-zv97xy6byxmm5qhv --- addons/web/static/src/js/view_editor.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 1e5aef495c8..dc2d1489f80 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -60,7 +60,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ action_manager.do_action(action); }, - check_attr: function(xml ,tag,level) { + check_attr: function(xml ,tag, level) { var obj = new Object(); obj.child_id = []; obj.id = this.xml_id++; @@ -82,14 +82,14 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ return obj; }, - save_object: function(val, parent_list, child_obj_list){ + save_object: function(val, parent_list, child_obj_list) { var self = this; var check_id = parent_list[0]; var p_list = parent_list.slice(1); if (val.child_id.length != 0) { $.each(val.child_id, function(key, val) { if (val.id == check_id) { - if (p_list.length!=0) { + if (p_list.length != 0) { self.save_object(val, p_list, child_obj_list); } else { val.child_id = child_obj_list; @@ -152,17 +152,24 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var ve_dataset = new openerp.web.DataSet(this,'ir.ui.view'); ve_dataset.read_ids([parseInt(view_id)], ['arch'], function (arch) { one_object = self.parse_xml(arch[0].arch,view_id); - one_object.arch = arch[0].arch; dataset = new openerp.web.DataSetSearch(self, 'ir.ui.view', null, null); dataset.read_slice([],{domain : [['inherit_id','=',parseInt(view_id)]]},function (result) { - _.each(result,function(res){ - self.inherit_view(one_object,res); - }); - return self.edit_view(one_object); + + return self.edit_view({"main_object": one_object, + "parent_child_id": self.parent_child_list(one_object, [])}); }); }); }, - + parent_child_list: function(one_object, p_list) { + var self = this; + _.each(one_object , function(element){ + if(element.child_id.length != 0){ + p_list.push({"key":element.id,"value":_.pluck(element.child_id, 'id')}); + self.parent_child_list(element.child_id,p_list); + } + }); + return p_list; + }, inherit_view: function(one_object, result){ var self = this; var root = $(result.arch).filter('*'); @@ -249,6 +256,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ edit_view : function(one_object){ var self = this; + console.log("++++++++++++++++++++++",one_object); this.dialog = new openerp.web.Dialog(this,{ modal: true, title: 'Edit Xml', @@ -268,7 +276,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }); this.dialog.start().open(); this.dialog.$element.html(QWeb.render('view_editor', { - 'data': one_object, + 'data': one_object['main_object'], })); $("tr[id^='viewedit-']").click(function() { -- cgit v1.2.3 From 548b641acc38e822c60960c67fdf1cda003d8693 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Fri, 7 Oct 2011 13:07:29 +0530 Subject: [IMP]implement two type of xpath and fix level convert into integer. bzr revid: vme@tinyerp.com-20111007073729-8e0prjh64cjwp3vj --- addons/web/static/src/js/view_editor.js | 50 +++++++++++++-------------------- 1 file changed, 19 insertions(+), 31 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index dc2d1489f80..32f25a01471 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -154,18 +154,21 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ one_object = self.parse_xml(arch[0].arch,view_id); dataset = new openerp.web.DataSetSearch(self, 'ir.ui.view', null, null); dataset.read_slice([],{domain : [['inherit_id','=',parseInt(view_id)]]},function (result) { - - return self.edit_view({"main_object": one_object, + _.each(result, function(res) { + self.inherit_view(one_object, res); + }); + return self.edit_view({"main_object": one_object, "parent_child_id": self.parent_child_list(one_object, [])}); }); }); }, + parent_child_list: function(one_object, p_list) { var self = this; _.each(one_object , function(element){ if(element.child_id.length != 0){ p_list.push({"key":element.id,"value":_.pluck(element.child_id, 'id')}); - self.parent_child_list(element.child_id,p_list); + self.parent_child_list(element.child_id, p_list); } }); return p_list; @@ -202,48 +205,34 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } xpath_object = self.parse_xml(xml,result.id); } - $.each(function(){ + $.each(one_object, function(key, val){ + self.search_object(val, check_list, xpath_object, []); }); - self.search_object(val,check_list,[],position,xpath_object['main_object'],[]); + }); }, - search_object: function(val ,list ,p_list ,position, xpath_object){ + + search_object: function(val ,list , xpath_object, p_list){ var self = this; var main_list = $.trim(val.name.replace(/[^a-zA-Z 0-9 _]+/g,' ')).split(" "); var insert = _.intersection(main_list,list); var check = _.indexOf(p_list.child_id,xpath_object[0]); if(check == -1){ if(insert.length == list.length){ - var level = val.level; + var level = val.level+1; $.each(xpath_object, function(key, val) { self.increase_level(val, level) }); - var index = _.indexOf(p_list.child_id,val); - switch (position) - { - case "before": - if (index != 0) { index--; } - p_list.child_id.splice(index,0,xpath_object[0]); - break; - case "after": - index++; - p_list.child_id.splice(index,0,xpath_object[0]); - break; - case "inside": - val.child_id.push(xpath_object[0]); - break; - case "replace": - break; - } - + val.child_id.push(xpath_object[0]); + return; }else{ if ( val.child_id.length != 0) { p_list = val; } $.each(val.child_id, function(key, val) { - self.search_object(val, list, p_list, position, xpath_object); + self.search_object(val, list, xpath_object, p_list); }); } } - return return_list; + }, increase_level :function(val, level){ @@ -256,7 +245,6 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ edit_view : function(one_object){ var self = this; - console.log("++++++++++++++++++++++",one_object); this.dialog = new openerp.web.Dialog(this,{ modal: true, title: 'Edit Xml', @@ -376,18 +364,18 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }); }, on_expand: function(self){ - var level = $(self).closest("tr[id^='viewedit-']").attr('level'); + var level = parseInt($(self).closest("tr[id^='viewedit-']").attr('level')); var cur_tr = $(self).closest("tr[id^='viewedit-']"); while (1){ var nxt_tr = cur_tr.next(); - if (nxt_tr.attr('level') > level){ + if (parseInt(nxt_tr.attr('level')) > level){ cur_tr = nxt_tr; nxt_tr.hide(); }else return nxt_tr; } }, on_collapse: function(self,parent_child_id,id,main_object){ - var id = self.id.split('-')[1]; + var id = parseInt(self.id.split('-')[1]); var datas = _.detect(parent_child_id,function(res){ return res.key == id; }); -- cgit v1.2.3 From e51b619b1dfe8c3fc1ba9fd33e5a3c05c88de1df Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Mon, 10 Oct 2011 18:14:52 +0530 Subject: [IMP]all type of xpath inherit completed bzr revid: vme@tinyerp.com-20111010124452-okzzpj9kyy9u51q3 --- addons/web/static/src/js/view_editor.js | 105 ++++++++++++++++++++++---------- 1 file changed, 74 insertions(+), 31 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 32f25a01471..fb2e13fed74 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -65,7 +65,10 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ obj.child_id = []; obj.id = this.xml_id++; obj.level = level+1; + obj.att_list = []; var render_name = "<" + tag; + obj.att_list = []; + obj.att_list.push(tag); $(xml).each(function() { _.each(this.attributes, function(attrs){ if (tag != 'button') { @@ -75,7 +78,12 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ if (attrs.nodeName == "name") { render_name += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';} } + if (attrs.nodeName != "position") { + obj.att_list.push([attrs.nodeName,attrs.nodeValue]); + } + }); + render_name+= ">"; }); obj.name = render_name; @@ -186,55 +194,90 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ _.each(xml_list , function(xml){ var parent_id; var check_list = []; - var position = $(xml).attr('position'); - if (xml.tagName.toLowerCase() == "xpath") { - var part_expr = _.without($(xml).attr('expr').split("/"),"");; - xpath_object = self.parse_xml(xml,result.id); - if (part_expr[part_expr.length-1].search("@")!=-1) { - check_list = $.trim(part_expr[part_expr.length-1].replace(/[^a-zA-Z 0-9 _]+/g,' ')).split(" "); - - }else{ - //search full path... - } + if (xml.tagName.toLowerCase() == "xpath" && ($(xml).attr('expr')).indexOf("//") == -1) { + var part_expr = _.without($(xml).attr('expr').split("/"),""); + xpath_object = self.parse_xml(xml,result.id); + self.full_path_search(part_expr ,one_object[0].child_id ,xpath_object,one_object); } else { - var xml_child = $(xml).children(); - check_list.push(xml.tagName.toLowerCase()); - if ($(root[0]).attr('name')){ - check_list.push($(root[0]).attr('name')); - check_list.push("name"); - } xpath_object = self.parse_xml(xml,result.id); + if($(xml).attr('expr')){ + check_list = $.trim(($(xml).attr('expr')).replace(/[^a-zA-Z 0-9 _]+/g,' ')).split(" "); + }else{ + check_list = _.flatten(xpath_object[0].child_id[0].att_list); + } + $.each(one_object, function(key, val){ + self.search_object(val, check_list, xpath_object); + }); } - $.each(one_object, function(key, val){ - self.search_object(val, check_list, xpath_object, []); - }); - }); }, + full_path_search: function(part_expr ,val ,xpath_object, one_object) { + var self = this; + var obj; + var check_list = _.without($.trim(part_expr[0].replace(/[^a-zA-Z 0-9 _]+/g,'!')).split("!"),""); + if(check_list.length == 2){ + var int_val = parseInt(check_list[1]); + if(int_val){ + var list_1 = _.select(val,function(element){ + var main_list = _.flatten(element.att_list); + return _.include(main_list, check_list[0]); + }); + obj = val[_.indexOf(val,list_1[int_val-1])]; + }else{ + obj = _.detect(val,function(element){ + var main_list = _.flatten(element.att_list); + return _.include(main_list, check_list[0]); + }); + } + }else{ + obj = _.detect(val,function(element){ + var main_list = _.flatten(element.att_list); + check_list = _.uniq(check_list); + var insert = _.intersection(main_list,check_list); + if(insert.length == check_list.length ){return element;} + }); + } + part_expr.shift(); + if (part_expr.length !=0){ + self.full_path_search(part_expr ,obj.child_id ,xpath_object,one_object); + }else{ + if(obj){ + var level = obj.level+1; + $.each(xpath_object, function(key, val) { + self.increase_level(val, level) + }); + obj.child_id.push(xpath_object[0]); + }else{ + $.each(one_object, function(key, val){ + self.search_object(val, check_list, xpath_object); + }); + } + } + return obj; + }, - search_object: function(val ,list , xpath_object, p_list){ + search_object: function(val ,list , xpath_object){ var self = this; - var main_list = $.trim(val.name.replace(/[^a-zA-Z 0-9 _]+/g,' ')).split(" "); - var insert = _.intersection(main_list,list); - var check = _.indexOf(p_list.child_id,xpath_object[0]); - if(check == -1){ - if(insert.length == list.length){ + if(xpath_object.length != 0){ + var main_list = _.flatten(val.att_list); + list = _.uniq(list); + var insert = _.intersection(main_list,list); + if(insert.length == list.length ){ var level = val.level+1; $.each(xpath_object, function(key, val) { self.increase_level(val, level) - }); + }); val.child_id.push(xpath_object[0]); + xpath_object.pop(); return; }else{ - if ( val.child_id.length != 0) { p_list = val; } $.each(val.child_id, function(key, val) { - self.search_object(val, list, xpath_object, p_list); + self.search_object(val, list, xpath_object); }); } } - }, - + increase_level :function(val, level){ var self = this; val.level = level; -- cgit v1.2.3 From 081cca81003c596e8fe5cd845cf134cbf7f9b92c Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Mon, 10 Oct 2011 18:40:50 +0530 Subject: [IMP] spaces done between parameter. bzr revid: vme@tinyerp.com-20111010131050-qmhx05s9qavs73rp --- addons/web/static/src/js/view_editor.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index fb2e13fed74..eecf54253ea 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -73,13 +73,13 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ _.each(this.attributes, function(attrs){ if (tag != 'button') { if (attrs.nodeName == "string" || attrs.nodeName == "name" || attrs.nodeName == "index") { - render_name += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';} + render_name += ' ' + attrs.nodeName + '=' + '"' + attrs.nodeValue + '"' ; } } else { if (attrs.nodeName == "name") { - render_name += ' ' +attrs.nodeName+'='+'"'+attrs.nodeValue+'"';} + render_name += ' ' + attrs.nodeName + '=' + '"' + attrs.nodeValue + '"'; } } if (attrs.nodeName != "position") { - obj.att_list.push([attrs.nodeName,attrs.nodeValue]); + obj.att_list.push( [attrs.nodeName,attrs.nodeValue] ); } }); @@ -115,7 +115,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var child_obj_list = []; var children_list = $(xml).filter(root).children(); var parents = $(children_list[0]).parents().get(); - _.each(children_list, function(child_node){ + _.each(children_list, function( child_node ){ var string = self.check_attr(child_node,child_node.tagName.toLowerCase(),parents.length); child_obj_list.push(string); }); @@ -137,7 +137,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ return main_object; }, - parse_xml: function(arch,view_id) { + parse_xml: function(arch, view_id) { var self = this; var root = $(arch).filter(":first")[0]; var tag = root.tagName.toLowerCase(); @@ -148,7 +148,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ obj.name = "" var root_object = self.check_attr(root,tag,0); f_obj = self.children_function(arch, tag, [], this.xml_id-1, [root_object], []) - obj.child_id.push(f_obj[0]); + obj.child_id.push( f_obj[0] ); f_obj.pop(); f_obj.push(obj); return f_obj; -- cgit v1.2.3 From 22099a2d9e5f0f201cb1e64304038478f60be495 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Tue, 11 Oct 2011 19:04:56 +0530 Subject: [IMP]fix review's issue and try to convert single method for inherited view search bzr revid: vme@tinyerp.com-20111011133456-vq1i5cv2pmbkhixz --- addons/web/static/src/js/view_editor.js | 64 +++++++++++++++++++-------------- addons/web/static/src/xml/base.xml | 22 +++++++----- 2 files changed, 50 insertions(+), 36 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 4ab03a88a0d..530b06bdb28 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -145,6 +145,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ obj.child_id = []; obj.id = this.xml_id++; obj.level = 0; + obj.att_list = []; obj.name = "" var root_object = self.check_attr(root,tag,0); f_obj = self.children_function(arch, tag, [], this.xml_id-1, [root_object], []) @@ -198,7 +199,10 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ if (xml.tagName.toLowerCase() == "xpath" && ($(xml).attr('expr')).indexOf("//") == -1) { var part_expr = _.without($(xml).attr('expr').split("/"),""); xpath_object = self.parse_xml(xml,result.id); - self.full_path_search(part_expr ,one_object[0].child_id ,xpath_object,one_object); + _.each(part_expr,function(part){ + check_list.push(_.without($.trim(part.replace(/[^a-zA-Z 0-9 _]+/g,'!')).split("!"),"")); + }); + self.full_path_search(check_list ,one_object[0].child_id ,xpath_object); } else { xpath_object = self.parse_xml(xml,result.id); if($(xml).attr('expr')){ @@ -206,55 +210,61 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }else{ check_list = _.flatten(xpath_object[0].child_id[0].att_list); } - $.each(one_object, function(key, val){ - self.search_object(val, check_list, xpath_object); - }); + + self.full_path_search(check_list ,one_object ,xpath_object); + } }); }, - full_path_search: function(part_expr ,val ,xpath_object, one_object) { + full_path_search: function(check_list ,val ,xpath_object) { var self = this; var obj; - var check_list = _.without($.trim(part_expr[0].replace(/[^a-zA-Z 0-9 _]+/g,'!')).split("!"),""); - if(check_list.length == 2){ - var int_val = parseInt(check_list[1]); + if(xpath_object.length!=0){ + var check = check_list[0]; + + if(check.length == 2){ + var int_val = parseInt(check[1]); if(int_val){ var list_1 = _.select(val,function(element){ var main_list = _.flatten(element.att_list); - return _.include(main_list, check_list[0]); + return _.include(main_list, check[0]); }); obj = val[_.indexOf(val,list_1[int_val-1])]; }else{ obj = _.detect(val,function(element){ var main_list = _.flatten(element.att_list); - return _.include(main_list, check_list[0]); + return _.include(main_list, check[0]); }); } }else{ obj = _.detect(val,function(element){ var main_list = _.flatten(element.att_list); - check_list = _.uniq(check_list); - var insert = _.intersection(main_list,check_list); - if(insert.length == check_list.length ){return element;} + check = _.uniq(check); + var insert = _.intersection(main_list,check); + if(insert.length == check.length ){return element;} }); } - part_expr.shift(); - if (part_expr.length !=0){ - self.full_path_search(part_expr ,obj.child_id ,xpath_object,one_object); - }else{ - if(obj){ - var level = obj.level+1; - $.each(xpath_object, function(key, val) { - self.increase_level(val, level) - }); - obj.child_id.push(xpath_object[0]); + if(obj){ + check_list.shift(); + if (check_list.length !=0){ + self.full_path_search(check_list ,obj.child_id ,xpath_object); }else{ - $.each(one_object, function(key, val){ - self.search_object(val, check_list, xpath_object); - }); + + var level = obj.level+1; + $.each(xpath_object, function(key, val) { + self.increase_level(val, level) + }); + obj.child_id.push(xpath_object[0]); + xpath_object.pop(); + console.log("check",check,obj) } + return obj; + }else{ + _.each(val,function(element){ + self.full_path_search(check_list ,element.child_id ,xpath_object); + }); } - return obj; + } }, search_object : function(val ,list , xpath_object){ diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index d0fbe16c6df..d8ec6f30daf 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1302,20 +1302,24 @@ - - - - -
- + + + - + + - + + - + +
-- cgit v1.2.3 From d071a3b2663ea8df0a43e0860ecea188f9b70055 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Wed, 12 Oct 2011 15:58:01 +0530 Subject: [IMP]optimize code and fix product inherited view. bzr revid: vme@tinyerp.com-20111012102801-i7v1aqux18gh56a3 --- addons/web/static/src/js/view_editor.js | 135 ++++++++++++-------------------- addons/web/static/src/js/view_form.js | 7 +- 2 files changed, 57 insertions(+), 85 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 530b06bdb28..b95672ecfd8 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -90,7 +90,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ return obj; }, - save_object : function(val, parent_list, child_obj_list) { + save_object: function(val, parent_list, child_obj_list) { var self = this; var check_id = parent_list[0]; var p_list = parent_list.slice(1); @@ -110,27 +110,23 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }, - children_function: function(xml, root, parent_list, parent_id, main_object){ + xml_node_create: function(xml, root, parent_list, parent_id, main_object){ var self = this; var child_obj_list = []; var children_list = $(xml).filter(root).children(); var parents = $(children_list[0]).parents().get(); _.each(children_list, function (child_node) { - var string = self.check_attr(child_node,child_node.tagName.toLowerCase(),parents.length); - child_obj_list.push(string); + child_obj_list.push(self.check_attr(child_node,child_node.tagName.toLowerCase(),parents.length)); }); if (children_list.length != 0) { - var parents = $(children_list[0]).parents().get(); if (parents.length <= parent_list.length) { parent_list.splice(parents.length - 1); } parent_list.push(parent_id); - _.each(main_object, function (val, key) { - self.save_object(val, parent_list.slice(1), child_obj_list); - }); + self.save_object(main_object[0], parent_list.slice(1), child_obj_list); } - for (var i=0;i" + var obj ={'child_id':[],'id':this.xml_id++,'level':0,'att_list':[],'name':""}; var root_object = self.check_attr(root,tag,0); - f_obj = self.children_function(arch, tag, [], this.xml_id-1, [root_object], []) - obj.child_id.push( f_obj[0] ); - f_obj.pop(); - f_obj.push(obj); - return f_obj; + obj.child_id = self.xml_node_create(arch, tag, [], this.xml_id-1, [root_object], []) + return [obj]; }, get_data: function() { @@ -186,8 +174,6 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var self = this; var root = $(result.arch).filter('*'); var xml_list = []; - var xpath_object ; - var part_expr = []; if (root[0].tagName.toLowerCase() == "data") { xml_list = $(root[0]).children(); } else { @@ -196,94 +182,75 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ _.each(xml_list , function(xml){ var parent_id; var check_list = []; + var xpath_object = self.parse_xml(xml,result.id); if (xml.tagName.toLowerCase() == "xpath" && ($(xml).attr('expr')).indexOf("//") == -1) { var part_expr = _.without($(xml).attr('expr').split("/"),""); - xpath_object = self.parse_xml(xml,result.id); _.each(part_expr,function(part){ check_list.push(_.without($.trim(part.replace(/[^a-zA-Z 0-9 _]+/g,'!')).split("!"),"")); }); - self.full_path_search(check_list ,one_object[0].child_id ,xpath_object); } else { - xpath_object = self.parse_xml(xml,result.id); if($(xml).attr('expr')){ - check_list = $.trim(($(xml).attr('expr')).replace(/[^a-zA-Z 0-9 _]+/g,' ')).split(" "); + check_list = [$.trim(($(xml).attr('expr')).replace(/[^a-zA-Z 0-9 _]+/g,' ')).split(" ")]; }else{ - check_list = _.flatten(xpath_object[0].child_id[0].att_list); + check_list = [_.flatten(xpath_object[0].child_id[0].att_list)]; } - - self.full_path_search(check_list ,one_object ,xpath_object); - } + self.full_path_search(check_list ,one_object ,xpath_object); }); }, full_path_search: function(check_list ,val ,xpath_object) { var self = this; - var obj; if(xpath_object.length!=0){ - var check = check_list[0]; - - if(check.length == 2){ - var int_val = parseInt(check[1]); - if(int_val){ - var list_1 = _.select(val,function(element){ + var check = check_list[0]; + var obj; + if(check.length == 2){ + if(parseInt(check[1])){ + var list_1 = _.select(val,function(element){ + var main_list = _.flatten(element.att_list); + return _.include(main_list, check[0]); + }); + obj = val[_.indexOf(val,list_1[parseInt(check[1])-1])]; + } else { + obj = _.detect(val, function(element){ + var main_list = _.flatten(element.att_list); + return _.include(main_list, check[0]); + }); + } + }else if(check.length == 3){ + obj = _.detect(val,function(element){ var main_list = _.flatten(element.att_list); - return _.include(main_list, check[0]); + check = _.uniq(check); + var insert = _.intersection(main_list,check); + if(insert.length == check.length ){return element;} }); - obj = val[_.indexOf(val,list_1[int_val-1])]; }else{ - obj = _.detect(val,function(element){ + var list_1 = _.select(val,function(element){ var main_list = _.flatten(element.att_list); return _.include(main_list, check[0]); }); + if(list_1 != 0){ + if(check_list.length == 1){ + obj = list_1[0]; + }else{ + check_list.shift(); + } + } } - }else{ - obj = _.detect(val,function(element){ - var main_list = _.flatten(element.att_list); - check = _.uniq(check); - var insert = _.intersection(main_list,check); - if(insert.length == check.length ){return element;} - }); - } - if(obj){ - check_list.shift(); - if (check_list.length !=0){ - self.full_path_search(check_list ,obj.child_id ,xpath_object); - }else{ - + if(obj){ + check_list.shift(); + if (check_list.length !=0){ + self.full_path_search(check_list ,obj.child_id ,xpath_object); + }else{ var level = obj.level+1; - $.each(xpath_object, function(key, val) { - self.increase_level(val, level) - }); + self.increase_level(xpath_object[0], level) obj.child_id.push(xpath_object[0]); xpath_object.pop(); - console.log("check",check,obj) + return; + } } - return obj; - }else{ - _.each(val,function(element){ + else { + _.each(val,function(element){ self.full_path_search(check_list ,element.child_id ,xpath_object); - }); - } - } - }, - - search_object : function(val ,list , xpath_object){ - var self = this; - if(xpath_object.length != 0){ - var main_list = _.flatten(val.att_list); - list = _.uniq(list); - var insert = _.intersection(main_list,list); - if(insert.length == list.length ){ - var level = val.level+1; - $.each(xpath_object, function(key, val) { - self.increase_level(val, level) - }); - val.child_id.push(xpath_object[0]); - xpath_object.pop(); - return; - }else{ - $.each(val.child_id, function(key, val) { - self.search_object(val, list, xpath_object); }); } } diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index aecb7e534ea..4f082c49fff 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -918,6 +918,11 @@ openerp.web.form.WidgetButton = openerp.web.form.Widget.extend({ on_confirmed: function() { var self = this; + if(this.node.attrs.context && (!f_context.__ref)) + _.extend(this.view.dataset.context, this.view.datatarecord); + + + return this.view.do_execute_action( this.node.attrs, this.view.dataset, this.view.datarecord.id, function () { self.view.reload(); @@ -928,7 +933,7 @@ openerp.web.form.WidgetButton = openerp.web.form.Widget.extend({ this.check_disable(); }, check_disable: function() { - if (this.force_disabled || !this.view.is_interactible_record()) { + if (this.force_disabled || !this.view.is_interactible_record() || this.readonly) { this.$element.find("button").attr("disabled", "disabled"); this.$element.find("button").css("color", "grey"); } else { -- cgit v1.2.3 From 560206d3c43903a5bf97319f09516fdb868ae6aa Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Wed, 12 Oct 2011 16:06:08 +0530 Subject: [fix]removed other file's changes. bzr revid: vme@tinyerp.com-20111012103608-y20172v3uhcmcrs2 --- addons/web/static/src/js/view_form.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 4f082c49fff..aecb7e534ea 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -918,11 +918,6 @@ openerp.web.form.WidgetButton = openerp.web.form.Widget.extend({ on_confirmed: function() { var self = this; - if(this.node.attrs.context && (!f_context.__ref)) - _.extend(this.view.dataset.context, this.view.datatarecord); - - - return this.view.do_execute_action( this.node.attrs, this.view.dataset, this.view.datarecord.id, function () { self.view.reload(); @@ -933,7 +928,7 @@ openerp.web.form.WidgetButton = openerp.web.form.Widget.extend({ this.check_disable(); }, check_disable: function() { - if (this.force_disabled || !this.view.is_interactible_record() || this.readonly) { + if (this.force_disabled || !this.view.is_interactible_record()) { this.$element.find("button").attr("disabled", "disabled"); this.$element.find("button").css("color", "grey"); } else { -- cgit v1.2.3 From 2f2832f598445cf4266847158208b261fdeb58f4 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Wed, 12 Oct 2011 17:07:46 +0530 Subject: [IMP] // with any level supported. bzr revid: vme@tinyerp.com-20111012113746-9ozx06oet5l3hudx --- addons/web/static/src/js/view_editor.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 988a0330856..2881a9a217b 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -182,17 +182,13 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var parent_id; var check_list = []; var xpath_object = self.parse_xml(xml,result.id); - if (xml.tagName.toLowerCase() == "xpath" && ($(xml).attr('expr')).indexOf("//") == -1) { + if (xml.tagName.toLowerCase() == "xpath" ) { var part_expr = _.without($(xml).attr('expr').split("/"),""); _.each(part_expr,function(part){ check_list.push(_.without($.trim(part.replace(/[^a-zA-Z 0-9 _]+/g,'!')).split("!"),"")); }); } else { - if($(xml).attr('expr')){ - check_list = [$.trim(($(xml).attr('expr')).replace(/[^a-zA-Z 0-9 _]+/g,' ')).split(" ")]; - }else{ check_list = [_.flatten(xpath_object[0].child_id[0].att_list)]; - } } self.full_path_search(check_list ,one_object ,xpath_object); }); -- cgit v1.2.3 From 90891fd08f497aae1eb059e492a71e6bd4a043ec Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Wed, 12 Oct 2011 17:55:30 +0530 Subject: [IMP]if-else replace with switch case bzr revid: vme@tinyerp.com-20111012122530-prscg6end1y00sh8 --- addons/web/static/src/js/view_editor.js | 52 ++++++++++++++++----------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 2881a9a217b..d42470003b6 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -198,38 +198,38 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ if(xpath_object.length!=0){ var check = check_list[0]; var obj; - if(check.length == 2){ - if(parseInt(check[1])){ - var list_1 = _.select(val,function(element){ + switch (check.length) { + case 2: + if(parseInt(check[1])){ + var list_1 = _.select(val,function(element){ + var main_list = _.flatten(element.att_list); + return _.include(main_list, check[0]); + }); + obj = val[_.indexOf(val,list_1[parseInt(check[1])-1])]; + } else { + obj = _.detect(val, function(element){ + var main_list = _.flatten(element.att_list); + return _.include(main_list, check[0]); + }); + } + break; + case 3: + obj = _.detect(val,function(element){ var main_list = _.flatten(element.att_list); - return _.include(main_list, check[0]); + check = _.uniq(check); + var insert = _.intersection(main_list,check); + if(insert.length == check.length ){return element;} }); - obj = val[_.indexOf(val,list_1[parseInt(check[1])-1])]; - } else { - obj = _.detect(val, function(element){ + break; + case 1: + var list_1 = _.select(val,function(element){ var main_list = _.flatten(element.att_list); return _.include(main_list, check[0]); }); - } - }else if(check.length == 3){ - obj = _.detect(val,function(element){ - var main_list = _.flatten(element.att_list); - check = _.uniq(check); - var insert = _.intersection(main_list,check); - if(insert.length == check.length ){return element;} - }); - }else{ - var list_1 = _.select(val,function(element){ - var main_list = _.flatten(element.att_list); - return _.include(main_list, check[0]); - }); - if(list_1 != 0){ - if(check_list.length == 1){ - obj = list_1[0]; - }else{ - check_list.shift(); + if(list_1 != 0){ + (check_list.length == 1)? obj = list_1[0] : check_list.shift(); } - } + break; } if(obj){ check_list.shift(); -- cgit v1.2.3 From e1f9558ecf36f389b12dc6a35bbfdba46ad42973 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Wed, 12 Oct 2011 18:42:53 +0530 Subject: fix bzr revid: ysa@tinyerp.com-20111012131253-hjm2i9pew98el3lo --- addons/web/static/src/js/view_editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 0498df42600..81c0d91043d 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -235,7 +235,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } else { _.each(val,function(element){ - self.full_path_search(cKKheck_list ,element.child_id ,xpath_object); + self.full_path_search(check_list ,element.child_id ,xpath_object); }); } } -- cgit v1.2.3 From 557895f275e785548e91d624c7a5575d612c9052 Mon Sep 17 00:00:00 2001 From: "Kunal Chavda (OpenERP)" Date: Fri, 14 Oct 2011 16:51:01 +0530 Subject: [IMP]Improved code for using element. bzr revid: kch@tinyerp.com-20111014112101-0ch74erynmj56isc --- addons/web/static/src/js/view_editor.js | 37 +++++++++++++++++---------------- 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 81c0d91043d..e042ee1d889 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -34,7 +34,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }, }; var action_manager = new openerp.web.ActionManager(this); - this.dialog = new openerp.web.Dialog(this,{ + this.view_edit_dialog = new openerp.web.Dialog(this,{ modal: true, title: 'ViewEditor', width: 750, @@ -52,9 +52,9 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }, }); - this.dialog.start(); - this.dialog.open(); - action_manager.appendTo(this.dialog); + this.view_edit_dialog.start(); + this.view_edit_dialog.open(); + action_manager.appendTo(this.view_edit_dialog); action_manager.do_action(action); }, check_attr: function(xml, tag, level) { @@ -134,7 +134,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }, get_data: function() { var self = this; - var view_id =(($("input[name='radiogroup']:checked").parent()).parent()).attr('data-id'); + var view_id =((this.view_edit_dialog.$element.find("input[name='radiogroup']:checked").parent()).parent()).attr('data-id'); var ve_dataset = new openerp.web.DataSet(this, 'ir.ui.view'); ve_dataset.read_ids([parseInt(view_id)], ['arch'], function (arch) { one_object = self.parse_xml(arch[0].arch,view_id); @@ -249,7 +249,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }, edit_view: function(one_object) { var self = this; - this.dialog = new openerp.web.Dialog(this,{ + this.edit_xml_dialog = new openerp.web.Dialog(this,{ modal: true, title: 'Edit Xml', width: 750, @@ -266,15 +266,15 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } } }); - this.dialog.start().open(); - this.dialog.$element.html(QWeb.render('view_editor', { + this.edit_xml_dialog.start().open(); + this.edit_xml_dialog.$element.html(QWeb.render('view_editor', { 'data': one_object['main_object'], })); - $("tr[id^='viewedit-']").click(function() { + this.edit_xml_dialog.$element.find("tr[id^='viewedit-']").click(function() { $("tr[id^='viewedit-']").removeClass('ui-selected'); $(this).addClass('ui-selected'); }); - $("img[id^='parentimg-']").click(function() { + this.edit_xml_dialog.$element.find("img[id^='parentimg-']").click(function() { if ($(this).attr('src') == '/web/static/src/img/collapse.gif') { $(this).attr('src', '/web/static/src/img/expand.gif'); self.on_expand(this); @@ -284,7 +284,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ self.on_collapse(this,one_object['parent_child_id'], one_object['main_object']); } }); - $("img[id^='side-']").click(function() { + this.edit_xml_dialog.$element.find("img[id^='side-']").click(function() { var side = $(this).closest("tr[id^='viewedit-']") var id_tr = (side.attr('id')).split('-')[1]; var img = side.find("img[id='parentimg-"+id_tr+"']").attr('src'); ; @@ -347,7 +347,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var last_tr_id = (last_tr.attr('id')).split('-')[1]; img = last_tr.find("img[id='parentimg-" + last_tr_id + "']").attr('src'); if (img) { - $("img[id='parentimg-" + last_tr_id + "']").attr('src', '/web/static/src/img/expand.gif'); + this.edit_xml_dialog.$element.find("img[id='parentimg-" + last_tr_id + "']").attr('src', '/web/static/src/img/expand.gif'); while (1) { var next_tr = last_tr.next(); if (next_tr.attr('level') <= level || next_tr.length == 0) break; @@ -364,9 +364,9 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }); }, - on_expand: function(self){ - var level = parseInt($(self).closest("tr[id^='viewedit-']").attr('level')); - var cur_tr = $(self).closest("tr[id^='viewedit-']"); + on_expand: function(expand_img){ + var level = parseInt($(expand_img).closest("tr[id^='viewedit-']").attr('level')); + var cur_tr = $(expand_img).closest("tr[id^='viewedit-']"); while (1) { var nxt_tr = cur_tr.next(); if (parseInt(nxt_tr.attr('level')) > level){ @@ -375,13 +375,14 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } else return nxt_tr; } }, - on_collapse: function(self, parent_child_id, id, main_object) { - var id = self.id.split('-')[1]; + on_collapse: function(collapse_img, parent_child_id, id, main_object) { + var self = this; + var id = collapse_img.id.split('-')[1]; var datas = _.detect(parent_child_id,function(res) { return res.key == id; }); _.each(datas.value, function(rec) { - var tr = $("tr[id='viewedit-"+rec+"']"); + var tr = self.edit_xml_dialog.$element.find("tr[id='viewedit-"+rec+"']"); tr.find("img[id='parentimg-"+rec+"']").attr('src','/web/static/src/img/expand.gif'); tr.show(); }); -- cgit v1.2.3 From e7888afb9dc03ce9d68eda47ec3de8d39de9633d Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Mon, 17 Oct 2011 18:51:16 +0530 Subject: [IMP]implement code for save and move functionality in view editor. bzr revid: vme@tinyerp.com-20111017132116-rntmapdk4g043gpa --- addons/web/static/src/js/view_editor.js | 41 +++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index d42470003b6..5fadfdaa289 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -95,7 +95,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var p_list = parent_list.slice(1); if (val.child_id.length != 0) { _.each(val.child_id, function(val, key) { - if (val.id==check_id) { + if (val.id == check_id) { if (p_list.length!=0) { self.save_object(val, p_list, child_obj_list); } else { @@ -144,18 +144,21 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ get_data: function() { var self = this; + var view_arch_list = []; var view_id =(($("input[name='radiogroup']:checked").parent()).parent()).attr('data-id'); var ve_dataset = new openerp.web.DataSet(this, 'ir.ui.view'); ve_dataset.read_ids([parseInt(view_id)], ['arch'], function (arch) { one_object = self.parse_xml(arch[0].arch,view_id); - one_object.arch = arch[0].arch; + view_arch_list.push({"view_id" : view_id, "arch" : arch[0].arch}); dataset = new openerp.web.DataSetSearch(self, 'ir.ui.view', null, null); dataset.read_slice([], {domain : [['inherit_id','=', parseInt(view_id)]]}, function (result) { _.each(result, function(res) { + view_arch_list.push({"view_id":res.id,"arch":res.arch}); self.inherit_view(one_object, res); }); return self.edit_view({"main_object": one_object, - "parent_child_id": self.parent_child_list(one_object, [])}); + "parent_child_id": self.parent_child_list(one_object, []), + "arch": view_arch_list}); }); }); }, @@ -226,7 +229,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var main_list = _.flatten(element.att_list); return _.include(main_list, check[0]); }); - if(list_1 != 0){ + if(list_1.length != 0){ (check_list.length == 1)? obj = list_1[0] : check_list.shift(); } break; @@ -373,10 +376,39 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ $(last_tr).after(rec); }); } + var arch1 = one_object["arch"][0].arch; + root = $(arch1).filter(":first")[0]; + self.get_node(one_object["arch"][0].arch, + one_object['main_object'][0].child_id[0], + parseInt(id_tr), + one_object['main_object'][0].child_id[0].chld_id, level, one_object); break; } }); }, + get_node: function(arch, obj, id, child_list, level, one_object){ + var self = this; + var children_list = $(arch).children(); + if(obj.level <= level){ + if(id != obj.id){ + for(var i=0;i< children_list.length; i++){ + if(obj.child_id){var child_list = obj.child_id}; + + self.get_node(children_list[i], obj.child_id[i], id, child_list, level, one_object); + } + }else{ + var next = $(arch).next() + $(next).after(arch); + var index = _.indexOf(child_list,obj) + var re_insert_obj = child_list.splice(index,1); + child_list.splice(index+1, 0, re_insert_obj[0]); + var p = $(arch).parents(); + one_object["arch"][0].arch = p[p.length-1]; + utfstring = unescape(encodeURIComponent(p)); + return; + } + } + }, on_expand: function(self){ var level = parseInt($(self).closest("tr[id^='viewedit-']").attr('level')); var cur_tr = $(self).closest("tr[id^='viewedit-']"); @@ -390,6 +422,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }, on_collapse: function(self, parent_child_id, id, main_object) { var id = self.id.split('-')[1]; + var datas = _.detect(parent_child_id,function(res) { return res.key == id; }); -- cgit v1.2.3 From ebcad72bcd72d83f077568ad51ef8727d9a0a2db Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Wed, 19 Oct 2011 15:20:44 +0530 Subject: [imp]implement code for xml saving and moving element of xml. bzr revid: vme@tinyerp.com-20111019095044-1z54rlklwlkvbsqq --- addons/web/static/src/js/view_editor.js | 41 ++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 5fadfdaa289..ccf0e4f75d6 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -301,7 +301,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }); $("img[id^='side-']").click(function() { - var side = $(this).closest("tr[id^='viewedit-']") + var side = $(this).closest("tr[id^='viewedit-']"); var id_tr = (side.attr('id')).split('-')[1]; var img = side.find("img[id='parentimg-"+id_tr+"']").attr('src'); ; var level = side.attr('level'); @@ -376,38 +376,47 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ $(last_tr).after(rec); }); } + var arch1 = one_object["arch"][0].arch; root = $(arch1).filter(":first")[0]; self.get_node(one_object["arch"][0].arch, one_object['main_object'][0].child_id[0], parseInt(id_tr), - one_object['main_object'][0].child_id[0].chld_id, level, one_object); + one_object['main_object'][0].child_id[0].chld_id, level , + one_object["arch"][0].view_id); break; } }); }, - get_node: function(arch, obj, id, child_list, level, one_object){ + get_node: function(arch, obj, id, child_list, level, view_id){ var self = this; var children_list = $(arch).children(); if(obj.level <= level){ - if(id != obj.id){ + if(id == obj.id){ + var next = $(arch).next() + $(next).after(arch); + var parent = $(arch).parents(); + parent = parent[parent.length-1]; + var convert_to_utf = ""; + var s = new XMLSerializer(); + var stream = { + write : function(string) + {convert_to_utf = convert_to_utf + string + "";} + }; + s.serializeToStream(parent, stream, "UTF-8"); + convert_to_utf = convert_to_utf.replace('xmlns="http://www.w3.org/1999/xhtml"', ""); + convert_to_utf = '' + convert_to_utf; + dataset = new openerp.web.DataSet(this, 'ir.ui.view'); + dataset.write(parseInt(view_id),{"arch":convert_to_utf},function(r){ + }); + }else{ for(var i=0;i< children_list.length; i++){ if(obj.child_id){var child_list = obj.child_id}; - - self.get_node(children_list[i], obj.child_id[i], id, child_list, level, one_object); + self.get_node(children_list[i], obj.child_id[i], id, child_list, level, view_id); } - }else{ - var next = $(arch).next() - $(next).after(arch); - var index = _.indexOf(child_list,obj) - var re_insert_obj = child_list.splice(index,1); - child_list.splice(index+1, 0, re_insert_obj[0]); - var p = $(arch).parents(); - one_object["arch"][0].arch = p[p.length-1]; - utfstring = unescape(encodeURIComponent(p)); - return; } } + }, on_expand: function(self){ var level = parseInt($(self).closest("tr[id^='viewedit-']").attr('level')); -- cgit v1.2.3 From c507d1ef7ea17d9a6d0a59466a4c57fe81db23cb Mon Sep 17 00:00:00 2001 From: "RavishchanraMurari (Open ERP)" Date: Thu, 20 Oct 2011 17:21:46 +0530 Subject: company_id_in_multi_company bzr revid: rmu@tinyerp.com-20111020115146-p0ai3x3q0u48390k --- addons/web/static/src/js/search.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 9cab0ade9d0..2a4d3b1cdfe 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -63,6 +63,8 @@ openerp.web.SearchView = openerp.web.Widget.extend(/** @lends openerp.web.Search rows.push(row); var filters = []; _.each(items, function (item) { + if(!item.attrs.hasOwnProperty('invisible') && item.attrs.invisible!=1) + { if (filters.length && item.tag !== 'filter') { row.push( new openerp.web.search.FilterGroup( @@ -98,6 +100,7 @@ openerp.web.SearchView = openerp.web.Widget.extend(/** @lends openerp.web.Search this.make_field( item, fields[item['attrs'].name])); } + } } }, this); if (filters.length) { -- cgit v1.2.3 From 0101378e100d6cdb6c9242c00caa01bd63d20db4 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 20 Oct 2011 18:47:27 +0530 Subject: [IMP]implement code for get view according to element moving from db. bzr revid: vme@tinyerp.com-20111020131727-ks0awx1z18g0ytf0 --- addons/web/static/src/js/view_editor.js | 110 ++++++++++++++++++++------------ 1 file changed, 69 insertions(+), 41 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index ccf0e4f75d6..a645593f437 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -46,7 +46,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ //to do }, "Edit": function(){ - self.xml_id = 0 ; + self.xml_id=0; self.get_data(); }, "Close": function(){ @@ -80,9 +80,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ if (attrs.nodeName != "position") { obj.att_list.push( [attrs.nodeName,attrs.nodeValue] ); } - }); - render_name+= ">"; }); obj.name = render_name; @@ -109,7 +107,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }, - xml_node_create: function(xml, root, parent_list, parent_id, main_object){ + xml_node_create: function(xml, root, parent_list, parent_id, main_object ){ var self = this; var child_obj_list = []; var children_list = $(xml).filter(root).children(); @@ -284,7 +282,6 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ this.dialog.$element.html(QWeb.render('view_editor', { 'data': one_object['main_object'], })); - $("tr[id^='viewedit-']").click(function() { $("tr[id^='viewedit-']").removeClass('ui-selected'); $(this).addClass('ui-selected'); @@ -304,12 +301,23 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var side = $(this).closest("tr[id^='viewedit-']"); var id_tr = (side.attr('id')).split('-')[1]; var img = side.find("img[id='parentimg-"+id_tr+"']").attr('src'); ; - var level = side.attr('level'); + var level = parseInt(side.attr('level')); var list_shift =[]; var last_tr; var cur_tr = side; list_shift.push(side); var next_tr; + var ls = side; + var view_id; + var view_xml_id; + while(1){ + ls = ls.prev(); + if(($(ls).find('a').text()).search("view_id") != -1 && parseInt(ls.attr('level')) < level){ + view_id = parseInt(($(ls).find('a').text()).replace(/[^0-9]+/g,'')); + view_xml_id = (ls.attr('id')).split('-')[1]; + break; + } + } switch (this.id) { case "side-add": break; @@ -320,7 +328,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ case "side-up": while (1) { var prev_tr = cur_tr.prev(); - if(level >= prev_tr.attr('level') || prev_tr.length == 0) { + if(level >= parseInt(prev_tr.attr('level')) || prev_tr.length == 0) { last_tr = prev_tr; break; } @@ -329,7 +337,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ if (img) { while (1) { next_tr = side.next(); - if (next_tr.attr('level') <= level || next_tr.length == 0) { + if ( parseInt(next_tr.attr('level')) <= level || next_tr.length == 0) { break; } else { list_shift.push(next_tr); @@ -337,7 +345,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } } } - if (last_tr.length != 0 && last_tr.attr('level') == level) { + if (last_tr.length != 0 && parseInt(last_tr.attr('level')) == level) { _.each(list_shift, function(rec) { $(last_tr).before(rec); }); @@ -347,7 +355,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ if (img) { while (1) { next_tr = cur_tr.next(); - if (next_tr.attr('level') <= level || next_tr.length == 0) { + if ( parseInt(next_tr.attr('level')) <= level || next_tr.length == 0) { last_tr = next_tr; break; } else { @@ -359,7 +367,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ else { last_tr = cur_tr.next(); } - if (last_tr.length != 0 && last_tr.attr('level') == level) { + if (last_tr.length != 0 && parseInt(last_tr.attr('level')) == level) { var last_tr_id = (last_tr.attr('id')).split('-')[1]; img = last_tr.find("img[id='parentimg-" + last_tr_id + "']").attr('src'); if (img) { @@ -375,48 +383,69 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ _.each(list_shift, function(rec) { $(last_tr).after(rec); }); + self.save_move_arch(one_object, view_id, view_xml_id, id_tr, level); } - - var arch1 = one_object["arch"][0].arch; - root = $(arch1).filter(":first")[0]; - self.get_node(one_object["arch"][0].arch, - one_object['main_object'][0].child_id[0], - parseInt(id_tr), - one_object['main_object'][0].child_id[0].chld_id, level , - one_object["arch"][0].view_id); break; } }); }, - get_node: function(arch, obj, id, child_list, level, view_id){ + save_move_arch: function(one_object, view_id, view_xml_id, id_tr, level){ var self = this; - var children_list = $(arch).children(); - if(obj.level <= level){ - if(id == obj.id){ - var next = $(arch).next() - $(next).after(arch); - var parent = $(arch).parents(); - parent = parent[parent.length-1]; - var convert_to_utf = ""; - var s = new XMLSerializer(); - var stream = { - write : function(string) - {convert_to_utf = convert_to_utf + string + "";} - }; - s.serializeToStream(parent, stream, "UTF-8"); - convert_to_utf = convert_to_utf.replace('xmlns="http://www.w3.org/1999/xhtml"', ""); - convert_to_utf = '' + convert_to_utf; - dataset = new openerp.web.DataSet(this, 'ir.ui.view'); - dataset.write(parseInt(view_id),{"arch":convert_to_utf},function(r){ + var arch = _.detect(one_object['arch'],function(element){ + return element.view_id == view_id; + }); + var obj = self.get_view_object(view_xml_id, one_object['main_object'], []); + return self.get_node(arch.arch, obj[0].child_id[0], parseInt(id_tr), [], parseInt(level), + parseInt(view_id), arch); + }, + get_view_object: function(view_xml_id, one_object,result){ + var self = this; + if(result.length==0){ + var check = _.detect(one_object , function(obj){ + return view_xml_id==obj.id; + }); + if(check){result.push(check);}; + _.each(one_object, function(obj){ + self.get_view_object(view_xml_id, obj.child_id, result); }); + } + return result; + }, + get_node: function(arch1, obj, id, child_list, level, view_id, arch){ + var self = this; + console.log(obj.id,id); + var children_list = $(arch1).children(); + if(obj.level <= level){ + if(parseInt(id) == obj.id){ + var next = $(arch1).next() + $(next).after(arch1); + var parent = $(arch1).parents(); + console.log(id,"--------",obj.id); + console.log(next,"========",arch1); + parent = parent[parent.length-1]; + var convert_to_utf = ""; + var s = new XMLSerializer(); + var stream = { + write : function(string) + {convert_to_utf = convert_to_utf + string + "";} + }; + var index = _.indexOf(child_list,obj) + var re_insert_obj = child_list.splice(index,1); + child_list.splice(index+1, 0, re_insert_obj[0]); + s.serializeToStream(parent, stream, "UTF-8"); + convert_to_utf = convert_to_utf.replace('xmlns="http://www.w3.org/1999/xhtml"', ""); + convert_to_utf = '' + convert_to_utf; + arch.arch = convert_to_utf; + dataset = new openerp.web.DataSet(this, 'ir.ui.view'); + dataset.write(parseInt(view_id),{"arch":convert_to_utf},function(r){ + }); }else{ for(var i=0;i< children_list.length; i++){ if(obj.child_id){var child_list = obj.child_id}; - self.get_node(children_list[i], obj.child_id[i], id, child_list, level, view_id); + self.get_node(children_list[i], obj.child_id[i], id, child_list, level, view_id, arch); } } } - }, on_expand: function(self){ var level = parseInt($(self).closest("tr[id^='viewedit-']").attr('level')); @@ -431,7 +460,6 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }, on_collapse: function(self, parent_child_id, id, main_object) { var id = self.id.split('-')[1]; - var datas = _.detect(parent_child_id,function(res) { return res.key == id; }); -- cgit v1.2.3 From d049a25fa5f5053014d5930da14818fd056a1cac Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Fri, 21 Oct 2011 12:21:03 +0530 Subject: [FIX] Fixed the issue of buttons 'First', '<', '>', 'Last' would be nice at the bottom, too lp bug: https://launchpad.net/bugs/878106 fixed bzr revid: tpa@tinyerp.com-20111021065103-slbb7n124cuyvwhm --- addons/web/static/src/xml/base.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 7720ae2d38b..c3f15cf281c 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -612,6 +612,23 @@ + + + + + + + + + + + + -- cgit v1.2.3 From 75a57eed129f7491adfa4cf1f26551b79da6cd04 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Fri, 21 Oct 2011 16:14:41 +0530 Subject: [IMP] Fixed the issue of buttons 'First', '<', '>', 'Last' would be nice at the bottom, too bzr revid: tpa@tinyerp.com-20111021104441-k2lnnciqalsjii2j --- addons/web/static/src/xml/base.xml | 51 ++++++++++++++------------------------ 1 file changed, 19 insertions(+), 32 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index c3f15cf281c..7665a72e77b 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -567,22 +567,8 @@ t-if="options.selectable and options.deletable"> Delete + - - - - - - - - - - @@ -612,25 +598,26 @@ - - - - - - - - - - - - + + + + + + + + + + + + + -- cgit v1.2.3 From 940b1138aec2296a5a20095c2be3ee9a997bf1e2 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Mon, 24 Oct 2011 11:39:26 +0530 Subject: [IMP] Fixed the issue of buttons 'First', '<', '>', 'Last' would be nice at the bottom, too bzr revid: tpa@tinyerp.com-20111024060926-f47bcg8jkmx449z2 --- addons/web/static/src/xml/base.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 7665a72e77b..4bbee042f6d 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -567,8 +567,8 @@ t-if="options.selectable and options.deletable"> Delete - + -- cgit v1.2.3 From cdac09e3dce901458f87ed5eca4d10a2981c9938 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 24 Oct 2011 10:40:05 +0200 Subject: [fix] css problem in database screen when we use a too high resolution bzr revid: nicolas.vanhoren@openerp.com-20111024084005-et884p0px0l08ge8 --- addons/web/static/src/css/base.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 6872b921435..1f8796b539c 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -159,7 +159,7 @@ body.openerp, .openerp textarea, .openerp input, .openerp select, .openerp optio } .db_container { - width: 15%; + width: 196px; background: #666666; } -- cgit v1.2.3 From 2ce07c97c615c405d2171244dd47f8b52edf8c73 Mon Sep 17 00:00:00 2001 From: kbh Date: Mon, 24 Oct 2011 14:47:30 +0530 Subject: [FIX] Fixed the issue of checkbutton select all/none in tree view. lp bug: https://launchpad.net/bugs/878108 fixed bzr revid: kbh@bde-desktop-20111024091730-dkzafro2f9e0k7tf --- addons/web/static/src/js/view_list.js | 8 +++++++- addons/web/static/src/xml/base.xml | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index d09ec1d3035..6fd4cdf2e03 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -201,8 +201,8 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# this.setup_columns(this.fields_view.fields, grouped); this.$element.html(QWeb.render("ListView", this)); - // Head hook + this.$element.find('#all_checked').click(this.do_all_checked); this.$element.find('.oe-list-add') .click(this.do_add_record) .attr('disabled', grouped && this.options.editable); @@ -269,6 +269,11 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# this.set_common_sidebar_sections(this.sidebar); } }, + + do_all_checked:function (ev) { + var all_checkbox = this.$element.find('.oe-record-selector :checkbox') + all_checkbox.attr('checked', !all_checkbox.attr('checked')); + }, /** * Configures the ListView pager based on the provided dataset's information * @@ -650,6 +655,7 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# $first_header.attr('colspan', parseInt(colspan, 10) + count); } // Padding for column titles, footer and data rows + var $rows = this.$element .find('.oe-listview-header-columns, tr:not(thead tr)') .not(options['except']); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 7720ae2d38b..4c21a565a69 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -593,7 +593,8 @@ - + + -- cgit v1.2.3 From 62c52bf0c21f07a75734bb18872e3047f7191f67 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 24 Oct 2011 11:21:40 +0200 Subject: [FIX] Do not use node.parentElement (sorry all) lp bug: https://launchpad.net/bugs/879797 fixed bzr revid: fme@openerp.com-20111024092140-zvrtzmy9cppjyaj2 --- addons/web/static/src/js/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index 4ed33341ea6..39a1ba7ef64 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -1048,7 +1048,7 @@ openerp.web.qweb = new QWeb2.Engine(); openerp.web.qweb.debug = (window.location.search.indexOf('?debug') !== -1); openerp.web.qweb.format_text_node = function(s) { // Note that 'this' is the Qweb Node of the text - var translation = this.node.parentElement.attributes['t-translation']; + var translation = this.node.parentNode.attributes['t-translation']; if (translation && translation.value === 'off') { return s; } -- cgit v1.2.3 From 1945d19d150544668de7020d7c67b2f2a327a128 Mon Sep 17 00:00:00 2001 From: "RavishchanraMurari (Open ERP)" Date: Mon, 24 Oct 2011 17:44:15 +0530 Subject: mulit_company_in group_by bzr revid: rmu@tinyerp.com-20111024121415-wkjyjzl6ydqz3t7o --- addons/web/static/src/js/search.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 45a0d40e96e..48d58b5776c 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -63,8 +63,9 @@ openerp.web.SearchView = openerp.web.Widget.extend(/** @lends openerp.web.Search rows.push(row); var filters = []; _.each(items, function (item) { - if(!item.attrs.hasOwnProperty('invisible') && item.attrs.invisible!=1) - { + if (item.attrs.invisible === '1') { + return; + } if (filters.length && item.tag !== 'filter') { row.push( new openerp.web.search.FilterGroup( @@ -101,7 +102,7 @@ openerp.web.SearchView = openerp.web.Widget.extend(/** @lends openerp.web.Search item, fields[item['attrs'].name])); } } - } + }, this); if (filters.length) { row.push(new openerp.web.search.FilterGroup(filters, this)); -- cgit v1.2.3 From 3e20652e55ce8f8eb53d3dc1edf9321a63d5c888 Mon Sep 17 00:00:00 2001 From: kbh Date: Mon, 24 Oct 2011 18:59:59 +0530 Subject: [IMP] Fixed the issue of checkbutton select all/none in tree view. bzr revid: kbh@bde-desktop-20111024132959-y9b3scfye91nut1c --- addons/web/static/src/js/view_list.js | 5 +++++ addons/web/static/src/xml/base.xml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 6fd4cdf2e03..1f8430df8a2 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -202,6 +202,11 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# this.$element.html(QWeb.render("ListView", this)); // Head hook + this.$element.find('.all-record-selector').click(function(){ + self.$element.find(':checkbox').prop('checked', + self.$element.find('.all-record-selector').prop('checked') || false); + }); + this.$element.find('#all_checked').click(this.do_all_checked); this.$element.find('.oe-list-add') .click(this.do_add_record) diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 4c21a565a69..81611f0315a 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -594,7 +594,7 @@ - + -- cgit v1.2.3 From ce45893633ca0492dfc57a8cd180374565560357 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 24 Oct 2011 15:44:13 +0200 Subject: [FIX] Display 'don't import' placeholder when no value selected bzr revid: xmo@openerp.com-20111024134413-kgcgemdzquwtn0ns --- addons/web/static/src/xml/base.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 2860174c30f..db3f082ed03 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1461,7 +1461,7 @@ - + -- cgit v1.2.3 From a8b81ed5754ef0f2495b28b517f2a5b7ed9ba749 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 24 Oct 2011 15:55:21 +0200 Subject: [ADD] dropdown arrow next to import autocompletes bzr revid: xmo@openerp.com-20111024135521-aikh791r9j94moal --- addons/web/static/src/js/data_import.js | 4 ++++ addons/web/static/src/xml/base.xml | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/data_import.js b/addons/web/static/src/js/data_import.js index 711e790dfaa..025ff8df1c5 100644 --- a/addons/web/static/src/js/data_import.js +++ b/addons/web/static/src/js/data_import.js @@ -205,6 +205,10 @@ openerp.web.DataImport = openerp.web.Dialog.extend({ return; } + this.$element.delegate('.oe-m2o-drop-down-button', 'click', function () { + $(this).prev('input').focus(); + }); + var self = this; this.ready.then(function () { var $fields = self.$element.find('.sel_fields').bind('blur', function () { diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index db3f082ed03..7d010d5867b 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1461,7 +1461,8 @@ - + + -- cgit v1.2.3 From b45b7ad22cce753a00fff13981502e2c807cee79 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 24 Oct 2011 16:06:58 +0200 Subject: [IMP] import: only show second step once file has been uploaded bzr revid: xmo@openerp.com-20111024140658-8t9csv9i6gd30luj --- addons/web/static/src/js/data_import.js | 2 +- addons/web/static/src/xml/base.xml | 39 +++++++++++++++++---------------- 2 files changed, 21 insertions(+), 20 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/data_import.js b/addons/web/static/src/js/data_import.js index 025ff8df1c5..42f0cf8d680 100644 --- a/addons/web/static/src/js/data_import.js +++ b/addons/web/static/src/js/data_import.js @@ -80,7 +80,7 @@ openerp.web.DataImport = openerp.web.Dialog.extend({ this.toggle_import_button(false); this.$element.find('#csvfile').change(this.on_autodetect_data); this.$element.find('fieldset').change(this.on_autodetect_data); - this.$element.find('fieldset legend').click(function() { + this.$element.delegate('fieldset legend', 'click', function() { $(this).next().toggle(); }); this.ready.push(new openerp.web.DataSet(this, this.model).call( diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 7d010d5867b..201ac964ac9 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1419,8 +1419,27 @@

-

2. Check your file format

+ +
+ +

2. Check your file format

+ + + + + + + + + + +
+
+ + +
+
Import Options @@ -1451,25 +1470,7 @@
-
- - - - - - - - - - -
-
- - -
-

The import failed due to:

-- cgit v1.2.3 From cd59e5e6fbf07bb1783dde48ecdafa73000d33c4 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 24 Oct 2011 16:17:37 +0200 Subject: [ADD] open/close arrow next to import options bzr revid: xmo@openerp.com-20111024141737-bk2rg08wvll1hgno --- addons/web/static/src/css/data_import.css | 12 ++++++++++++ addons/web/static/src/js/data_import.js | 2 +- addons/web/static/src/xml/base.xml | 9 +++++---- 3 files changed, 18 insertions(+), 5 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/css/data_import.css b/addons/web/static/src/css/data_import.css index 1fb3b22aa45..b1c4330402f 100644 --- a/addons/web/static/src/css/data_import.css +++ b/addons/web/static/src/css/data_import.css @@ -11,6 +11,18 @@ .openerp .oe_import_grid-row .oe_import_grid-cell { border-bottom: 1px solid #E3E3E3; } +.openerp .oe-import fieldset { + cursor: pointer; +} +.openerp .oe-import fieldset legend:before { + content: '\25BC '; +} +.openerp .oe-import fieldset.oe-closed legend:before { + content: '\25B6 '; +} +.openerp .oe-import fieldset.oe-closed table { + display: none; +} .openerp .separator.horizontal { font-weight: bold; border-bottom-width: 1px; diff --git a/addons/web/static/src/js/data_import.js b/addons/web/static/src/js/data_import.js index 42f0cf8d680..a284669732d 100644 --- a/addons/web/static/src/js/data_import.js +++ b/addons/web/static/src/js/data_import.js @@ -81,7 +81,7 @@ openerp.web.DataImport = openerp.web.Dialog.extend({ this.$element.find('#csvfile').change(this.on_autodetect_data); this.$element.find('fieldset').change(this.on_autodetect_data); this.$element.delegate('fieldset legend', 'click', function() { - $(this).next().toggle(); + $(this).parent().toggleClass('oe-closed'); }); this.ready.push(new openerp.web.DataSet(this, this.model).call( 'fields_get', [], function (fields) { diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 201ac964ac9..f2f77b83eb7 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1409,7 +1409,8 @@ Import -
+

1. Import a .CSV file

Select a .CSV file to import. If you need a sample of file to import, @@ -1440,9 +1441,9 @@ -

- Import Options - +
+ Import Options +
-
-- cgit v1.2.3 From 06344150ebf2860247929c76f3fc6d9b43ca27b9 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 24 Oct 2011 16:27:44 +0200 Subject: [FIX] automatically open options box if the file fails to parse entirely bzr revid: xmo@openerp.com-20111024142744-zeal912gqf9bvrrp --- addons/web/static/src/css/data_import.css | 4 +++ addons/web/static/src/js/data_import.js | 3 ++ addons/web/static/src/xml/base.xml | 46 +++++++++++++++---------------- 3 files changed, 30 insertions(+), 23 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/css/data_import.css b/addons/web/static/src/css/data_import.css index b1c4330402f..e5d1c9a910c 100644 --- a/addons/web/static/src/css/data_import.css +++ b/addons/web/static/src/css/data_import.css @@ -11,6 +11,10 @@ .openerp .oe_import_grid-row .oe_import_grid-cell { border-bottom: 1px solid #E3E3E3; } + +.openerp .oe-import-no-result .oe-import-result { + display: none; +} .openerp .oe-import fieldset { cursor: pointer; } diff --git a/addons/web/static/src/js/data_import.js b/addons/web/static/src/js/data_import.js index a284669732d..355c6c1b493 100644 --- a/addons/web/static/src/js/data_import.js +++ b/addons/web/static/src/js/data_import.js @@ -194,9 +194,11 @@ openerp.web.DataImport = openerp.web.Dialog.extend({ : with_headers ? results.records.slice(1) : results.records })); + this.$element.find('fieldset').addClass('oe-closed'); } else if (results['error']) { result_node.append(QWeb.render('ImportView.error', { 'error': results['error']})); + this.$element.find('fieldset').removeClass('oe-closed'); } else if (results['success']) { if (this.widget_parent.widget_parent.active_view == "list") { this.widget_parent.reload_content(); @@ -204,6 +206,7 @@ openerp.web.DataImport = openerp.web.Dialog.extend({ this.stop(); return; } + this.$element.find('form').removeClass('oe-import-no-result'); this.$element.delegate('.oe-m2o-drop-down-button', 'click', function () { $(this).prev('input').focus(); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index f2f77b83eb7..1054a76dcf6 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1410,7 +1410,7 @@ + class="oe-import oe-import-no-result">

1. Import a .CSV file

Select a .CSV file to import. If you need a sample of file to import, @@ -1420,28 +1420,9 @@

-
- -
- -

2. Check your file format

- - - - - - - - - - -
-
- - -
-
-
+

2. Check your file format

+
+
Import Options @@ -1471,6 +1452,25 @@
+ + + + + + + + + + + + + +
+
+ + +
+

The import failed due to:

-- cgit v1.2.3 From a617e3bacc5ea44b4aa3ec9840e3eb8a4009047f Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 24 Oct 2011 17:10:39 +0200 Subject: [fix] small problem with the context menu of m2o when there is not item selected bzr revid: nicolas.vanhoren@openerp.com-20111024151039-k9jlntcj3n56h13d --- addons/web/static/src/xml/base.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 1054a76dcf6..349dccec867 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -859,9 +859,9 @@
    -
  • Open...
  • +
  • Open...
  • Create...
  • -
  • Search...
  • +
  • Search...
  • -- cgit v1.2.3 From 84a383d5aa7c3ef6a2fc38fb06953b447d831651 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 24 Oct 2011 17:11:58 +0200 Subject: [IMP] make notebooks in page view identical to those of normal form view as requested by fp bzr revid: xmo@openerp.com-20111024151158-7hqox4k6xrjujxnb --- addons/web/static/src/js/view_form.js | 4 ---- addons/web/static/src/xml/base.xml | 6 ------ 2 files changed, 10 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 7d3f96925e0..aa1fbab90e1 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2813,9 +2813,6 @@ openerp.web.form.FieldStatus = openerp.web.form.Field.extend({ } }); -openerp.web.form.WidgetNotebookReadonly = openerp.web.form.WidgetNotebook.extend({ - template: 'WidgetNotebook.readonly' -}); openerp.web.form.FieldReadonly = openerp.web.form.Field.extend({ }); @@ -2934,7 +2931,6 @@ openerp.web.form.widgets = new openerp.web.Registry({ 'statusbar': 'openerp.web.form.FieldStatus' }); openerp.web.form.readonly = openerp.web.form.widgets.clone({ - 'notebook': 'openerp.web.form.WidgetNotebookReadonly', 'char': 'openerp.web.form.FieldCharReadonly', 'email': 'openerp.web.form.FieldEmailReadonly', 'url': 'openerp.web.form.FieldUrlReadonly', diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 349dccec867..95ad99726f8 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -744,12 +744,6 @@ - - -

    - - -
    -- cgit v1.2.3 From 19bb1dda1a0d59b3010f06b53e47473ee0923105 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 24 Oct 2011 17:20:13 +0200 Subject: [IMP] use empty box/check mark for page boolean fields, instead of cross vs check mark bzr revid: xmo@openerp.com-20111024152013-nhi8kwra46se0yva --- addons/web/static/src/js/view_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index aa1fbab90e1..a8ccfcb3e46 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2848,7 +2848,7 @@ openerp.web.form.FieldUrlReadonly = openerp.web.form.FieldURIReadonly.extend({ }); openerp.web.form.FieldBooleanReadonly = openerp.web.form.FieldCharReadonly.extend({ set_value: function (value) { - this._super(value ? '\u2714' : '\u2718'); + this._super(value ? '\u2611' : '\u2610'); } }); openerp.web.form.FieldSelectionReadonly = openerp.web.form.FieldReadonly.extend({ -- cgit v1.2.3 From 6cb7f2b6f9cad1bd02dda34ad283342e1565995e Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 24 Oct 2011 17:20:56 +0200 Subject: [imp] m2o now supports readonly mode bzr revid: nicolas.vanhoren@openerp.com-20111024152056-2nfx7zk4kc9py17k --- addons/web/static/src/js/view_form.js | 11 +++++++++++ addons/web/static/src/xml/base.xml | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index a8ccfcb3e46..1f1b5b8ef6f 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1628,6 +1628,11 @@ openerp.web.form.FieldMany2One = openerp.web.form.Field.extend({ } else { $("#" + self.cm_id + " .oe_m2o_menu_item_mandatory").addClass("oe-m2o-disabled-cm"); } + if (!self.readonly) { + $("#" + self.cm_id + " .oe_m2o_menu_item_noreadonly").removeClass("oe-m2o-disabled-cm"); + } else { + $("#" + self.cm_id + " .oe_m2o_menu_item_noreadonly").addClass("oe-m2o-disabled-cm"); + } return true; }, menuStyle: {width: "200px"} }); @@ -1647,6 +1652,8 @@ openerp.web.form.FieldMany2One = openerp.web.form.Field.extend({ } }); this.$drop_down.click(function() { + if (self.readonly) + return; if (self.$input.autocomplete("widget").is(":visible")) { self.$input.autocomplete("close"); } else { @@ -1853,6 +1860,10 @@ openerp.web.form.FieldMany2One = openerp.web.form.Field.extend({ }, focus: function () { this.$input.focus(); + }, + update_dom: function() { + this._super.apply(this, arguments); + this.$input.attr('disabled', this.readonly); } }); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 95ad99726f8..c0007275ffa 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -854,8 +854,8 @@
    • Open...
    • -
    • Create...
    • -
    • Search...
    • +
    • Create...
    • +
    • Search...
    • -- cgit v1.2.3 From f097e140b8b51437258ae03000b37f1677f6098b Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Tue, 25 Oct 2011 00:54:31 +0200 Subject: [IMP] try session instead of openerp,db and we would rename Session into Connection bzr revid: al@openerp.com-20111024225431-g9eaqophnw3k8hh4 --- addons/web/static/src/js/views.js | 86 +++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 43 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index f402a51bf7e..b7a3d185bc1 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -2,21 +2,21 @@ * OpenERP web library *---------------------------------------------------------*/ -openerp.web.views = function(db) { +openerp.web.views = function(session) { -var _t = db.web._t; +var _t = session.web._t; /** * Registry for all the client actions key: tag value: widget */ -db.web.client_actions = new db.web.Registry(); +session.web.client_actions = new session.web.Registry(); /** * Registry for all the main views */ -db.web.views = new db.web.Registry(); +session.web.views = new session.web.Registry(); -db.web.ActionManager = db.web.Widget.extend({ +session.web.ActionManager = session.web.Widget.extend({ identifier_prefix: "actionmanager", init: function(parent) { this._super(parent); @@ -93,20 +93,20 @@ db.web.ActionManager = db.web.Widget.extend({ ir_actions_act_window: function (action, on_close) { if (action.target === 'new') { if (this.dialog == null) { - this.dialog = new db.web.Dialog(this, { title: action.name, width: '80%' }); + this.dialog = new session.web.Dialog(this, { title: action.name, width: '80%' }); if(on_close) this.dialog.on_close.add(on_close); this.dialog.start(); } else { this.dialog_viewmanager.stop(); } - this.dialog_viewmanager = new db.web.ViewManagerAction(this, action); + this.dialog_viewmanager = new session.web.ViewManagerAction(this, action); this.dialog_viewmanager.appendTo(this.dialog.$element); this.dialog.open(); } else { this.dialog_stop(); this.content_stop(); - this.inner_viewmanager = new db.web.ViewManagerAction(this, action); + this.inner_viewmanager = new session.web.ViewManagerAction(this, action); this.inner_viewmanager.appendTo(this.$element); this.url_update(action); } @@ -124,7 +124,7 @@ db.web.ActionManager = db.web.Widget.extend({ if (this.dialog && action.context) { var model = action.context.active_model; if (model === 'base.module.upgrade' || model === 'base.setup.installer' || model === 'base.module.upgrade') { - db.webclient.do_reload(); + session.webclient.do_reload(); } } this.dialog_stop(); @@ -140,7 +140,7 @@ db.web.ActionManager = db.web.Widget.extend({ }, ir_actions_client: function (action) { this.content_stop(); - var ClientWidget = db.web.client_actions.get_object(action.tag); + var ClientWidget = session.web.client_actions.get_object(action.tag); (this.client_widget = new ClientWidget(this, action.params)).appendTo(this); }, ir_actions_report_xml: function(action) { @@ -164,12 +164,12 @@ db.web.ActionManager = db.web.Widget.extend({ } }); -db.web.ViewManager = db.web.Widget.extend(/** @lends db.web.ViewManager# */{ +session.web.ViewManager = session.web.Widget.extend(/** @lends session.web.ViewManager# */{ identifier_prefix: "viewmanager", template: "ViewManager", /** - * @constructs db.web.ViewManager - * @extends db.web.Widget + * @constructs session.web.ViewManager + * @extends session.web.Widget * * @param parent * @param dataset @@ -185,10 +185,10 @@ db.web.ViewManager = db.web.Widget.extend(/** @lends db.web.ViewManager# */{ this.views_src = _.map(views, function(x) {return x instanceof Array? {view_id: x[0], view_type: x[1]} : x;}); this.views = {}; this.flags = this.flags || {}; - this.registry = db.web.views; + this.registry = session.web.views; }, render: function() { - return db.web.qweb.render(this.template, { + return session.web.qweb.render(this.template, { self: this, prefix: this.element_id, views: this.views_src}); @@ -284,7 +284,7 @@ db.web.ViewManager = db.web.Widget.extend(/** @lends db.web.ViewManager# */{ if (this.searchview) { this.searchview.stop(); } - this.searchview = new db.web.SearchView( + this.searchview = new session.web.SearchView( this, this.dataset, view_id, search_defaults, this.flags.search_view === false); @@ -334,13 +334,13 @@ db.web.ViewManager = db.web.Widget.extend(/** @lends db.web.ViewManager# */{ on_action_executed: function () {} }); -db.web.ViewManagerAction = db.web.ViewManager.extend(/** @lends oepnerp.web.ViewManagerAction# */{ +session.web.ViewManagerAction = session.web.ViewManager.extend(/** @lends oepnerp.web.ViewManagerAction# */{ template:"ViewManagerAction", /** - * @constructs db.web.ViewManagerAction - * @extends db.web.ViewManager + * @constructs session.web.ViewManagerAction + * @extends session.web.ViewManager * - * @param {db.web.ActionManager} parent parent object/widget + * @param {session.web.ActionManager} parent parent object/widget * @param {Object} action descriptor for the action this viewmanager needs to manage its views. */ init: function(parent, action) { @@ -350,7 +350,7 @@ db.web.ViewManagerAction = db.web.ViewManager.extend(/** @lends oepnerp.web.View this._super(parent, null, action.views); this.session = parent.session; this.action = action; - var dataset = new db.web.DataSetSearch(this, action.res_model, action.context, action.domain); + var dataset = new session.web.DataSetSearch(this, action.res_model, action.context, action.domain); if (action.res_id) { dataset.ids.push(action.res_id); dataset.index = 0; @@ -400,12 +400,12 @@ db.web.ViewManagerAction = db.web.ViewManager.extend(/** @lends oepnerp.web.View this.$element.find('.oe_get_xml_view').click(function () { // TODO: add search view? - $('
      ').text(db.web.json_node_to_xml(
      +            $('
      ').text(session.web.json_node_to_xml(
                       self.views[self.active_view].controller.fields_view.arch, true))
                           .dialog({ width: '95%'});
               });
               if (this.action.help && !this.flags.low_profile) {
      -            var Users = new db.web.DataSet(self, 'res.users'),
      +            var Users = new session.web.DataSet(self, 'res.users'),
                       header = this.$element.find('.oe-view-manager-header');
                   header.delegate('blockquote button', 'click', function() {
                       var $this = $(this);
      @@ -451,7 +451,7 @@ db.web.ViewManagerAction = db.web.ViewManager.extend(/** @lends oepnerp.web.View
               var grandparent = this.widget_parent && this.widget_parent.widget_parent;
               // display shortcuts if on the first view for the action
               var $shortcut_toggle = this.$element.find('.oe-shortcut-toggle');
      -        if (!(grandparent instanceof db.web.WebClient) ||
      +        if (!(grandparent instanceof session.web.WebClient) ||
                   !(view.view_type === this.views_src[0].view_type
                       && view.view_id === this.views_src[0].view_id)) {
                   $shortcut_toggle.hide();
      @@ -488,7 +488,7 @@ db.web.ViewManagerAction = db.web.ViewManager.extend(/** @lends oepnerp.web.View
            * Intercept do_action resolution from children views
            */
           on_action_executed: function () {
      -        return new db.web.DataSet(this, 'res.log')
      +        return new session.web.DataSet(this, 'res.log')
                       .call('get', [], this.do_display_log);
           },
           /**
      @@ -515,7 +515,7 @@ db.web.ViewManagerAction = db.web.ViewManager.extend(/** @lends oepnerp.web.View
           }
       });
       
      -db.web.Sidebar = db.web.Widget.extend({
      +session.web.Sidebar = session.web.Widget.extend({
           init: function(parent, element_id) {
               this._super(parent, element_id);
               this.items = {};
      @@ -524,7 +524,7 @@ db.web.Sidebar = db.web.Widget.extend({
           start: function() {
               this._super(this);
               var self = this;
      -        this.$element.html(db.web.qweb.render('Sidebar'));
      +        this.$element.html(session.web.qweb.render('Sidebar'));
               this.$element.find(".toggle-sidebar").click(function(e) {
                   self.do_toggle();
               });
      @@ -601,7 +601,7 @@ db.web.Sidebar = db.web.Widget.extend({
       
               if(!$section) {
                   section_id = _.uniqueId(this.element_id + '_section_' + code + '_');
      -            var $section = $(db.web.qweb.render("Sidebar.section", {
      +            var $section = $(session.web.qweb.render("Sidebar.section", {
                       section_id: section_id,
                       name: name,
                       classname: 'oe_sidebar_' + code,
      @@ -633,7 +633,7 @@ db.web.Sidebar = db.web.Widget.extend({
                       this.items[items[i].element_id] = items[i];
                   }
       
      -            var $items = $(db.web.qweb.render("Sidebar.section.items", {items: items}));
      +            var $items = $(session.web.qweb.render("Sidebar.section.items", {items: items}));
       
                   $items.find('a.oe_sidebar_action_a').click(function() {
                       var item = self.items[$(this).attr('id')];
      @@ -687,7 +687,7 @@ db.web.Sidebar = db.web.Widget.extend({
           }
       });
       
      -db.web.TranslateDialog = db.web.Dialog.extend({
      +session.web.TranslateDialog = session.web.Dialog.extend({
           dialog_title: _t("Translations"),
           init: function(view) {
               // TODO fme: should add the language to fields_view_get because between the fields view get
      @@ -707,14 +707,14 @@ db.web.TranslateDialog = db.web.Dialog.extend({
               this.translatable_fields_keys = _.map(this.view.translatable_fields || [], function(i) { return i.name });
               this.languages = null;
               this.languages_loaded = $.Deferred();
      -        (new db.web.DataSetSearch(this, 'res.lang', this.view.dataset.get_context(),
      +        (new session.web.DataSetSearch(this, 'res.lang', this.view.dataset.get_context(),
                   [['translatable', '=', '1']])).read_slice(['code', 'name'], { sort: 'id' }, this.on_languages_loaded);
           },
           start: function() {
               var self = this;
               this._super();
               $.when(this.languages_loaded).then(function() {
      -            self.$element.html(db.web.qweb.render('TranslateDialog', { widget: self }));
      +            self.$element.html(session.web.qweb.render('TranslateDialog', { widget: self }));
                   self.$element.tabs();
                   if (!(self.view.translatable_fields && self.view.translatable_fields.length)) {
                       self.hide_tabs('fields');
      @@ -819,7 +819,7 @@ db.web.TranslateDialog = db.web.Dialog.extend({
           }
       });
       
      -db.web.View = db.web.Widget.extend(/** @lends db.web.View# */{
      +session.web.View = session.web.Widget.extend(/** @lends session.web.View# */{
           template: "EmptyComponent",
           set_default_options: function(options) {
               this.options = options || {};
      @@ -833,7 +833,7 @@ db.web.View = db.web.Widget.extend(/** @lends db.web.View# */{
           },
           open_translate_dialog: function(field) {
               if (!this.translate_dialog) {
      -            this.translate_dialog = new db.web.TranslateDialog(this).start();
      +            this.translate_dialog = new session.web.TranslateDialog(this).start();
               }
               this.translate_dialog.open(field);
           },
      @@ -845,7 +845,7 @@ db.web.View = db.web.Widget.extend(/** @lends db.web.View# */{
            * @param {String} [action_data.special=null] special action handlers (currently: only ``'cancel'``)
            * @param {String} [action_data.type='workflow'] the action type, if present, one of ``'object'``, ``'action'`` or ``'workflow'``
            * @param {Object} [action_data.context=null] additional action context, to add to the current context
      -     * @param {db.web.DataSet} dataset a dataset object used to communicate with the server
      +     * @param {session.web.DataSet} dataset a dataset object used to communicate with the server
            * @param {Object} [record_id] the identifier of the object on which the action is to be applied
            * @param {Function} on_closed callback to execute when dialog is closed or when the action does not generate any result (no new action)
            */
      @@ -857,12 +857,12 @@ db.web.View = db.web.Widget.extend(/** @lends db.web.View# */{
                       return self.widget_parent.on_action_executed.apply(null, arguments);
                   }
               };
      -        var context = new db.web.CompoundContext(dataset.get_context(), action_data.context || {});
      +        var context = new session.web.CompoundContext(dataset.get_context(), action_data.context || {});
               
               var handler = function (r) {
                   var action = r.result;
                   if (action && action.constructor == Object) {
      -                var ncontext = new db.web.CompoundContext(context);
      +                var ncontext = new session.web.CompoundContext(context);
                       if (record_id) {
                           ncontext.add({
                               active_id: record_id,
      @@ -899,7 +899,7 @@ db.web.View = db.web.Widget.extend(/** @lends db.web.View# */{
           /**
            * Directly set a view to use instead of calling fields_view_get. This method must
            * be called before start(). When an embedded view is set, underlying implementations
      -     * of db.web.View must use the provided view instead of any other one.
      +     * of session.web.View must use the provided view instead of any other one.
            *
            * @param embedded_view A view.
            */
      @@ -917,7 +917,7 @@ db.web.View = db.web.Widget.extend(/** @lends db.web.View# */{
           },
           on_sidebar_manage_views: function() {
               if (this.fields_view && this.fields_view.arch) {
      -            $('' + db.web.json_node_to_xml(this.fields_view.arch, true) + '').dialog({ width: '95%', height: 600});
      +            $('' + session.web.json_node_to_xml(this.fields_view.arch, true) + '').dialog({ width: '95%', height: 600});
               } else {
                   this.do_warn("Manage Views", "Could not find current view declaration");
               }
      @@ -929,11 +929,11 @@ db.web.View = db.web.Widget.extend(/** @lends db.web.View# */{
               console.log('Todo');
           },
           on_sidebar_import: function() {
      -        var import_view = new db.web.DataImport(this, this.dataset);
      +        var import_view = new session.web.DataImport(this, this.dataset);
               import_view.start();
           },
           on_sidebar_export: function() {
      -        var export_view = new db.web.DataExport(this, this.dataset);
      +        var export_view = new session.web.DataExport(this, this.dataset);
               export_view.start();
           },
           on_sidebar_translate: function() {
      @@ -943,7 +943,7 @@ db.web.View = db.web.Widget.extend(/** @lends db.web.View# */{
           }
       });
       
      -db.web.json_node_to_xml = function(node, single_quote, indent) {
      +session.web.json_node_to_xml = function(node, single_quote, indent) {
           // For debugging purpose, this function will convert a json node back to xml
           // Maybe usefull for xml view editor
       
      @@ -972,7 +972,7 @@ db.web.json_node_to_xml = function(node, single_quote, indent) {
               r += '>\n';
               var childs = [];
               for (var i = 0, ii = node.children.length; i < ii; i++) {
      -            childs.push(db.web.json_node_to_xml(node.children[i], single_quote, indent + 1));
      +            childs.push(session.web.json_node_to_xml(node.children[i], single_quote, indent + 1));
               }
               r += childs.join('\n');
               r += '\n' + sindent + '';
      -- 
      cgit v1.2.3
      
      
      From 276cff1807bfda7851845d977be058b388b1d67b Mon Sep 17 00:00:00 2001
      From: kbh 
      Date: Tue, 25 Oct 2011 11:31:42 +0530
      Subject: [IMP] Remove unnecessary code in checkbutton select all/none in list
       view.
      
      bzr revid: kbh@bde-desktop-20111025060142-47y025oqteocdgj3
      ---
       addons/web/static/src/js/view_list.js | 4 ----
       1 file changed, 4 deletions(-)
      
      (limited to 'addons/web/static/src')
      
      diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js
      index 1f8430df8a2..6a08b2c3160 100644
      --- a/addons/web/static/src/js/view_list.js
      +++ b/addons/web/static/src/js/view_list.js
      @@ -275,10 +275,6 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
               }
           },
       
      -    do_all_checked:function (ev) {
      -        var all_checkbox = this.$element.find('.oe-record-selector :checkbox')
      -        all_checkbox.attr('checked', !all_checkbox.attr('checked'));
      -    },
           /**
            * Configures the ListView pager based on the provided dataset's information
            *
      -- 
      cgit v1.2.3
      
      
      From fa94cf757893db64b840cfb011c69a76aacb794a Mon Sep 17 00:00:00 2001
      From: kbh 
      Date: Tue, 25 Oct 2011 11:54:29 +0530
      Subject: [IMP] Remove unnecessary code in checkbutton select all/none in list
       view.
      
      bzr revid: kbh@bde-desktop-20111025062429-dvx4x0h1caqwg21i
      ---
       addons/web/static/src/js/view_list.js | 1 -
       1 file changed, 1 deletion(-)
      
      (limited to 'addons/web/static/src')
      
      diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js
      index 6a08b2c3160..29decd946f6 100644
      --- a/addons/web/static/src/js/view_list.js
      +++ b/addons/web/static/src/js/view_list.js
      @@ -207,7 +207,6 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
                       self.$element.find('.all-record-selector').prop('checked')  || false);
               });
       
      -        this.$element.find('#all_checked').click(this.do_all_checked);
               this.$element.find('.oe-list-add')
                       .click(this.do_add_record)
                       .attr('disabled', grouped && this.options.editable);
      -- 
      cgit v1.2.3
      
      
      From 96339d71609b4e51b59341026cb1882abe16ed56 Mon Sep 17 00:00:00 2001
      From: "Yogesh (OpenERP)" 
      Date: Tue, 25 Oct 2011 12:13:23 +0530
      Subject: [FIX]
      
      bzr revid: ysa@tinyerp.com-20111025064323-ds0o146bi1r83kd5
      ---
       addons/web/static/src/js/views.js | 2 +-
       1 file changed, 1 insertion(+), 1 deletion(-)
      
      (limited to 'addons/web/static/src')
      
      diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js
      index afcc87a40a7..10e53efa591 100644
      --- a/addons/web/static/src/js/views.js
      +++ b/addons/web/static/src/js/views.js
      @@ -917,7 +917,7 @@ session.web.View = session.web.Widget.extend(/** @lends session.web.View# */{
           },
           on_sidebar_manage_views: function() {
               if (this.fields_view && this.fields_view.arch) {
      -            var view_editor = new db.web.ViewEditor(this, this.$element, this.dataset, this.fields_view.arch);
      +            var view_editor = new session.web.ViewEditor(this, this.$element, this.dataset, this.fields_view.arch);
                   view_editor.start();
               } else {
                   this.do_warn("Manage Views", "Could not find current view declaration");
      -- 
      cgit v1.2.3
      
      
      From ba2f06a2ac17699cf33ccaaa2479f8a51f0b6970 Mon Sep 17 00:00:00 2001
      From: Xavier Morel 
      Date: Tue, 25 Oct 2011 09:06:26 +0200
      Subject: [ADD] missing deferred propagation in ListView.reload_content
      
      bzr revid: xmo@openerp.com-20111025070626-pxxp6virhhomb7kl
      ---
       addons/web/static/src/js/view_list.js | 5 +++++
       1 file changed, 5 insertions(+)
      
      (limited to 'addons/web/static/src')
      
      diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js
      index d09ec1d3035..4408cab8e3b 100644
      --- a/addons/web/static/src/js/view_list.js
      +++ b/addons/web/static/src/js/view_list.js
      @@ -424,10 +424,13 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
           },
           /**
            * re-renders the content of the list view
      +     *
      +     * @returns {$.Deferred} promise to content reloading
            */
           reload_content: function () {
               var self = this;
               this.records.reset();
      +        var reloaded = $.Deferred();
               this.$element.find('.oe-listview-content').append(
                   this.groups.render(function () {
                       if (self.dataset.index == null) {
      @@ -438,7 +441,9 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
                           }
                       }
                       self.compute_aggregates();
      +                reloaded.resolve();
                   }));
      +        return reloaded.promise();
           },
           /**
            * Handler for the result of eval_domain_and_context, actually perform the
      -- 
      cgit v1.2.3
      
      
      From 55ad46220db83d2f5d6dd86d243d0d9843b74511 Mon Sep 17 00:00:00 2001
      From: "Yogesh (OpenERP)" 
      Date: Tue, 25 Oct 2011 14:19:51 +0530
      Subject: [IMP] improve css and view.
      
      bzr revid: ysa@tinyerp.com-20111025084951-0ty7vt1kfw0nrykr
      ---
       addons/web/static/src/css/base.css | 26 +++++++++++++++++---
       addons/web/static/src/xml/base.xml | 50 +++++++++++++++++++-------------------
       2 files changed, 47 insertions(+), 29 deletions(-)
      
      (limited to 'addons/web/static/src')
      
      diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css
      index 34ec885b2a9..88d419c4059 100644
      --- a/addons/web/static/src/css/base.css
      +++ b/addons/web/static/src/css/base.css
      @@ -1410,12 +1410,30 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after {
           border-color: rgba(0,0,0,0);
           border-left-color: #B5B9FF;
       }
      -.openerp .view_editor{
      +.openerp .oe_view_editor {
      +    border-collapse: collapse;
      +    padding: 0;
      +    align: left;
      +    width: 100%;
      +}
      +.openerp .oe_view_editor_colum{
           font-size: 90%;
           font-weight: normal;
      -    height : 10%;
           padding: 0;
           border-bottom: 1px solid #CFCCCC;
       }
      -
      -
      +.openerp .oe_view_editor_row:hover{
      +    background-color: #F3F3F3;
      +}
      +.openerp .oe_view_editor_tree_grid{
      +    text-align: left;
      +    white-space: nowrap;
      +    border-collapse: collapse;
      +    width: 100%;
      +}
      +.openerp .oe_view_editor_tree_grid a:hover {
      +    color: blue;
      +}
      +.openerp .oe_view_editor_tree_grid a {
      +    display: block;
      +}
      diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml
      index 27a99f61c05..323854fa7a3 100644
      --- a/addons/web/static/src/xml/base.xml
      +++ b/addons/web/static/src/xml/base.xml
      @@ -1279,17 +1279,17 @@
           
       
       
      -    
      +    
      -
- + + -
+
- + @@ -1297,36 +1297,36 @@
- + - - - - - + + + + + Export -- cgit v1.2.3 From b6a0874f4cc406788f0bf7045e279f43f8bd82ed Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 25 Oct 2011 10:51:12 +0200 Subject: [FIX] disgusting hack to skip around race condition When clicking on an action button, form view first saves then executes the action. In doing so, it causes the o2m field to call ListView#reload_content twice without waiting for the reloading to end, generating a race condition in ListView.List#render_dataset. As a result, the read_slice callback fills the list twice (once for each #reload_content call), resulting in everything being duplicated. Clear the content of the records collection before adding stuff. note: collections should dedup on ids. lp bug: https://launchpad.net/bugs/877965 fixed bzr revid: xmo@openerp.com-20111025085112-q38q8m0k2mopwadg --- addons/web/static/src/js/view_list.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 4408cab8e3b..bf6f79b9cc0 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -1206,6 +1206,10 @@ openerp.web.ListView.Groups = openerp.web.Class.extend( /** @lends openerp.web.L var options = { offset: page * limit, limit: limit }; //TODO xmo: investigate why we need to put the setTimeout setTimeout(function() {dataset.read_slice(fields, options , function (records) { + // FIXME: ignominious hacks, parents (aka form view) should not send two ListView#reload_content concurrently + if (self.records.length) { + self.records.reset(null, {silent: true}); + } if (!self.datagroup.openable) { view.configure_pager(dataset); } else { @@ -1546,7 +1550,8 @@ var Collection = openerp.web.Class.extend(/** @lends Collection# */{ * @param {Array} [records] * @returns this */ - reset: function (records) { + reset: function (records, options) { + options = options || {}; _(this._proxies).each(function (proxy) { proxy.reset(); }); @@ -1557,7 +1562,9 @@ var Collection = openerp.web.Class.extend(/** @lends Collection# */{ if (records) { this.add(records); } - this.trigger('reset', this); + if (!options.silent) { + this.trigger('reset', this); + } return this; }, /** -- cgit v1.2.3 From 1ee677eadbfa3e4c7d9836c48bea735f41f6a5a7 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Tue, 25 Oct 2011 16:40:12 +0530 Subject: [IMP]implement save and move functionality with all type of views and tag. bzr revid: vme@tinyerp.com-20111025111012-o991yy8rm666yk91 --- addons/web/static/src/js/view_editor.js | 99 ++++++++++++++++++++++----------- 1 file changed, 65 insertions(+), 34 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index a645593f437..29a3f083883 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -77,10 +77,8 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ if (attrs.nodeName == "name") { render_name += ' ' + attrs.nodeName + '=' + '"' + attrs.nodeValue + '"'; } } - if (attrs.nodeName != "position") { - obj.att_list.push( [attrs.nodeName,attrs.nodeValue] ); - } - }); + obj.att_list.push( [attrs.nodeName,attrs.nodeValue] ); + }); render_name+= ">"; }); obj.name = render_name; @@ -189,7 +187,13 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ check_list.push(_.without($.trim(part.replace(/[^a-zA-Z 0-9 _]+/g,'!')).split("!"),"")); }); } else { - check_list = [_.flatten(xpath_object[0].child_id[0].att_list)]; + var temp = []; + _.each(xpath_object[0].child_id[0].att_list, function(list){ + if(!_.include(list, "position")){ + temp.push(list); + } + }); + check_list = [_.flatten(temp)]; } self.full_path_search(check_list ,one_object ,xpath_object); }); @@ -345,10 +349,13 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } } } - if (last_tr.length != 0 && parseInt(last_tr.attr('level')) == level) { + if (last_tr.length != 0 + && parseInt(last_tr.attr('level')) == level + && ($(last_tr).find('a').text()).search("view_id") == -1) { _.each(list_shift, function(rec) { $(last_tr).before(rec); }); + self.save_move_arch(one_object, view_id, view_xml_id, id_tr, level, "up"); } break; case "side-down": @@ -379,25 +386,40 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ last_tr = next_tr; } } + list_shift.reverse(); - _.each(list_shift, function(rec) { - $(last_tr).after(rec); - }); - self.save_move_arch(one_object, view_id, view_xml_id, id_tr, level); + if(($(side.next()).find('a').text()).search("view_id") == -1){ + _.each(list_shift, function(rec) { + $(last_tr).after(rec); + }); + self.save_move_arch(one_object, view_id, view_xml_id, id_tr, level, "down"); + } } break; } }); }, - save_move_arch: function(one_object, view_id, view_xml_id, id_tr, level){ + + save_move_arch: function(one_object, view_id, view_xml_id, id_tr, level, move_direct){ var self = this; var arch = _.detect(one_object['arch'],function(element){ return element.view_id == view_id; }); var obj = self.get_view_object(view_xml_id, one_object['main_object'], []); + if(($(arch.arch).filter("data")).length != 0 && view_xml_id != 0){ + var check_list = _.flatten(obj[0].child_id[0].att_list); + arch.arch = _.detect($(arch.arch).children(), function(xml_child){ + var temp_obj = self.check_attr(xml_child, xml_child.tagName.toLowerCase()); + var main_list = _.flatten(temp_obj.att_list); + check_list = _.uniq(check_list); + var insert = _.intersection(main_list,check_list); + if(insert.length == check_list.length ){return xml_child;} + }); + } return self.get_node(arch.arch, obj[0].child_id[0], parseInt(id_tr), [], parseInt(level), - parseInt(view_id), arch); + parseInt(view_id), arch, move_direct); }, + get_view_object: function(view_xml_id, one_object,result){ var self = this; if(result.length==0){ @@ -411,42 +433,49 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } return result; }, - get_node: function(arch1, obj, id, child_list, level, view_id, arch){ + + get_node: function(arch1, obj, id, child_list, level, view_id, arch, move_direct){ var self = this; - console.log(obj.id,id); var children_list = $(arch1).children(); - if(obj.level <= level){ - if(parseInt(id) == obj.id){ - var next = $(arch1).next() - $(next).after(arch1); + var list_obj_xml = _.zip(children_list,obj.child_id); + if(id){ + if(obj.id == id){ + var id; var parent = $(arch1).parents(); - console.log(id,"--------",obj.id); - console.log(next,"========",arch1); + var index = _.indexOf(child_list,obj) + var re_insert_obj = child_list.splice(index,1); + if(move_direct == "down"){ + var next = $(arch1).next(); + $(next).after(arch1); + child_list.splice(index+1, 0, re_insert_obj[0]); + }else{ + var prev = $(arch1).prev(); + $(prev).before(arch1); + child_list.splice(index-1, 0, re_insert_obj[0]); + } parent = parent[parent.length-1]; var convert_to_utf = ""; - var s = new XMLSerializer(); - var stream = { - write : function(string) + var xml_serilalizer = new XMLSerializer(); + var stream = { + write : function(string) {convert_to_utf = convert_to_utf + string + "";} - }; - var index = _.indexOf(child_list,obj) - var re_insert_obj = child_list.splice(index,1); - child_list.splice(index+1, 0, re_insert_obj[0]); - s.serializeToStream(parent, stream, "UTF-8"); + }; + xml_serilalizer.serializeToStream(parent, stream, "UTF-8"); convert_to_utf = convert_to_utf.replace('xmlns="http://www.w3.org/1999/xhtml"', ""); convert_to_utf = '' + convert_to_utf; arch.arch = convert_to_utf; dataset = new openerp.web.DataSet(this, 'ir.ui.view'); - dataset.write(parseInt(view_id),{"arch":convert_to_utf},function(r){ + dataset.write(parseInt(view_id),{"arch":convert_to_utf},function(r){ + }); + } + if(obj.level <= level){ + _.each(list_obj_xml, function(child_node){ + self.get_node(child_node[0], child_node[1], id, obj.child_id, level, view_id, arch, move_direct); }); - }else{ - for(var i=0;i< children_list.length; i++){ - if(obj.child_id){var child_list = obj.child_id}; - self.get_node(children_list[i], obj.child_id[i], id, child_list, level, view_id, arch); - } } } }, + on_expand: function(self){ var level = parseInt($(self).closest("tr[id^='viewedit-']").attr('level')); var cur_tr = $(self).closest("tr[id^='viewedit-']"); @@ -458,6 +487,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } else return nxt_tr; } }, + on_collapse: function(self, parent_child_id, id, main_object) { var id = self.id.split('-')[1]; var datas = _.detect(parent_child_id,function(res) { @@ -469,5 +499,6 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ tr.show(); }); } + }); }; -- cgit v1.2.3 From a34f06dd4cb617227cd68b955ba65c6d7d18eda2 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Tue, 25 Oct 2011 14:42:51 +0200 Subject: [imp] changed default mode of o2m to tree (was tree,form) bzr revid: nicolas.vanhoren@openerp.com-20111025124251-uy67cprw499wcb7c --- addons/web/static/src/js/view_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 1f1b5b8ef6f..d227b091645 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1936,7 +1936,7 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ }); var modes = this.node.attrs.mode; - modes = !!modes ? modes.split(",") : ["tree", "form"]; + modes = !!modes ? modes.split(",") : ["tree"]; var views = []; _.each(modes, function(mode) { var view = { -- cgit v1.2.3 From 7451d66e4b2e59c926d0746dc8767f763b1e218d Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 25 Oct 2011 15:23:26 +0200 Subject: [ADD] search: prefix to the view title when the current view is searchable: bzr revid: xmo@openerp.com-20111025132326-83i1t2adn4o5vsjo --- addons/web/static/src/js/views.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index b7a3d185bc1..78abe6a8fdb 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -444,6 +444,16 @@ session.web.ViewManagerAction = session.web.ViewManager.extend(/** @lends oepner if (!self.action.name && fvg) { self.$element.find('.oe_view_title').text(fvg.arch.attrs.string || fvg.name); } + + var $title = self.$element.find('.oe_view_title'), + $search_prefix = $title.find('span'); + if (controller.searchable !== false) { + if (!$search_prefix.length) { + $title.prepend('' + _t("Search:") + ''); + } + } else { + $search_prefix.remove(); + } }); }, shortcut_check : function(view) { -- cgit v1.2.3 From 69f909a9a16e55f17e4bb76324ce8b2f21670dac Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 25 Oct 2011 15:24:12 +0200 Subject: [REN] 'New' button of ListView to 'Create' bzr revid: xmo@openerp.com-20111025132412-4vx57uf1vipcyfkq --- addons/web/static/src/js/view_list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 32ed7cf0741..0db60c72c07 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -11,7 +11,7 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# // whether the column headers should be displayed 'header': true, // display addition button, with that label - 'addable': _t("New"), + 'addable': _t("Create"), // whether the list view can be sorted, note that once a view has been // sorted it can not be reordered anymore 'sortable': true, -- cgit v1.2.3 From 59c9d34417feb2f4ac84efb2cf2fe153dc864276 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 25 Oct 2011 16:37:38 +0200 Subject: [ADD] title to all viewmanager variants Uses the string of the current view arch by default, overridden with action name by ViewManagerAction. Mostly of use for/with o2m and m2m fields bzr revid: xmo@openerp.com-20111025143738-yugscol5kabg8whv --- addons/web/static/src/js/views.js | 17 ++++++++++++++++- addons/web/static/src/xml/base.xml | 6 +++--- 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 78abe6a8fdb..3c1889e66c9 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -271,6 +271,10 @@ session.web.ViewManager = session.web.Widget.extend(/** @lends session.web.View } } } + $.when(view_promise).then(function () { + self.$element.find('.oe_view_title:first').text( + self.display_title()); + }); return view_promise; }, /** @@ -331,7 +335,15 @@ session.web.ViewManager = session.web.Widget.extend(/** @lends session.web.View /** * Called by children view after executing an action */ - on_action_executed: function () {} + on_action_executed: function () {}, + display_title: function () { + var view = this.views[this.active_view]; + if (view) { + // ick + return view.controller.fields_view.arch.attrs.string; + } + return ''; + } }); session.web.ViewManagerAction = session.web.ViewManager.extend(/** @lends oepnerp.web.ViewManagerAction# */{ @@ -522,6 +534,9 @@ session.web.ViewManagerAction = session.web.ViewManager.extend(/** @lends oepner return false; }); }); + }, + display_title: function () { + return this.action.name; } }); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 7e081520ffc..da96ad8be8b 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -415,6 +415,9 @@ +
+ - - - - -
- + - + + - + + - + + + + id="side-down" src="/web/static/src/img/icons/gtk-go-down.png" style="cursor: pointer;"/>
+

+ +

-

- -

    -- cgit v1.2.3 From dd514b567dbdf30e9367c827965c7c936d51453a Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Tue, 25 Oct 2011 18:20:31 +0200 Subject: [imp] made m2m support readonly bzr revid: nicolas.vanhoren@openerp.com-20111025162031-wsjaebu713nht3i1 --- addons/web/static/src/js/view_form.js | 53 +++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 12 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index d227b091645..e3584c21c13 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2196,6 +2196,7 @@ openerp.web.form.FieldMany2Many = openerp.web.form.Field.extend({ this._super(view, node); this.list_id = _.uniqueId("many2many"); this.is_started = $.Deferred(); + this.is_setted = $.Deferred(); }, start: function() { this._super.apply(this, arguments); @@ -2207,18 +2208,10 @@ openerp.web.form.FieldMany2Many = openerp.web.form.Field.extend({ this.dataset.on_unlink.add_last(function(ids) { self.on_ui_change(); }); - - this.list_view = new openerp.web.form.Many2ManyListView(this, this.dataset, false, { - 'addable': 'Add', - 'selectable': self.multi_selection - }); - this.list_view.m2m_field = this; - this.list_view.on_loaded.add_last(function() { - self.is_started.resolve(); + + this.is_setted.then(function() { + self.load_view(); }); - setTimeout(function () { - self.list_view.appendTo($("#" + self.list_id)); - }, 0); }, set_value: function(value) { value = value || []; @@ -2229,15 +2222,51 @@ openerp.web.form.FieldMany2Many = openerp.web.form.Field.extend({ this.dataset.set_ids(value); var self = this; $.when(this.is_started).then(function() { + console.log("lalala"); self.list_view.reload_content(); }); + this.is_setted.resolve(); }, get_value: function() { return [commands.replace_with(this.dataset.ids)]; }, validate: function() { this.invalid = false; - // TODO niv + }, + load_view: function() { + console.info("yop"); + var self = this; + this.list_view = new openerp.web.form.Many2ManyListView(this, this.dataset, false, { + 'addable': self.readonly ? null : 'Add', + 'deletable': self.readonly ? false : true, + 'selectable': self.multi_selection + }); + this.list_view.m2m_field = this; + var loaded = $.Deferred(); + this.list_view.on_loaded.add_last(function() { + self.is_started.resolve(); + loaded.resolve(); + }); + setTimeout(function () { + self.list_view.appendTo($("#" + self.list_id)); + }, 0); + return loaded; + }, + update_dom: function() { + this._super.apply(this, arguments); + var self = this; + if (this.previous_readonly !== this.readonly) { + this.previous_readonly = this.readonly; + if (this.list_view) { + $.when(this.is_started).then(function() { + self.list_view.stop(); + $.when(self.load_view()).then(function() { + console.log("lalala2"); + self.list_view.reload_content(); + }); + }); + } + } } }); -- cgit v1.2.3 From 20e5cb63a43dcd135f3b3ecedb2e7d444c3dc53b Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 25 Oct 2011 18:35:31 +0200 Subject: [FIX] json_node_to_xml: whitespaces wrongly inserted around text nodes causing bugs in kanban views. bzr revid: fme@openerp.com-20111025163531-nxr8gb4j2f7wne2a --- addons/web/static/src/js/views.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 78abe6a8fdb..41be7a18286 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -953,19 +953,19 @@ session.web.View = session.web.Widget.extend(/** @lends session.web.View# */{ } }); -session.web.json_node_to_xml = function(node, single_quote, indent) { +session.web.json_node_to_xml = function(node, human_readable, indent) { // For debugging purpose, this function will convert a json node back to xml // Maybe usefull for xml view editor + indent = indent || 0; + var sindent = (human_readable ? (new Array(indent + 1).join('\t')) : ''), + r = sindent + '<' + node.tag, + cr = human_readable ? '\n' : ''; if (typeof(node) === 'string') { - return node; - } - else if (typeof(node.tag) !== 'string' || !node.children instanceof Array || !node.attrs instanceof Object) { + return sindent + node; + } else if (typeof(node.tag) !== 'string' || !node.children instanceof Array || !node.attrs instanceof Object) { throw("Node a json node"); } - indent = indent || 0; - var sindent = new Array(indent + 1).join('\t'), - r = sindent + '<' + node.tag; for (var attr in node.attrs) { var vattr = node.attrs[attr]; if (typeof(vattr) !== 'string') { @@ -973,19 +973,19 @@ session.web.json_node_to_xml = function(node, single_quote, indent) { vattr = JSON.stringify(vattr); } vattr = vattr.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); - if (single_quote) { + if (human_readable) { vattr = vattr.replace(/"/g, "'"); } r += ' ' + attr + '="' + vattr + '"'; } if (node.children && node.children.length) { - r += '>\n'; + r += '>' + cr; var childs = []; for (var i = 0, ii = node.children.length; i < ii; i++) { - childs.push(session.web.json_node_to_xml(node.children[i], single_quote, indent + 1)); + childs.push(session.web.json_node_to_xml(node.children[i], human_readable, indent + 1)); } - r += childs.join('\n'); - r += '\n' + sindent + ''; + r += childs.join(cr); + r += cr + sindent + ''; return r; } else { return r + '/>'; -- cgit v1.2.3 From de31afa995eb169a92c75dbad930b917252c7f78 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 25 Oct 2011 20:50:30 +0200 Subject: [FIX] Password fields values are not hidden lp bug: https://launchpad.net/bugs/880804 fixed bzr revid: fme@openerp.com-20111025185030-vw69honpjoaekh2v --- addons/web/static/src/js/view_form.js | 11 +++++++++++ addons/web/static/src/xml/base.xml | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index e3584c21c13..c701f21fee1 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1170,6 +1170,10 @@ openerp.web.form.Field = openerp.web.form.Widget.extend(/** @lends openerp.web.f openerp.web.form.FieldChar = openerp.web.form.Field.extend({ template: 'FieldChar', + init: function (view, node) { + this._super(view, node); + this.password = this.node.attrs.password === 'True' || this.node.attrs.password === '1'; + }, start: function() { this._super.apply(this, arguments); this.$element.find('input').change(this.on_ui_change); @@ -2858,9 +2862,16 @@ openerp.web.form.FieldReadonly = openerp.web.form.Field.extend({ }); openerp.web.form.FieldCharReadonly = openerp.web.form.FieldReadonly.extend({ template: 'FieldChar.readonly', + init: function(view, node) { + this._super(view, node); + this.password = this.node.attrs.password === 'True' || this.node.attrs.password === '1'; + }, set_value: function (value) { this._super.apply(this, arguments); var show_value = openerp.web.format_value(value, this, ''); + if (this.password) { + show_value = new Array(show_value.length + 1).join('*'); + } this.$element.find('div').text(show_value); return show_value; } diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 7e081520ffc..7b330cd8112 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -763,7 +763,7 @@

    - Date: Wed, 26 Oct 2011 10:25:43 +0200 Subject: [IMP] Add underscore ( '_' ) lib in default rendering context of the qweb instance used in the webclient bzr revid: fme@openerp.com-20111026082543-xsnfh298e0wb0ccw --- addons/web/static/src/js/core.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index 39a1ba7ef64..ab0247e81b4 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -1046,6 +1046,9 @@ openerp.web.TranslationDataBase = openerp.web.Class.extend(/** @lends openerp.we openerp.web._t = new openerp.web.TranslationDataBase().build_translation_function(); openerp.web.qweb = new QWeb2.Engine(); openerp.web.qweb.debug = (window.location.search.indexOf('?debug') !== -1); +openerp.web.qweb.default_dict = { + '_' : _ +} openerp.web.qweb.format_text_node = function(s) { // Note that 'this' is the Qweb Node of the text var translation = this.node.parentNode.attributes['t-translation']; -- cgit v1.2.3 From f0714ccd72b61f66d565a8f8b8073b66756ff44a Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Wed, 26 Oct 2011 12:05:38 +0200 Subject: [imp] removed useless logging bzr revid: nicolas.vanhoren@openerp.com-20111026100538-momcgi4s3lxy560l --- addons/web/static/src/js/view_form.js | 3 --- 1 file changed, 3 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index c701f21fee1..cf5d98bb3e6 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2226,7 +2226,6 @@ openerp.web.form.FieldMany2Many = openerp.web.form.Field.extend({ this.dataset.set_ids(value); var self = this; $.when(this.is_started).then(function() { - console.log("lalala"); self.list_view.reload_content(); }); this.is_setted.resolve(); @@ -2238,7 +2237,6 @@ openerp.web.form.FieldMany2Many = openerp.web.form.Field.extend({ this.invalid = false; }, load_view: function() { - console.info("yop"); var self = this; this.list_view = new openerp.web.form.Many2ManyListView(this, this.dataset, false, { 'addable': self.readonly ? null : 'Add', @@ -2265,7 +2263,6 @@ openerp.web.form.FieldMany2Many = openerp.web.form.Field.extend({ $.when(this.is_started).then(function() { self.list_view.stop(); $.when(self.load_view()).then(function() { - console.log("lalala2"); self.list_view.reload_content(); }); }); -- cgit v1.2.3 From 9a48657a45d132761f0c2ef8e62d964b55e3b8d7 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Wed, 26 Oct 2011 14:55:24 +0200 Subject: [imp] made o2m reload when readonly property is changed bzr revid: nicolas.vanhoren@openerp.com-20111026125524-c77rmzd6gq9u9oke --- addons/web/static/src/js/view_form.js | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index cf5d98bb3e6..0c8ee47ff66 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1939,6 +1939,13 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ self.on_ui_change(); }); + this.is_setted.then(function() { + self.load_views(); + }); + }, + load_views: function() { + var self = this; + var modes = this.node.attrs.mode; modes = !!modes ? modes.split(",") : ["tree"]; var views = []; @@ -1959,7 +1966,7 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ views.push(view); }); this.views = views; - + this.viewmanager = new openerp.web.ViewManager(this, this.dataset, views); this.viewmanager.registry = openerp.web.views.clone({ list: 'openerp.web.form.One2ManyListView', @@ -1968,6 +1975,9 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ var once = $.Deferred().then(function() { self.init_form_last_update.resolve(); }); + var def = $.Deferred().then(function() { + self.is_started.resolve(); + }); this.viewmanager.on_controller_inited.add_last(function(view_type, controller) { if (view_type == "list") { controller.o2m = self; @@ -1982,7 +1992,7 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ } else if (view_type == "graph") { self.reload_current_view() } - self.is_started.resolve(); + def.resolve(); }); this.viewmanager.on_mode_switch.add_first(function() { self.save_form_view(); @@ -1992,6 +2002,7 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ self.viewmanager.appendTo(self.$element); }, 0); }); + return def; }, reload_current_view: function() { var self = this; @@ -2131,7 +2142,18 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ }, update_dom: function() { this._super.apply(this, arguments); - this.$element.toggleClass('disabled', this.readonly); + var self = this; + if (this.previous_readonly !== this.readonly) { + this.previous_readonly = this.readonly; + if (this.viewmanager) { + $.when(this.is_started).then(function() { + self.viewmanager.stop(); + $.when(self.load_views()).then(function() { + self.reload_current_view(); + }); + }); + } + } } }); -- cgit v1.2.3 From 9988d503b193afb44855149bf3b8c7a3e76893ba Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Wed, 26 Oct 2011 16:11:48 +0200 Subject: [imp] implemented readonly in o2m in list view only bzr revid: nicolas.vanhoren@openerp.com-20111026141148-kl37triimsivvh9n --- addons/web/static/src/js/view_form.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 0c8ee47ff66..fd40f038e78 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1960,6 +1960,10 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ } if(view.view_type === "list") { view.options.selectable = self.multi_selection; + if (self.readonly) { + view.options.addable = null; + view.options.deletable = null; + } } else if (view.view_type === "form") { view.options.not_interactible_on_create = true; } @@ -1981,6 +1985,8 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ this.viewmanager.on_controller_inited.add_last(function(view_type, controller) { if (view_type == "list") { controller.o2m = self; + if (self.readonly) + controller.set_editable(false); } else if (view_type == "form") { controller.on_record_loaded.add_last(function() { once.resolve(); @@ -2197,6 +2203,8 @@ openerp.web.form.One2ManyListView = openerp.web.ListView.extend({ }, do_activate_record: function(index, id) { var self = this; + if (self.o2m.readonly) + return; var pop = new openerp.web.form.FormOpenPopup(self.o2m.view); pop.show_element(self.o2m.field.relation, id, self.o2m.build_context(),{ auto_write: false, -- cgit v1.2.3 From 08ef807c3b2e500544357c9d3daf1363f5df83fe Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Wed, 26 Oct 2011 16:42:18 +0200 Subject: [imp] implemented readonly in o2m in form view too bzr revid: nicolas.vanhoren@openerp.com-20111026144218-vn44rlkzo7vo0umq --- addons/web/static/src/js/view_form.js | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index fd40f038e78..2bc4cd50766 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -105,17 +105,7 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView# this.$form_header.find('button.oe_form_button_cancel').click(this.do_cancel); this.$form_header.find('button.oe_form_button_new').click(this.on_button_new); this.$form_header.find('button.oe_form_button_duplicate').click(this.on_button_duplicate); - this.$form_header.find('button.oe_form_button_toggle').click(function () { - self.translatable_fields = []; - self.widgets = {}; - self.fields = {}; - self.$form_header.find('button').unbind('click'); - self.registry = self.registry === openerp.web.form.widgets - ? openerp.web.form.readonly - : openerp.web.form.widgets; - self.on_loaded(self.fields_view); - self.reload(); - }); + this.$form_header.find('button.oe_form_button_toggle').click(this.on_toggle_readonly); if (this.options.sidebar && this.options.sidebar_id) { this.sidebar = new openerp.web.Sidebar(this, this.options.sidebar_id); @@ -127,6 +117,18 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView# } this.has_been_loaded.resolve(); }, + on_toggle_readonly: function() { + var self = this; + self.translatable_fields = []; + self.widgets = {}; + self.fields = {}; + self.$form_header.find('button').unbind('click'); + self.registry = self.registry === openerp.web.form.widgets + ? openerp.web.form.readonly + : openerp.web.form.widgets; + self.on_loaded(self.fields_view); + self.reload(); + }, do_show: function () { var promise; if (this.dataset.index === null) { @@ -1974,7 +1976,7 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ this.viewmanager = new openerp.web.ViewManager(this, this.dataset, views); this.viewmanager.registry = openerp.web.views.clone({ list: 'openerp.web.form.One2ManyListView', - form: 'openerp.web.form.One2ManyFormView' + form: 'openerp.web.FormView' }); var once = $.Deferred().then(function() { self.init_form_last_update.resolve(); @@ -1988,6 +1990,10 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ if (self.readonly) controller.set_editable(false); } else if (view_type == "form") { + if (self.readonly) { + controller.on_toggle_readonly(); + $(controller.$element.find(".oe_form_buttons")[0]).children().remove(); + } controller.on_record_loaded.add_last(function() { once.resolve(); }); @@ -2170,9 +2176,6 @@ openerp.web.form.One2ManyDataSet = openerp.web.BufferedDataSet.extend({ } }); -openerp.web.form.One2ManyFormView = openerp.web.FormView.extend({ -}); - openerp.web.form.One2ManyListView = openerp.web.ListView.extend({ do_add_record: function () { if (this.options.editable) { -- cgit v1.2.3 From 5bc7011b52f824878891a98c90f4d87ad5941a15 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Wed, 26 Oct 2011 17:23:05 +0200 Subject: [fix] race condition in m2m bzr revid: nicolas.vanhoren@openerp.com-20111026152305-t7rg7mn37h91swra --- addons/web/static/src/js/view_form.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 2bc4cd50766..29d7e70b6ed 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2232,7 +2232,8 @@ openerp.web.form.FieldMany2Many = openerp.web.form.Field.extend({ init: function(view, node) { this._super(view, node); this.list_id = _.uniqueId("many2many"); - this.is_started = $.Deferred(); + this.is_loaded = $.Deferred(); + this.initial_is_loaded = this.is_loaded; this.is_setted = $.Deferred(); }, start: function() { @@ -2258,9 +2259,7 @@ openerp.web.form.FieldMany2Many = openerp.web.form.Field.extend({ this._super(value); this.dataset.set_ids(value); var self = this; - $.when(this.is_started).then(function() { - self.list_view.reload_content(); - }); + self.reload_content(); this.is_setted.resolve(); }, get_value: function() { @@ -2279,7 +2278,7 @@ openerp.web.form.FieldMany2Many = openerp.web.form.Field.extend({ this.list_view.m2m_field = this; var loaded = $.Deferred(); this.list_view.on_loaded.add_last(function() { - self.is_started.resolve(); + self.initial_is_loaded.resolve(); loaded.resolve(); }); setTimeout(function () { @@ -2287,16 +2286,22 @@ openerp.web.form.FieldMany2Many = openerp.web.form.Field.extend({ }, 0); return loaded; }, + reload_content: function() { + var self = this; + this.is_loaded = this.is_loaded.pipe(function() { + return self.list_view.reload_content(); + }); + }, update_dom: function() { this._super.apply(this, arguments); var self = this; if (this.previous_readonly !== this.readonly) { this.previous_readonly = this.readonly; if (this.list_view) { - $.when(this.is_started).then(function() { + this.is_loaded = this.is_loaded.pipe(function() { self.list_view.stop(); - $.when(self.load_view()).then(function() { - self.list_view.reload_content(); + return $.when(self.load_view()).then(function() { + self.reload_content(); }); }); } -- cgit v1.2.3 From 5329b9273ade63e8dd7da67108361dfc8b21c731 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Wed, 26 Oct 2011 17:31:09 +0200 Subject: [fix] potential race condition in o2m bzr revid: nicolas.vanhoren@openerp.com-20111026153109-8pcjlo7c5ud6bkko --- addons/web/static/src/js/view_form.js | 42 ++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 29d7e70b6ed..78bacfd37d0 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1923,7 +1923,8 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ multi_selection: false, init: function(view, node) { this._super(view, node); - this.is_started = $.Deferred(); + this.is_loaded = $.Deferred(); + this.initial_is_loaded = this.is_loaded; this.is_setted = $.Deferred(); this.form_last_update = $.Deferred(); this.init_form_last_update = this.form_last_update; @@ -1982,7 +1983,7 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ self.init_form_last_update.resolve(); }); var def = $.Deferred().then(function() { - self.is_started.resolve(); + self.initial_is_loaded.resolve(); }); this.viewmanager.on_controller_inited.add_last(function(view_type, controller) { if (view_type == "list") { @@ -2018,20 +2019,23 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ }, reload_current_view: function() { var self = this; - var view = self.viewmanager.views[self.viewmanager.active_view].controller; - if(self.viewmanager.active_view === "list") { - view.reload_content(); - } else if (self.viewmanager.active_view === "form") { - if (this.dataset.index === null && this.dataset.ids.length >= 1) { - this.dataset.index = 0; - } - var act = function() { - return view.do_show(); + self.is_loaded = self.is_loaded.pipe(function() { + var view = self.viewmanager.views[self.viewmanager.active_view].controller; + if(self.viewmanager.active_view === "list") { + return view.reload_content(); + } else if (self.viewmanager.active_view === "form") { + if (self.dataset.index === null && self.dataset.ids.length >= 1) { + self.dataset.index = 0; + } + var act = function() { + return view.do_show(); + } + self.form_last_update = self.form_last_update.pipe(act, act); + return self.form_last_update; + } else if (self.viewmanager.active_view === "graph") { + return view.do_search(self.build_domain(), self.dataset.get_context(), []); } - this.form_last_update = this.form_last_update.pipe(act, act);; - } else if (self.viewmanager.active_view === "graph") { - view.do_search(this.build_domain(), this.dataset.get_context(), []); - } + }); }, set_value: function(value) { value = value || []; @@ -2088,9 +2092,7 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ if (this.dataset.index === null && this.dataset.ids.length > 0) { this.dataset.index = 0; } - $.when(this.is_started).then(function() { - self.reload_current_view(); - }); + self.reload_current_view(); this.is_setted.resolve(); }, get_value: function() { @@ -2158,9 +2160,9 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ if (this.previous_readonly !== this.readonly) { this.previous_readonly = this.readonly; if (this.viewmanager) { - $.when(this.is_started).then(function() { + this.is_loaded = this.is_loaded.pipe(function() { self.viewmanager.stop(); - $.when(self.load_views()).then(function() { + return $.when(self.load_views()).then(function() { self.reload_current_view(); }); }); -- cgit v1.2.3 From 33c4580c039a5597f817baefb296c20d8e41e2d3 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Wed, 26 Oct 2011 17:39:44 +0200 Subject: [fix] problem when switching from form view to list view in o2m bzr revid: nicolas.vanhoren@openerp.com-20111026153944-bdk335em06dxxi2p --- addons/web/static/src/js/view_form.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 78bacfd37d0..796f577017f 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2007,8 +2007,11 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ } def.resolve(); }); - this.viewmanager.on_mode_switch.add_first(function() { - self.save_form_view(); + this.viewmanager.on_mode_switch.add_first(function(n_mode, b, c, d, e) { + $.when(self.save_form_view()).then(function() { + if(n_mode === "list") + setTimeout(function() {self.reload_current_view();}, 0); + }); }); this.is_setted.then(function() { setTimeout(function () { -- cgit v1.2.3 From 6acbb08aa786b4a890f2cc89ec4a5ec7888c41a9 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 27 Oct 2011 10:24:36 +0200 Subject: [ADD] method forcing the saving of a listview if it's being edited (and not doing anything if it's not) bzr revid: xmo@openerp.com-20111027082436-46zcjurzxtg5n9zt --- addons/web/static/src/js/view_list_editable.js | 83 +++++++++++++++++++------- 1 file changed, 61 insertions(+), 22 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index 4cc081a6266..94da157a866 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -78,6 +78,17 @@ openerp.web.list_editable = function (openerp) { // tree/@editable takes priority on everything else if present. this.options.editable = data.arch.attrs.editable || this.options.editable; return this._super(data, grouped); + }, + /** + * Ensures the editable list is saved (saves any pending edition if + * needed, or tries to) + * + * Returns a deferred to the end of the saving. + * + * @returns {$.Deferred} + */ + ensure_saved: function () { + return this.groups.ensure_saved(); } }); @@ -86,6 +97,18 @@ openerp.web.list_editable = function (openerp) { new_record: function () { // TODO: handle multiple children this.children[null].new_record(); + }, + /** + * Ensures descendant editable List instances are all saved if they have + * pending editions. + * + * @returns {$.Deferred} + */ + ensure_saved: function () { + return $.when.apply(null, + _.invoke( + _.values(this.children), + 'ensure_saved')); } }); @@ -254,9 +277,11 @@ openerp.web.list_editable = function (openerp) { * sibling if asked. * * @param {Boolean} [edit_next=false] should the next row become editable + * @returns {$.Deferred} */ save_row: function (edit_next) { - var self = this; + //noinspection JSPotentiallyInvalidConstructorUsage + var self = this, done = $.Deferred(); this.edition_form.do_save(function (result) { if (result.created && !self.edition_id) { self.records.add({id: result.result}, @@ -267,28 +292,42 @@ openerp.web.list_editable = function (openerp) { next_record = self.records.at( self.records.indexOf(edited_record) + 1); - self.handle_onwrite(self.edition_id); - self.cancel_pending_edition().then(function () { - $(self).trigger('saved', [self.dataset]); - if (!edit_next) { - return; - } - if (result.created) { - self.new_record(); - return; - } - var next_record_id; - if (next_record) { - next_record_id = next_record.get('id'); - self.dataset.index = _(self.dataset.ids) - .indexOf(next_record_id); - } else { - self.dataset.index = 0; - next_record_id = self.records.at(0).get('id'); - } - self.edit_record(next_record_id); - }); + $.when( + self.handle_onwrite(self.edition_id), + self.cancel_pending_edition().then(function () { + $(self).trigger('saved', [self.dataset]); + if (!edit_next) { + return; + } + if (result.created) { + self.new_record(); + return; + } + var next_record_id; + if (next_record) { + next_record_id = next_record.get('id'); + self.dataset.index = _(self.dataset.ids) + .indexOf(next_record_id); + } else { + self.dataset.index = 0; + next_record_id = self.records.at(0).get('id'); + } + self.edit_record(next_record_id); + })).then(function () { + done.resolve(); + }); }, this.options.editable === 'top'); + return done.promise(); + }, + /** + * If the current list is being edited, ensures it's saved + */ + ensure_saved: function () { + if (this.edition) { + return this.save_row(); + } + //noinspection JSPotentiallyInvalidConstructorUsage + return $.Deferred().resolve().promise(); }, /** * Cancels the edition of the row for the current dataset index -- cgit v1.2.3 From 8290deff05b0ffb4855f3232fd1b320633d86e4d Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 27 Oct 2011 10:36:17 +0200 Subject: [ADD] handle failure to save in ListView#ensure_saved: reject the deferred bzr revid: xmo@openerp.com-20111027083617-medipetfasqvfacq --- addons/web/static/src/js/view_list_editable.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index 94da157a866..dba0a1abba4 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -316,7 +316,9 @@ openerp.web.list_editable = function (openerp) { })).then(function () { done.resolve(); }); - }, this.options.editable === 'top'); + }, this.options.editable === 'top').fail(function () { + done.reject(); + }); return done.promise(); }, /** -- cgit v1.2.3 From d52a8f3f2080781489c85dfb9f1038c658d158eb Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 27 Oct 2011 11:57:07 +0200 Subject: [FIX] states-based row colors failing to apply on o2ms due to overly precise rule lp bug: https://launchpad.net/bugs/882175 fixed bzr revid: xmo@openerp.com-20111027095707-22brxk7fyg3w4svj --- addons/web/static/src/css/base.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 744d218a83b..e8f1ff9c3bb 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -846,7 +846,7 @@ label.error { .openerp .oe_frame.oe_forms { clear: both; } -.openerp table.oe_frame td { +.openerp table.oe_frame { color: #4c4c4c; } .openerp td.oe_form_frame_cell { -- cgit v1.2.3 From 66ea5439741704346a45441b009240797628636f Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 27 Oct 2011 14:43:25 +0200 Subject: [FIX] Add support for @align attribute in form views lp bug: https://launchpad.net/bugs/844625 fixed bzr revid: fme@openerp.com-20111027124325-ckd8kuujbb591nqu --- addons/web/static/src/css/base.css | 13 ++++++++++++- addons/web/static/src/js/view_form.js | 13 +++++++++++-- addons/web/static/src/xml/base.xml | 4 ++-- 3 files changed, 25 insertions(+), 5 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index e8f1ff9c3bb..ae73607aab0 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -874,7 +874,6 @@ label.error { } .openerp .oe_forms label.oe_label, .openerp .oe_forms label.oe_label_help { - text-align: right; margin: 3px 0 0 10px; } .openerp label.oe_label_help span { @@ -885,6 +884,18 @@ label.error { top: -4px; padding: 0 2px; } +.openerp .oe_align_left { + text-align: left; +} +.openerp .oe_align_right { + text-align: right; +} +.openerp .oe_align_center { + text-align: center; +} +.openerp .oe_forms .oe_form_paragraph { + margin: 3px 0 0 0; +} /* Inputs */ .openerp .oe_forms input[type="text"], .openerp .oe_forms input[type="password"], .openerp .oe_forms select, .openerp .oe_forms textarea { diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index b864365df99..6f499a0adf7 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -717,6 +717,16 @@ openerp.web.form.Widget = openerp.web.Widget.extend(/** @lends openerp.web.form. this.invisible = this.modifiers['invisible'] === true; this.classname = 'oe_form_' + this.type; + this.align = parseFloat(this.node.attrs.align); + if (isNaN(this.align) || this.align === 1) { + this.align = 'right'; + } else if (this.align === 0) { + this.align = 'left'; + } else { + this.align = 'center'; + } + + this.width = this.node.attrs.width; }, start: function() { @@ -1046,8 +1056,7 @@ openerp.web.form.WidgetLabel = openerp.web.form.Widget.extend({ this._super(view, node); - // TODO fme: support for attrs.align - if (this.node.tag == 'label' && (this.node.attrs.colspan || (this.string && this.string.length > 32))) { + if (this.node.tag == 'label' && (this.align === 'left' || this.node.attrs.colspan || (this.string && this.string.length > 32))) { this.template = "WidgetParagraph"; this.colspan = parseInt(this.node.attrs.colspan || 1, 10); } else { diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index dbee68fdb83..8984daffeb3 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -752,7 +752,7 @@ -

    +

    Date: Thu, 27 Oct 2011 14:45:03 +0200 Subject: [IMP] blockUI defaults configuration * Set throbber image as the default message * Ensure blockUI is on top of dialogs bzr revid: xmo@openerp.com-20111027124503-i4u0fmqij3o80sy3 --- addons/web/static/src/js/chrome.js | 6 +++--- addons/web/static/src/js/core.js | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index bdb8e23c20b..38923d268cf 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -343,7 +343,7 @@ openerp.web.Database = openerp.web.Widget.extend(/** @lends openerp.web.Database self.$option_id.find("form[name=create_db_form]").validate({ submitHandler: function (form) { var fields = $(form).serializeArray(); - $.blockUI({message:''}); + $.blockUI(); self.rpc("/web/database/create", {'fields': fields}, function(result) { if (result.error) { $.unblockUI(); @@ -392,7 +392,7 @@ openerp.web.Database = openerp.web.Widget.extend(/** @lends openerp.web.Database .html(QWeb.render("BackupDB", self)) .find("form[name=backup_db_form]").validate({ submitHandler: function (form) { - $.blockUI({message:''}); + $.blockUI(); self.session.get_file({ form: form, error: function (body) { @@ -413,7 +413,7 @@ openerp.web.Database = openerp.web.Widget.extend(/** @lends openerp.web.Database self.$option_id.find("form[name=restore_db_form]").validate({ submitHandler: function (form) { - $.blockUI({message:''}); + $.blockUI(); $(form).ajaxSubmit({ url: '/web/database/restore', type: 'POST', diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index ab0247e81b4..9563abea49a 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -1043,6 +1043,10 @@ openerp.web.TranslationDataBase = openerp.web.Class.extend(/** @lends openerp.we } }); +if ($.blockUI) { + $.blockUI.defaults.baseZ = 1100; + $.blockUI.defaults.message = ''; +} openerp.web._t = new openerp.web.TranslationDataBase().build_translation_function(); openerp.web.qweb = new QWeb2.Engine(); openerp.web.qweb.debug = (window.location.search.indexOf('?debug') !== -1); -- cgit v1.2.3 From 9d4602fcb83c0499583b24feb11908ef3ea8c3cf Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 27 Oct 2011 14:54:48 +0200 Subject: [FIX] unfuck formatting of negative floats bzr revid: xmo@openerp.com-20111027125448-3wkk61xpt8uwjgt1 --- addons/web/static/src/js/formats.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/formats.js b/addons/web/static/src/js/formats.js index 3ab972f7a86..ca540844b7f 100644 --- a/addons/web/static/src/js/formats.js +++ b/addons/web/static/src/js/formats.js @@ -27,14 +27,8 @@ openerp.web.format_value = function (value, descriptor, value_if_empty) { return _.sprintf('%d', value); case 'float': var precision = descriptor.digits ? descriptor.digits[1] : 2; - var int_part = Math.floor(value); - var dec_part = _.sprintf( - '%.' + precision + 'f', - Math.abs(value) % 1).substring(2); - return _.sprintf('%d%s%s', - int_part, - openerp.web._t.database.parameters.decimal_point, - dec_part); + return _.sprintf('%.' + precision + 'f', value) + .replace('.', openerp.web._t.database.parameters.decimal_point); case 'float_time': return _.sprintf("%02d:%02d", Math.floor(value), -- cgit v1.2.3 From 680f93f745e87f0e86946345d869cfaf9910be3b Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 27 Oct 2011 15:58:28 +0200 Subject: [IMP] display wait throbber/blockUI for network operations taking more than ~3s (aggregated) lp bug: https://launchpad.net/bugs/854017 fixed bzr revid: xmo@openerp.com-20111027135828-y1q85e8pq2uh3frz --- addons/web/static/src/js/chrome.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 38923d268cf..484c58ef2c4 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -195,10 +195,20 @@ openerp.web.Loading = openerp.web.Widget.extend(/** @lends openerp.web.Loading# init: function(parent, element_id) { this._super(parent, element_id); this.count = 0; + this.blocked_ui = false; this.session.on_rpc_request.add_first(this.on_rpc_event, 1); this.session.on_rpc_response.add_last(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; + $.blockUI(); + }, 3000); + } + this.count += increment; if (this.count) { //this.$element.html(QWeb.render("Loading", {})); @@ -206,6 +216,12 @@ openerp.web.Loading = openerp.web.Widget.extend(/** @lends openerp.web.Loading# this.$element.show(); this.widget_parent.$element.addClass('loading'); } else { + clearTimeout(this.long_running_timer); + // Don't unblock if blocked by somebody else + if (self.blocked_ui) { + this.blocked_ui = false; + $.unblockUI(); + } this.$element.fadeOut(); this.widget_parent.$element.removeClass('loading'); } -- cgit v1.2.3 From 6f899d86c010300295dc64977849e87f67b93731 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 27 Oct 2011 17:31:32 +0200 Subject: [IMP] rename Session to Connection and create one at initialisation bzr revid: chs@openerp.com-20111027153132-qoj0fiwoj813gsda --- addons/web/static/src/js/boot.js | 25 ++++++++++++++++++- addons/web/static/src/js/chrome.js | 8 +++--- addons/web/static/src/js/core.js | 50 ++++++++------------------------------ addons/web/static/src/js/data.js | 12 ++++++--- 4 files changed, 45 insertions(+), 50 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/boot.js b/addons/web/static/src/js/boot.js index f41185be0c6..a8ecd8a0ee5 100644 --- a/addons/web/static/src/js/boot.js +++ b/addons/web/static/src/js/boot.js @@ -21,7 +21,16 @@ * * @param {Array} modules list of modules to initialize */ - init: function(modules) { + init: function(modules, connection, callback) { + + if (/^(function|undefined)$/.test(typeof connection)) { + callback = connection; + connection = { + host: document.location.protocol + '//' + document.location.host, + }; + } + + var new_instance = { // links to the global openerp _openerp: openerp, @@ -39,6 +48,20 @@ for(var i=0; i < modules.length; i++) { openerp[modules[i]](new_instance); } + + new_instance.connector = new new_instance.web.Connection(connection.host); + if (connection.login) { + new_instance.connector.login(connection.database, connection.login, connection.password, function() { + if (callback) { + callback(new_instance); + } + }); + } else { + if (callback) { + callback(new_instance); + } + } + return new_instance; } }; diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 38923d268cf..27f0188e355 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -136,10 +136,9 @@ openerp.web.Dialog = openerp.web.OldWidget.extend(/** @lends openerp.web.Dialog# } }); -openerp.web.CrashManager = openerp.web.SessionAware.extend({ - init: function(parent) { - this._super((parent || {}).session); - this.session.on_rpc_error.add(this.on_rpc_error); +openerp.web.CrashManager = openerp.web.CallbackEnabled.extend({ + init: function() { + openerp.connector.on_rpc_error.add(this.on_rpc_error); }, on_rpc_error: function(error) { this.error = error; @@ -951,7 +950,6 @@ openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClie this.$element.html(QWeb.render("Interface", params)); this.notification = new openerp.web.Notification(); - this.session = new openerp.web.Session(); this.loading = new openerp.web.Loading(this,"oe_loading"); this.crashmanager = new openerp.web.CrashManager(this); diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index 9563abea49a..75f2bb8ef71 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -237,8 +237,8 @@ openerp.web.Registry = openerp.web.Class.extend( /** @lends openerp.web.Registry * registry was created. * * An object path is simply a dotted name from the openerp root to the - * object pointed to (e.g. ``"openerp.web.Session"`` for an OpenERP - * session object). + * object pointed to (e.g. ``"openerp.web.Connection"`` for an OpenERP + * connection object). * * @constructs openerp.web.Registry * @param {Object} mapping a mapping of keys to object-paths @@ -338,9 +338,9 @@ openerp.web.CallbackEnabled = openerp.web.Class.extend(/** @lends openerp.web.Ca } }); -openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web.Session# */{ +openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.web.Connection# */{ /** - * @constructs openerp.web.Session + * @constructs openerp.web.Connection * @extends openerp.web.CallbackEnabled * * @param {String} [server] JSON-RPC endpoint hostname @@ -490,6 +490,7 @@ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web return true; }).then(success_callback); }, + login: function() { this.session_login.apply(this, arguments); }, /** * Reloads uid and session_id from local storage, if they exist */ @@ -716,36 +717,6 @@ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web } }); -openerp.web.SessionAware = openerp.web.CallbackEnabled.extend(/** @lends openerp.web.SessionAware# */{ - /** - * Utility class that any class is allowed to extend to easy common manipulations. - * - * It provides rpc calls, callback on all methods preceded by "on_" or "do_" and a - * logging facility. - * - * @constructs openerp.web.SessionAware - * @extends openerp.web.CallbackEnabled - * - * @param {openerp.web.Session} session - */ - init: function(session) { - this._super(); - this.session = session; - }, - /** - * Performs a JSON-RPC call - * - * @param {String} url endpoint url - * @param {Object} data RPC parameters - * @param {Function} success RPC call success callback - * @param {Function} error RPC call error callback - * @returns {jQuery.Deferred} deferred object for the RPC call - */ - rpc: function(url, data, success, error) { - return this.session.rpc(url, data, success, error); - } -}); - /** * Base class for all visual components. Provides a lot of functionalities helpful * for the management of a part of the DOM. @@ -756,8 +727,6 @@ openerp.web.SessionAware = openerp.web.CallbackEnabled.extend(/** @lends openerp * destroyed too). * - Insertion in DOM. * - * Widget also extends SessionAware for ease of use. - * * Guide to create implementations of the Widget class: * ============================================== * @@ -798,7 +767,7 @@ openerp.web.SessionAware = openerp.web.CallbackEnabled.extend(/** @lends openerp * * That will kill the widget in a clean way and erase its content from the dom. */ -openerp.web.Widget = openerp.web.SessionAware.extend(/** @lends openerp.web.Widget# */{ +openerp.web.Widget = openerp.web.CallbackEnabled.extend(/** @lends openerp.web.Widget# */{ /** * The name of the QWeb template that will be used for rendering. Must be * redefined in subclasses or the default render() method can not be used. @@ -817,7 +786,7 @@ openerp.web.Widget = openerp.web.SessionAware.extend(/** @lends openerp.web.Widg * Construct the widget and set its parent if a parent is given. * * @constructs openerp.web.Widget - * @extends openerp.web.SessionAware + * @extends openerp.web.CallbackEnabled * * @param {openerp.web.Widget} parent Binds the current instance to the given Widget instance. * When that widget is destroyed by calling stop(), the current instance will be @@ -828,7 +797,8 @@ openerp.web.Widget = openerp.web.SessionAware.extend(/** @lends openerp.web.Widg * for new components this argument should not be provided any more. */ init: function(parent, /** @deprecated */ element_id) { - this._super((parent || {}).session); + this._super(); + this.session = openerp.connector; // if given an element_id, try to get the associated DOM element and save // a reference in this.$element. Else just generate a unique identifier. this.element_id = element_id; @@ -967,7 +937,7 @@ openerp.web.Widget = openerp.web.SessionAware.extend(/** @lends openerp.web.Widg rpc: function(url, data, success, error) { var def = $.Deferred().then(success, error); var self = this; - this._super(url, data). then(function() { + openerp.connector.rpc(url, data). then(function() { if (!self.widget_is_stopped) def.resolve.apply(def, arguments); }, function() { diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index 069506586ad..4e14b9eb6a9 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -32,7 +32,7 @@ openerp.web.DataGroup = openerp.web.Widget.extend( /** @lends openerp.web.DataG * @constructs openerp.web.DataGroup * @extends openerp.web.Widget * - * @param {openerp.web.Session} session Current OpenERP session + * @param {openerp.web.Widget} parent widget * @param {String} model name of the model managed by this DataGroup * @param {Array} domain search domain for this DataGroup * @param {Object} context context of the DataGroup's searches @@ -785,11 +785,15 @@ openerp.web.ProxyDataSet = openerp.web.DataSetSearch.extend({ on_unlink: function(ids) {} }); -openerp.web.Model = openerp.web.SessionAware.extend({ - init: function(session, model_name) { - this._super(session); +openerp.web.Model = openerp.web.CallbackEnabled.extend({ + init: function(_, model_name) { + this._super(); this.model_name = model_name; }, + rpc: function() { + var c = openerp.connector; + return c.rpc.apply(c, arguments); + }, get_func: function(method_name) { var self = this; return function() { -- cgit v1.2.3 From 125ce4ec850062c2df619ac789067e3bd666facd Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 28 Oct 2011 10:50:51 +0200 Subject: [FIX] on a button action, ListView should send the content of the corresponding record as (evaluation) context also needs to set active_id, and let's throw active_ids and active_model in for the same price lp bug: https://launchpad.net/bugs/881301 fixed bzr revid: xmo@openerp.com-20111028085051-p49564vmrozkr1fr --- addons/web/static/src/js/view_list.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 0db60c72c07..e891a6c7db7 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -524,6 +524,17 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# return field.name === name; }); if (!action) { return; } + + var c = new openerp.web.CompoundContext(); + c.set_eval_context(_.extend({ + active_id: id, + active_ids: [id], + active_model: this.dataset.model + }, this.records.get(id).toContext())); + if (action.context) { + c.add(action.context); + } + action.context = c; this.do_execute_action(action, this.dataset, id, callback); }, /** @@ -1446,6 +1457,25 @@ var Record = openerp.web.Class.extend(/** @lends Record# */{ } return {data: form_data}; + }, + /** + * Converts the current record to a format expected by context evaluations + * (identical to record.attributes, except m2o fields are their integer + * value rather than a pair) + */ + toContext: function () { + var output = {}, attrs = this.attributes; + for(var k in attrs) { + var val = attrs[k]; + if (typeof val !== 'object') { + output[k] = val; + } else if (val instanceof Array) { + output[k] = val[0]; + } else { + throw new Error("Can't convert value " + val + " to context"); + } + } + return output; } }); Record.include(Events); -- cgit v1.2.3 From 4df4d335e60f0d2e8d71e07f8dd17addc63bac9b Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 28 Oct 2011 10:52:12 +0200 Subject: [IMP] remove a few object trailing commas bzr revid: xmo@openerp.com-20111028085212-vjpb1oejd8cv24mt --- addons/web/static/src/js/chrome.js | 6 +++--- addons/web/static/src/js/views.js | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 484c58ef2c4..22c2b0ba2ea 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -29,11 +29,11 @@ openerp.web.Notification = openerp.web.Widget.extend(/** @lends openerp.web.Not warn: function(title, text) { this.$element.notify('create', 'oe_notification_alert', { title: title, - text: text, + text: text }, { - expires: false, + expires: false }); - }, + } }); diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index d243fa55230..4e8f6d30022 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -569,7 +569,7 @@ session.web.Sidebar = session.web.Widget.extend({ { label: _t("Manage Views"), callback: this.call_default_on_sidebar, - title: _t("Manage views of the current object"), + title: _t("Manage views of the current object") }, { label: _t("Edit Workflow"), callback: this.call_default_on_sidebar, @@ -578,7 +578,7 @@ session.web.Sidebar = session.web.Widget.extend({ }, { label: _t("Customize Object"), callback: this.call_default_on_sidebar, - title: _t("Manage views of the current object"), + title: _t("Manage views of the current object") } ]); @@ -586,10 +586,10 @@ session.web.Sidebar = session.web.Widget.extend({ this.add_items('other', [ { label: _t("Import"), - callback: this.call_default_on_sidebar, + callback: this.call_default_on_sidebar }, { label: _t("Export"), - callback: this.call_default_on_sidebar, + callback: this.call_default_on_sidebar }, { label: _t("Translate"), callback: this.call_default_on_sidebar, @@ -629,7 +629,7 @@ session.web.Sidebar = session.web.Widget.extend({ var $section = $(session.web.qweb.render("Sidebar.section", { section_id: section_id, name: name, - classname: 'oe_sidebar_' + code, + classname: 'oe_sidebar_' + code })); $section.appendTo(this.$element.find('div.sidebar-actions')); this.sections[code] = $section; -- cgit v1.2.3 From b70adac1285a7d49cd3ce5e839aa1b89037a9e14 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Mon, 31 Oct 2011 14:22:31 +0530 Subject: [Fix]fix browser issue of converting jquery dom to string. bzr revid: vme@tinyerp.com-20111031085231-kd32p1593xx1qxlt --- addons/web/static/src/js/view_editor.js | 47 +++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 17 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 7828c4366c9..b92654ea42f 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -56,6 +56,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ this.view_edit_dialog.open(); action_manager.appendTo(this.view_edit_dialog); action_manager.do_action(action); + }, check_attr: function(xml, tag, level) { var obj = new Object(); @@ -307,7 +308,8 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var view_xml_id; while(1){ ls = ls.prev(); - if(($(ls).find('a').text()).search("view_id") != -1 && parseInt(ls.attr('level')) < level){ + if((self.edit_xml_dialog.$element.find(ls).find('a').text()).search("view_id") != -1 + && parseInt(ls.attr('level')) < level){ view_id = parseInt(($(ls).find('a').text()).replace(/[^0-9]+/g,'')); view_xml_id = (ls.attr('id')).split('-')[1]; break; @@ -342,7 +344,8 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } if (last_tr.length != 0 && parseInt(last_tr.attr('level')) == level - && ($(last_tr).find('a').text()).search("view_id") == -1) { + && + (self.edit_xml_dialog.$element.find(last_tr).find('a').text()).search("view_id") == -1) { _.each(list_shift, function(rec) { $(last_tr).before(rec); }); @@ -369,7 +372,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var last_tr_id = (last_tr.attr('id')).split('-')[1]; img = last_tr.find("img[id='parentimg-" + last_tr_id + "']").attr('src'); if (img) { - this.edit_xml_dialog.$element.find("img[id='parentimg-" + last_tr_id + "']").attr('src', '/web/static/src/img/expand.gif'); + self.edit_xml_dialog.$element.find("img[id='parentimg-" + last_tr_id + "']").attr('src', '/web/static/src/img/expand.gif'); while (1) { var next_tr = last_tr.next(); if (next_tr.attr('level') <= level || next_tr.length == 0) break; @@ -379,7 +382,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } list_shift.reverse(); - if(($(side.next()).find('a').text()).search("view_id") == -1){ + if((self.edit_xml_dialog.$element.find(side.next()).find('a').text()).search("view_id") == -1){ _.each(list_shift, function(rec) { $(last_tr).after(rec); }); @@ -444,19 +447,15 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ child_list.splice(index-1, 0, re_insert_obj[0]); } parent = parent[parent.length-1]; - var convert_to_utf = ""; - var xml_serilalizer = new XMLSerializer(); - var stream = { - write : function(string) - {convert_to_utf = convert_to_utf + string + "";} - }; - xml_serilalizer.serializeToStream(parent, stream, "UTF-8"); - convert_to_utf = convert_to_utf.replace('xmlns="http://www.w3.org/1999/xhtml"', ""); - convert_to_utf = '' + convert_to_utf; - arch.arch = convert_to_utf; - dataset = new openerp.web.DataSet(this, 'ir.ui.view'); - dataset.write(parseInt(view_id),{"arch":convert_to_utf},function(r){ - }); + var convert_to_utf = self.xml2Str(parent); + if(convert_to_utf){ + convert_to_utf = convert_to_utf.replace('xmlns="http://www.w3.org/1999/xhtml"', ""); + convert_to_utf = '' + convert_to_utf; + arch.arch = convert_to_utf; + dataset = new openerp.web.DataSet(this, 'ir.ui.view'); + dataset.write(parseInt(view_id),{"arch":convert_to_utf},function(r){ + }); + } } if(obj.level <= level){ _.each(list_obj_xml, function(child_node){ @@ -465,6 +464,20 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } } }, + xml2Str: function(xmlNode) { + try { + return (new XMLSerializer()).serializeToString(xmlNode); + } + catch (e) { + try { + return xmlNode.xml; + } + catch (e) { + return false; + } + } + + }, on_expand: function(expand_img){ var level = parseInt($(expand_img).closest("tr[id^='viewedit-']").attr('level')); -- cgit v1.2.3 From 41ebcc4079a57cbb619e00cebdb75d792f2e386e Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 31 Oct 2011 11:27:52 +0100 Subject: [imp] added non editable implementation for o2m & m2m bzr revid: nicolas.vanhoren@openerp.com-20111031102752-qdsfzzj747h5yp1w --- addons/web/static/src/js/view_form.js | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 6f499a0adf7..8955237ce39 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1955,6 +1955,9 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ self.load_views(); }); }, + is_readonly: function() { + return this.readonly || this.force_readonly; + }, load_views: function() { var self = this; @@ -1972,7 +1975,7 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ } if(view.view_type === "list") { view.options.selectable = self.multi_selection; - if (self.readonly) { + if (self.is_readonly()) { view.options.addable = null; view.options.deletable = null; } @@ -1997,10 +2000,10 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({ this.viewmanager.on_controller_inited.add_last(function(view_type, controller) { if (view_type == "list") { controller.o2m = self; - if (self.readonly) + if (self.is_readonly()) controller.set_editable(false); } else if (view_type == "form") { - if (self.readonly) { + if (self.is_readonly()) { controller.on_toggle_readonly(); $(controller.$element.find(".oe_form_buttons")[0]).children().remove(); } @@ -2220,7 +2223,7 @@ openerp.web.form.One2ManyListView = openerp.web.ListView.extend({ }, do_activate_record: function(index, id) { var self = this; - if (self.o2m.readonly) + if (self.o2m.is_readonly) return; var pop = new openerp.web.form.FormOpenPopup(self.o2m.view); pop.show_element(self.o2m.field.relation, id, self.o2m.build_context(),{ @@ -2282,11 +2285,14 @@ openerp.web.form.FieldMany2Many = openerp.web.form.Field.extend({ validate: function() { this.invalid = false; }, + is_readonly: function() { + return this.readonly || this.force_readonly; + }, load_view: function() { var self = this; this.list_view = new openerp.web.form.Many2ManyListView(this, this.dataset, false, { - 'addable': self.readonly ? null : 'Add', - 'deletable': self.readonly ? false : true, + 'addable': self.is_readonly() ? null : 'Add', + 'deletable': self.is_readonly() ? false : true, 'selectable': self.multi_selection }); this.list_view.m2m_field = this; @@ -3030,6 +3036,13 @@ openerp.web.form.widgets = new openerp.web.Registry({ 'binary': 'openerp.web.form.FieldBinaryFile', 'statusbar': 'openerp.web.form.FieldStatus' }); + +openerp.web.form.FieldMany2ManyReadonly = openerp.web.form.FieldMany2Many.extend({ + force_readonly: true +}); +openerp.web.form.FieldOne2ManyReadonly = openerp.web.form.FieldOne2Many.extend({ + force_readonly: true +}); openerp.web.form.readonly = openerp.web.form.widgets.clone({ 'char': 'openerp.web.form.FieldCharReadonly', 'email': 'openerp.web.form.FieldEmailReadonly', @@ -3040,6 +3053,9 @@ openerp.web.form.readonly = openerp.web.form.widgets.clone({ 'datetime': 'openerp.web.form.FieldCharReadonly', 'selection' : 'openerp.web.form.FieldSelectionReadonly', 'many2one': 'openerp.web.form.FieldMany2OneReadonly', + 'many2many' : 'openerp.web.form.FieldMany2ManyReadonly', + 'one2many' : 'openerp.web.form.FieldOne2ManyReadonly', + 'one2many_list' : 'openerp.web.form.FieldOne2ManyReadonly', 'boolean': 'openerp.web.form.FieldBooleanReadonly', 'float': 'openerp.web.form.FieldCharReadonly', 'integer': 'openerp.web.form.FieldCharReadonly', -- cgit v1.2.3 From 85012767c8b9d09ffdbe2a4f1496db24f3c8d27c Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 31 Oct 2011 11:43:04 +0100 Subject: [imp] allowed to click on an element of a readonly o2m to open it in a popup bzr revid: nicolas.vanhoren@openerp.com-20111031104304-b3ur1j34nqe4o674 --- addons/web/static/src/js/view_form.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 8955237ce39..a1dcd726127 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2223,8 +2223,6 @@ openerp.web.form.One2ManyListView = openerp.web.ListView.extend({ }, do_activate_record: function(index, id) { var self = this; - if (self.o2m.is_readonly) - return; var pop = new openerp.web.form.FormOpenPopup(self.o2m.view); pop.show_element(self.o2m.field.relation, id, self.o2m.build_context(),{ auto_write: false, @@ -2233,7 +2231,8 @@ openerp.web.form.One2ManyListView = openerp.web.ListView.extend({ read_function: function() { return self.o2m.dataset.read_ids.apply(self.o2m.dataset, arguments); }, - form_view_options: {'not_interactible_on_create':true} + form_view_options: {'not_interactible_on_create':true}, + readonly: self.o2m.is_readonly() }); pop.on_write.add(function(id, data) { self.o2m.dataset.write(id, data, {}, function(r) { @@ -2578,6 +2577,7 @@ openerp.web.form.FormOpenPopup = openerp.web.OldWidget.extend(/** @lends openerp * - read_function * - parent_view * - form_view_options + * - readonly */ show_element: function(model, row_id, context, options) { this.model = model; @@ -2617,7 +2617,13 @@ openerp.web.form.FormOpenPopup = openerp.web.OldWidget.extend(/** @lends openerp this.view_form.set_embedded_view(this.options.alternative_form_view); } this.view_form.appendTo(this.$element.find("#" + this.element_id + "_view_form")); + var once = $.Deferred().then(function() { + if (self.options.readonly) { + self.view_form.on_toggle_readonly(); + } + }); this.view_form.on_loaded.add_last(function() { + once.resolve(); var $buttons = self.view_form.$element.find(".oe_form_buttons"); $buttons.html(QWeb.render("FormOpenPopup.form.buttons")); var $nbutton = $buttons.find(".oe_formopenpopup-form-save"); @@ -2626,6 +2632,9 @@ openerp.web.form.FormOpenPopup = openerp.web.OldWidget.extend(/** @lends openerp self.stop(); }); }); + if (self.options.readonly) { + $nbutton.hide(); + } var $cbutton = $buttons.find(".oe_formopenpopup-form-close"); $cbutton.click(function() { self.stop(); -- cgit v1.2.3 From 0d75c597cd0f6b27e85b82779f61172ff66093a3 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 31 Oct 2011 11:54:44 +0100 Subject: [fix] potential problem with m2o bzr revid: nicolas.vanhoren@openerp.com-20111031105444-mjdgrhuylh146ryy --- addons/web/static/src/js/view_form.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index a1dcd726127..cd015bf1fe2 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1829,7 +1829,7 @@ openerp.web.form.FieldMany2One = openerp.web.form.Field.extend({ self.original_value = undefined; self._change_int_ext_value(rval); }; - if(typeof(value) === "number") { + if(!(typeof(value) instanceof Array)) { var dataset = new openerp.web.DataSetStatic(this, this.field.relation, self.build_context()); dataset.name_get([value], function(data) { real_set_value(data[0]); @@ -3000,7 +3000,7 @@ openerp.web.form.FieldMany2OneReadonly = openerp.web.form.FieldCharReadonly.exte var real_set_value = function(rval) { self.$element.find('div').text(rval ? rval[1] : ''); }; - if(typeof(value) === "number") { + if(!(typeof(value) instanceof Array)) { var dataset = new openerp.web.DataSetStatic( this, this.field.relation, self.build_context()); dataset.name_get([value], function(data) { -- cgit v1.2.3 From 499b2e033aea69e1059df442e45effaa9eea7491 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 31 Oct 2011 12:06:20 +0100 Subject: [fix] typo bzr revid: nicolas.vanhoren@openerp.com-20111031110620-b00p18d0ebckr4xt --- addons/web/static/src/js/view_form.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index cd015bf1fe2..aeddf2945d0 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1829,7 +1829,7 @@ openerp.web.form.FieldMany2One = openerp.web.form.Field.extend({ self.original_value = undefined; self._change_int_ext_value(rval); }; - if(!(typeof(value) instanceof Array)) { + if (value && !(value instanceof Array)) { var dataset = new openerp.web.DataSetStatic(this, this.field.relation, self.build_context()); dataset.name_get([value], function(data) { real_set_value(data[0]); @@ -3000,7 +3000,7 @@ openerp.web.form.FieldMany2OneReadonly = openerp.web.form.FieldCharReadonly.exte var real_set_value = function(rval) { self.$element.find('div').text(rval ? rval[1] : ''); }; - if(!(typeof(value) instanceof Array)) { + if (value && !(value instanceof Array)) { var dataset = new openerp.web.DataSetStatic( this, this.field.relation, self.build_context()); dataset.name_get([value], function(data) { -- cgit v1.2.3 From 16b9b4347709d3406b4e4281f25d8cb6dfe156cb Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 31 Oct 2011 12:09:37 +0100 Subject: [imp] modified many2one in readonly mode to be able to click on it to open a popup bzr revid: nicolas.vanhoren@openerp.com-20111031110937-den8gj0j5zwfflw3 --- addons/web/static/src/js/view_form.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index aeddf2945d0..0294f248978 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2632,13 +2632,14 @@ openerp.web.form.FormOpenPopup = openerp.web.OldWidget.extend(/** @lends openerp self.stop(); }); }); - if (self.options.readonly) { - $nbutton.hide(); - } var $cbutton = $buttons.find(".oe_formopenpopup-form-close"); $cbutton.click(function() { self.stop(); }); + if (self.options.readonly) { + $nbutton.hide(); + $cbutton.text(_t("Close")); + } self.view_form.do_show(); }); this.dataset.on_write.add(this.on_write); @@ -2998,7 +2999,15 @@ openerp.web.form.FieldMany2OneReadonly = openerp.web.form.FieldCharReadonly.exte self.update_dom(); self.on_value_changed(); var real_set_value = function(rval) { - self.$element.find('div').text(rval ? rval[1] : ''); + self.value = rval; + var div = $(self.$element.find('div')); + div.html(''); + var a = $(div.find("a")); + a.text(rval ? rval[1] : ''); + a.click(function() { + var pop = new openerp.web.form.FormOpenPopup(self.view); + pop.show_element(self.field.relation, self.value[0],self.build_context(), {readonly:true}); + }); }; if (value && !(value instanceof Array)) { var dataset = new openerp.web.DataSetStatic( -- cgit v1.2.3 From 04435177466d1caeb20936145b47777b9620ae70 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 31 Oct 2011 16:49:07 +0100 Subject: [fix] problem with m2o search popup, should not be multi-selectable bzr revid: nicolas.vanhoren@openerp.com-20111031154907-uf9way132l54n7lw --- addons/web/static/src/js/view_form.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 0294f248978..237199d5472 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2428,10 +2428,7 @@ openerp.web.form.SelectCreatePopup = openerp.web.OldWidget.extend(/** @lends ope this.searchview.stop(); } this.searchview = new openerp.web.SearchView(this, - this.dataset, false, { - "selectable": !this.options.disable_multiple_selection, - "deletable": false - }); + this.dataset, false, {}); this.searchview.on_search.add(function(domains, contexts, groupbys) { if (self.initial_ids) { self.do_search(domains.concat([[["id", "in", self.initial_ids]], self.domain]), @@ -2458,7 +2455,9 @@ openerp.web.form.SelectCreatePopup = openerp.web.OldWidget.extend(/** @lends ope }); self.view_list = new openerp.web.form.SelectCreateListView(self, self.dataset, false, - _.extend({'deletable': false}, self.options.list_view_options || {})); + _.extend({'deletable': false, + 'selectable': !self.options.disable_multiple_selection + }, self.options.list_view_options || {})); self.view_list.popup = self; self.view_list.appendTo($("#" + self.element_id + "_view_list")).pipe(function() { self.view_list.do_show(); -- cgit v1.2.3 From c0c775014605a45a63fd6ccb40461a3762eb1244 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Tue, 1 Nov 2011 12:21:05 +0530 Subject: [FIX] vieweditor:- used close method instead of manually destory. bzr revid: ysa@tinyerp.com-20111101065105-kurbcohyig31qudu --- addons/web/static/src/js/view_editor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index e042ee1d889..8aebced3e98 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -48,7 +48,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ self.get_data(); }, "Close": function(){ - $(this).dialog('destroy'); + this.view_edit_dialog.close(); } }, }); @@ -262,7 +262,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ //todo }, "Close": function(){ - $(this).dialog('destroy'); + this.edit_xml_dialog.close(); } } }); -- cgit v1.2.3 From 21a5438b3a50f1f4b1f258f23f52bc029de106a6 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Tue, 1 Nov 2011 12:24:21 +0530 Subject: [FIX] bzr revid: ysa@tinyerp.com-20111101065421-kk7ixnqsrqon3th8 --- addons/web/static/src/js/view_editor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 8aebced3e98..429192570f1 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -48,7 +48,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ self.get_data(); }, "Close": function(){ - this.view_edit_dialog.close(); + self.view_edit_dialog.close(); } }, }); @@ -262,7 +262,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ //todo }, "Close": function(){ - this.edit_xml_dialog.close(); + self.edit_xml_dialog.close(); } } }); -- cgit v1.2.3 From c1a65b4970a93c30488aa4df14d0ebf36e3a86aa Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Wed, 2 Nov 2011 10:52:29 +0530 Subject: [IMP]removed direct use of jquery. bzr revid: vme@tinyerp.com-20111102052229-kyld21aha689n9p0 --- addons/web/static/src/js/view_editor.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index b92654ea42f..98804f5c03d 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -280,7 +280,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ 'data': one_object['main_object'], })); this.edit_xml_dialog.$element.find("tr[id^='viewedit-']").click(function() { - $("tr[id^='viewedit-']").removeClass('ui-selected'); + self.edit_xml_dialog.$element.find("tr[id^='viewedit-']").removeClass('ui-selected'); $(this).addClass('ui-selected'); }); this.edit_xml_dialog.$element.find("img[id^='parentimg-']").click(function() { @@ -372,7 +372,8 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var last_tr_id = (last_tr.attr('id')).split('-')[1]; img = last_tr.find("img[id='parentimg-" + last_tr_id + "']").attr('src'); if (img) { - self.edit_xml_dialog.$element.find("img[id='parentimg-" + last_tr_id + "']").attr('src', '/web/static/src/img/expand.gif'); + self.edit_xml_dialog.$element.find("img[id='parentimg-" + last_tr_id + "']"). + attr('src', '/web/static/src/img/expand.gif'); while (1) { var next_tr = last_tr.next(); if (next_tr.attr('level') <= level || next_tr.length == 0) break; -- cgit v1.2.3 From 6159ab1714c9a171f1d7eda20f8503ae85e26f35 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Wed, 2 Nov 2011 11:47:35 +0530 Subject: [IMP]impove save and move funcationality. bzr revid: vme@tinyerp.com-20111102061735-28mlg6y4qrvdku4g --- addons/web/static/src/js/view_editor.js | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 98804f5c03d..f41b77f1744 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -33,7 +33,6 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ radio:true }, }; - var action_manager = new openerp.web.ActionManager(this); this.view_edit_dialog = new openerp.web.Dialog(this,{ modal: true, title: 'ViewEditor', @@ -52,28 +51,23 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }, }); - this.view_edit_dialog.start(); - this.view_edit_dialog.open(); + this.view_edit_dialog.start().open(); + var action_manager = new openerp.web.ActionManager(this); action_manager.appendTo(this.view_edit_dialog); action_manager.do_action(action); - }, check_attr: function(xml, tag, level) { - var obj = new Object(); - obj.child_id = []; - obj.id = this.xml_id++; - obj.level = level+1; + var obj = {'child_id':[],'id':this.xml_id++,'level':level+1,'att_list':[],'name':""}; var render_name = "<" + tag; - obj.att_list = []; obj.att_list.push(tag); $(xml).each(function() { _.each(this.attributes, function(attrs){ if (tag != 'button') { if (attrs.nodeName == "string" || attrs.nodeName == "name" || attrs.nodeName == "index") { - render_name += ' ' + attrs.nodeName + '=' + '"' + attrs.nodeValue + '"' ; } + render_name += ' ' + attrs.nodeName + '=' + '"' + attrs.nodeValue + '"' ;} } else { if (attrs.nodeName == "name") { - render_name += ' ' + attrs.nodeName + '=' + '"' + attrs.nodeValue + '"'; } + render_name += ' ' + attrs.nodeName + '=' + '"' + attrs.nodeValue + '"';} } obj.att_list.push( [attrs.nodeName,attrs.nodeValue] ); }); @@ -368,6 +362,9 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ else { last_tr = cur_tr.next(); } + if((self.edit_xml_dialog.$element.find(last_tr).find('a').text()).search("view_id") != -1){ + return; + } if (last_tr.length != 0 && parseInt(last_tr.attr('level')) == level) { var last_tr_id = (last_tr.attr('id')).split('-')[1]; img = last_tr.find("img[id='parentimg-" + last_tr_id + "']").attr('src'); @@ -383,12 +380,11 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } list_shift.reverse(); - if((self.edit_xml_dialog.$element.find(side.next()).find('a').text()).search("view_id") == -1){ - _.each(list_shift, function(rec) { - $(last_tr).after(rec); - }); - self.save_move_arch(one_object, view_id, view_xml_id, id_tr, level, "down"); - } + _.each(list_shift, function(rec) { + $(last_tr).after(rec); + }); + self.save_move_arch(one_object, view_id, view_xml_id, id_tr, level, "down"); + } break; } -- cgit v1.2.3 From 6f91e87f8cf55a4ba79809b697dbdd575f05677a Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 2 Nov 2011 11:05:11 +0100 Subject: [FIX] correct CrashManager bzr revid: chs@openerp.com-20111102100511-f58vlgnv12cti8ry --- addons/web/static/src/js/chrome.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 27f0188e355..c8ebbb2b12a 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -138,6 +138,7 @@ openerp.web.Dialog = openerp.web.OldWidget.extend(/** @lends openerp.web.Dialog# openerp.web.CrashManager = openerp.web.CallbackEnabled.extend({ init: function() { + this._super(); openerp.connector.on_rpc_error.add(this.on_rpc_error); }, on_rpc_error: function(error) { @@ -951,7 +952,7 @@ openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClie this.notification = new openerp.web.Notification(); this.loading = new openerp.web.Loading(this,"oe_loading"); - this.crashmanager = new openerp.web.CrashManager(this); + this.crashmanager = new openerp.web.CrashManager(); this.header = new openerp.web.Header(this); this.login = new openerp.web.Login(this); -- cgit v1.2.3 From ae0bf044ef1d63bc0bb19eb9dccc0218c63a9c65 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 2 Nov 2011 12:11:05 +0100 Subject: [IMP] qweb templates are stored in addon manifest and given by the server bzr revid: chs@openerp.com-20111102111105-ibyupno1e47sv9ho --- addons/web/static/src/js/chrome.js | 3 +-- addons/web/static/src/js/core.js | 17 +++++++++++++++++ addons/web/static/src/js/search.js | 7 +++---- 3 files changed, 21 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index c8ebbb2b12a..f2b90c5cf7f 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -943,14 +943,13 @@ openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClie this._super(null, element_id); openerp.webclient = this; - QWeb.add_template("/web/static/src/xml/base.xml"); var params = {}; if(jQuery.param != undefined && jQuery.deparam(jQuery.param.querystring()).kitten != undefined) { this.$element.addClass("kitten-mode-activated"); } this.$element.html(QWeb.render("Interface", params)); - this.notification = new openerp.web.Notification(); + this.notification = new openerp.web.Notification(this); this.loading = new openerp.web.Loading(this,"oe_loading"); this.crashmanager = new openerp.web.CrashManager(); diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index 75f2bb8ef71..837e9faab64 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -364,7 +364,9 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp. // TODO: session should have an optional name indicating that they'll // be saved to (and revived from) cookies this.name = 'session'; + this.do_load_qweb(['/web/webclient/qweb']); }, + start: function() { this.session_restore(); }, @@ -487,6 +489,7 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp. self.user_context = result.context; self.db = result.db; self.session_save(); + self.on_session_valid(); return true; }).then(success_callback); }, @@ -578,6 +581,7 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp. self.rpc('/web/webclient/jslist', {"mods": modules}, function(files) { self.do_load_js(file_list.concat(files)); }); + self.rpc('/web/webclient/qweblist', {"mods": modules}, self.do_load_qweb); openerp._modules_loaded = true; }); }); @@ -611,6 +615,19 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp. this.on_modules_loaded(); } }, + do_load_qweb: function(files) { + var self = this; + _.each(files, function(file) { + $.ajax({ + url: file, + type: 'get', + async: false, + dataType: 'text', + }).then(function(xml) { + openerp.web.qweb.add_template(_(xml).trim()); + }); + }); + }, on_modules_loaded: function() { for(var j=0; j Date: Wed, 2 Nov 2011 17:10:34 +0530 Subject: [IMP] View editor :- implement functionality of preview button. bzr revid: ysa@tinyerp.com-20111102114034-nmj18kx32igvqdub --- addons/web/static/src/js/view_editor.js | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 09cfe84c702..a93f71e87bc 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -130,13 +130,14 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ get_data: function() { var self = this; var view_arch_list = []; - var view_id =((this.view_edit_dialog.$element.find("input[name='radiogroup']:checked").parent()).parent()).attr('data-id'); + self.main_view_id =((this.view_edit_dialog.$element.find("input[name='radiogroup']:checked").parent()).parent()).attr('data-id'); var ve_dataset = new openerp.web.DataSet(this, 'ir.ui.view'); - ve_dataset.read_ids([parseInt(view_id)], ['arch'], function (arch) { - one_object = self.parse_xml(arch[0].arch,view_id); - view_arch_list.push({"view_id" : view_id, "arch" : arch[0].arch}); + ve_dataset.read_ids([parseInt(self.main_view_id)], ['arch', 'type'], function (arch) { + one_object = self.parse_xml(arch[0].arch,self.main_view_id); + self.main_view_type = arch[0].type + view_arch_list.push({"view_id" : self.main_view_id, "arch" : arch[0].arch}); dataset = new openerp.web.DataSetSearch(self, 'ir.ui.view', null, null); - dataset.read_slice([], {domain : [['inherit_id','=', parseInt(view_id)]]}, function (result) { + dataset.read_slice([], {domain : [['inherit_id','=', parseInt(self.main_view_id)]]}, function (result) { _.each(result, function(res) { view_arch_list.push({"view_id":res.id,"arch":res.arch}); self.inherit_view(one_object, res); @@ -263,7 +264,22 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ //todo }, "Preview": function(){ - //todo + var action = { + context:self.session.user_context, + res_model : self.model, + views : [[self.main_view_id, self.main_view_type]], + type: 'ir.actions.act_window', + target: "new", + flags: { + sidebar: false, + views_switcher: false, + action_buttons:false, + search_view:false, + pager:false, + }, + }; + var action_manager = new openerp.web.ActionManager(self); + action_manager.do_action(action); }, "Close": function(){ self.edit_xml_dialog.close(); -- cgit v1.2.3 From 7eebc26519285ff00f891835d3ad6c43e0373354 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 3 Nov 2011 15:47:38 +0100 Subject: [FIX] absolutify relative uris when merging css files bzr revid: chs@openerp.com-20111103144738-u5oewg8bo81yync5 --- addons/web/static/src/css/base.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 3430dfe196a..94e36d60419 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1088,7 +1088,7 @@ label.error { list-style: none; } .openerp .oe-view-manager-logs li:before { - content: '→ '; + content: '\2192 '; } .openerp .oe-view-manager-logs a { text-decoration: none; @@ -1448,3 +1448,4 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after { .openerp .oe_view_editor_tree_grid a { display: block; } + -- cgit v1.2.3 From 6389731d37ab0cd836b98d03cb5ad52b83bb5d19 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 7 Nov 2011 14:45:39 +0100 Subject: [IMP] Refactored form view's buttons Yuck bzr revid: fme@openerp.com-20111107134539-ndykhew56v66i218 --- addons/web/static/src/js/view_form.js | 59 ++++++++++++++++++++++++----------- addons/web/static/src/xml/base.xml | 18 ++++++----- 2 files changed, 51 insertions(+), 26 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 237199d5472..d18066f99c5 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -10,6 +10,7 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView# * view should be displayed (if there is one active). */ searchable: false, + readonly : false, form_template: "FormView", identifier_prefix: 'formview-', /** @@ -37,7 +38,7 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView# this.dirty_for_user = false; this.default_focus_field = null; this.default_focus_button = null; - this.registry = openerp.web.form.widgets; + this.registry = this.readonly ? openerp.web.form.readonly : openerp.web.form.widgets; this.has_been_loaded = $.Deferred(); this.$form_header = null; this.translatable_fields = []; @@ -101,10 +102,11 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView# self.on_pager_action(action); }); - this.$form_header.find('button.oe_form_button_save').click(this.do_save); + this.$form_header.find('button.oe_form_button_save').click(this.do_save_then_readonly); this.$form_header.find('button.oe_form_button_cancel').click(this.do_cancel); this.$form_header.find('button.oe_form_button_new').click(this.on_button_new); this.$form_header.find('button.oe_form_button_duplicate').click(this.on_button_duplicate); + this.$form_header.find('button.oe_form_button_delete').click(this.on_button_delete); this.$form_header.find('button.oe_form_button_toggle').click(this.on_toggle_readonly); if (this.options.sidebar && this.options.sidebar_id) { @@ -123,11 +125,16 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView# self.widgets = {}; self.fields = {}; self.$form_header.find('button').unbind('click'); - self.registry = self.registry === openerp.web.form.widgets - ? openerp.web.form.readonly - : openerp.web.form.widgets; + self.readonly = !self.readonly; + self.registry = self.readonly ? openerp.web.form.readonly : openerp.web.form.widgets; self.on_loaded(self.fields_view); - self.reload(); + return self.reload(); + }, + do_set_readonly: function() { + return this.readonly ? $.Deferred().resolve() : this.on_toggle_readonly(); + }, + do_set_editable: function() { + return !this.readonly ? $.Deferred().resolve() : this.on_toggle_readonly(); }, do_show: function () { var promise; @@ -164,6 +171,8 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView# this.$form_header.find('.oe_form_on_update').show(); this.$form_header.find('button.oe_form_button_new').show(); } + this.$form_header.find('.oe_form_on_readonly').toggle(this.readonly); + this.$form_header.find('.oe_form_on_editable').toggle(!this.readonly); this.dirty_for_user = false; this.datarecord = record; for (var f in this.fields) { @@ -344,14 +353,16 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView# $.when(this.has_been_loaded).then(function() { if (self.can_be_discarded()) { var keys = _.keys(self.fields_view.fields); - if (keys.length) { - self.dataset.default_get(keys).then(self.on_record_loaded).then(function() { + $.when(self.do_set_editable()).then(function() { + if (keys.length) { + self.dataset.default_get(keys).then(self.on_record_loaded).then(function() { + def.resolve(); + }); + } else { + self.on_record_loaded({}); def.resolve(); - }); - } else { - self.on_record_loaded({}); - def.resolve(); - } + } + }); } }); return def.promise(); @@ -363,7 +374,20 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView# if (self.can_be_discarded()) { self.dataset.call('copy', [self.datarecord.id, {}, self.dataset.context]).then(function(new_id) { return self.on_created({ result : new_id }); - }).then(function() { + }).then(self.do_set_editable).then(function() { + def.resolve(); + }); + } + }); + return def.promise(); + }, + on_button_delete: function() { + var self = this; + var def = $.Deferred(); + $.when(this.has_been_loaded).then(function() { + if (self.can_be_discarded() && self.datarecord.id) { + self.dataset.unlink([self.datarecord.id]).then(function() { + self.on_pager_action('next'); def.resolve(); }); } @@ -381,6 +405,9 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView# * @param {Function} success callback on save success * @param {Boolean} [prepend_on_create=false] if ``do_save`` creates a new record, should that record be inserted at the start of the dataset (by default, records are added at the end) */ + do_save_then_readonly: function(success, prepend_on_create) { + return this.do_save(success, prepend_on_create).then(this.do_set_readonly); + }, do_save: function(success, prepend_on_create) { var self = this; var action = function() { @@ -428,10 +455,6 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView# this.mutating_lock = this.mutating_lock.pipe(action, action); return this.mutating_lock; }, - switch_readonly: function() { - }, - switch_editable: function() { - }, on_invalid: function() { var msg = "
      "; _.each(this.fields, function(f) { diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 0d86a840718..1fc98ba34ee 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -473,8 +473,6 @@

    - -
  • @@ -551,6 +549,7 @@
  • @@ -660,16 +659,18 @@ +
    - + - - - + + +
    @@ -1010,6 +1011,7 @@ +
    -- cgit v1.2.3 From c4a13f1b3e92261612db8bd76a8e5fbb2a258974 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 7 Nov 2011 15:44:35 +0100 Subject: [REM] Removed unused code bzr revid: fme@openerp.com-20111107144435-k693w21gnmsd0dt5 --- addons/web/static/src/js/view_form.js | 4 ---- 1 file changed, 4 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index d18066f99c5..603e2abb008 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -103,7 +103,6 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView# }); this.$form_header.find('button.oe_form_button_save').click(this.do_save_then_readonly); - this.$form_header.find('button.oe_form_button_cancel').click(this.do_cancel); this.$form_header.find('button.oe_form_button_new').click(this.on_button_new); this.$form_header.find('button.oe_form_button_duplicate').click(this.on_button_duplicate); this.$form_header.find('button.oe_form_button_delete').click(this.on_button_delete); @@ -512,9 +511,6 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView# on_action: function (action) { console.debug('Executing action', action); }, - do_cancel: function () { - console.debug("Cancelling form"); - }, reload: function() { var self = this; var act = function() { -- cgit v1.2.3 From 5290ada81f998e29da7777116e317478c69d05e6 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 8 Nov 2011 16:56:33 +0100 Subject: [FIX] correct criss-cross merge bzr revid: chs@openerp.com-20111108155633-8lymglmg46sfv0ko --- addons/web/static/src/js/boot.js | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/boot.js b/addons/web/static/src/js/boot.js index fef9b5168a8..5fba5f4d8d4 100644 --- a/addons/web/static/src/js/boot.js +++ b/addons/web/static/src/js/boot.js @@ -21,16 +21,7 @@ * * @param {Array} modules list of modules to initialize */ - init: function(modules, connection, callback) { - - if (/^(function|undefined)$/.test(typeof connection)) { - callback = connection; - connection = { - host: document.location.protocol + '//' + document.location.host, - }; - } - - + init: function(modules) { var new_instance = { // links to the global openerp _openerp: openerp, @@ -48,20 +39,6 @@ for(var i=0; i < modules.length; i++) { openerp[modules[i]](new_instance); } - - new_instance.connector = new new_instance.web.Connection(connection.host); - if (connection.login) { - new_instance.connector.login(connection.database, connection.login, connection.password, function() { - if (callback) { - callback(new_instance); - } - }); - } else { - if (callback) { - callback(new_instance); - } - } - return new_instance; } }; -- cgit v1.2.3