diff --git a/addons/web_mobile/static/src/js/chrome_mobile.js b/addons/web_mobile/static/src/js/chrome_mobile.js
index 10616fb0846..231ba37f366 100644
--- a/addons/web_mobile/static/src/js/chrome_mobile.js
+++ b/addons/web_mobile/static/src/js/chrome_mobile.js
@@ -141,12 +141,13 @@ openerp.web_mobile.Shortcuts = openerp.web.Widget.extend({
$shortcut = $(ev.currentTarget);
id = $shortcut.data('menu');
res_id = $shortcut.data('res');
+
if(!$('[id^="oe_list_'+res_id+'"]').html()){
$('
').appendTo('#moe');
this.listview = new openerp.web_mobile.ListView(self, "oe_list_"+res_id, res_id);
this.listview.start();
}else{
- $.mobile.changePage($('#oe_list_'+res_id), "slide", true, true);
+ $.mobile.changePage('#oe_list_'+res_id, "slide", true, true);
}
ev.preventDefault();
ev.stopPropagation();
@@ -260,6 +261,7 @@ openerp.web_mobile.Secondary = openerp.web.Widget.extend({
id = $menu.data('menu');
ev.preventDefault();
ev.stopPropagation();
+
if(!$('[id^="oe_list_'+id+'"]').html()){
$('
').appendTo('#moe');
this.listview = new openerp.web_mobile.ListView(this, "oe_list_"+id, id);
diff --git a/addons/web_mobile/static/src/js/form_mobile.js b/addons/web_mobile/static/src/js/form_mobile.js
index 7b9a922a682..570f6844ba7 100644
--- a/addons/web_mobile/static/src/js/form_mobile.js
+++ b/addons/web_mobile/static/src/js/form_mobile.js
@@ -5,20 +5,30 @@
openerp.web_mobile.form_mobile = function (openerp) {
openerp.web_mobile.FormView = openerp.web.Widget.extend({
- init: function(session, element_id, list_id, action, head_title) {
+ init: function(session, element_id, list_id, action, head_title, resmodel, viewid) {
this._super(session, element_id);
this.list_id = list_id;
this.action = action;
this.head_title = head_title;
+ this.resmodel = resmodel;
+ this.viewid = viewid;
+
},
start: function() {
var self = this;
var id = this.list_id;
- var model = this.action.res_model;
- var view_id = this.action.views[1][0];
- this.dataset = new openerp.web.DataSetSearch(this, this.action.res_model, null, null);
+
+ var model = this.action.res_model || this.resmodel;
+ if(this.action){
+ var view_id = this.action.views[1][0];
+ }else{
+ var view_id = this.viewid;
+ }
+
+ this.dataset = new openerp.web.DataSetSearch(this, model, null, null);
var context = new openerp.web.CompoundContext(this.dataset.get_context());
this.dataset.read_slice([],{}, function (result) {
+
for (var i = 0; i < result.length; i++) {
if (result[i].id == id) {
var data = result[i];
@@ -29,6 +39,7 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
var view_fields = result.arch.children;
var get_fields = self.get_fields(view_fields);
var selection = new openerp.web_mobile.Selection();
+
for (var j = 0; j < view_fields.length; j++) {
if (view_fields[j].tag == 'notebook') {
var notebooks = view_fields[j];
@@ -58,10 +69,19 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
$.mobile.changePage("#oe_options", "slide", true, true);
}
});
- self.$element.find('select').change(function(ev){
- selection.on_select_option(ev);
+ self.$element.find('#formbutton').click(function(){
+ 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", true, true);
+ }
+ }
});
-
self.$element.find('[data-role=collapsible-set]').find('[data-role=collapsible]').each(function(i){
for (var k = 0; k < notebooks.children.length; k++) {
@@ -84,6 +104,19 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
}else{
$(this).find('p').html(QWeb.render("FormView", {'get_fields': get_fields,'fields' : result.fields, 'values' : data }));
}
+ $(this).find('p').find('#formbutton').click(function(){
+ 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", true, true);
+ }
+ }
+ });
}
});
@@ -101,6 +134,7 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
});
var relational = $(this).attr('for');
if(result.fields[relational]){
+
var head = $.trim($(this).text());
var dataset = new openerp.web.DataSetStatic(self, result.fields[relational].relation, result.fields[relational].context);
dataset.domain=[['id', 'in', data[relational]]];
@@ -111,12 +145,12 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
}
if(!$('[id^="oe_list_'+relational+'_'+self.element_id+'"]').html()){
$('
').appendTo('#moe');
- $('#oe_list_'+relational+'_'+self.element_id).html(QWeb.render("ListView", {'records' : res}));
- $('#oe_list_'+relational+'_'+self.element_id).find("[data-role=header]").find('h1').html(head);
- $('#oe_list_'+relational+'_'+self.element_id).find("[data-role=header]").find('#home').click(function(){
+ $('[id^="oe_list_'+relational+'_'+self.element_id+'"]').html(QWeb.render("ListView", {'records' : res}));
+ $('[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", true, true);
});
- $('#oe_list_'+relational+'_'+self.element_id).find("[data-role=footer]").find('#shrotcuts').click(function(){
+ $('[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();
@@ -125,7 +159,7 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
$.mobile.changePage("#oe_shortcuts", "slide", true, true);
}
});
- $('#oe_list_'+relational+'_'+self.element_id).find("[data-role=footer]").find('#preference').click(function(){
+ $('[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();
@@ -134,7 +168,7 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
$.mobile.changePage("#oe_options", "slide", true, true);
}
});
- $('#oe_list_'+relational+'_'+self.element_id).find("a#list-id").click(function(ev){
+ $('[id^="oe_list_'+relational+'_'+self.element_id+'"]').find("a#list-id").click(function(ev){
ev.preventDefault();
ev.stopPropagation();
var head_title = $(this).text();
@@ -146,8 +180,8 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
var data_relational = result_relational[i];
}
}
- if(!$('[id^="oe_listform_'+listid+'"]').html()){
- $('
').appendTo('#moe');
+ 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);
@@ -163,16 +197,13 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
}
}
}
- $('#oe_listform_'+listid).html(QWeb.render("FormView", {'get_fields': get_fields_test, 'notebooks': false, 'fields' : fields_test, 'values' : data_relational, 'temp_flag':'1' }));
+ $('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').html(QWeb.render("FormView", {'get_fields': get_fields_test, 'notebooks': false, 'fields' : fields_test, 'values' : data_relational, 'temp_flag':'1' }));
- $('#oe_listform_'+listid).find('select').change(function(ev){
- selection.on_select_option(ev);
- });
- $('#oe_listform_'+listid).find("[data-role=header]").find('h1').html(head_title);
- $('#oe_listform_'+listid).find("[data-role=header]").find('#home').click(function(){
+ $('[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", true, true);
});
- $('#oe_listform_'+listid).find("[data-role=footer]").find('#shrotcuts').click(function(){
+ $('[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();
@@ -181,7 +212,7 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
$.mobile.changePage("#oe_shortcuts", "slide", true, true);
}
});
- $('#oe_listform_'+listid).find("[data-role=footer]").find('#preference').click(function(){
+ $('[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();
@@ -190,9 +221,22 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
$.mobile.changePage("#oe_options", "slide", true, true);
}
});
- $.mobile.changePage('#oe_listform_'+listid, "slide", true, true);
+ $('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').find('#formbutton').click(function(){
+ 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", true, true);
+ }
+ }
+ });
+ $.mobile.changePage('#oe_form_'+listid+result.fields[relational].relation, "slide", true, true);
}else{
- $.mobile.changePage('#oe_listform_'+listid, "slide", true, true);
+ $.mobile.changePage('#oe_form_'+listid+result.fields[relational].relation, "slide", true, true);
}
});
});
diff --git a/addons/web_mobile/static/src/js/list_mobile.js b/addons/web_mobile/static/src/js/list_mobile.js
index ba43274f32e..654e76ca0be 100644
--- a/addons/web_mobile/static/src/js/list_mobile.js
+++ b/addons/web_mobile/static/src/js/list_mobile.js
@@ -59,12 +59,12 @@ openerp.web_mobile.ListView = openerp.web.Widget.extend({
id = $record.data('id');
head_title = $.trim($record.text());
- if(!$('[id^="oe_form_'+id+'"]').html()){
- $('
').appendTo('#moe');
- this.formview = new openerp.web_mobile.FormView(this, "oe_form_"+id, id, this.action, head_title);
+ if(!$('[id^="oe_form_'+id+this.action.res_model+'"]').html()){
+ $('
').appendTo('#moe');
+ this.formview = new openerp.web_mobile.FormView(this, "oe_form_"+id+this.action.res_model, id, this.action, head_title, '' ,'');
this.formview.start();
}else{
- $.mobile.changePage('#oe_form_'+id, "slide", true, true);
+ $.mobile.changePage('#oe_form_'+id+this.action.res_model, "slide", true, true);
}
}
});
diff --git a/addons/web_mobile/static/src/xml/web_mobile.xml b/addons/web_mobile/static/src/xml/web_mobile.xml
index 89734d40890..bac1b262596 100644
--- a/addons/web_mobile/static/src/xml/web_mobile.xml
+++ b/addons/web_mobile/static/src/xml/web_mobile.xml
@@ -232,7 +232,7 @@
:
-