diff --git a/addons/web/common/http.py b/addons/web/common/http.py index 69220eec2d7..96af5afe65e 100644 --- a/addons/web/common/http.py +++ b/addons/web/common/http.py @@ -406,7 +406,7 @@ class Root(object): params = urllib.urlencode(request.args) return werkzeug.utils.redirect(self.root + '?' + params, 301)( environ, start_response) - elif request.path == '/mobile': + elif request.path == '/mobile' or ('#' in request.path): return werkzeug.utils.redirect( '/web_mobile/static/src/web_mobile.html', 301)(environ, start_response) diff --git a/addons/web_mobile/static/src/js/chrome_mobile.js b/addons/web_mobile/static/src/js/chrome_mobile.js index 516de784adc..f86e0fec5f9 100644 --- a/addons/web_mobile/static/src/js/chrome_mobile.js +++ b/addons/web_mobile/static/src/js/chrome_mobile.js @@ -151,14 +151,6 @@ openerp.web_mobile.Shortcuts = openerp.web.Widget.extend({ $.mobile.changePage("#oe_menu", "slide", false, true); }); self.$element.find('#content').find("a").click(self.on_clicked); - self.$element.find("[data-role=footer]").find('#preference').click(function(){ - if(!$('#oe_options').html().length){ - this.options = new openerp.web_mobile.Options(self, "oe_options"); - this.options.start(); - }else{ - $.mobile.changePage("#oe_options", "slide", false, true); - } - }); $.mobile.changePage("#oe_shortcuts", "slide", false, true); }); }, @@ -261,22 +253,6 @@ openerp.web_mobile.Secondary = openerp.web.Widget.extend({ this.$element.html(this.render(v)); this.$element.find("[data-role=header]").find("h1").html(this.data.name); this.$element.add(this.$secondary_menu).find('#content').find("a").click(this.on_menu_click); - this.$element.find("[data-role=footer]").find('#shrotcuts').click(function(){ - if(!$('#oe_shortcuts').html().length){ - this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts"); - this.shortcuts.start(); - }else{ - $.mobile.changePage("#oe_shortcuts", "slide", false, true); - } - }); - this.$element.find("[data-role=footer]").find('#preference').click(function(){ - if(!$('#oe_options').html().length){ - this.options = new openerp.web_mobile.Options(self, "oe_options"); - this.options.start(); - }else{ - $.mobile.changePage("#oe_options", "slide", false, true); - } - }); this.$element.find("[data-role=header]").find('#home').click(function(){ $.mobile.changePage("#oe_menu", "slide", false, true); }); @@ -328,14 +304,6 @@ openerp.web_mobile.Options = openerp.web.Widget.extend({ var self = this; this.$element.html(this.render(this)); this.$element.find("[data-role=header]").find('h1').html('Preference'); - this.$element.find("[data-role=footer]").find('#shrotcuts').click(function(){ - if(!$('#oe_shortcuts').html().length){ - this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts"); - this.shortcuts.start(); - }else{ - $.mobile.changePage("#oe_shortcuts", "slide", false, true); - } - }); this.$element.find("[data-role=header]").find('#home').click(function(){ $.mobile.changePage("#oe_menu", "slide", false, true); }); diff --git a/addons/web_mobile/static/src/js/form_mobile.js b/addons/web_mobile/static/src/js/form_mobile.js index 598f3c29739..448bc11c5aa 100644 --- a/addons/web_mobile/static/src/js/form_mobile.js +++ b/addons/web_mobile/static/src/js/form_mobile.js @@ -41,221 +41,91 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({ var fields = result.fields; var view_fields = result.arch.children; var get_fields = this.get_fields(view_fields); + var values = self.datarecord; for (var j = 0; j < view_fields.length; j++) { if (view_fields[j].tag == 'notebook') { var notebooks = view_fields[j]; } } - self.$element.html(self.render({'get_fields': get_fields, 'notebooks': notebooks || false, 'fields' : fields, 'values' : self.datarecord ,'temp_flag':'1'})); - self.formatdata(get_fields, fields, result, self.datarecord,self.element_id,'element'); + self.$element.html(self.render({'get_fields': get_fields, 'notebooks': notebooks || false, 'fields' : fields, 'values' : values ,'temp_flag':'1'})); self.$element.find("[data-role=header]").find('h1').html(self.head_title); self.$element.find("[data-role=header]").find('#home').click(function(){ $.mobile.changePage("#oe_menu", "slide", false, true); }); - self.$element.find("[data-role=footer]").find('#shrotcuts').click(function(){ - if(!$('#oe_shortcuts').html().length){ - this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts"); - this.shortcuts.start(); - }else{ - $.mobile.changePage("#oe_shortcuts", "slide", false, true); - } - }); - self.$element.find("[data-role=footer]").find('#preference').click(function(){ - if(!$('#oe_options').html().length){ - this.options = new openerp.web_mobile.Options(self, "oe_options"); - this.options.start(); - }else{ - $.mobile.changePage("#oe_options", "slide", false, true); - } - }); - self.$element.find('#formbutton').click(function(){ - var head = $(this).prev().find('select').find("option:selected").text(); - var selected_id = $(this).prev().find('select').val(); - var select_model = $(this).prev().find('select').attr('for'); - if(selected_id!="false"){ - if(!$('[id^="oe_form_'+selected_id+select_model+'"]').html()){ - $('
').appendTo('#moe'); - this.formview = new openerp.web_mobile.FormView(self, "oe_form_"+selected_id+select_model, selected_id, '', head, select_model, false); - this.formview.start(); - }else{ - $.mobile.changePage('#oe_form_'+selected_id+select_model, "slide", false, true); - } - } - }); self.$element.find('[data-role=collapsible-set]').find('[data-role=collapsible]').each(function(i){ for (var k = 0; k < notebooks.children.length; k++) { if (notebooks.children[k].attrs.string == $(this).attr('id')) { - get_fields = self.get_fields(notebooks.children[k].children); - for (var i = 0; i < get_fields.length; i++) { - if (fields[get_fields[i].attrs.name].type == 'one2many'){ - self.relational_fields = get_fields[i].attrs.name; - if(fields[get_fields[i].attrs.name].views.form){ - var get_fields_test = self.get_fields(fields[get_fields[i].attrs.name].views.form.arch.children); - var fields_test = fields[get_fields[i].attrs.name]['views'].form.fields; - var notebook=fields[get_fields[i].attrs.name].views.form.arch; - } - } - } - $(this).find('div#page_content').html(self.render({'get_fields': get_fields,'fields' : result.fields, 'values' : self.datarecord})); + get_fields_notebook = self.get_fields(notebooks.children[k].children); + $(this).find('div#page_content').html(self.render({'get_fields': get_fields_notebook,'fields' : fields, 'values' : values})); } - self.formatdata(get_fields, fields, result, self.datarecord,'page_content','element'); - - $(this).find('div#page_content').find('#formbutton').click(function(){ - var head = $(this).prev().find('select').find("option:selected").text(); - var selected_id = $(this).prev().find('select').val(); - var select_model = $(this).prev().find('select').attr('for'); - if(selected_id!="false"){ - if(!$('[id^="oe_form_'+selected_id+select_model+'"]').html()){ - $('
').appendTo('#moe'); - this.formview = new openerp.web_mobile.FormView(self, "oe_form_"+selected_id+select_model, selected_id, '', head, select_model, false); - this.formview.start(); - }else{ - $.mobile.changePage('#oe_form_'+selected_id+select_model, "slide", false, true); - } - } - }); } }); - self.$element.find('[data-role=collapsible-set]').find('[data-role=collapsible]').find('div#page_content').find('[data-role=content]').find('ul').find('li').click(function(ev){ + self.$element.find('#o2m_m2m').click(function(ev) { ev.preventDefault(); ev.stopPropagation(); - var latid,lastid; - $(this).parents().each(function(){ - latid = $(this).attr('id'); - self.$element.find('[data-role=collapsible-set]').find('[data-role=collapsible]').each(function(){ - if(latid==$(this).attr('id')){ - lastid = $(this).attr('id'); - } - }); - }); var relational = $(this).attr('for'); - if(result.fields[relational]){ - var head = $.trim($(this).text()); - var dataset = new openerp.web.DataSetSearch(self, result.fields[relational].relation, result.fields[relational].context); - dataset.domain=[['id', 'in', self.datarecord[relational]]]; - dataset.read_slice([], {}, function(result1,ids){ - _.extend(self.action.context,{"html_name_get" : true}); - var dataset1 = new openerp.web.DataSet(self, result.fields[relational].relation,result.fields[relational].context); - dataset1.name_get(dataset.ids,function(res){ - var additional = ""; - if(res['html_name_get']){ - additional = res['display']; - } - if(!$('[id^="oe_list_'+relational+'_'+self.element_id+'"]').html()){ - $('
').appendTo('#moe'); - $('[id^="oe_list_'+relational+'_'+self.element_id+'"]').html(openerp.web.qweb.render("ListView", {'records' : res,'data': additional})); - $('[id^="oe_list_'+relational+'_'+self.element_id+'"]').find("[data-role=header]").find('h1').html(head); - $('[id^="oe_list_'+relational+'_'+self.element_id+'"]').find("[data-role=header]").find('#home').click(function(){ - $.mobile.changePage("#oe_menu", "slide", false, true); - }); - $('[id^="oe_list_'+relational+'_'+self.element_id+'"]').find("[data-role=footer]").find('#shrotcuts').click(function(){ - if(!$('#oe_shortcuts').html().length){ - this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts"); - this.shortcuts.start(); - }else{ - $.mobile.changePage("#oe_shortcuts", "slide", false, true); - } - }); - $('[id^="oe_list_'+relational+'_'+self.element_id+'"]').find("[data-role=footer]").find('#preference').click(function(){ - if(!$('#oe_options').html().length){ - this.options = new openerp.web_mobile.Options(self, "oe_options"); - this.options.start(); - }else{ - $.mobile.changePage("#oe_options", "slide", false, true); - } - }); - $('[id^="oe_list_'+relational+'_'+self.element_id+'"]').find("a#list-id").click(function(ev){ - ev.preventDefault(); - ev.stopPropagation(); - var head_title = $(this).text(); - var listid = $(ev.currentTarget).data('id'); - dataset = new openerp.web.DataSetSearch(self, dataset.model, null, null); - dataset.read_slice([],{}, function (result_relational) { - for (var i = 0; i < result_relational.length; i++) { - if (result_relational[i].id == listid) { - var data_relational = result_relational[i]; - } - } - if(!$('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').html()){ - $('
').appendTo('#moe'); - - for (var k = 0; k < notebooks.children.length; k++) { - if (notebooks.children[k].attrs.string == lastid) { - get_fields = self.get_fields(notebooks.children[k].children); - for (var i = 0; i < get_fields.length; i++) { - if (fields[get_fields[i].attrs.name].type == 'one2many'){ - self.relational_fields = get_fields[i].attrs.name; - if(fields[get_fields[i].attrs.name].views.form){ - var get_fields_test = self.get_fields(fields[get_fields[i].attrs.name].views.form.arch.children); - var fields_test = fields[get_fields[i].attrs.name]['views'].form.fields; - var notebook=fields[get_fields[i].attrs.name].views.form.arch; - } - } - } - } - } - if(notebook){ - $('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').html(self.render({'get_fields': get_fields_test, 'notebooks': false, 'fields' : fields_test, 'values' : data_relational, 'temp_flag':'1' })); - }else{ - $('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').html(self.render({'get_fields': get_fields_test, 'notebooks': false, 'fields' : fields, 'values' : data_relational, 'temp_flag':'1' })); - } - $('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').find("[data-role=header]").find('h1').html(head_title); - $('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').find("[data-role=header]").find('#home').click(function(){ - $.mobile.changePage("#oe_menu", "slide", false, true); - }); - $('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').find("[data-role=footer]").find('#shrotcuts').click(function(){ - if(!$('#oe_shortcuts').html().length){ - this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts"); - this.shortcuts.start(); - }else{ - $.mobile.changePage("#oe_shortcuts", "slide", false, true); - } - }); - $('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').find("[data-role=footer]").find('#preference').click(function(){ - if(!$('#oe_options').html().length){ - this.options = new openerp.web_mobile.Options(self, "oe_options"); - this.options.start(); - }else{ - $.mobile.changePage("#oe_options", "slide", false, true); - } - }); - $('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').find('#formbutton').click(function(){ - var head = $(this).prev().find('select').find("option:selected").text(); - var selected_id = $(this).prev().find('select').val(); - var select_model = $(this).prev().find('select').attr('for'); - if(selected_id!="false"){ - if(!$('[id^="oe_form_'+selected_id+select_model+'"]').html()){ - $('
').appendTo('#moe'); - this.formview = new openerp.web_mobile.FormView(self, "oe_form_"+selected_id+select_model, selected_id, '', head, select_model, false); - this.formview.start(); - }else{ - $.mobile.changePage('#oe_form_'+selected_id+select_model, "slide", false, true); - } - } - }); - if(notebook){ - self.formatdata(get_fields_test, fields_test, result, data_relational,'oe_form_'+listid+result.fields[relational].relation,'element'); - }else{ - self.formatdata(get_fields_test, fields, result, data_relational,'oe_form_'+listid+result.fields[relational].relation,'element'); - } - $.mobile.changePage('#oe_form_'+listid+result.fields[relational].relation, "slide", false, true); - self.formatdata('', '', '', '','oe_form_'+listid+result.fields[relational].relation,'slider'); + var rel_field = fields[relational]; + var rel_ids = values[relational]; + var head = rel_field.string; + if (rel_ids) { + var datasearch = new openerp.web.DataSetSearch(self, rel_field.relation, rel_field.context); + datasearch.domain=[['id', 'in', rel_ids]]; + datasearch.read_slice(['name'], {context:rel_field.context, domain: datasearch.domain, limit:80}, function(listrec){ + _.extend(rel_field.context,{"html_name_get" : true}); + var dataset = new openerp.web.DataSet(self, rel_field.relation,rel_field.context); + dataset.name_get(listrec,function(res){ + var additional = ""; + if(res['html_name_get']){ + additional = res['display']; + } + if(!$('[id^="oe_list_'+relational+'_'+self.element_id+'"]').html()){ + $('
').appendTo('#moe'); + $('[id^="oe_list_'+relational+'_'+self.element_id+'"]').html(openerp.web.qweb.render("ListView", {'records' : res,'data': additional})); + $('[id^="oe_list_'+relational+'_'+self.element_id+'"]').find("[data-role=header]").find('h1').html(head); + $('[id^="oe_list_'+relational+'_'+self.element_id+'"]').find("[data-role=header]").find('#home').click(function(){ + $.mobile.changePage("#oe_menu", "slide", false, true); + }); + $('[id^="oe_list_'+relational+'_'+self.element_id+'"]').find("a#list-id").click(function(ev){ + ev.preventDefault(); + ev.stopPropagation(); + var head_title = $(this).text(); + var listid = $(ev.currentTarget).data('id'); + if(!$('[id^="oe_form_'+listid+rel_field.relation+'"]').html()){ + $('
').appendTo('#moe'); + this.formview = new openerp.web_mobile.FormView(self, "oe_form_"+listid+rel_field.relation, listid, '', head, rel_field.relation, false); + this.formview.start(); }else{ - $.mobile.changePage('#oe_form_'+listid+result.fields[relational].relation, "slide", false, true); + $.mobile.changePage('#oe_form_'+listid+rel_field.relation, "slide", false, true); } }); - }); - $.mobile.changePage("#oe_list_"+relational+"_"+self.element_id, "slide", false, true); - }else{ - $.mobile.changePage("#oe_list_"+relational+"_"+self.element_id, "slide", false, true); - } + $.mobile.changePage("#oe_list_"+relational+"_"+self.element_id, "slide", false, true); + }else{ + $.mobile.changePage("#oe_list_"+relational+"_"+self.element_id, "slide", false, true); + } }); - }); + }); } }); + self.$element.find('#m2o_btn').click(this.open_m2o_form); $.mobile.changePage("#"+self.element_id, "slide", false, true); self.formatdata('', '', '', '',self.element_id,'slider'); }, + open_m2o_form : function(ev) { + ev.preventDefault(); + ev.stopPropagation(); + var head = $(this).find('a').attr('name'); + var selected_id = $(this).find('a').attr('value'); + var select_model = $(this).attr('for'); + if(selected_id){ + if(!$('[id^="oe_form_'+selected_id+select_model+'"]').html()){ + $('
').appendTo('#moe'); + this.formview = new openerp.web_mobile.FormView(self, "oe_form_"+selected_id+select_model, selected_id, '', head, select_model, false); + this.formview.start(); + }else{ + $.mobile.changePage('#oe_form_'+selected_id+select_model, "slide", false, true); + } + } + }, get_fields: function(view_fields, fields) { this.fields = fields || []; for (var i=0; i < view_fields.length; i++){ @@ -324,16 +194,6 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({ $(this).css('left', '-9999px'); }); }); - // image displayed with m2o field - $('[id^="'+id+'"]').find('div[class=ui-select]').each(function(){ - $(this).next().each(function(){ - if($(this).attr('id')=="formbutton"){ - $(this).prev().css('display','inline-table'); - $(this).prev().find('a').find('.ui-btn-inner').removeClass('ui-btn-inner'); - $(this).prev().find('a').find('span:first').css('padding-right','150px'); - } - }); - }); } } }); diff --git a/addons/web_mobile/static/src/js/list_mobile.js b/addons/web_mobile/static/src/js/list_mobile.js index 7e9fff16262..67058bf72f6 100644 --- a/addons/web_mobile/static/src/js/list_mobile.js +++ b/addons/web_mobile/static/src/js/list_mobile.js @@ -30,13 +30,12 @@ openerp.web_mobile.ListView = openerp.web.Widget.extend({ }, on_search_data: function(ev){ var self = this; - var dataset = new openerp.web.DataSetSearch(this, this.action.res_model,this.action.context); - dataset.domain = self.action.domain; - dataset.read_slice([], {}, function(result,ids){ + var datasearch = new openerp.web.DataSetSearch(self, self.action.res_model,self.action.context); + datasearch.domain = self.action.domain; + datasearch.read_slice(['name'], {context:datasearch.context, domain: datasearch.domain, limit:80}, function(listresult){ _.extend(self.action.context,{"html_name_get" : true}); - - var dataset1 = new openerp.web.DataSet(self, self.action.res_model,self.action.context); - dataset1.name_get(dataset.ids,function(res){ + var dataset = new openerp.web.DataSet(self, datasearch.model,datasearch.context); + dataset.name_get(listresult,function(res){ var additional = ""; if(res['html_name_get']){ additional = res['display']; @@ -46,22 +45,6 @@ openerp.web_mobile.ListView = openerp.web.Widget.extend({ self.$element.find("[data-role=header]").find('#home').click(function(){ $.mobile.changePage("#oe_menu", "slide", false, true); }); - self.$element.find("[data-role=footer]").find('#shrotcuts').click(function(){ - if (!$('#oe_shortcuts').html().length) { - this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts"); - this.shortcuts.start(); - }else{ - $.mobile.changePage("#oe_shortcuts", "slide", false, true); - } - }); - self.$element.find("[data-role=footer]").find('#preference').click(function(){ - if(!$('#oe_options').html().length){ - this.options = new openerp.web_mobile.Options(self, "oe_options"); - this.options.start(); - }else{ - $.mobile.changePage("#oe_options", "slide", false, true); - } - }); self.$element.find("a#list-id").click(self.on_list_click); $.mobile.changePage("#"+self.element_id, "slide", false, true); }); diff --git a/addons/web_mobile/static/src/xml/web_mobile.xml b/addons/web_mobile/static/src/xml/web_mobile.xml index d2af2e95573..f94117e6e0e 100644 --- a/addons/web_mobile/static/src/xml/web_mobile.xml +++ b/addons/web_mobile/static/src/xml/web_mobile.xml @@ -72,7 +72,6 @@ - @@ -114,7 +113,6 @@ - @@ -126,7 +124,6 @@ - @@ -159,7 +156,6 @@ - @@ -283,7 +279,9 @@ @@ -292,35 +290,23 @@ : - - - - - - - + + + + @@ -343,8 +329,5 @@ - - - \ No newline at end of file