1 /*---------------------------------------------------------
2 * OpenERP Web Mobile List View
3 *---------------------------------------------------------*/
5 openerp.web_mobile.list_mobile = function (openerp) {
7 openerp.web_mobile.ListView = openerp.web.Widget.extend({
11 init: function(session, element_id, list_id) {
12 this._super(session, element_id);
13 this.list_id = list_id;
16 this.rpc('/web/menu/action', {'menu_id': this.list_id}, this.on_menu_action_loaded);
18 on_menu_action_loaded: function(data) {
20 if (data.action.length) {
21 this.action = data.action[0][2];
22 return this.rpc('/web/listview/load', {
23 model: this.action.res_model,
24 view_id: this.action.views[0][0],
26 context: this.action.context,
28 }, this.on_search_data);
31 on_search_data: function(ev){
34 var datasearch = new openerp.web.DataSetSearch(self, self.action.res_model,self.action.context);
35 datasearch.domain = self.action.domain;
36 datasearch.read_slice(['name'], {context:datasearch.context, domain: datasearch.domain, limit:80}).then(function(listresult){
37 _.each(listresult, function(i) {
40 _.extend(self.action.context,{"html_name_get" : true});
41 var dataset = new openerp.web.DataSet(self, datasearch.model,datasearch.context);
42 dataset.name_get(list_ids,function(res){
44 if(res['html_name_get']){
45 additional = res['display'];
47 self.$element.html(self.render({'records': res, 'data': additional }));
48 self.$element.find("[data-role=header]").find('h1').html(self.action.name);
49 self.$element.find("[data-role=header]").find('#home').click(function(){
50 $.mobile.changePage("#oe_menu", "slide", false, true);
52 self.$element.find("a#list-id").click(self.on_list_click);
53 $.mobile.changePage("#"+self.element_id, "slide", false, true);
54 self.$element.find("a#list-id").find('span').addClass('desc');
58 on_list_click: function(ev) {
59 var $record = $(ev.currentTarget);
63 id = $record.data('id');
64 head_title = $.trim($record.text());
65 if(!$('[id^="oe_form_'+id+this.action.res_model+'"]').html()){
66 $('<div id="oe_form_'+id+this.action.res_model+'" data-role="page" data-url="oe_form_'+id+this.action.res_model+'"> </div>').appendTo('#moe');
67 this.formview = new openerp.web_mobile.FormView(this, "oe_form_"+id+this.action.res_model, id, this.action, head_title, '' ,'');
68 this.formview.start();
70 $.mobile.changePage('#oe_form_'+id+this.action.res_model, "slide", false, true);