[fix] the create button in the gantt view does not work

bzr revid: nicolas.vanhoren@openerp.com-20120113164458-ag5ouf4fy3l6xce9
This commit is contained in:
niv-openerp 2012-01-13 17:44:58 +01:00
commit 0b7552b0fb
1 changed files with 33 additions and 14 deletions

View File

@ -111,7 +111,7 @@ openerp.web_gantt.GanttView = openerp.web.View.extend({
var name = started_projects[0][self.parent];
self.name = name instanceof Array? name[name.length - 1] : name;
}
this.$element.find('#add_task').click(function(){
this.$element.find('#add_task').click(function() {
self.editTask();
});
@ -364,19 +364,38 @@ openerp.web_gantt.GanttView = openerp.web.View.extend({
}
if(event_id) event_id = parseInt(event_id, 10);
var pop = new openerp.web.form.FormOpenPopup(this);
pop.show_element(this.model, event_id, this.context || this.dataset.context, {});
pop.on_write.add(function(id, data) {
var get_project = _.find(self.database_projects, function(project){ return project.id == id});
if (get_project) {
_.extend(get_project, data);
} else {
_.extend(self.database_projects, _.extend(data, {'id': id}));
}
self.reloadView();
});
if (!event_id) {
var pop = new openerp.web.form.SelectCreatePopup(this);
pop.select_element(
this.model,
{
title: _t("Create: ") + this.name,
initial_view: 'form',
disable_multiple_selection: true
},
this.dataset.domain,
this.context || this.dataset.context
)
pop.on_select_elements.add_last(function(element_ids) {
self.dataset.read_ids(element_ids,[]).done(function(projects) {
self.database_projects.concat(projects);
self.reloadView();
});
});
}
else {
var pop = new openerp.web.form.FormOpenPopup(this);
pop.show_element(this.model, event_id, this.context || this.dataset.context, {'title' : _t("Open: ") + this.name});
pop.on_write.add(function(id, data) {
var get_project = _.find(self.database_projects, function(project){ return project.id == id});
if (get_project) {
_.extend(get_project, data);
} else {
_.extend(self.database_projects, _.extend(data, {'id': id}));
}
self.reloadView();
});
}
},
set_width: function() {