From 109ddd9d0ca7760806aef959f55ce649f2036df0 Mon Sep 17 00:00:00 2001 From: "Vaibhav (OpenERP)" Date: Thu, 3 Nov 2011 16:21:41 +0530 Subject: [PATCH 001/185] [IMP] Gantt View.Still need to improve for group by. bzr revid: vda@tinyerp.com-20111103105141-dahiz09fvu0l45bu --- .../lib/dhtmlxGantt/sources/dhtmlxcommon.js | 31 +++ .../lib/dhtmlxGantt/sources/dhtmlxgantt.js | 19 +- addons/web_gantt/static/src/js/gantt.js | 202 ++++++++++++++---- addons/web_gantt/static/src/xml/web_gantt.xml | 2 +- 4 files changed, 197 insertions(+), 57 deletions(-) diff --git a/addons/web_gantt/static/lib/dhtmlxGantt/sources/dhtmlxcommon.js b/addons/web_gantt/static/lib/dhtmlxGantt/sources/dhtmlxcommon.js index bc7de14346d..7f68a0a702c 100644 --- a/addons/web_gantt/static/lib/dhtmlxGantt/sources/dhtmlxcommon.js +++ b/addons/web_gantt/static/lib/dhtmlxGantt/sources/dhtmlxcommon.js @@ -2,6 +2,37 @@ Copyright DHTMLX LTD. http://www.dhtmlx.com To use this component please contact sales@dhtmlx.com to obtain license */ + +dhtmlx=function(obj){ + for (var a in obj) dhtmlx[a]=obj[a]; + return dhtmlx; //simple singleton +}; +dhtmlx.extend_api=function(name,map,ext){ + var t = window[name]; + if (!t) return; //component not defined + window[name]=function(obj){ + if (obj && typeof obj == "object" && !obj.tagName){ + var that = t.apply(this,(map._init?map._init(obj):arguments)); + //global settings + for (var a in dhtmlx) + if (map[a]) this[map[a]](dhtmlx[a]); + //local settings + for (var a in obj){ + if (map[a]) this[map[a]](obj[a]); + else if (a.indexOf("on")==0){ + this.attachEvent(a,obj[a]); + } + } + } else + var that = t.apply(this,arguments); + if (map._patch) map._patch(this); + return that||this; + }; + window[name].prototype=t.prototype; + if (ext) + dhtmlXHeir(window[name].prototype,ext); +}; + dhtmlxAjax={ get:function(url,callback){ var t=new dtmlXMLLoaderObject(true); diff --git a/addons/web_gantt/static/lib/dhtmlxGantt/sources/dhtmlxgantt.js b/addons/web_gantt/static/lib/dhtmlxGantt/sources/dhtmlxgantt.js index 0d838fdd510..52b9b562e96 100644 --- a/addons/web_gantt/static/lib/dhtmlxGantt/sources/dhtmlxgantt.js +++ b/addons/web_gantt/static/lib/dhtmlxGantt/sources/dhtmlxgantt.js @@ -173,9 +173,8 @@ GanttProjectInfo.prototype.getTaskByIdInTree = function(parentTask, id) * @type: public * @topic: 0 */ -function GanttTaskInfo(id, name, est, duration, percentCompleted, predecessorTaskId, color) +function GanttTaskInfo(id, name, est, duration, percentCompleted, predecessorTaskId) { - this.color = color || "white"; this.Id = id; this.Name = name; this.EST = est; @@ -349,7 +348,7 @@ GanttProject.prototype.create = function() * @type: public * @topic: 0 */ -function GanttChart(day_length) +function GanttChart() { this.Error = new GanttError(); this.dhtmlXMLSenderObject = new dhtmlXMLSenderObject(this); @@ -357,7 +356,7 @@ function GanttChart(day_length) //settings this.heightTaskItem = 12; this.dayInPixels = 24; - this.hoursInDay = day_length; + this.hoursInDay = 8; this._showTreePanel = true; this._showTooltip = true; this.isShowDescTask = false; @@ -1162,7 +1161,7 @@ GanttProject.prototype.deleteChildTask = function(task) * @type: public * @topic: 1 */ -GanttProject.prototype.insertTask = function(id, name, EST, Duration, PercentCompleted, predecessorTaskId, color, parentTaskId) +GanttProject.prototype.insertTask = function(id, name, EST, Duration, PercentCompleted, predecessorTaskId, parentTaskId) { var task = null; var _task = null; @@ -1205,7 +1204,7 @@ GanttProject.prototype.insertTask = function(id, name, EST, Duration, PercentCom return false; } - task = new GanttTaskInfo(id, name, EST, Duration, PercentCompleted, predecessorTaskId, color); + task = new GanttTaskInfo(id, name, EST, Duration, PercentCompleted, predecessorTaskId); if (!this.Chart.checkPosParentTask(parentTask, task)) { this.Chart.Error.throwError("DATA_INSERT_ERROR", 19, [parentTaskId,id]); @@ -4870,13 +4869,11 @@ GanttTask.prototype.createTaskItem = function() cellTblTask.height = this.Chart.heightTaskItem + "px"; cellTblTask.width = this.TaskInfo.PercentCompleted + "%"; cellTblTask.style.lineHeight = "1px"; - cellTblTask.style.backgroundColor = self.TaskInfo.color; - var imgPr = document.createElement("img"); imgPr.style.width = (this.TaskInfo.PercentCompleted * this.TaskInfo.Duration * this.Chart.hourInPixelsWork) / 100 + "px"; imgPr.style.height = this.Chart.heightTaskItem + "px"; cellTblTask.appendChild(imgPr); - //imgPr.src = this.Chart.imgs + "progress_filled.png"; + imgPr.src = this.Chart.imgs + "progress_filled.png"; } if (this.TaskInfo.PercentCompleted != 100) @@ -4946,9 +4943,9 @@ GanttTask.prototype.createTaskItem = function() } var taskClick = function() { - self.Chart.callEvent("onTaskDblClick", [self]); + self.Chart.callEvent("onTaskClick", [self]); }; - this.addEvent(divMove, 'dblclick', taskClick, false); + this.addEvent(divMove, 'click', taskClick, false); if (this.Chart.isEditable) { diff --git a/addons/web_gantt/static/src/js/gantt.js b/addons/web_gantt/static/src/js/gantt.js index bdd57b7bf0a..3ba19a67c98 100644 --- a/addons/web_gantt/static/src/js/gantt.js +++ b/addons/web_gantt/static/src/js/gantt.js @@ -2,7 +2,9 @@ * OpenERP web_gantt *---------------------------------------------------------*/ openerp.web_gantt = function (openerp) { +var _t = openerp.web._t; var QWeb = openerp.web.qweb; + QWeb.add_template('/web_gantt/static/src/xml/web_gantt.xml'); openerp.web.views.add('gantt', 'openerp.web_gantt.GanttView'); openerp.web_gantt.GanttView = openerp.web.View.extend({ @@ -13,68 +15,167 @@ init: function(parent, dataset, view_id) { this.dataset = dataset; this.model = dataset.model; this.view_id = view_id; - this.fields_views = {}; - this.widgets = {}; - this.widgets_counter = 0; - this.fields = this.dataset.fields ? this.dataset.fields: {}; - this.ids = this.dataset.ids; - this.name = ""; - this.date_start = ""; - this.date_delay = ""; - this.date_stop = ""; - this.color_field = ""; - this.colors = []; - this.color_values = []; - this.calendar_fields = {}; - this.info_fields = []; - this.domain = this.dataset._domain ? this.dataset._domain: []; + this.domain = this.dataset.domain || []; + this.groupby = []; this.context = this.dataset.context || {}; + this.has_been_loaded = $.Deferred(); +// this.ganttChartControl = new GanttChart(); + this.COLOR_PALETTE = ['#ccccff', '#cc99ff', '#75507b', '#3465a4', '#73d216', '#c17d11', '#edd400', + '#fcaf3e', '#ef2929', '#ff00c9', '#ad7fa8', '#729fcf', '#8ae234', '#e9b96e', '#fce94f', + '#ff8e00', '#ff0000', '#b0008c', '#9000ff', '#0078ff', '#00ff00', '#e6ff00', '#ffff00', + '#905000', '#9b0000', '#840067', '#510090', '#0000c9', '#009b00', '#9abe00', '#ffc900']; }, start: function() { this._super(); - this.rpc("/web/view/load", {"model": this.model, "view_id": this.view_id, "view_type": "gantt"}, this.on_loaded); + return this.rpc("/web/view/load", {"model": this.model, "view_id": this.view_id, "view_type": "gantt"}, this.on_loaded); }, on_loaded: function(data) { - - var self = this; - this.fields_view = data; - - this.name = this.fields_view.arch.attrs.string; - this.view_id = this.fields_view.view_id; - - this.date_start = this.fields_view.arch.attrs.date_start; - this.date_delay = this.fields_view.arch.attrs.date_delay; - this.date_stop = this.fields_view.arch.attrs.date_stop; - - this.color_field = this.fields_view.arch.attrs.color; + this.fields_view = data, + this.name = this.fields_view.arch.attrs.string, + this.view_id = this.fields_view.view_id, + this.fields = this.fields_view.fields; + + this.date_start = this.fields_view.arch.attrs.date_start, + this.date_delay = this.fields_view.arch.attrs.date_delay, + this.date_stop = this.fields_view.arch.attrs.date_stop, this.day_length = this.fields_view.arch.attrs.day_length || 8; + + this.color_field = this.fields_view.arch.attrs.color, this.colors = this.fields_view.arch.attrs.colors; - var arch_children = this.fields_view.arch.children[0]; - this.text = arch_children.children[0] ? arch_children.children[0].attrs.name : arch_children.attrs.name; - this.parent = this.fields_view.arch.children[0].attrs.link; - - this.format = "yyyy-MM-dd"; - this.grp = []; - - self.create_gantt(); - self.get_events(); - - this.$element.html(QWeb.render("GanttView", {"view": this, "fields_view": this.fields_view})); - + + var level = this.fields_view.arch.children[0]; + this.parent = level.attrs.link, + this.text = level.children.length ? level.children[0].attrs.name : level.attrs.name; + + this.$element.html(QWeb.render("GanttView", {'height': $('.oe-application-container').height(), 'width': $('.oe-application-container').width()})); + this.has_been_loaded.resolve(); + }, + + on_project_loaded: function(projects) { + + if(!projects.length) return; + var self = this, + unstarted_project = _.detect(projects, function(res) { + return !res[self.date_start]; + }); + + if(unstarted_project) return self.do_warn(_t("Start date is not defined "), unstarted_project.id); + + $.when(this.project_starting_date(projects), this.project_duration(projects), this.calculate_difference()) + .done(function() { + var Project = new GanttProjectInfo(0, self.name, self.project_start_date), + Task = new GanttTaskInfo(0, self.name, self.project_start_date, self.total_duration, 100, ""); + $.when(self.add_tasks(projects, Task)) + .done(function() { + self.init_gantt_view(Project, Task); + }) + }); + }, + + project_duration: function(projects) { + + var self = this; + this.project_duration = []; + + _.each(projects, function(project, index) { + if (this.date_stop && project[this.date_stop]) { + //ToDO + console.log('TODO for date_stop'); + self.project_duration.push(0); + } else if(self.date_delay && project[self.date_delay]) { + self.project_duration.push(project[self.date_delay]); + } else { + self.project_duration.push(0); + } + }); + + this.max_project_duration = _.max(this.project_duration); + + return $.Deferred().resolve().promise(); + }, + + calculate_difference: function() { + + + var extend_end_date_day = Math.floor(this.max_project_duration / this.day_length), + extend_end_date_hours = this.max_project_duration % this.day_length; + + this.project_end_date = this.project_end_date.add({days: extend_end_date_day, hours: extend_end_date_hours}) + + var DAY = 1000 * 60 * 60 * 24, + difference = Math.abs(this.project_start_date.getTime() - this.project_end_date.getTime()), + day = Math.ceil(difference / DAY), + hour = (difference % DAY)/(1000 * 60 * 60), + DiffHour = (day * this.day_length) + hour; + + this.total_duration = parseFloat(DiffHour.toFixed(2)); + return $.Deferred().resolve().promise(); + }, + + add_tasks: function(tasks, parentTask) { + var self = this; + + _.each(tasks, function(task, index) { + parentTask.addChildTask(new GanttTaskInfo(task.id, task.name, self.format_date(task[self.date_start]), self.project_duration[index], 100, "")); + }); + + return $.Deferred().resolve().promise(); + }, + + project_starting_date : function(projects) { + var self = this; + var min_date = _.min(projects, function(prj) { + return new Date(prj[self.date_start]); + }); + + var max_date = _.max(projects, function(prj) { + return self.format_date(prj[self.date_start]) + }); + this.project_end_date = this.format_date(max_date[self.date_start]); + if (min_date) this.project_start_date = this.format_date(min_date[self.date_start]); + else + this.project_start_date = Date.today(); + + return $.Deferred().resolve().promise(); }, - create_gantt: function() { + init_gantt_view: function(Project, Task) { + Project.addTask(Task); + ganttChartControl = new GanttChart(); - ganttChartControl = new GanttChart(this.day_length); + // Setup paths and behavior ganttChartControl.setImagePath("/web_gantt/static/lib/dhtmlxGantt/codebase/imgs/"); ganttChartControl.setEditable(true); ganttChartControl.showTreePanel(true); ganttChartControl.showContextMenu(false); ganttChartControl.showDescTask(true,'d,s-f'); ganttChartControl.showDescProject(true,'n,d'); - + // Load data structure + ganttChartControl.addProject(Project); + ganttChartControl.create('GanttView'); + // Create Gantt control + + }, + + add_project_info: function(smalldate, project, index) { + + }, + + format_date : function(date) { + var datetime_regex = /^(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d)(?:\.\d+)?$/, + date_regex = /^\d\d\d\d-\d\d-\d\d$/, + time_regex = /^(\d\d:\d\d:\d\d)(?:\.\d+)?$/, + def = $.Deferred(); + if(date_regex.exec(date)) { + this.date_format = "yyyy-MM-dd"; + } else if(time_regex.exec(date)) { + this.date_format = "HH:mm:ss"; + } else { + this.date_format = "yyyy-MM-dd HH:mm:ss"; + } + return openerp.web.auto_str_to_date(date); }, get_events: function() { @@ -502,8 +603,19 @@ init: function(parent, dataset, view_id) { do_search: function (domains, contexts, groupbys) { var self = this; - this.grp = groupbys; - self.reload_gantt(); + this.group_by = groupbys; + $.when(this.has_been_loaded).then(function() { + self.dataset + .read_slice(_.keys(self.fields), { + domain: domains, + context: contexts, + group_by: groupbys + }) + .done(function(projects) { + self.on_project_loaded(projects); + }); + }) + } }); diff --git a/addons/web_gantt/static/src/xml/web_gantt.xml b/addons/web_gantt/static/src/xml/web_gantt.xml index d064d6e9ef2..48a1a1025dd 100644 --- a/addons/web_gantt/static/src/xml/web_gantt.xml +++ b/addons/web_gantt/static/src/xml/web_gantt.xml @@ -1,5 +1,5 @@ From 8224421647c6b40876c3b341c76c9b2c4587ea47 Mon Sep 17 00:00:00 2001 From: "Vaibhav (OpenERP)" Date: Thu, 3 Nov 2011 17:32:52 +0530 Subject: [PATCH 002/185] [FIX] added events. bzr revid: vda@tinyerp.com-20111103120252-ius83ekv8dz54wgl --- addons/web_gantt/static/src/js/gantt.js | 440 +++--------------------- 1 file changed, 56 insertions(+), 384 deletions(-) diff --git a/addons/web_gantt/static/src/js/gantt.js b/addons/web_gantt/static/src/js/gantt.js index 3ba19a67c98..931579502f1 100644 --- a/addons/web_gantt/static/src/js/gantt.js +++ b/addons/web_gantt/static/src/js/gantt.js @@ -49,6 +49,10 @@ init: function(parent, dataset, view_id) { this.parent = level.attrs.link, this.text = level.children.length ? level.children[0].attrs.name : level.attrs.name; + if (!this.date_start) { + return self.do_warn(_t("date_start is not defined ")) + } + this.$element.html(QWeb.render("GanttView", {'height': $('.oe-application-container').height(), 'width': $('.oe-application-container').width()})); this.has_been_loaded.resolve(); }, @@ -57,20 +61,18 @@ init: function(parent, dataset, view_id) { if(!projects.length) return; var self = this, - unstarted_project = _.detect(projects, function(res) { - return !res[self.date_start]; + started_projects = _.filter(projects, function(res) { + return res[self.date_start]; }); - if(unstarted_project) return self.do_warn(_t("Start date is not defined "), unstarted_project.id); - - $.when(this.project_starting_date(projects), this.project_duration(projects), this.calculate_difference()) + $.when(this.project_starting_date(started_projects), this.project_duration(started_projects), this.calculate_difference()) .done(function() { var Project = new GanttProjectInfo(0, self.name, self.project_start_date), Task = new GanttTaskInfo(0, self.name, self.project_start_date, self.total_duration, 100, ""); - $.when(self.add_tasks(projects, Task)) + $.when(self.add_tasks(started_projects, Task)) .done(function() { self.init_gantt_view(Project, Task); - }) + }); }); }, @@ -142,8 +144,10 @@ init: function(parent, dataset, view_id) { }, init_gantt_view: function(Project, Task) { + Project.addTask(Task); - ganttChartControl = new GanttChart(); + var self = this, + ganttChartControl = new GanttChart(); // Setup paths and behavior ganttChartControl.setImagePath("/web_gantt/static/lib/dhtmlxGantt/codebase/imgs/"); @@ -157,9 +161,18 @@ init: function(parent, dataset, view_id) { ganttChartControl.create('GanttView'); // Create Gantt control - }, - - add_project_info: function(smalldate, project, index) { + + // Setup Events + ganttChartControl.attachEvent("onTaskStartDrag", function(task) { + var task_date = task.getEST(); + if(task_date.getHours()) { + task_date.set({hour: task_date.getHours(), minute : task_date.getMinutes(), second:0}); + } + }); + ganttChartControl.attachEvent("onTaskEndResize", function(task) {return self.ResizeTask(task);}); + ganttChartControl.attachEvent("onTaskEndDrag", function(task) {return self.ResizeTask(task);}); + + ganttChartControl.attachEvent("onTaskDblClick", function(task) { return self.editTask(task);}); }, @@ -177,320 +190,38 @@ init: function(parent, dataset, view_id) { } return openerp.web.auto_str_to_date(date); }, - - get_events: function() { - - var self = this; - this.dataset.read_slice([],{}, function(result) { - self.load_event(result); - }); - - }, - - load_event: function(events) { - - var self = this; - var result = events; - var smalldate = ""; - - COLOR_PALETTE = ['#ccccff', '#cc99ff', '#75507b', '#3465a4', '#73d216', '#c17d11', '#edd400', - '#fcaf3e', '#ef2929', '#ff00c9', '#ad7fa8', '#729fcf', '#8ae234', '#e9b96e', '#fce94f', - '#ff8e00', '#ff0000', '#b0008c', '#9000ff', '#0078ff', '#00ff00', '#e6ff00', '#ffff00', - '#905000', '#9b0000', '#840067', '#510090', '#0000c9', '#009b00', '#9abe00', '#ffc900']; - - if (result.length != 0){ - var show_event = []; - for (var i in result){ - var res = result[i]; - if (res[this.date_start] != false){ - - var start_date = this.convert_str_date(res[this.date_start]); - res[this.date_start] = start_date; - show_event.push(res); - if (smalldate == ""){ - smalldate = start_date; - } - else{ - if (start_date < smalldate){ - smalldate = start_date; - } - } - } - } - if (smalldate == ""){ - smalldate = Date.today(); - } - project = new GanttProjectInfo("_1", "", smalldate); - ganttChartControl.addProject(project); - } - - //create child - var k = 0; - var color_box = {}; - var parents = {}; - var all_events = {}; - var child_event = {}; - var temp_id = ""; - var final_events = []; - for (var i in show_event) { - - var res = show_event[i]; - - var id = res['id']; - var text = res[this.text]; - var start_date = res[this.date_start]; - - var color = res[this.color_field][0] || res[this.color_field]; - if (color_box[color] == undefined){ - color_box[color] = COLOR_PALETTE[k]; - k += 1; - } - - if (this.date_stop != undefined){ - if (res[this.date_stop] != false){ - var stop_date = this.convert_str_date(res[this.date_stop]); - var duration= self.hours_between(start_date, stop_date); - } - else{ - var duration = 0; - } - } - else{ - var duration = res[this.date_delay]; - } - if (!duration) - duration = 0; - - if (self.grp.length){ - for (var j in self.grp){ - var grp_key = res[self.grp[j]['group_by']]; - if (typeof(grp_key) == "object"){ - grp_key = res[self.grp[j]['group_by']][1]; - } - else{ - grp_key = res[self.grp[j]['group_by']]; - } - - if (!grp_key){ - grp_key = "Undefined"; - } - - if (j == 0){ - if (parents[grp_key] == undefined){ - var mod_id = i+ "_" +j; - parents[grp_key] = mod_id; - child_event[mod_id] = {}; - all_events[mod_id] = {'parent': "", 'evt':[mod_id , grp_key, start_date, start_date, 100, "", "white"]}; - } - else{ - mod_id = parents[grp_key]; - } - temp_id = mod_id; - }else{ - if (child_event[mod_id][grp_key] == undefined){ - var ch_mod_id = i+ "_" +j; - child_event[mod_id][grp_key] = ch_mod_id; - child_event[ch_mod_id] = {}; - temp_id = ch_mod_id; - all_events[ch_mod_id] = {'parent': mod_id, 'evt':[ch_mod_id , grp_key, start_date, start_date, 100, "","white"]}; - mod_id = ch_mod_id; - } - else{ - mod_id = child_event[mod_id][grp_key]; - temp_id = mod_id; - } - } - } - all_events[id] = {'parent': temp_id, 'evt':[id , text, start_date, duration, 100, "", color_box[color]]}; - final_events.push(id); - } - else { - if (i == 0) { - var mod_id = "_" + i; - all_events[mod_id] = {'parent': "", 'evt': [mod_id, this.name, start_date, start_date, 100, "", "white"]}; - } - all_events[id] = {'parent': mod_id, 'evt':[id , text, start_date, duration, 100, "", color_box[color]]}; - final_events.push(id); - } - } - - for (var i in final_events){ - var evt_id = final_events[i]; - var evt_date = all_events[evt_id]['evt'][2]; - while (all_events[evt_id]['parent'] != "") { - var parent_id =all_events[evt_id]['parent']; - if (all_events[parent_id]['evt'][2] > evt_date){ - all_events[parent_id]['evt'][2] = evt_date; - } - evt_id = parent_id; - } - } - var evt_id = []; - var evt_date = ""; - var evt_duration = ""; - var evt_end_date = ""; - var project_tree_field = []; - for (var i in final_events){ - evt_id = final_events[i]; - evt_date = all_events[evt_id]['evt'][2]; - evt_duration = all_events[evt_id]['evt'][3]; - - var evt_str_date = this.convert_date_str(evt_date); - evt_end_date = this.end_date(evt_str_date, evt_duration); - - while (all_events[evt_id]['parent'] != "") { - var parent_id =all_events[evt_id]['parent']; - if (all_events[parent_id]['evt'][3] < evt_end_date){ - all_events[parent_id]['evt'][3] = evt_end_date; - } - evt_id = parent_id; - } - } - - for (var j in self.grp) { - self.render_events(all_events, j); - } - - if (!self.grp.length) { - self.render_events(all_events, 0); - } - - for (var i in final_events) { - evt_id = final_events[i]; - res = all_events[evt_id]; - task=new GanttTaskInfo(res['evt'][0], res['evt'][1], res['evt'][2], res['evt'][3], res['evt'][4], "",res['evt'][6]); - prt = project.getTaskById(res['parent']); - prt.addChildTask(task); - } - - var oth_hgt = 264; - var min_hgt = 150; - var name_min_wdt = 150; - var gantt_hgt = jQuery(window).height() - oth_hgt; - var search_wdt = jQuery("#oe_app_search").width(); - - if (gantt_hgt > min_hgt){ - jQuery('#GanttDiv').height(gantt_hgt).width(search_wdt); - } else{ - jQuery('#GanttDiv').height(min_hgt).width(search_wdt); - } - - ganttChartControl.create("GanttDiv"); - ganttChartControl.attachEvent("onTaskStartDrag", function(task) {self.on_drag_start(task);}); - ganttChartControl.attachEvent("onTaskEndResize", function(task) {self.on_resize_drag_end(task, "resize");}); - ganttChartControl.attachEvent("onTaskEndDrag", function(task) {self.on_resize_drag_end(task, "drag");}); + + ResizeTask: function(task) { - ganttChartControl.attachEvent("onTaskDblClick", function(task) {self.open_popup(task);}); + var event_id = task.getId(); - var taskdiv = jQuery("div.taskPanel").parent(); - taskdiv.addClass('ganttTaskPanel'); - taskdiv.prev().addClass('ganttDayPanel'); - var $gantt_panel = jQuery(".ganttTaskPanel , .ganttDayPanel"); - - var ganttrow = jQuery('.taskPanel').closest('tr'); - var gtd = ganttrow.children(':first-child'); - gtd.children().addClass('task-name'); - - jQuery(".toggle-sidebar").click(function(e) { - self.set_width(); - }); - - jQuery(window).bind('resize',function() { - window.clearTimeout(ganttChartControl._resize_timer); - ganttChartControl._resize_timer = window.setTimeout(function(){ - self.reload_gantt(); - }, 200); - }); - - jQuery("div #_1, div #_1 + div").hide(); - }, - - set_width: function() { - - $gantt_panel.width(1); - jQuery(".ganttTaskPanel").parent().width(1); - - var search_wdt = jQuery("#oe_app_search").width(); - var day_wdt = jQuery(".ganttDayPanel").children().children().width(); - jQuery('#GanttDiv').css('width','100%'); - - if (search_wdt - day_wdt <= name_min_wdt){ - jQuery(".ganttTaskPanel").parent().width(search_wdt - name_min_wdt); - jQuery(".ganttTaskPanel").width(search_wdt - name_min_wdt); - jQuery(".ganttDayPanel").width(search_wdt - name_min_wdt - 14); - jQuery('.task-name').width(name_min_wdt); - jQuery('.task-name').children().width(name_min_wdt); - }else{ - jQuery(".ganttTaskPanel").parent().width(day_wdt); - jQuery(".ganttTaskPanel").width(day_wdt); - jQuery(".taskPanel").width(day_wdt - 16); - jQuery(".ganttDayPanel").width(day_wdt -16); - jQuery('.task-name').width(search_wdt - day_wdt); - jQuery('.task-name').children().width(search_wdt - day_wdt); + + if(!event_id) + return this.do_warn(_t("Project can not be resized")); + + var data = {}; + data[this.date_start] = task.getEST().toString(this.date_format); + + if(this.date_stop) { + var diff = task.getDuration() % this.day_length, + finished_date = task.getFinishDate().add({hours: diff}); + data[this.date_stop] = finished_date.toString(this.date_format); + } else { + data[this.date_delay] = task.getDuration(); } - + this.dataset + .write(event_id, data, {}) + .done(function() { + self.reloadView(); + }); }, - - end_date: function(dat, duration) { - - var self = this; - - var dat = this.convert_str_date(dat); - - var day = Math.floor(duration/self.day_length); - var hrs = duration % self.day_length; - - dat.add(day).days(); - dat.add(hrs).hour(); - - return dat; - }, - - hours_between: function(date1, date2, parent_task) { - - var ONE_DAY = 1000 * 60 * 60 * 24; - var date1_ms = date1.getTime(); - var date2_ms = date2.getTime(); - var difference_ms = Math.abs(date1_ms - date2_ms); - - var d = parent_task? Math.ceil(difference_ms / ONE_DAY) : Math.floor(difference_ms / ONE_DAY); - var h = (difference_ms % ONE_DAY)/(1000 * 60 * 60); - var num = (d * this.day_length) + h; - return parseFloat(num.toFixed(2)); - - }, - - render_events : function(all_events, j) { - - var self = this; - for (var i in all_events){ - var res = all_events[i]; - if ((typeof(res['evt'][3])) == "object"){ - res['evt'][3] = self.hours_between(res['evt'][2],res['evt'][3], true); - } - - k = res['evt'][0].toString().indexOf('_'); - - if (k != -1) { - if (res['evt'][0].substring(k) == "_"+j){ - if (j == 0){ - task = new GanttTaskInfo(res['evt'][0], res['evt'][1], res['evt'][2], res['evt'][3], res['evt'][4], "",res['evt'][6]); - project.addTask(task); - } else { - task = new GanttTaskInfo(res['evt'][0], res['evt'][1], res['evt'][2], res['evt'][3], res['evt'][4], "",res['evt'][6]); - prt = project.getTaskById(res['parent']); - prt.addChildTask(task); - } - } - } - } - }, - - open_popup : function(task) { + + editTask: function(task) { var self = this; var event_id = task.getId(); - if(event_id.toString().search("_") != -1) - return; + if(!event_id) + return false; + if(event_id) event_id = parseInt(event_id, 10); var action_manager = new openerp.web.ActionManager(this); @@ -506,7 +237,7 @@ init: function(parent, dataset, view_id) { var form_view = action_manager.inner_viewmanager.views.form.controller; form_view.do_save(function() { - self.get_events(); + self.reloadView(); }); $(this).dialog('destroy'); } @@ -528,35 +259,9 @@ init: function(parent, dataset, view_id) { } }); }, - - on_drag_start : function(task){ - var st_date = task.getEST(); - if(st_date.getHours()){ - self.hh = st_date.getHours(); - self.mm = st_date.getMinutes(); - } - }, - - on_resize_drag_end : function(task, evt){ - - var event_id = task.getId(); - var data = {}; - - if(event_id.toString().search("_") != -1) - return; - if (evt == "drag"){ - full_date = task.getEST().set({hour: self.hh, minute : self.mm, second:0}); - data[this.date_start] = this.convert_date_str(full_date); - } - if (this.date_stop != undefined){ - tm = (task.getDuration() % this.day_length); - stp = task.getFinishDate().add(tm).hour(); - data[this.date_stop] = this.convert_date_str(stp); - }else{ - data[this.date_delay] = task.getDuration(); - } - this.dataset.write(event_id, data, {}, function(result) {}); - + + reloadView: function() { + self.on_project_loaded(self.database_projects); }, do_show: function () { @@ -567,51 +272,18 @@ init: function(parent, dataset, view_id) { this.$element.hide(); }, - convert_str_date: function (str){ - if (str.length == 19){ - this.format = "yyyy-MM-dd HH:mm:ss"; - return openerp.web.str_to_datetime(str); - } else if (str.length == 10){ - this.format = "yyyy-MM-dd"; - return openerp.web.str_to_date(str); - } else if (str.length == 8){ - this.format = "HH:mm:ss"; - return openerp.web.str_to_time(str); - } - throw "Unrecognized date/time format"; - }, - - convert_date_str: function(full_date) { - if (this.format == "yyyy-MM-dd HH:mm:ss"){ - return openerp.web.datetime_to_str(full_date); - } else if (this.format == "yyyy-MM-dd"){ - return openerp.web.date_to_str(full_date); - } else if (this.format == "HH:mm:ss"){ - return openerp.web.time_to_str(full_date); - } - throw "Unrecognized date/time format"; - }, - - reload_gantt: function() { - var self = this; - this.dataset.read_slice([],{}, function(response) { - ganttChartControl.clearAll(); - jQuery("#GanttDiv").children().remove(); - self.load_event(response); - }); - }, - do_search: function (domains, contexts, groupbys) { var self = this; this.group_by = groupbys; $.when(this.has_been_loaded).then(function() { self.dataset - .read_slice(_.keys(self.fields), { + .read_slice([], { domain: domains, context: contexts, group_by: groupbys }) .done(function(projects) { + self.database_projects = projects; self.on_project_loaded(projects); }); }) From 11826b8e57bb854cb50bb4b4952f71dff3778b26 Mon Sep 17 00:00:00 2001 From: "Vaibhav (OpenERP)" Date: Thu, 3 Nov 2011 17:56:35 +0530 Subject: [PATCH 003/185] [FIX] Clear GanttView. bzr revid: vda@tinyerp.com-20111103122635-k5fbv5dau3gizygb --- addons/web_gantt/static/src/js/gantt.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/addons/web_gantt/static/src/js/gantt.js b/addons/web_gantt/static/src/js/gantt.js index 931579502f1..ff2c072111f 100644 --- a/addons/web_gantt/static/src/js/gantt.js +++ b/addons/web_gantt/static/src/js/gantt.js @@ -65,8 +65,12 @@ init: function(parent, dataset, view_id) { return res[self.date_start]; }); - $.when(this.project_starting_date(started_projects), this.project_duration(started_projects), this.calculate_difference()) + $.when(this.project_starting_date(started_projects), this.get_project_duration(started_projects), this.calculate_difference()) .done(function() { + if(self.ganttChartControl) { + self.ganttChartControl.clearAll(); + self.$element.find('#GanttView').empty(); + } var Project = new GanttProjectInfo(0, self.name, self.project_start_date), Task = new GanttTaskInfo(0, self.name, self.project_start_date, self.total_duration, 100, ""); $.when(self.add_tasks(started_projects, Task)) @@ -76,13 +80,13 @@ init: function(parent, dataset, view_id) { }); }, - project_duration: function(projects) { + get_project_duration: function(projects) { var self = this; this.project_duration = []; _.each(projects, function(project, index) { - if (this.date_stop && project[this.date_stop]) { + if (self.date_stop && project[self.date_stop]) { //ToDO console.log('TODO for date_stop'); self.project_duration.push(0); @@ -94,13 +98,10 @@ init: function(parent, dataset, view_id) { }); this.max_project_duration = _.max(this.project_duration); - return $.Deferred().resolve().promise(); }, calculate_difference: function() { - - var extend_end_date_day = Math.floor(this.max_project_duration / this.day_length), extend_end_date_hours = this.max_project_duration % this.day_length; @@ -139,15 +140,15 @@ init: function(parent, dataset, view_id) { if (min_date) this.project_start_date = this.format_date(min_date[self.date_start]); else this.project_start_date = Date.today(); - return $.Deferred().resolve().promise(); }, init_gantt_view: function(Project, Task) { Project.addTask(Task); - var self = this, - ganttChartControl = new GanttChart(); + var self = this; + + var ganttChartControl = this.ganttChartControl = new GanttChart(); // Setup paths and behavior ganttChartControl.setImagePath("/web_gantt/static/lib/dhtmlxGantt/codebase/imgs/"); @@ -275,6 +276,7 @@ init: function(parent, dataset, view_id) { do_search: function (domains, contexts, groupbys) { var self = this; this.group_by = groupbys; + $.when(this.has_been_loaded).then(function() { self.dataset .read_slice([], { From 0fc1f948c49e9508996b4ec53285cef900ef1b96 Mon Sep 17 00:00:00 2001 From: "Vaibhav (OpenERP)" Date: Thu, 3 Nov 2011 18:45:51 +0530 Subject: [PATCH 004/185] [FIX] Add parent field if name not defined. bzr revid: vda@tinyerp.com-20111103131551-3j8ofmslyfmxjhj2 --- addons/web_gantt/static/src/js/gantt.js | 30 ++++++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/addons/web_gantt/static/src/js/gantt.js b/addons/web_gantt/static/src/js/gantt.js index ff2c072111f..3ca05b7d24c 100644 --- a/addons/web_gantt/static/src/js/gantt.js +++ b/addons/web_gantt/static/src/js/gantt.js @@ -16,10 +16,8 @@ init: function(parent, dataset, view_id) { this.model = dataset.model; this.view_id = view_id; this.domain = this.dataset.domain || []; - this.groupby = []; this.context = this.dataset.context || {}; this.has_been_loaded = $.Deferred(); -// this.ganttChartControl = new GanttChart(); this.COLOR_PALETTE = ['#ccccff', '#cc99ff', '#75507b', '#3465a4', '#73d216', '#c17d11', '#edd400', '#fcaf3e', '#ef2929', '#ff00c9', '#ad7fa8', '#729fcf', '#8ae234', '#e9b96e', '#fce94f', '#ff8e00', '#ff0000', '#b0008c', '#9000ff', '#0078ff', '#00ff00', '#e6ff00', '#ffff00', @@ -65,19 +63,34 @@ init: function(parent, dataset, view_id) { return res[self.date_start]; }); + if(!self.name) { + var name = started_projects[0][self.parent]; + self.name = name instanceof Array? name[name.length - 1] : name; + } + $.when(this.project_starting_date(started_projects), this.get_project_duration(started_projects), this.calculate_difference()) - .done(function() { + .then(function() { if(self.ganttChartControl) { self.ganttChartControl.clearAll(); self.$element.find('#GanttView').empty(); } + }).then(this.group_projects(started_projects)) + .done(function() { + var Project = new GanttProjectInfo(0, self.name, self.project_start_date), Task = new GanttTaskInfo(0, self.name, self.project_start_date, self.total_duration, 100, ""); $.when(self.add_tasks(started_projects, Task)) .done(function() { self.init_gantt_view(Project, Task); }); - }); + }) + }, + + group_projects: function(projects) { + var def = $.Deferred(), + self = this; + if (!this.group_by.length) return def.resolve().promise(); + return def.resolve().promise(); }, get_project_duration: function(projects) { @@ -121,7 +134,13 @@ init: function(parent, dataset, view_id) { var self = this; _.each(tasks, function(task, index) { - parentTask.addChildTask(new GanttTaskInfo(task.id, task.name, self.format_date(task[self.date_start]), self.project_duration[index], 100, "")); + var name = task[self.text]; + if(task[self.text] instanceof Array) { + name = task[self.text][1]; + } + parentTask.addChildTask( + new GanttTaskInfo(task.id, name, self.format_date(task[self.date_start]), self.project_duration[index], 100, "") + ); }); return $.Deferred().resolve().promise(); @@ -276,7 +295,6 @@ init: function(parent, dataset, view_id) { do_search: function (domains, contexts, groupbys) { var self = this; this.group_by = groupbys; - $.when(this.has_been_loaded).then(function() { self.dataset .read_slice([], { From 119a277cd9b6863678a988c2e0e302443d03629a Mon Sep 17 00:00:00 2001 From: "Vaibhav (OpenERP)" Date: Fri, 4 Nov 2011 18:32:08 +0530 Subject: [PATCH 005/185] [FIX] Generate Groups. bzr revid: vda@tinyerp.com-20111104130208-i7xujd6mv2jm48fe --- addons/web_gantt/static/src/js/gantt.js | 105 +++++++++++++++--------- 1 file changed, 66 insertions(+), 39 deletions(-) diff --git a/addons/web_gantt/static/src/js/gantt.js b/addons/web_gantt/static/src/js/gantt.js index 3ca05b7d24c..12cd687b978 100644 --- a/addons/web_gantt/static/src/js/gantt.js +++ b/addons/web_gantt/static/src/js/gantt.js @@ -18,10 +18,6 @@ init: function(parent, dataset, view_id) { this.domain = this.dataset.domain || []; this.context = this.dataset.context || {}; this.has_been_loaded = $.Deferred(); - this.COLOR_PALETTE = ['#ccccff', '#cc99ff', '#75507b', '#3465a4', '#73d216', '#c17d11', '#edd400', - '#fcaf3e', '#ef2929', '#ff00c9', '#ad7fa8', '#729fcf', '#8ae234', '#e9b96e', '#fce94f', - '#ff8e00', '#ff0000', '#b0008c', '#9000ff', '#0078ff', '#00ff00', '#e6ff00', '#ffff00', - '#905000', '#9b0000', '#840067', '#510090', '#0000c9', '#009b00', '#9abe00', '#ffc900']; }, start: function() { @@ -63,39 +59,70 @@ init: function(parent, dataset, view_id) { return res[self.date_start]; }); + this.database_projects = started_projects; + if(!self.name) { var name = started_projects[0][self.parent]; self.name = name instanceof Array? name[name.length - 1] : name; } - $.when(this.project_starting_date(started_projects), this.get_project_duration(started_projects), this.calculate_difference()) + $.when(this.project_starting_date(), this.get_project_duration(), this.calculate_difference()) .then(function() { if(self.ganttChartControl) { self.ganttChartControl.clearAll(); self.$element.find('#GanttView').empty(); } - }).then(this.group_projects(started_projects)) - .done(function() { - - var Project = new GanttProjectInfo(0, self.name, self.project_start_date), - Task = new GanttTaskInfo(0, self.name, self.project_start_date, self.total_duration, 100, ""); - $.when(self.add_tasks(started_projects, Task)) - .done(function() { - self.init_gantt_view(Project, Task); - }); }) + .then(this.group_projects()) + .then(this.generate_projects()) + .then(this.add_tasks()) + .done(this.init_gantt_view()); }, - group_projects: function(projects) { - var def = $.Deferred(), + generate_projects : function() { + var projects = this.database_projects, self = this; + + this.GanttProjects = [], + this.GanttTasks = []; + if(this.GroupProject) { + _.each(this.GroupProject, function(grp, index) { + self.GanttProjects.push(new GanttProjectInfo(index, grp, self.project_start_date)); + self.GanttTasks.push(new GanttTaskInfo(index, grp, self.project_start_date, self.total_duration, 100, "")); + }); + } else { + this.GanttProjects.push(new GanttProjectInfo(0, self.name, self.project_start_date)); + this.GanttTasks.push(new GanttTaskInfo(0, self.name, self.project_start_date, self.total_duration, 100, "")); + } + + return $.Deferred().resolve().promise(); + }, + + group_projects: function() { + var def = $.Deferred(), + self = this, + projects = this.database_projects; + if (!this.group_by.length) return def.resolve().promise(); + + var groups = _.pluck(projects, this.group_by[0]); + this.GroupProject = []; + _.each(groups, function(grp) { + if(grp instanceof Array) { + grp = grp[grp.length - 1]; + } + if(!_.include(self.GroupProject,grp)) + self.GroupProject.push(grp); + }); + return def.resolve().promise(); }, - get_project_duration: function(projects) { + get_project_duration: function() { - var self = this; + var self = this, + projects = this.database_projects; + this.project_duration = []; _.each(projects, function(project, index) { @@ -130,15 +157,16 @@ init: function(parent, dataset, view_id) { return $.Deferred().resolve().promise(); }, - add_tasks: function(tasks, parentTask) { - var self = this; + add_tasks: function() { + var self = this, + tasks = this.database_projects; _.each(tasks, function(task, index) { var name = task[self.text]; if(task[self.text] instanceof Array) { name = task[self.text][1]; } - parentTask.addChildTask( + self.GanttTasks[0].addChildTask( new GanttTaskInfo(task.id, name, self.format_date(task[self.date_start]), self.project_duration[index], 100, "") ); }); @@ -146,15 +174,16 @@ init: function(parent, dataset, view_id) { return $.Deferred().resolve().promise(); }, - project_starting_date : function(projects) { - var self = this; - var min_date = _.min(projects, function(prj) { - return new Date(prj[self.date_start]); - }); - - var max_date = _.max(projects, function(prj) { - return self.format_date(prj[self.date_start]) - }); + project_starting_date : function() { + var self = this, + projects = this.database_projects, + min_date = _.min(projects, function(prj) { + return new Date(prj[self.date_start]); + }), + max_date = _.max(projects, function(prj) { + return self.format_date(prj[self.date_start]); + }); + this.project_end_date = this.format_date(max_date[self.date_start]); if (min_date) this.project_start_date = this.format_date(min_date[self.date_start]); else @@ -162,9 +191,10 @@ init: function(parent, dataset, view_id) { return $.Deferred().resolve().promise(); }, - init_gantt_view: function(Project, Task) { + init_gantt_view: function() { - Project.addTask(Task); + + this.GanttProjects[0].addTask(this.GanttTasks[0]); var self = this; var ganttChartControl = this.ganttChartControl = new GanttChart(); @@ -176,11 +206,11 @@ init: function(parent, dataset, view_id) { ganttChartControl.showContextMenu(false); ganttChartControl.showDescTask(true,'d,s-f'); ganttChartControl.showDescProject(true,'n,d'); - // Load data structure - ganttChartControl.addProject(Project); - ganttChartControl.create('GanttView'); - // Create Gantt control + // Load data structure + ganttChartControl.addProject(this.GanttProjects[0]); + // Create Gantt control + ganttChartControl.create('GanttView'); // Setup Events ganttChartControl.attachEvent("onTaskStartDrag", function(task) { @@ -191,9 +221,7 @@ init: function(parent, dataset, view_id) { }); ganttChartControl.attachEvent("onTaskEndResize", function(task) {return self.ResizeTask(task);}); ganttChartControl.attachEvent("onTaskEndDrag", function(task) {return self.ResizeTask(task);}); - ganttChartControl.attachEvent("onTaskDblClick", function(task) { return self.editTask(task);}); - }, format_date : function(date) { @@ -303,7 +331,6 @@ init: function(parent, dataset, view_id) { group_by: groupbys }) .done(function(projects) { - self.database_projects = projects; self.on_project_loaded(projects); }); }) From e3f04a459f9e929c2090f4f2e2019ab34f5625d3 Mon Sep 17 00:00:00 2001 From: "Vaibhav (OpenERP)" Date: Sat, 5 Nov 2011 10:12:51 +0530 Subject: [PATCH 006/185] [FIX] First level group_by. bzr revid: vda@tinyerp.com-20111105044251-2raq858ij8m21ha3 --- addons/web_gantt/static/src/js/gantt.js | 70 +++++++++++++++---------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/addons/web_gantt/static/src/js/gantt.js b/addons/web_gantt/static/src/js/gantt.js index 12cd687b978..46628babc2f 100644 --- a/addons/web_gantt/static/src/js/gantt.js +++ b/addons/web_gantt/static/src/js/gantt.js @@ -83,18 +83,19 @@ init: function(parent, dataset, view_id) { var projects = this.database_projects, self = this; - this.GanttProjects = [], this.GanttTasks = []; - if(this.GroupProject) { + if(this.group_by.length) { _.each(this.GroupProject, function(grp, index) { - self.GanttProjects.push(new GanttProjectInfo(index, grp, self.project_start_date)); - self.GanttTasks.push(new GanttTaskInfo(index, grp, self.project_start_date, self.total_duration, 100, "")); + self.GanttTasks.push([]); + _.each(grp, function(g, g_index) { + self.GanttTasks[index].push(new GanttTaskInfo(index + '_'+ g_index, g, self.project_start_date, self.total_duration, 100, "")); + }); +// self.GanttTasks.push(new GanttTaskInfo(index, grp, self.project_start_date, self.total_duration, 100, "")); }); } else { - this.GanttProjects.push(new GanttProjectInfo(0, self.name, self.project_start_date)); this.GanttTasks.push(new GanttTaskInfo(0, self.name, self.project_start_date, self.total_duration, 100, "")); } - + this.GanttProjects = new GanttProjectInfo(0, self.name, self.project_start_date); return $.Deferred().resolve().promise(); }, @@ -105,16 +106,16 @@ init: function(parent, dataset, view_id) { if (!this.group_by.length) return def.resolve().promise(); - var groups = _.pluck(projects, this.group_by[0]); this.GroupProject = []; - _.each(groups, function(grp) { - if(grp instanceof Array) { - grp = grp[grp.length - 1]; - } - if(!_.include(self.GroupProject,grp)) - self.GroupProject.push(grp); - }); + _.each(this.group_by, function(group) { + self.GroupProject.push( + _.uniq( + _.map(_.pluck(projects, group), function(prj) { + return prj instanceof Array ? prj[1] : prj; + }) + )); + }); return def.resolve().promise(); }, @@ -160,17 +161,17 @@ init: function(parent, dataset, view_id) { add_tasks: function() { var self = this, tasks = this.database_projects; - - _.each(tasks, function(task, index) { - var name = task[self.text]; - if(task[self.text] instanceof Array) { - name = task[self.text][1]; - } - self.GanttTasks[0].addChildTask( - new GanttTaskInfo(task.id, name, self.format_date(task[self.date_start]), self.project_duration[index], 100, "") - ); - }); - + if (this.group_by.length) { + } + else { + _.each(tasks, function(task, index){ + var name = task[self.text]; + if (task[self.text] instanceof Array) { + name = task[self.text][1]; + } + self.GanttTasks[0].addChildTask(new GanttTaskInfo(task.id, name, self.format_date(task[self.date_start]), self.project_duration[index], 100, "")); + }); + } return $.Deferred().resolve().promise(); }, @@ -192,11 +193,21 @@ init: function(parent, dataset, view_id) { }, init_gantt_view: function() { - - - this.GanttProjects[0].addTask(this.GanttTasks[0]); var self = this; + if (this.group_by.length) { + _.each(this.GanttTasks, function(tasks) { + _.each(tasks, function(task, index) { + self.GanttProjects.addTask(task); + }) + }); + } + else { + _.each(this.GanttTasks, function(tsk, index){ + self.GanttProjects.addTask(tsk); + }); + } + var ganttChartControl = this.ganttChartControl = new GanttChart(); // Setup paths and behavior @@ -208,7 +219,8 @@ init: function(parent, dataset, view_id) { ganttChartControl.showDescProject(true,'n,d'); // Load data structure - ganttChartControl.addProject(this.GanttProjects[0]); + ganttChartControl.addProject(this.GanttProjects); + // Create Gantt control ganttChartControl.create('GanttView'); From 60bbf83479b5058eeabbf893435ee47d11ca66db Mon Sep 17 00:00:00 2001 From: "Vaibhav (OpenERP)" Date: Tue, 8 Nov 2011 12:44:15 +0530 Subject: [PATCH 007/185] [FIX] Add subtask for groupby. bzr revid: vda@tinyerp.com-20111108071415-ehui6wvm31xi6qqg --- addons/web_gantt/static/src/js/gantt.js | 116 +++++++++++++----------- 1 file changed, 64 insertions(+), 52 deletions(-) diff --git a/addons/web_gantt/static/src/js/gantt.js b/addons/web_gantt/static/src/js/gantt.js index 46628babc2f..abfb7e8c4fa 100644 --- a/addons/web_gantt/static/src/js/gantt.js +++ b/addons/web_gantt/static/src/js/gantt.js @@ -61,7 +61,7 @@ init: function(parent, dataset, view_id) { this.database_projects = started_projects; - if(!self.name) { + if(!self.name && started_projects.length) { var name = started_projects[0][self.parent]; self.name = name instanceof Array? name[name.length - 1] : name; } @@ -79,26 +79,6 @@ init: function(parent, dataset, view_id) { .done(this.init_gantt_view()); }, - generate_projects : function() { - var projects = this.database_projects, - self = this; - - this.GanttTasks = []; - if(this.group_by.length) { - _.each(this.GroupProject, function(grp, index) { - self.GanttTasks.push([]); - _.each(grp, function(g, g_index) { - self.GanttTasks[index].push(new GanttTaskInfo(index + '_'+ g_index, g, self.project_start_date, self.total_duration, 100, "")); - }); -// self.GanttTasks.push(new GanttTaskInfo(index, grp, self.project_start_date, self.total_duration, 100, "")); - }); - } else { - this.GanttTasks.push(new GanttTaskInfo(0, self.name, self.project_start_date, self.total_duration, 100, "")); - } - this.GanttProjects = new GanttProjectInfo(0, self.name, self.project_start_date); - return $.Deferred().resolve().promise(); - }, - group_projects: function() { var def = $.Deferred(), self = this, @@ -106,19 +86,68 @@ init: function(parent, dataset, view_id) { if (!this.group_by.length) return def.resolve().promise(); - this.GroupProject = []; - - _.each(this.group_by, function(group) { - self.GroupProject.push( - _.uniq( - _.map(_.pluck(projects, group), function(prj) { - return prj instanceof Array ? prj[1] : prj; - }) - )); - }); + this.GroupProject = _.map(this.group_by, function(grp) { + return _.groupBy(projects, function(prj) { + return prj[grp]; + }) + }); return def.resolve().promise(); }, + generate_projects : function() { + var projects = this.database_projects, + self = this; + + this.GanttTasks = []; + if(this.group_by.length) { + _.each(this.GroupProject, function(GrpProject, index) { + self.GanttTasks.push([]); + var counter = 0; + _.each(GrpProject, function(grp, grpindex) { + var name = grpindex.split(','); + self.GanttTasks[index] + .push(new GanttTaskInfo(index + '_' + counter , name[name.length - 1], self.project_start_date, self.total_duration, 100, "")); + counter += 1; + }); + }) + } else { + this.GanttTasks.push(new GanttTaskInfo(0, self.name, self.project_start_date, self.total_duration, 100, "")); + } + this.GanttProjects = new GanttProjectInfo(0, self.name, self.project_start_date); + return $.Deferred().resolve().promise(); + }, + + add_tasks: function() { + var self = this, + tasks = this.database_projects; + if (this.group_by.length) { + _.each(this.GroupProject, function(grpproject, index) { + var counter = 0; + _.each(grpproject, function(prj, gindex) { + _.each(prj, function(task, tindex) { + var name = task[self.text]; + if (task[self.text] instanceof Array) { + name = task[self.text][1]; + } + self.GanttTasks[index][counter] + .addChildTask(new GanttTaskInfo(task.id, name, self.format_date(task[self.date_start]), self.project_duration[index], 100, "")) + }); + counter += 1; + }) + }); + } + else { + _.each(tasks, function(task, index){ + var name = task[self.text]; + if (task[self.text] instanceof Array) { + name = task[self.text][1]; + } + self.GanttTasks[0].addChildTask(new GanttTaskInfo(task.id, name, self.format_date(task[self.date_start]), self.project_duration[index], 100, "")); + }); + } + return $.Deferred().resolve().promise(); + }, + get_project_duration: function() { var self = this, @@ -158,23 +187,6 @@ init: function(parent, dataset, view_id) { return $.Deferred().resolve().promise(); }, - add_tasks: function() { - var self = this, - tasks = this.database_projects; - if (this.group_by.length) { - } - else { - _.each(tasks, function(task, index){ - var name = task[self.text]; - if (task[self.text] instanceof Array) { - name = task[self.text][1]; - } - self.GanttTasks[0].addChildTask(new GanttTaskInfo(task.id, name, self.format_date(task[self.date_start]), self.project_duration[index], 100, "")); - }); - } - return $.Deferred().resolve().promise(); - }, - project_starting_date : function() { var self = this, projects = this.database_projects, @@ -196,11 +208,11 @@ init: function(parent, dataset, view_id) { var self = this; if (this.group_by.length) { - _.each(this.GanttTasks, function(tasks) { - _.each(tasks, function(task, index) { + _.each(self.GanttTasks, function(tasks, index) { + _.each(tasks, function(task, tindex) { self.GanttProjects.addTask(task); - }) - }); + }); + }) } else { _.each(this.GanttTasks, function(tsk, index){ From f1f7637d69e0691202779fa592cbcf20c0cd5f19 Mon Sep 17 00:00:00 2001 From: "Vaibhav (OpenERP)" Date: Tue, 8 Nov 2011 13:05:28 +0530 Subject: [PATCH 008/185] [FIX] duration calculation for date_stop. bzr revid: vda@tinyerp.com-20111108073528-r4lrw0zxtsv1604a --- addons/web_gantt/static/src/js/gantt.js | 28 ++++++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/addons/web_gantt/static/src/js/gantt.js b/addons/web_gantt/static/src/js/gantt.js index abfb7e8c4fa..8ee3fbfaca5 100644 --- a/addons/web_gantt/static/src/js/gantt.js +++ b/addons/web_gantt/static/src/js/gantt.js @@ -60,7 +60,9 @@ init: function(parent, dataset, view_id) { }); this.database_projects = started_projects; - + if(!started_projects.length) + return self.do_warn(_t("date_start is not defined")); + if(!self.name && started_projects.length) { var name = started_projects[0][self.parent]; self.name = name instanceof Array? name[name.length - 1] : name; @@ -157,9 +159,7 @@ init: function(parent, dataset, view_id) { _.each(projects, function(project, index) { if (self.date_stop && project[self.date_stop]) { - //ToDO - console.log('TODO for date_stop'); - self.project_duration.push(0); + self.project_duration.push(self.duration_difference(project[self.date_start], project[self.date_stop])); } else if(self.date_delay && project[self.date_delay]) { self.project_duration.push(project[self.date_delay]); } else { @@ -171,6 +171,20 @@ init: function(parent, dataset, view_id) { return $.Deferred().resolve().promise(); }, + duration_difference: function(start_date, end_date) { + + var DAY = 1000 * 60 * 60 * 24, + date1_ms = openerp.web.auto_str_to_date(start_date).getTime(), + date2_ms = openerp.web.auto_str_to_date(end_date).getTime(), + difference_ms = Math.abs(date1_ms - date2_ms); + + var d = Math.floor(difference_ms / DAY), + h = (difference_ms % DAY)/(1000 * 60 * 60), + num = (d * this.day_length) + h; + return parseFloat(num.toFixed(2)); + + }, + calculate_difference: function() { var extend_end_date_day = Math.floor(this.max_project_duration / this.day_length), extend_end_date_hours = this.max_project_duration % this.day_length; @@ -196,7 +210,6 @@ init: function(parent, dataset, view_id) { max_date = _.max(projects, function(prj) { return self.format_date(prj[self.date_start]); }); - this.project_end_date = this.format_date(max_date[self.date_start]); if (min_date) this.project_start_date = this.format_date(min_date[self.date_start]); else @@ -212,7 +225,7 @@ init: function(parent, dataset, view_id) { _.each(tasks, function(task, tindex) { self.GanttProjects.addTask(task); }); - }) + }); } else { _.each(this.GanttTasks, function(tsk, index){ @@ -351,8 +364,7 @@ init: function(parent, dataset, view_id) { self.dataset .read_slice([], { domain: domains, - context: contexts, - group_by: groupbys + context: contexts }) .done(function(projects) { self.on_project_loaded(projects); From 282f6756ad1da705d20bc81bd1c0f031aa47db97 Mon Sep 17 00:00:00 2001 From: "Vaibhav (OpenERP)" Date: Tue, 8 Nov 2011 14:30:08 +0530 Subject: [PATCH 009/185] [FIX] Events attached only to child tasks. bzr revid: vda@tinyerp.com-20111108090008-f65kvdlplgzryarb --- addons/web_gantt/static/src/js/gantt.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/addons/web_gantt/static/src/js/gantt.js b/addons/web_gantt/static/src/js/gantt.js index 8ee3fbfaca5..bb19ecbbae6 100644 --- a/addons/web_gantt/static/src/js/gantt.js +++ b/addons/web_gantt/static/src/js/gantt.js @@ -251,14 +251,21 @@ init: function(parent, dataset, view_id) { // Setup Events ganttChartControl.attachEvent("onTaskStartDrag", function(task) { - var task_date = task.getEST(); - if(task_date.getHours()) { - task_date.set({hour: task_date.getHours(), minute : task_date.getMinutes(), second:0}); + if (task.parentTask) { + var task_date = task.getEST(); + if (task_date.getHours()) { + task_date.set({ + hour: task_date.getHours(), + minute: task_date.getMinutes(), + second: 0 + }); + } } }); + ganttChartControl.attachEvent("onTaskEndResize", function(task) {return self.ResizeTask(task);}); ganttChartControl.attachEvent("onTaskEndDrag", function(task) {return self.ResizeTask(task);}); - ganttChartControl.attachEvent("onTaskDblClick", function(task) { return self.editTask(task);}); + ganttChartControl.attachEvent("onTaskClick", function(task) { return self.editTask(task);}); }, format_date : function(date) { @@ -278,10 +285,10 @@ init: function(parent, dataset, view_id) { ResizeTask: function(task) { - var event_id = task.getId(); + var self = this, + event_id = task.getId(); - - if(!event_id) + if(!event_id || !task.parentTask) return this.do_warn(_t("Project can not be resized")); var data = {}; @@ -302,11 +309,11 @@ init: function(parent, dataset, view_id) { }, editTask: function(task) { + var self = this; var event_id = task.getId(); - if(!event_id) + if(!event_id || !task.parentTask) return false; - if(event_id) event_id = parseInt(event_id, 10); var action_manager = new openerp.web.ActionManager(this); From 4a7cc97197a77a441c0a94d50f8439af2b9841c6 Mon Sep 17 00:00:00 2001 From: "Vaibhav (OpenERP)" Date: Thu, 10 Nov 2011 15:53:05 +0530 Subject: [PATCH 010/185] [FIX] follow multi level Group. bzr revid: vda@tinyerp.com-20111110102305-3h661p2va5unyo15 --- addons/web_gantt/static/src/js/gantt.js | 38 ++++++++----------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/addons/web_gantt/static/src/js/gantt.js b/addons/web_gantt/static/src/js/gantt.js index 2165bd7ce88..effaf17dfe3 100644 --- a/addons/web_gantt/static/src/js/gantt.js +++ b/addons/web_gantt/static/src/js/gantt.js @@ -88,6 +88,7 @@ init: function(parent, dataset, view_id) { this.GroupProject = _.map(this.group_by, function(grp) { return _.groupBy(projects, function(prj) { + if(!prj[grp]) prj[grp] = 'Undefined'; return prj[grp]; }) }); @@ -100,16 +101,12 @@ init: function(parent, dataset, view_id) { this.GanttTasks = []; if(this.group_by.length) { - _.each(this.GroupProject, function(GrpProject, index) { - self.GanttTasks.push([]); - var counter = 0; - _.each(GrpProject, function(grp, grpindex) { - var name = grpindex.split(','); - self.GanttTasks[index] - .push(new GanttTaskInfo(index + '_' + counter , name[name.length - 1], self.project_start_date, self.total_duration, 100, "")); - counter += 1; - }); - }) + _.each(this.GroupProject, function(grp, index) { + var name = _.keys(grp)[0]; + name = name.split(','); +// index > 0 ? "" + (index - 1) + self.GanttTasks.push(new GanttTaskInfo(index, name[name.length - 1], self.project_start_date, self.total_duration, 100, index > 0 ? (index - 1) : "")); + }); } else { this.GanttTasks.push(new GanttTaskInfo(0, self.name, self.project_start_date, self.total_duration, 100, "")); } @@ -121,19 +118,10 @@ init: function(parent, dataset, view_id) { var self = this, tasks = this.database_projects; if (this.group_by.length) { - _.each(this.GroupProject, function(grpproject, index) { - var counter = 0; - _.each(grpproject, function(prj, gindex) { - _.each(prj, function(task, tindex) { - var name = task[self.text]; - if (task[self.text] instanceof Array) { - name = task[self.text][1]; - } - self.GanttTasks[index][counter] - .addChildTask(new GanttTaskInfo(task.id, name, self.format_date(task[self.date_start]), self.project_duration[index], 100, "")) - }); - counter += 1; - }) + _.each(_.values(_.last(this.GroupProject))[0], function(task, index) { + var name = task[self.text]; + _.last(self.GanttTasks) + .addChildTask(new GanttTaskInfo(task.id, name, self.format_date(task[self.date_start]), self.project_duration[index], 100, "")) }); } else { @@ -220,9 +208,7 @@ init: function(parent, dataset, view_id) { if (this.group_by.length) { _.each(self.GanttTasks, function(tasks, index) { - _.each(tasks, function(task, tindex) { - self.GanttProjects.addTask(task); - }); + self.GanttProjects.addTask(tasks); }); } else { From a9cb7736c46987b4f7168408261e41a4ec45df09 Mon Sep 17 00:00:00 2001 From: "Jiten (OpenERP)" Date: Wed, 16 Nov 2011 18:08:34 +0530 Subject: [PATCH 011/185] [IMP] Remove bottom bar (footer) from other pages to show only in main menu. bzr revid: jra@tinyerp.com-20111116123834-2vejdxbd7morztfv --- .../web_mobile/static/src/js/chrome_mobile.js | 32 ------------- .../web_mobile/static/src/js/form_mobile.js | 48 ------------------- .../web_mobile/static/src/js/list_mobile.js | 16 ------- .../web_mobile/static/src/xml/web_mobile.xml | 7 --- 4 files changed, 103 deletions(-) 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..32d1c39f133 100644 --- a/addons/web_mobile/static/src/js/form_mobile.js +++ b/addons/web_mobile/static/src/js/form_mobile.js @@ -52,22 +52,6 @@ openerp.web_mobile.FormView = 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('#formbutton').click(function(){ var head = $(this).prev().find('select').find("option:selected").text(); var selected_id = $(this).prev().find('select').val(); @@ -148,22 +132,6 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({ $('[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(); @@ -203,22 +171,6 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({ $('[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(); diff --git a/addons/web_mobile/static/src/js/list_mobile.js b/addons/web_mobile/static/src/js/list_mobile.js index 7e9fff16262..c7b77737e6d 100644 --- a/addons/web_mobile/static/src/js/list_mobile.js +++ b/addons/web_mobile/static/src/js/list_mobile.js @@ -46,22 +46,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..898d86c1735 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 @@ - @@ -343,8 +339,5 @@ - - - \ No newline at end of file From b0ece86d7cf44cdccfd563ce9d547bd72c79dbba Mon Sep 17 00:00:00 2001 From: "Vaibhav (OpenERP)" Date: Wed, 16 Nov 2011 19:08:44 +0530 Subject: [PATCH 012/185] [FIX] Create node. bzr revid: vda@tinyerp.com-20111116133844-qp4fp3pkruqpgobr --- addons/web_gantt/static/src/js/gantt.js | 59 ++++++++----------- addons/web_gantt/static/src/xml/web_gantt.xml | 1 + 2 files changed, 25 insertions(+), 35 deletions(-) diff --git a/addons/web_gantt/static/src/js/gantt.js b/addons/web_gantt/static/src/js/gantt.js index effaf17dfe3..ec212c7007d 100644 --- a/addons/web_gantt/static/src/js/gantt.js +++ b/addons/web_gantt/static/src/js/gantt.js @@ -65,7 +65,9 @@ init: function(parent, dataset, view_id) { var name = started_projects[0][self.parent]; self.name = name instanceof Array? name[name.length - 1] : name; } - + this.$element.find('#add_task').click(function(){ + self.editTask(); + }); $.when(this.project_starting_date(), this.get_project_duration(), this.calculate_difference()) .then(function() { if(self.ganttChartControl) { @@ -83,30 +85,23 @@ init: function(parent, dataset, view_id) { var def = $.Deferred(), self = this, projects = this.database_projects; - - if (!this.group_by.length) return def.resolve().promise(); - this.GroupProject = _.map(this.group_by, function(grp) { - return _.groupBy(projects, function(prj) { - if(!prj[grp]) prj[grp] = 'Undefined'; - return prj[grp]; - }) + if (!this.group_by.length) return def.resolve().promise(); + this.data_groups = _.groupBy(projects, function(project, index) { + return _.map(self.group_by, function(group, index) { + if(!project[group]) project[group] = 'Undefined'; + else if(project[group] instanceof Array) project[group] = project[group][1]; + return project[group]; }); + }); return def.resolve().promise(); }, - generate_projects : function() { var projects = this.database_projects, self = this; this.GanttTasks = []; if(this.group_by.length) { - _.each(this.GroupProject, function(grp, index) { - var name = _.keys(grp)[0]; - name = name.split(','); -// index > 0 ? "" + (index - 1) - self.GanttTasks.push(new GanttTaskInfo(index, name[name.length - 1], self.project_start_date, self.total_duration, 100, index > 0 ? (index - 1) : "")); - }); } else { this.GanttTasks.push(new GanttTaskInfo(0, self.name, self.project_start_date, self.total_duration, 100, "")); } @@ -118,11 +113,7 @@ init: function(parent, dataset, view_id) { var self = this, tasks = this.database_projects; if (this.group_by.length) { - _.each(_.values(_.last(this.GroupProject))[0], function(task, index) { - var name = task[self.text]; - _.last(self.GanttTasks) - .addChildTask(new GanttTaskInfo(task.id, name, self.format_date(task[self.date_start]), self.project_duration[index], 100, "")) - }); + } else { _.each(tasks, function(task, index){ @@ -207,9 +198,7 @@ init: function(parent, dataset, view_id) { var self = this; if (this.group_by.length) { - _.each(self.GanttTasks, function(tasks, index) { - self.GanttProjects.addTask(tasks); - }); + } else { _.each(this.GanttTasks, function(tsk, index){ @@ -293,13 +282,16 @@ init: function(parent, dataset, view_id) { }, editTask: function(task) { - - var self = this; - var event_id = task.getId(); - if(!event_id || !task.parentTask) - return false; + var self = this, + event_id; + if (!task) + event_id = null; + else { + event_id = task.getId(); + if(!event_id || !task.parentTask) + return false; + } if(event_id) event_id = parseInt(event_id, 10); - var action_manager = new openerp.web.ActionManager(this); var dialog = new openerp.web.Dialog(this, { @@ -337,7 +329,7 @@ init: function(parent, dataset, view_id) { }, reloadView: function() { - self.on_project_loaded(self.database_projects); + this.on_project_loaded(this.database_projects); }, do_show: function () { @@ -352,16 +344,13 @@ init: function(parent, dataset, view_id) { var self = this; this.group_by = groupbys; $.when(this.has_been_loaded).then(function() { - self.dataset - .read_slice([], { + self.dataset.read_slice([], { domain: domains, context: contexts - }) - .done(function(projects) { + }).done(function(projects){ self.on_project_loaded(projects); }); }) - } }); diff --git a/addons/web_gantt/static/src/xml/web_gantt.xml b/addons/web_gantt/static/src/xml/web_gantt.xml index 48a1a1025dd..35cab76b452 100644 --- a/addons/web_gantt/static/src/xml/web_gantt.xml +++ b/addons/web_gantt/static/src/xml/web_gantt.xml @@ -1,5 +1,6 @@ From ab599f36463c2d8cc58cc5bd3878979eb7466bb9 Mon Sep 17 00:00:00 2001 From: "Jiten (OpenERP)" Date: Fri, 18 Nov 2011 12:11:38 +0530 Subject: [PATCH 013/185] [IMP] Some Changes to show Maximum 80 records in listview. bzr revid: jra@tinyerp.com-20111118064138-d9idrs8brq943r2r --- addons/web_mobile/static/src/js/form_mobile.js | 4 ++-- addons/web_mobile/static/src/js/list_mobile.js | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/web_mobile/static/src/js/form_mobile.js b/addons/web_mobile/static/src/js/form_mobile.js index 32d1c39f133..6f50bb6760d 100644 --- a/addons/web_mobile/static/src/js/form_mobile.js +++ b/addons/web_mobile/static/src/js/form_mobile.js @@ -117,10 +117,10 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({ 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){ + dataset.read_slice([], {limit:80}, 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){ + dataset1.name_get(result1,function(res){ var additional = ""; if(res['html_name_get']){ additional = res['display']; diff --git a/addons/web_mobile/static/src/js/list_mobile.js b/addons/web_mobile/static/src/js/list_mobile.js index c7b77737e6d..5813b9c216e 100644 --- a/addons/web_mobile/static/src/js/list_mobile.js +++ b/addons/web_mobile/static/src/js/list_mobile.js @@ -32,11 +32,10 @@ openerp.web_mobile.ListView = openerp.web.Widget.extend({ 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){ + dataset.read_slice([], {limit:80}, function(result,ids){ _.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){ + dataset1.name_get(result,function(res){ var additional = ""; if(res['html_name_get']){ additional = res['display']; From c95adf2c8a8530ad433d0de27781b22af093cfa3 Mon Sep 17 00:00:00 2001 From: "Vaibhav (OpenERP)" Date: Mon, 21 Nov 2011 14:45:12 +0530 Subject: [PATCH 014/185] [FIX] Reload and update record on Resize. bzr revid: vda@tinyerp.com-20111121091512-8o5wxtid0cky2on8 --- addons/web_gantt/static/src/js/gantt.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/addons/web_gantt/static/src/js/gantt.js b/addons/web_gantt/static/src/js/gantt.js index ec212c7007d..77170d103ff 100644 --- a/addons/web_gantt/static/src/js/gantt.js +++ b/addons/web_gantt/static/src/js/gantt.js @@ -87,13 +87,17 @@ init: function(parent, dataset, view_id) { projects = this.database_projects; if (!this.group_by.length) return def.resolve().promise(); - this.data_groups = _.groupBy(projects, function(project, index) { - return _.map(self.group_by, function(group, index) { + this.data_groups = _.groupBy(projects, function(project) { + return _.map(self.group_by, function(group) { if(!project[group]) project[group] = 'Undefined'; else if(project[group] instanceof Array) project[group] = project[group][1]; return project[group]; }); }); + + this.group_keys = _.map(this.group_by, function(group, index) { + return _.map(projects, function(project){return project[group]}); + }); return def.resolve().promise(); }, generate_projects : function() { @@ -102,6 +106,7 @@ init: function(parent, dataset, view_id) { this.GanttTasks = []; if(this.group_by.length) { + } else { this.GanttTasks.push(new GanttTaskInfo(0, self.name, self.project_start_date, self.total_duration, 100, "")); } @@ -198,10 +203,9 @@ init: function(parent, dataset, view_id) { var self = this; if (this.group_by.length) { - } else { - _.each(this.GanttTasks, function(tsk, index){ + _.each(this.GanttTasks, function(tsk, index) { self.GanttProjects.addTask(tsk); }); } @@ -238,7 +242,6 @@ init: function(parent, dataset, view_id) { ganttChartControl.attachEvent("onTaskEndResize", function(task) {return self.ResizeTask(task);}); ganttChartControl.attachEvent("onTaskEndDrag", function(task) {return self.ResizeTask(task);}); - ganttChartControl.attachEvent("onTaskClick", function(task) { return self.editTask(task);}); }, format_date : function(date) { @@ -257,7 +260,6 @@ init: function(parent, dataset, view_id) { }, ResizeTask: function(task) { - var self = this, event_id = task.getId(); @@ -277,6 +279,8 @@ init: function(parent, dataset, view_id) { this.dataset .write(event_id, data, {}) .done(function() { + var get_project = _.find(self.database_projects, function(project){ return project.id == event_id}); + _.extend(get_project,data); self.reloadView(); }); }, @@ -350,7 +354,7 @@ init: function(parent, dataset, view_id) { }).done(function(projects){ self.on_project_loaded(projects); }); - }) + }); } }); From ef3c7d9c3b51e4ae30de02c74517df3e7307a93d Mon Sep 17 00:00:00 2001 From: "Vaibhav (OpenERP)" Date: Mon, 21 Nov 2011 16:49:31 +0530 Subject: [PATCH 015/185] [FIX] Done for level 1 group. todo for multi level. bzr revid: vda@tinyerp.com-20111121111931-f149p9vau10vsx60 --- addons/web_gantt/static/src/js/gantt.js | 42 ++++++++++++++++++++----- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/addons/web_gantt/static/src/js/gantt.js b/addons/web_gantt/static/src/js/gantt.js index 77170d103ff..63845361b7b 100644 --- a/addons/web_gantt/static/src/js/gantt.js +++ b/addons/web_gantt/static/src/js/gantt.js @@ -106,7 +106,13 @@ init: function(parent, dataset, view_id) { this.GanttTasks = []; if(this.group_by.length) { - + if(this.group_by.length > 1) { + + } else { + _.each(_.uniq(this.group_keys[0]), function(group, index) { + self.GanttTasks.push(new GanttTaskInfo(index, group, self.project_start_date, self.total_duration, 100,"")); + }); + } } else { this.GanttTasks.push(new GanttTaskInfo(0, self.name, self.project_start_date, self.total_duration, 100, "")); } @@ -118,7 +124,21 @@ init: function(parent, dataset, view_id) { var self = this, tasks = this.database_projects; if (this.group_by.length) { - + if (this.group_by.length > 1) { + } else { + _.each(_.values(this.data_groups), function(child_tasks, index) { + _.each(child_tasks, function(chld) { + var name = chld[self.text]; + if (chld[self.text] instanceof Array) { + name = chld[self.text][1]; + } + var duration = _.keys(self.group_project_duration).indexOf(""+chld.id); + duration = _.values(self.group_project_duration)[duration]; + self.GanttTasks[index].addChildTask(new GanttTaskInfo(chld.id, name, self.format_date(chld[self.date_start]), duration, 100, "")) + }); + + }); + } } else { _.each(tasks, function(task, index){ @@ -138,15 +158,19 @@ init: function(parent, dataset, view_id) { projects = this.database_projects; this.project_duration = []; - + this.group_project_duration = {}; _.each(projects, function(project, index) { + var duration = 0, + id = project.id; if (self.date_stop && project[self.date_stop]) { - self.project_duration.push(self.duration_difference(project[self.date_start], project[self.date_stop])); + duration = self.duration_difference(project[self.date_start], project[self.date_stop]); +// self.project_duration.push(self.duration_difference(project[self.date_start], project[self.date_stop])); } else if(self.date_delay && project[self.date_delay]) { - self.project_duration.push(project[self.date_delay]); - } else { - self.project_duration.push(0); + duration = project[self.date_delay]; +// self.project_duration.push(project[self.date_delay]); } + self.project_duration.push(duration); + self.group_project_duration[id] = duration; }); this.max_project_duration = _.max(this.project_duration); @@ -203,6 +227,9 @@ init: function(parent, dataset, view_id) { var self = this; if (this.group_by.length) { + _.each(this.GanttTasks, function(tsk, index) { + self.GanttProjects.addTask(tsk); + }); } else { _.each(this.GanttTasks, function(tsk, index) { @@ -239,7 +266,6 @@ init: function(parent, dataset, view_id) { } } }); - ganttChartControl.attachEvent("onTaskEndResize", function(task) {return self.ResizeTask(task);}); ganttChartControl.attachEvent("onTaskEndDrag", function(task) {return self.ResizeTask(task);}); }, From aad7d22763beb1774218bd7f041a918a56237964 Mon Sep 17 00:00:00 2001 From: "Jiten (OpenERP)" Date: Mon, 21 Nov 2011 17:47:26 +0530 Subject: [PATCH 016/185] [IMP] Improve m2o field to remove image for open related form and make it as o2m. bzr revid: jra@tinyerp.com-20111121121726-pat4r2ypa3o93tr9 --- .../web_mobile/static/src/js/form_mobile.js | 69 ++++--------------- .../web_mobile/static/src/xml/web_mobile.xml | 26 ++----- 2 files changed, 22 insertions(+), 73 deletions(-) diff --git a/addons/web_mobile/static/src/js/form_mobile.js b/addons/web_mobile/static/src/js/form_mobile.js index 6f50bb6760d..cc816b75a21 100644 --- a/addons/web_mobile/static/src/js/form_mobile.js +++ b/addons/web_mobile/static/src/js/form_mobile.js @@ -52,20 +52,6 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({ self.$element.find("[data-role=header]").find('#home').click(function(){ $.mobile.changePage("#oe_menu", "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')) { @@ -83,21 +69,6 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({ $(this).find('div#page_content').html(self.render({'get_fields': get_fields,'fields' : result.fields, 'values' : self.datarecord})); } 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){ @@ -146,7 +117,6 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({ } 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); @@ -171,20 +141,6 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({ $('[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('#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{ @@ -205,9 +161,24 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({ }); } }); + 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) { + var head = $(this).find('a').attr('name'); + var selected_id = $(this).find('a').attr('value'); + var select_model = $(this).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); + } + } + }, get_fields: function(view_fields, fields) { this.fields = fields || []; for (var i=0; i < view_fields.length; i++){ @@ -276,16 +247,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/xml/web_mobile.xml b/addons/web_mobile/static/src/xml/web_mobile.xml index 898d86c1735..1d6f81404d2 100644 --- a/addons/web_mobile/static/src/xml/web_mobile.xml +++ b/addons/web_mobile/static/src/xml/web_mobile.xml @@ -288,25 +288,13 @@ : - - - - +
    From 205c8f6ea7e451354fade7a83c54ed64382ec9e6 Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Mon, 21 Nov 2011 18:01:15 +0530 Subject: [PATCH 017/185] [IMP] mrp_operations: Improved work orders to initialize the workflow for demo data and existing records. bzr revid: uco@tinyerp.com-20111121123115-3plhb42u04ye9ipj --- addons/mrp_operations/mrp_operation_data.xml | 3 +++ addons/mrp_operations/mrp_operations.py | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/addons/mrp_operations/mrp_operation_data.xml b/addons/mrp_operations/mrp_operation_data.xml index 7ce25b6d250..2d0694f12ac 100644 --- a/addons/mrp_operations/mrp_operation_data.xml +++ b/addons/mrp_operations/mrp_operation_data.xml @@ -30,5 +30,8 @@ done + + + diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index 7dc93731b03..e4815fee4c6 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -552,6 +552,17 @@ class mrp_operations_operation(osv.osv): return super(mrp_operations_operation, self).create(cr, uid, vals, context=context) + def initialize_workflow_instance(self, cr, uid, context=None): + wf_service = netsvc.LocalService("workflow") + wc_line_obj = self.pool.get('mrp.production.workcenter.line') + prod_obj = self.pool.get('mrp.production') + production_ids = prod_obj.search(cr, uid, [], context=context) + for op in prod_obj.browse(cr, uid, production_ids, context=context): + wc_lines = wc_line_obj.search(cr, uid, [('production_id','=',op.id)], context=context) + for line_id in wc_lines: + wf_service.trg_create(uid, 'mrp.production.workcenter.line', line_id, cr) + return True + _columns={ 'production_id':fields.many2one('mrp.production','Production',required=True), 'workcenter_id':fields.many2one('mrp.workcenter','Work Center',required=True), From eaebfd814d76a4767040d49e819a959fb89379f3 Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Mon, 21 Nov 2011 18:31:53 +0530 Subject: [PATCH 018/185] [IMP] mrp_operations: Some usability improvements mentioned on pad. bzr revid: uco@tinyerp.com-20111121130153-re5blfwujjwjvqy6 --- addons/mrp_operations/mrp_operations.py | 4 ++-- addons/mrp_operations/mrp_operations_view.xml | 13 +++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index e4815fee4c6..74d4ee3cf8a 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -86,10 +86,10 @@ class mrp_production_workcenter_line(osv.osv): _order = "sequence, date_planned" _columns = { - 'state': fields.selection([('draft','Draft'),('startworking', 'In Progress'),('pause','Pause'),('cancel','Cancelled'),('done','Finished')],'State', readonly=True, + 'state': fields.selection([('draft','Draft'),('startworking', 'In Progress'),('pause','Pending'),('cancel','Cancelled'),('done','Finished')],'State', readonly=True, help="* When a work order is created it is set in 'Draft' state.\n" \ "* When user sets work order in start mode that time it will be set in 'In Progress' state.\n" \ - "* When work order is in running mode, during that time if user wants to stop or to make changes in order then can set in 'Pause' state.\n" \ + "* When work order is in running mode, during that time if user wants to stop or to make changes in order then can set in 'Pending' state.\n" \ "* When the user cancels the work order it will be set in 'Canceled' state.\n" \ "* When order is completely processed that time it is set in 'Finished' state."), 'date_start_date': fields.function(_get_date_date, string='Start Date', type='date'), diff --git a/addons/mrp_operations/mrp_operations_view.xml b/addons/mrp_operations/mrp_operations_view.xml index 377a57d6121..e7decebbf4b 100644 --- a/addons/mrp_operations/mrp_operations_view.xml +++ b/addons/mrp_operations/mrp_operations_view.xml @@ -16,7 +16,7 @@ + From 342b0a1ac8b37d6bfb2a0ff3cf7dfdd6cb37b504 Mon Sep 17 00:00:00 2001 From: "Jiten (OpenERP)" Date: Tue, 29 Nov 2011 12:00:29 +0530 Subject: [PATCH 039/185] [IMP] To show many2many field on form view. bzr revid: jra@tinyerp.com-20111129063029-6pvqwh4uvts1pcft --- addons/web_mobile/static/src/xml/web_mobile.xml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/addons/web_mobile/static/src/xml/web_mobile.xml b/addons/web_mobile/static/src/xml/web_mobile.xml index 1d6f81404d2..1deb752cab6 100644 --- a/addons/web_mobile/static/src/xml/web_mobile.xml +++ b/addons/web_mobile/static/src/xml/web_mobile.xml @@ -298,13 +298,22 @@
      -
    • +
    • -
    -
    +
+
+ + + From 940500782a1358f4b449a00e308d48528a662407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20L=C3=B3pez=20L=C3=B3pez=20=28OpenERP=29?= Date: Tue, 29 Nov 2011 15:04:09 +0100 Subject: [PATCH 040/185] [ADD] new view definition for page bzr revid: rlo@openerp.com-20111129140409-mzelxhp40w5y093k --- addons/web/controllers/main.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 7dbd696cfb4..cbb73477c6a 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -605,6 +605,14 @@ def fix_view_modes(action): if 'views' not in action: generate_views(action) + id_form = None + for index, (id, mode) in enumerate(action['views']): + if mode == 'form': + id_form = id + break + if id_form is not None: + action['views'].insert(index + 1, (id_form, 'page')) + if action.pop('view_type', 'form') != 'form': return action From 5b0783dd7aa044b1b1cd3c742cb4a1c267cc4ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20L=C3=B3pez=20L=C3=B3pez=20=28OpenERP=29?= Date: Tue, 29 Nov 2011 15:39:11 +0100 Subject: [PATCH 041/185] [ADD] page view split out from form view bzr revid: rlo@openerp.com-20111129143911-ac4ptj0nh2nsbdqo --- addons/web/__openerp__.py | 1 + addons/web/static/src/js/boot.js | 2 +- addons/web/static/src/js/view_form.js | 155 +------------------------- addons/web/static/src/js/view_page.js | 152 +++++++++++++++++++++++++ 4 files changed, 155 insertions(+), 155 deletions(-) create mode 100644 addons/web/static/src/js/view_page.js diff --git a/addons/web/__openerp__.py b/addons/web/__openerp__.py index a6eaa32b3cd..433bebb5429 100644 --- a/addons/web/__openerp__.py +++ b/addons/web/__openerp__.py @@ -42,6 +42,7 @@ "static/src/js/data_import.js", "static/src/js/search.js", "static/src/js/view_form.js", + "static/src/js/view_page.js", "static/src/js/view_list.js", "static/src/js/view_list_editable.js", "static/src/js/view_tree.js", diff --git a/addons/web/static/src/js/boot.js b/addons/web/static/src/js/boot.js index 58dcd922ea9..c2aea24276b 100644 --- a/addons/web/static/src/js/boot.js +++ b/addons/web/static/src/js/boot.js @@ -59,7 +59,7 @@ openerp.web = function(instance) { openerp.web.formats(instance); openerp.web.chrome(instance); openerp.web.data(instance); - var files = ["views","search","list","form","list_editable","web_mobile","view_tree","data_export","data_import","view_editor"]; + var files = ["views","search","list","form", "page","list_editable","web_mobile","view_tree","data_export","data_import","view_editor"]; for(var i=0; i Date: Tue, 29 Nov 2011 15:58:10 +0100 Subject: [PATCH 042/185] [ADD] page view template split out from form template bzr revid: rlo@openerp.com-20111129145810-5l47j142zrn1ki50 --- addons/web/static/src/js/view_page.js | 1 + addons/web/static/src/xml/base.xml | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/view_page.js b/addons/web/static/src/js/view_page.js index cfa6f41e7ba..325f2bf7444 100644 --- a/addons/web/static/src/js/view_page.js +++ b/addons/web/static/src/js/view_page.js @@ -2,6 +2,7 @@ openerp.web.page = function (openerp) { openerp.web.views.add('page', 'openerp.web.PageView'); openerp.web.PageView = openerp.web.FormView.extend({ + form_template: "PageView", init: function () { this._super.apply(this, arguments); this.registry = openerp.web.form.readonly; diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 1fe4d028db4..577c6b52368 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -656,11 +656,7 @@ - - -
@@ -674,6 +670,16 @@
+ + + + + + + +
From bb67abe9140d73f6c8ad4c25eefc9d38be777485 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Wed, 30 Nov 2011 11:11:10 +0100 Subject: [PATCH 043/185] [IMP] account_voucher: improvements inj usability + changed the semantic of the payment_rate, which now depicts the rate of the payment_rate_currency_id against the voucher currency (instead of the main currency) bzr revid: qdp-launchpad@openerp.com-20111130101110-p19ujgsaqgfnuv1r --- addons/account_voucher/account_voucher.py | 100 +++++++++++------- .../test/account_voucher_report.yml | 4 +- addons/account_voucher/test/case4_cad_chf.yml | 2 + .../voucher_payment_receipt_view.xml | 18 ++-- 4 files changed, 76 insertions(+), 48 deletions(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 6860665f71d..22824cb8db0 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -159,15 +159,6 @@ class account_voucher(osv.osv): res = super(account_voucher, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) doc = etree.XML(res['arch']) - # replace the label of the field payment_rate - currency_obj = self.pool.get('res.currency') - base_currency_id = currency_obj.search(cr, uid, [('rate','=',1.0),('rate_ids','=',1.0)], context=context) - symbol = base_currency_id and currency_obj.name_get(cr, uid, base_currency_id, context=context)[0][1] - string = _("Rate for this operation: 1 %s is") % symbol - payment_rate_field = doc.xpath("//field[@name='payment_rate']") - for field in payment_rate_field: - field.set('string', string) - if context.get('type', 'sale') in ('purchase', 'payment'): nodes = doc.xpath("//field[@name='partner_id']") for node in nodes: @@ -183,17 +174,25 @@ class account_voucher(osv.osv): credit += l['amount'] return abs(amount - abs(credit - debit)) - def onchange_line_ids(self, cr, uid, ids, line_dr_ids, line_cr_ids, amount, context=None): + def onchange_line_ids(self, cr, uid, ids, line_dr_ids, line_cr_ids, amount, voucher_currency, context=None): context = context or {} if not line_dr_ids and not line_cr_ids: return {'value':{}} line_osv = self.pool.get("account.voucher.line") line_dr_ids = resolve_o2m_operations(cr, uid, line_osv, line_dr_ids, ['amount'], context) line_cr_ids = resolve_o2m_operations(cr, uid, line_osv, line_cr_ids, ['amount'], context) - return {'value': {'writeoff_amount': self._compute_writeoff_amount(cr, uid, line_dr_ids, line_cr_ids, amount)}} + + #loop into the lines to see if there is an amount allocated on a voucher line with a currency different than the voucher currency + is_multi_currency = False + for voucher_line in line_dr_ids+line_cr_ids: + if voucher_line.get('currency_id',False) != voucher_currency: + is_multi_currency = True + break + return {'value': {'writeoff_amount': self._compute_writeoff_amount(cr, uid, line_dr_ids, line_cr_ids, amount), 'is_multi_currency': is_multi_currency}} def _get_writeoff_amount(self, cr, uid, ids, name, args, context=None): if not ids: return {} + currency_obj = self.pool.get('res.currency') res = {} debit = credit = 0.0 for voucher in self.browse(cr, uid, ids, context=context): @@ -201,18 +200,24 @@ class account_voucher(osv.osv): debit += l.amount for l in voucher.line_cr_ids: credit += l.amount - res[voucher.id] = abs(voucher.amount - abs(credit - debit)) + currency = voucher.currency_id or voucher.company_id.currency_id + res[voucher.id] = currency_obj.round(cr, uid, currency, abs(voucher.amount - abs(credit - debit))) return res def _paid_amount_in_company_currency(self, cr, uid, ids, name, args, context=None): if not ids: return {} res = {} - debit = credit = 0.0 + voucher_rate = company_currency_rate = 1.0 for voucher in self.browse(cr, uid, ids, context=context): - rate = voucher.currency_id.rate or voucher.company_id.currency_id.rate - if voucher.currency_id == voucher.payment_rate_currency_id: - rate = voucher.payment_rate - res[voucher.id] = voucher.amount / rate * voucher.company_id.currency_id.rate + if voucher.currency_id: + ctx = context.copy() + ctx.update({'date': voucher.date}) + voucher_rate = self.browse(cr, uid, voucher.id, context=ctx).currency_id.rate + if voucher.company_id.currency_id.id == voucher.payment_rate_currency_id.id: + company_currency_rate = voucher.payment_rate + else: + company_currency_rate = voucher.company_id.currency_id.rate + res[voucher.id] = voucher.amount / voucher_rate * company_currency_rate return res _name = 'account.voucher' @@ -275,9 +280,10 @@ class account_voucher(osv.osv): 'analytic_id': fields.many2one('account.analytic.account','Write-Off Analytic Account', readonly=True, states={'draft': [('readonly', False)]}), 'writeoff_amount': fields.function(_get_writeoff_amount, string='Reconcile Amount', type='float', readonly=True), 'payment_rate_currency_id': fields.many2one('res.currency', 'Payment Rate Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}), - 'payment_rate': fields.float('Payment Rate', digits=(12,6), required=True, readonly=True, states={'draft': [('readonly', False)]}, - help='The specific rate that will be used for this voucher for the selected currency.'), + 'payment_rate': fields.float('Exchange Rate', digits=(12,6), required=True, readonly=True, states={'draft': [('readonly', False)]}, + help='The specific rate that will be used, in this voucher, between the selected currency (in \'Payment Rate Currency\' field) and the voucher currency.'), 'paid_amount_in_company_currency': fields.function(_paid_amount_in_company_currency, string='Paid Amount in Company Currency', type='float', readonly=True), + 'is_multi_currency': fields.boolean('Multi Currency Voucher', help='Fields with internal purpose only that depicts if the voucher is a multi currency one or not'), } _defaults = { 'period_id': _get_period, @@ -448,10 +454,15 @@ class account_voucher(osv.osv): return default def onchange_rate(self, cr, uid, ids, rate, amount, currency_id, payment_rate_currency_id, company_id, context=None): - res = {'value': {}} - if rate and amount and currency_id and currency_id == payment_rate_currency_id: - company_rate = self.pool.get('res.company').browse(cr, uid, company_id, context=context).currency_id.rate - res['value']['paid_amount_in_company_currency'] = amount / rate * company_rate + res = {'value': {'paid_amount_in_company_currency': amount}} + company_currency = self.pool.get('res.company').browse(cr, uid, company_id, context=context).currency_id + if rate and amount and currency_id:# and currency_id == payment_rate_currency_id: + voucher_rate = self.pool.get('res.currency').browse(cr, uid, currency_id, context).rate + if company_currency.id == payment_rate_currency_id: + company_rate = rate + else: + company_rate = self.pool.get('res.company').browse(cr, uid, company_id, context=context).currency_id.rate + res['value']['paid_amount_in_company_currency'] = amount / voucher_rate * company_rate return res def onchange_amount(self, cr, uid, ids, amount, rate, partner_id, journal_id, currency_id, ttype, date, payment_rate_currency_id, company_id, context=None): @@ -578,6 +589,7 @@ class account_voucher(osv.osv): else: amount_original = currency_pool.compute(cr, uid, company_currency, currency_id, line.credit or line.debit or 0.0) amount_unreconciled = currency_pool.compute(cr, uid, company_currency, currency_id, abs(line.amount_residual)) + currency_id = line.currency_id and line.currency_id.id or line.company_id.currency_id.id rs = { 'name':line.move_id.name, 'type': line.credit and 'dr' or 'cr', @@ -588,6 +600,7 @@ class account_voucher(osv.osv): 'date_original':line.date, 'date_due':line.date_maturity, 'amount_unreconciled': amount_unreconciled, + 'currency_id': currency_id, } #split voucher amount by most old first, but only for lines in the same currency @@ -650,7 +663,9 @@ class account_voucher(osv.osv): res['value'].update({'period_id':pids[0]}) if payment_rate_currency_id: ctx.update({'date': date}) - payment_rate = self.pool.get('res.currency').browse(cr, uid, payment_rate_currency_id, context=ctx).rate + payment_rate = 1.0 + if payment_rate_currency_id != currency_id: + payment_rate = self.pool.get('res.currency').browse(cr, uid, payment_rate_currency_id, context=ctx).rate vals = self.onchange_payment_rate_currency(cr, uid, ids, currency_id, payment_rate, payment_rate_currency_id, date, amount, company_id, context=context) vals['value'].update({'payment_rate': payment_rate}) for key in vals.keys(): @@ -674,12 +689,13 @@ class account_voucher(osv.osv): currency_id = journal.currency.id ctx = context.copy() ctx.update({'date': date}) - payment_rate = self.pool.get('res.currency').browse(cr, uid, currency_id, context=ctx).rate - vals['value'].update({'payment_rate': payment_rate}) + #on change of the journal, we need to TODO coment me + payment_rate = 1.0 + res = self.onchange_rate(cr, uid, ids, payment_rate, amount, currency_id, currency_id, company_id, context=ctx) for key in res.keys(): vals[key].update(res[key]) - if currency_id: + vals['value'].update({'payment_rate': payment_rate}) vals['value'].update({'currency_id': currency_id}) vals['value'].update({'payment_rate_currency_id': currency_id}) res = self.onchange_partner_id(cr, uid, ids, partner_id, journal_id, amount, currency_id, ttype, date, context) @@ -912,12 +928,7 @@ class account_voucher(osv.osv): # the rate specified on the voucher is for the company currency rate_between_voucher_and_base = voucher.currency_id.rate or 1.0 rate_between_base_and_company = voucher.payment_rate or 1.0 - res = amount / rate_between_voucher_and_base * rate_between_base_and_company - elif voucher.payment_rate_currency_id.id == voucher.currency_id.id: - # the rate specified on the voucher is for the voucher currency - rate_between_base_and_company = voucher.company_id.currency_id.rate or 1.0 - rate_between_voucher_and_base = voucher.payment_rate or 1.0 - res = amount / rate_between_voucher_and_base * rate_between_base_and_company + res = currency_obj.round(cr, uid, voucher.company_id.currency_id, (amount / rate_between_voucher_and_base * rate_between_base_and_company)) else: # the rate specified on the voucher is not relevant, we use all the rates in the system res = currency_obj.compute(cr, uid, voucher.currency_id.id, voucher.company_id.currency_id.id, amount, context=context) @@ -997,7 +1008,7 @@ class account_voucher(osv.osv): if not (tax_data.base_code_id and tax_data.tax_code_id): raise osv.except_osv(_('No Account Base Code and Account Tax Code!'),_("You have to configure account base code and account tax code on the '%s' tax!") % (tax_data.name)) - # compute the amount in foreign currency. + # compute the amount in foreign currency amount_currency = False if line.move_line_id: # We want to set it on the account move line as soon as the original line had a foreign currency @@ -1200,6 +1211,20 @@ class account_voucher_line(osv.osv): rs_data[line.id] = res return rs_data + def _currency_id(self, cr, uid, ids, name, args, context=None): + ''' + This function returns the currency id of a voucher line. It's either the currency of the + associated move line (if any) or the currency of the voucher or the company currency. + ''' + res = {} + for line in self.browse(cr, uid, ids, context=context): + move_line = line.move_line_id + if move_line: + res[line.id] = move_line.currency_id and move_line.currency_id.id or move_line.company_id.currency_id.id + else: + res[line.id] = line.voucher_id.currency_id and line.voucher_id.currency_id.id or line.voucher_id.company_id.currency_id.id + return res + _columns = { 'voucher_id':fields.many2one('account.voucher', 'Voucher', required=1, ondelete='cascade'), 'name':fields.char('Description', size=256), @@ -1216,6 +1241,7 @@ class account_voucher_line(osv.osv): 'amount_original': fields.function(_compute_balance, multi='dc', type='float', string='Original Amount', store=True), 'amount_unreconciled': fields.function(_compute_balance, multi='dc', type='float', string='Open Balance', store=True), 'company_id': fields.related('voucher_id','company_id', relation='res.company', type='many2one', string='Company', store=True, readonly=True), + 'currency_id': fields.function(_currency_id, string='Currency', type='many2one', relation='res.currency', readonly=True), } _defaults = { 'name': '', @@ -1252,10 +1278,10 @@ class account_voucher_line(osv.osv): ttype = 'dr' else: ttype = 'cr' - account_id = move_line.account_id.id res.update({ - 'account_id':account_id, - 'type': ttype + 'account_id': move_line.account_id.id, + 'type': ttype, + 'currency_id': move_line.currency_id and move_line.currency_id.id or move_line.company_id.currency_id.id, }) return { 'value':res, diff --git a/addons/account_voucher/test/account_voucher_report.yml b/addons/account_voucher/test/account_voucher_report.yml index b41c33e4470..85432f747aa 100644 --- a/addons/account_voucher/test/account_voucher_report.yml +++ b/addons/account_voucher/test/account_voucher_report.yml @@ -1,7 +1,7 @@ - Demo for Account Voucher - - !record {model: account.voucher, id: account_voucher_voucheraxelor0}: + !record {model: account.voucher, id: account_voucher_voucheraxelor0again}: account_id: account.cash company_id: base.main_company journal_id: account.bank_journal @@ -19,6 +19,6 @@ - !python {model: account.voucher}: | import netsvc, tools, os - (data, format) = netsvc.LocalService('report.voucher.cash_receipt.drcr').create(cr, uid, [ref("account_voucher_voucheraxelor0")], {}, {}) + (data, format) = netsvc.LocalService('report.voucher.cash_receipt.drcr').create(cr, uid, [ref("account_voucher_voucheraxelor0again")], {}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'account_voucher-report.'+format), 'wb+').write(data) diff --git a/addons/account_voucher/test/case4_cad_chf.yml b/addons/account_voucher/test/case4_cad_chf.yml index 7c0f9274ff8..f31a7393a8e 100644 --- a/addons/account_voucher/test/case4_cad_chf.yml +++ b/addons/account_voucher/test/case4_cad_chf.yml @@ -128,6 +128,8 @@ for item in voucher_id.line_cr_ids: if item.amount_unreconciled == 186.74: data += [(item.id, 186.74)] + else: + data += [(item.id, 0.0)] for line_id, amount in data: self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount}) assert (voucher_id.state=='draft'), "Voucher is not in draft state" diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml index db7c9d9ec54..6ed7ab0fe7c 100644 --- a/addons/account_voucher/voucher_payment_receipt_view.xml +++ b/addons/account_voucher/voucher_payment_receipt_view.xml @@ -92,7 +92,7 @@ - + - + - + @@ -203,11 +203,11 @@ - + - + @@ -318,7 +318,7 @@ - + - + - + - + From 4cb6d48f1ff5fa21244396768ed82860f7ceb4a6 Mon Sep 17 00:00:00 2001 From: "Jiten (OpenERP)" Date: Wed, 30 Nov 2011 16:56:14 +0530 Subject: [PATCH 044/185] [IMP] Improve m2m and o2m to show selected record in formview. bzr revid: jra@tinyerp.com-20111130112614-qrkmra8rzok7nksn --- .../web_mobile/static/src/js/form_mobile.js | 136 ++++++------------ .../web_mobile/static/src/xml/web_mobile.xml | 19 +-- 2 files changed, 47 insertions(+), 108 deletions(-) diff --git a/addons/web_mobile/static/src/js/form_mobile.js b/addons/web_mobile/static/src/js/form_mobile.js index cc816b75a21..13ff38bca5c 100644 --- a/addons/web_mobile/static/src/js/form_mobile.js +++ b/addons/web_mobile/static/src/js/form_mobile.js @@ -41,13 +41,13 @@ 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); @@ -55,110 +55,56 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({ 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'); } }); - 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([], {limit:80}, function(result1,ids){ + var rel_field = fields[relational]; + var head = rel_field.string; + var rel_model = rel_field.relation; + var rel_ids = values[relational]; + 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([], {limit:80}, function(listrec){ _.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(result1,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'); - 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); - }); - 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 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); diff --git a/addons/web_mobile/static/src/xml/web_mobile.xml b/addons/web_mobile/static/src/xml/web_mobile.xml index 1deb752cab6..f94117e6e0e 100644 --- a/addons/web_mobile/static/src/xml/web_mobile.xml +++ b/addons/web_mobile/static/src/xml/web_mobile.xml @@ -279,7 +279,9 @@ @@ -296,24 +298,15 @@ - + - - -
From 832436c1487ca6accf074da8e73ce5cccda51c48 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Wed, 30 Nov 2011 14:30:08 +0100 Subject: [PATCH 045/185] [IMP] account_voucher: usability changes bzr revid: qdp-launchpad@openerp.com-20111130133008-lki16nzzlz78s0h8 --- addons/account_voucher/account_voucher.py | 6 ++--- .../voucher_payment_receipt_view.xml | 24 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 22824cb8db0..999de8dfbf4 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -274,11 +274,11 @@ class account_voucher(osv.osv): 'payment_option':fields.selection([ ('without_writeoff', 'Keep Open'), ('with_writeoff', 'Reconcile Payment Balance'), - ], 'Payment Difference', required=True, readonly=True, states={'draft': [('readonly', False)]}), + ], 'Payment Difference', required=True, readonly=True, states={'draft': [('readonly', False)]}, help="This field helps you to choose what you want to do with the eventual difference between the paid amount and the sum of allocated amounts. You can either choose to keep open this difference on the partner's account, or reconcile it with the payment(s)"), 'writeoff_acc_id': fields.many2one('account.account', 'Counterpart Account', readonly=True, states={'draft': [('readonly', False)]}), 'comment': fields.char('Counterpart Comment', size=64, required=True, readonly=True, states={'draft': [('readonly', False)]}), 'analytic_id': fields.many2one('account.analytic.account','Write-Off Analytic Account', readonly=True, states={'draft': [('readonly', False)]}), - 'writeoff_amount': fields.function(_get_writeoff_amount, string='Reconcile Amount', type='float', readonly=True), + 'writeoff_amount': fields.function(_get_writeoff_amount, string='Difference Amount', type='float', readonly=True, help="Computed as the difference between the amount stated in the voucher and the sum of allocation on the voucher lines."), 'payment_rate_currency_id': fields.many2one('res.currency', 'Payment Rate Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}), 'payment_rate': fields.float('Exchange Rate', digits=(12,6), required=True, readonly=True, states={'draft': [('readonly', False)]}, help='The specific rate that will be used, in this voucher, between the selected currency (in \'Payment Rate Currency\' field) and the voucher currency.'), @@ -1231,7 +1231,7 @@ class account_voucher_line(osv.osv): 'account_id':fields.many2one('account.account','Account', required=True), 'partner_id':fields.related('voucher_id', 'partner_id', type='many2one', relation='res.partner', string='Partner'), 'untax_amount':fields.float('Untax Amount'), - 'amount':fields.float('Amount', digits_compute=dp.get_precision('Account')), + 'amount':fields.float('Allocation', digits_compute=dp.get_precision('Account')), 'reconcile': fields.boolean('Full Reconcile'), 'type':fields.selection([('dr','Debit'),('cr','Credit')], 'Dr/Cr'), 'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic Account'), diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml index 6ed7ab0fe7c..e2060a04533 100644 --- a/addons/account_voucher/voucher_payment_receipt_view.xml +++ b/addons/account_voucher/voucher_payment_receipt_view.xml @@ -102,8 +102,8 @@ - - + + @@ -116,8 +116,8 @@ - - + + @@ -177,9 +177,9 @@ - + - + @@ -193,9 +193,9 @@ - + - + @@ -329,9 +329,9 @@ - + - + @@ -345,9 +345,9 @@ - + - + From 8dcc7aac7ae32007795cf9c44f4a725a2c248404 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Wed, 30 Nov 2011 14:33:11 +0100 Subject: [PATCH 046/185] [IMP] account_voucher: usability changes bzr revid: qdp-launchpad@openerp.com-20111130133311-8t4sxrikywrkkkhh --- addons/account_voucher/voucher_payment_receipt_view.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml index e2060a04533..13cbaa74688 100644 --- a/addons/account_voucher/voucher_payment_receipt_view.xml +++ b/addons/account_voucher/voucher_payment_receipt_view.xml @@ -252,7 +252,7 @@ - - + +
@@ -672,12 +670,10 @@ - - - - + + + + From f247fb7dccda0fad8c82706b2ad914f7367f5eee Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 5 Dec 2011 15:00:54 +0100 Subject: [PATCH 069/185] [FIX] pos bzr revid: rco@openerp.com-20111205140054-u85cerkhw65o8vnp --- addons/point_of_sale/point_of_sale_view.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/point_of_sale_view.xml b/addons/point_of_sale/point_of_sale_view.xml index b1e3e6a6d00..165c6c83e3a 100644 --- a/addons/point_of_sale/point_of_sale_view.xml +++ b/addons/point_of_sale/point_of_sale_view.xml @@ -797,14 +797,16 @@ Start Point of Sale pos.ui + Point of Sale - images/pos.png - images/pos-hover.png + + From c2b1f5202658cd0efb366b4114bfad503c9d109e Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 5 Dec 2011 15:02:57 +0100 Subject: [PATCH 070/185] [REM] form view in mail message o2ms bzr revid: xmo@openerp.com-20111205140257-1h0dnuly3tqdqsnb --- addons/crm/crm_lead_view.xml | 61 +------------------ addons/crm_claim/crm_claim_view.xml | 28 +-------- .../crm_fundraising/crm_fundraising_view.xml | 28 +-------- addons/crm_helpdesk/crm_helpdesk_view.xml | 28 +-------- addons/event/event_view.xml | 28 +-------- addons/hr_recruitment/hr_recruitment_view.xml | 28 +-------- addons/mail/mail_thread_view.xml | 21 +------ addons/project_issue/project_issue_view.xml | 28 +-------- .../project_mailgate_view.xml | 24 +------- .../project_messages_view.xml | 9 --- 10 files changed, 10 insertions(+), 273 deletions(-) diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index 6527fa4cf25..e9c77b3bdc6 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -147,7 +147,7 @@ - + @@ -157,35 +157,6 @@ context="{'mail.compose.message.mode':'reply', 'message_id':active_id}" icon="terp-mail-replied" type="action" /> - - - - - - - - - - - - - - - - - -