[MERGE] from trunk
bzr revid: fva@openerp.com-20120924150127-uky1tz5g8ecnvqs2 bzr revid: fva@openerp.com-20120925141140-oe20lwnxjzmdqctx
This commit is contained in:
@@ -532,7 +532,9 @@ instance.web.Login = instance.web.Widget.extend({
|
||||
});
|
||||
var d;
|
||||
if (self.params.db) {
|
||||
d = self.do_login(self.params.db, self.params.login, self.params.password);
|
||||
if (self.params.login && self.params.password) {
|
||||
d = self.do_login(self.params.db, self.params.login, self.params.password);
|
||||
}
|
||||
} else {
|
||||
d = self.rpc("/web/database/get_list", {}).done(self.on_db_loaded).fail(self.on_db_failed);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,14 @@ instance.web.form = {};
|
||||
* Events:
|
||||
* - view_content_has_changed : when the values of the fields have changed. When
|
||||
* this event is triggered all fields should reprocess their modifiers.
|
||||
* - field_changed:<field_name> : when the value of a field change, an event is triggered
|
||||
* named "field_changed:<field_name>" with <field_name> replaced by the name of the field.
|
||||
* This event is not related to the on_change mechanism of OpenERP and is always called
|
||||
* when the value of a field is setted or changed. This event is only triggered when the
|
||||
* value of the field is syntactically valid, but it can be triggered when the value
|
||||
* is sematically invalid (ie, when a required field is false). It is possible that an event
|
||||
* about a precise field is never triggered even if that field exists in the view, in that
|
||||
* case the value of the field is assumed to be false.
|
||||
*/
|
||||
instance.web.form.FieldManagerMixin = {
|
||||
/**
|
||||
@@ -26,6 +34,11 @@ instance.web.form.FieldManagerMixin = {
|
||||
* Returns true when the view is in create mode.
|
||||
*/
|
||||
is_create_mode: function() {},
|
||||
/**
|
||||
* Returns the current value of a field present in the view. See the get_value() method
|
||||
* method in FieldInterface for further information.
|
||||
*/
|
||||
get_field_value: function(field_name) {},
|
||||
};
|
||||
|
||||
instance.web.views.add('form', 'instance.web.FormView');
|
||||
@@ -331,7 +344,9 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||
|
||||
_(this.fields).each(function (field, f) {
|
||||
field._dirty_flag = false;
|
||||
field._inhibit_on_change_flag = true;
|
||||
var result = field.set_value(self.datarecord[f] || false);
|
||||
field._inhibit_on_change_flag = false;
|
||||
set_values.push(result);
|
||||
});
|
||||
return $.when.apply(null, set_values).pipe(function() {
|
||||
@@ -580,7 +595,9 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||
if (field) {
|
||||
var value_ = result.value[f];
|
||||
if (field.get_value() != value_) {
|
||||
field._inhibit_on_change_flag = true;
|
||||
field.set_value(value_);
|
||||
field._inhibit_on_change_flag = false;
|
||||
field._dirty_flag = true;
|
||||
if (!_.contains(processed, field.name)) {
|
||||
this.do_onchange(field, processed);
|
||||
@@ -940,6 +957,15 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||
return self.dataset.parent_view.recursive_save();
|
||||
});
|
||||
},
|
||||
recursive_reload: function() {
|
||||
var self = this;
|
||||
var pre = $.when();
|
||||
if (self.dataset.parent_view)
|
||||
pre = self.dataset.parent_view.recursive_reload();
|
||||
return pre.pipe(function() {
|
||||
return self.reload();
|
||||
});
|
||||
},
|
||||
is_dirty: function() {
|
||||
return _.any(this.fields, function (value_) {
|
||||
return value_._dirty_flag;
|
||||
@@ -1043,6 +1069,12 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||
this.translatable_fields.push(field);
|
||||
}
|
||||
field.on('changed_value', this, function() {
|
||||
if (field.is_syntax_valid()) {
|
||||
this.trigger('field_changed:' + name);
|
||||
}
|
||||
if (field._inhibit_on_change_flag) {
|
||||
return;
|
||||
}
|
||||
field._dirty_flag = true;
|
||||
if (field.is_syntax_valid()) {
|
||||
this.do_onchange(field);
|
||||
@@ -1057,6 +1089,9 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||
is_create_mode: function() {
|
||||
return this.get("actual_mode") === "create";
|
||||
},
|
||||
get_field_value: function(field_name) {
|
||||
return this.fields[field_name].get_value();
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -1809,7 +1844,7 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({
|
||||
return this.view.do_execute_action(
|
||||
_.extend({}, this.node.attrs, {context: context}),
|
||||
this.view.dataset, this.view.datarecord.id, function () {
|
||||
self.view.reload();
|
||||
self.view.recursive_reload();
|
||||
});
|
||||
},
|
||||
check_disable: function() {
|
||||
@@ -1827,7 +1862,8 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({
|
||||
* - force_readonly: boolean, When it is true, the field should always appear
|
||||
* in read only mode, no matter what the value of the "readonly" property can be.
|
||||
* Events:
|
||||
* - changed_value: triggered to inform the view to check on_changes
|
||||
* - changed_value: triggered when the value of the field has changed. This can be due
|
||||
* to a user interaction or a call to set_value().
|
||||
*
|
||||
*/
|
||||
instance.web.form.FieldInterface = {
|
||||
@@ -1939,8 +1975,7 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w
|
||||
this.on("change:force_readonly", this, test_effective_readonly);
|
||||
test_effective_readonly.call(this);
|
||||
this.on("change:value", this, function() {
|
||||
if (! this._inhibit_on_change)
|
||||
this.trigger('changed_value');
|
||||
this.trigger('changed_value');
|
||||
this._check_css_flags();
|
||||
});
|
||||
},
|
||||
@@ -1975,9 +2010,7 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w
|
||||
this.$el.toggleClass('oe_form_required', this.get("required"));
|
||||
},
|
||||
set_value: function(value_) {
|
||||
this._inhibit_on_change = true;
|
||||
this.set({'value': value_});
|
||||
this._inhibit_on_change = false;
|
||||
},
|
||||
get_value: function() {
|
||||
return this.get('value');
|
||||
@@ -3312,6 +3345,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
|
||||
this.dataset.index = 0;
|
||||
}
|
||||
self.is_setted.resolve();
|
||||
this.trigger_on_change();
|
||||
return self.reload_current_view();
|
||||
},
|
||||
get_value: function() {
|
||||
@@ -3364,7 +3398,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
|
||||
}, this));
|
||||
},
|
||||
is_syntax_valid: function() {
|
||||
if (!this.viewmanager.views[this.viewmanager.active_view])
|
||||
if (! this.viewmanager || ! this.viewmanager.views[this.viewmanager.active_view])
|
||||
return true;
|
||||
var view = this.viewmanager.views[this.viewmanager.active_view].controller;
|
||||
switch (this.viewmanager.active_view) {
|
||||
|
||||
@@ -399,10 +399,14 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
||||
*/
|
||||
setup_columns: function (fields, grouped) {
|
||||
var registry = instance.web.list.columns;
|
||||
var reorder = this.options.reorderable;
|
||||
this.columns.splice(0, this.columns.length);
|
||||
this.columns.push.apply(this.columns,
|
||||
_(this.fields_view.arch.children).map(function (field) {
|
||||
var id = field.attrs.name;
|
||||
if(field.attrs.widget == 'handle' && !reorder){
|
||||
field.attrs.reorderable = reorder || true;
|
||||
}
|
||||
return registry.for_(id, fields[id], field);
|
||||
}));
|
||||
if (grouped) {
|
||||
@@ -411,9 +415,8 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
||||
}
|
||||
|
||||
this.visible_columns = _.filter(this.columns, function (column) {
|
||||
return column.invisible !== '1';
|
||||
return column.invisible !== '1' && !column.reorderable;
|
||||
});
|
||||
|
||||
this.aggregate_columns = _(this.visible_columns).invoke('to_aggregate');
|
||||
},
|
||||
/**
|
||||
|
||||
@@ -318,8 +318,8 @@ instance.web.ActionManager = instance.web.Widget.extend({
|
||||
}
|
||||
return this.ir_actions_common(action, on_close, clear_breadcrumbs);
|
||||
},
|
||||
ir_actions_client: function (action, on_close) {
|
||||
return this.ir_actions_common(action, on_close);
|
||||
ir_actions_client: function (action, on_close, clear_breadcrumbs) {
|
||||
return this.ir_actions_common(action, on_close, clear_breadcrumbs);
|
||||
},
|
||||
ir_actions_act_window_close: function (action, on_closed) {
|
||||
if (!this.dialog && on_closed) {
|
||||
|
||||
@@ -630,7 +630,7 @@
|
||||
<input type="checkbox" class="oe_list_record_selector"/>
|
||||
</th>
|
||||
<t t-foreach="columns" t-as="column">
|
||||
<th t-if="!column.meta and column.invisible !== '1'" t-att-data-id="column.id"
|
||||
<th t-if="!column.meta and column.invisible !== '1' and !column.reorderable" t-att-data-id="column.id"
|
||||
t-attf-class="oe_list_header_#{column.widget or column.type} #{((options.sortable and column.tag !== 'button') ? 'oe_sortable' : null)}">
|
||||
<t t-if="column.tag !== 'button'"><t t-esc="column.string"/></t>
|
||||
</th>
|
||||
@@ -685,7 +685,7 @@
|
||||
<t t-foreach="columns" t-as="column">
|
||||
<t t-set="number" t-value="column.type === 'integer' or column.type == 'float'"/>
|
||||
<t t-set="modifiers" t-value="column.modifiers_for(asData)"/>
|
||||
<td t-if="!column.meta and column.invisible !== '1'" t-att-title="column.help"
|
||||
<td t-if="!column.meta and column.invisible !== '1' and !column.reorderable" t-att-title="column.help"
|
||||
t-attf-class="oe_list_field_cell oe_list_field_#{column.widget or column.type} #{number ? 'oe_number' : ''} #{column.tag === 'button' ? 'oe-button' : ''} #{modifiers.readonly ? 'oe_readonly' : ''} #{modifiers.required ? 'oe_required' : ''}"
|
||||
t-att-data-field="column.id"
|
||||
><t t-raw="render_cell(record, column)"/></td>
|
||||
|
||||
Reference in New Issue
Block a user