[FIX] incorrect "new record" popup in calendar, did not take default values in account

In case the "trivial" (name + start date + end date) form is not
sufficient to create the record (because other fields are required),
the calendar view opens a full-blown form view of the tentatively
created record.

The calendar view did not go and fetch default values for the model,
leading to potentially invalid form states (such as missing values
other fields use to know what they're supposed to do, in this case the
"state" value was missing leading a number of form fields the user
needs to fill being readonly)

bzr revid: xmo@openerp.com-20111201090242-wpuo98af9p1514vn
This commit is contained in:
Xavier Morel 2011-12-01 10:02:42 +01:00
commit 740124b5fa
1 changed files with 7 additions and 2 deletions

View File

@ -252,8 +252,13 @@ openerp.web_calendar.CalendarView = openerp.web.View.extend({
self.refresh_minical();
}, function(r, event) {
self.creating_event_id = event_id;
self.form_dialog.form.on_record_loaded(data);
self.form_dialog.open();
var fields = self.form_dialog.form.fields_view.fields,
fields_to_fetch = _.difference(_(fields).keys(), _(data).keys());
self.dataset.default_get(fields_to_fetch, function (default_values) {
self.form_dialog.form.on_record_loaded(
_.extend(default_values, data));
self.form_dialog.open();
});
event.preventDefault();
});
},