/*--------------------------------------------------------- * OpenERP Web Mobile Form View *---------------------------------------------------------*/ openerp.web_mobile.form_mobile = function (openerp) { openerp.web_mobile.FormView = openerp.web.Widget.extend({ init: function(session, element_id, list_id, action) { this._super(session, element_id); this.list_id = list_id; this.action = action; this.content_expanded_class = "ui-collapsible-content ui-collapsible-content-expanded"; this.content_collapsed_class = "ui-collapsible-content ui-collapsible-content-collapsed"; this.expanded_class = "ui-collapsible-content-expanded"; this.collapsed_class = "ui-collapsible-content-collapsed"; this.plus_class = "ui-icon-plus"; this.minus_class = "ui-icon-minus"; }, 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 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]; } } self.rpc("/web/view/load", {"model": model, "view_id": view_id, "view_type": "form", context: context}, function (result) { var fields = result.fields; 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]; } } self.$element.html(QWeb.render("FormView", {'get_fields': get_fields, 'notebooks': notebooks || false, 'fields' : fields, 'values' : data })); self.$element.find("#header").find('h1').html(self.action.name); self.$element.find('select').change(function(ev){ selection.on_select_option(ev); }); self.$element.find('a').click(function(){ for (var k = 0; k < notebooks.children.length; k++) { var text = $(this).find('.ui-btn-text').text(); var next = $(this).next(); var span = $(this).find('span .ui-icon'); if (notebooks.children[k].attrs.string == $.trim(text)) { get_fields = self.get_fields(notebooks.children[k].children); $(this).parents().find('form').find('div').each( function() { var prev = $(this).prev(); var trim_class = $.trim($(this).attr('class')); if (trim_class == self.content_expanded_class || trim_class == self.content_collapsed_class) { prev.removeClass('ui-btn-active'); if ($.trim(prev.find('.ui-btn-text').text()) != notebooks.children[k].attrs.string) { self.expanded($(this),prev.find('span .ui-icon')); } } }); if (next.hasClass(self.content_collapsed_class)) { self.collapsed(next,span); } else if (next.hasClass(self.content_expanded_class)) { self.expanded(next,span); } if (!next.find('.detail').html().length) { for (var i = 0; i < get_fields.length; i++) { if (fields[get_fields[i].attrs.name].type == 'one2many'){ 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; } var relational = get_fields[i].attrs.name; } } if(notebook){ next.find('.detail').append(QWeb.render("FormView", {'get_fields': get_fields,'fields' : result.fields, 'values' : data,'til': notebook.attrs.string })); }else{ next.find('.detail').append(QWeb.render("FormView", {'get_fields': get_fields,'fields' : result.fields, 'values' : data })); } } //$.mobile.changePage($("#oe_form"), "slide", true, true); /*next.find('.detail').find('li').click(function(){ if(data[relational]){ var dataset = new openerp.web.DataSetStatic(self, result.fields[relational].relation, result.fields[relational].context); dataset.domain=[['id', 'in', data[relational]]]; dataset.name_search('', dataset.domain, 'in',false ,function(res){ for(var i=0;i