[MERGE] Sync with trunk

bzr revid: tde@openerp.com-20130909093126-dg8odqhq6g2bsd9w
bzr revid: tde@openerp.com-20130912073949-dib01nji97z0ogn2
This commit is contained in:
Thibault Delavallée 2013-09-12 09:39:49 +02:00
commit be64818d1b
5 changed files with 24 additions and 20 deletions

View File

@ -3,8 +3,12 @@
You can adapt this file completely to your liking, but it should at least You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive. contain the root `toctree` directive.
Welcome to OpenERP Web's documentation! OpenERP Web Reference Documentation
======================================= ===================================
See also the `OpenERP Web Training`_.
.. _OpenERP Web Training: https://doc.openerp.com/trunk/training/
Basics Basics
------ ------

View File

@ -61,18 +61,19 @@ instance.web.Query = instance.web.Class.extend({
}, },
_execute: function () { _execute: function () {
var self = this; var self = this;
return this._model.call('search_read', { return instance.session.rpc('/web/dataset/search_read', {
model: this._model.name,
fields: this._fields || false,
domain: instance.web.pyeval.eval('domains', domain: instance.web.pyeval.eval('domains',
[this._model.domain(this._filter)]), [this._model.domain(this._filter)]),
fields: this._fields || false,
offset: this._offset,
limit: this._limit,
order: instance.web.serialize_sort(this._order_by),
context: instance.web.pyeval.eval('contexts', context: instance.web.pyeval.eval('contexts',
[this._model.context(this._context)]), [this._model.context(this._context)]),
offset: this._offset,
limit: this._limit,
sort: instance.web.serialize_sort(this._order_by)
}).then(function (results) { }).then(function (results) {
self._count = results.length; self._count = results.length;
return results; return results.records;
}, null); }, null);
}, },
/** /**
@ -450,7 +451,7 @@ instance.web.DataSet = instance.web.Class.extend(instance.web.PropertiesMixin,
// TODO: reorder results to match ids list // TODO: reorder results to match ids list
return this._model.call('read', return this._model.call('read',
[ids, fields || false], [ids, fields || false],
{context: this._model.context(options.context)}); {context: this.get_context(options.context)});
}, },
/** /**
* Read a slice of the records represented by this DataSet, based on its * Read a slice of the records represented by this DataSet, based on its

View File

@ -166,13 +166,13 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
var is_loaded = 0, var is_loaded = 0,
$this = $(this), $this = $(this),
record_id = $this.data('id'), record_id = $this.data('id'),
parent_id = $this.data('parent-id'), row_parent_id = $this.data('row-parent-id'),
record = self.records[record_id], record = self.records[record_id],
children_ids = record[self.children_field]; children_ids = record[self.children_field];
_(children_ids).each(function(childid) { _(children_ids).each(function(childid) {
if (self.$el.find('[id=treerow_' + childid + '][data-parent-id='+ record_id +']').length ) { if (self.$el.find('[id=treerow_' + childid + '][data-row-parent-id='+ record_id +']').length ) {
if (self.$el.find('[id=treerow_' + childid + '][data-parent-id='+ record_id +']').is(':hidden')) { if (self.$el.find('[id=treerow_' + childid + '][data-row-parent-id='+ record_id +']').is(':hidden')) {
is_loaded = -1; is_loaded = -1;
} else { } else {
is_loaded++; is_loaded++;
@ -196,7 +196,6 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
_(records).each(function (record) { _(records).each(function (record) {
self.records[record.id] = record; self.records[record.id] = record;
}); });
var $curr_node = self.$el.find('#treerow_' + id); var $curr_node = self.$el.find('#treerow_' + id);
var children_rows = QWeb.render('TreeView.rows', { var children_rows = QWeb.render('TreeView.rows', {
'records': records, 'records': records,
@ -206,7 +205,7 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
'level': $curr_node.data('level') || 0, 'level': $curr_node.data('level') || 0,
'render': instance.web.format_value, 'render': instance.web.format_value,
'color_for': self.color_for, 'color_for': self.color_for,
'parent_id': id 'row_parent_id': id
}); });
if ($curr_node.length) { if ($curr_node.length) {
$curr_node.addClass('oe_open'); $curr_node.addClass('oe_open');
@ -250,7 +249,7 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
showcontent: function (curnode,record_id, show) { showcontent: function (curnode,record_id, show) {
curnode.parent('tr').toggleClass('oe_open', show); curnode.parent('tr').toggleClass('oe_open', show);
_(this.records[record_id][this.children_field]).each(function (child_id) { _(this.records[record_id][this.children_field]).each(function (child_id) {
var $child_row = this.$el.find('[id=treerow_' + child_id + '][data-parent-id='+ curnode.data('id') +']'); var $child_row = this.$el.find('[id=treerow_' + child_id + '][data-row-parent-id='+ curnode.data('id') +']');
if ($child_row.hasClass('oe_open')) { if ($child_row.hasClass('oe_open')) {
$child_row.toggleClass('oe_open',show); $child_row.toggleClass('oe_open',show);
this.showcontent($child_row, child_id, false); this.showcontent($child_row, child_id, false);

View File

@ -685,7 +685,7 @@
t-foreach="records" t-as="record" t-foreach="records" t-as="record"
t-att-id="'treerow_' + record.id" t-att-id="'treerow_' + record.id"
t-att-data-id="record.id" t-att-data-level="level + 1" t-att-data-id="record.id" t-att-data-level="level + 1"
t-att-data-parent-id="parent_id"> t-att-data-row-parent-id="row_parent_id">
<t t-set="children" t-value="record[children_field]"/> <t t-set="children" t-value="record[children_field]"/>
<t t-set="class" t-value="children and children.length ? 'treeview-tr' : 'treeview-td'"/> <t t-set="class" t-value="children and children.length ? 'treeview-tr' : 'treeview-td'"/>
<t t-set="rank" t-value="'oe-treeview-first'"/> <t t-set="rank" t-value="'oe-treeview-first'"/>

View File

@ -18,16 +18,16 @@ openerp.testing.section('data.model.group_by', {
"should have single grouping field"); "should have single grouping field");
return group_result; return group_result;
}); });
mock('foo:search_read', function (args, kwargs) { mock('/web/dataset/search_read', function (args) {
deepEqual(kwargs.domain, [['bar', '=', 3]], deepEqual(args.params.domain, [['bar', '=', 3]],
"should have domain matching that of group_by result"); "should have domain matching that of group_by result");
return [ return {records: [
{bar: 3, id: 1}, {bar: 3, id: 1},
{bar: 3, id: 2}, {bar: 3, id: 2},
{bar: 3, id: 4}, {bar: 3, id: 4},
{bar: 3, id: 8}, {bar: 3, id: 8},
{bar: 3, id: 16} {bar: 3, id: 16}
]; ], length: 5};
}); });
return m.query().group_by('bar') return m.query().group_by('bar')