[MERGE] bug fixes form 6.1 branch

bzr revid: xmo@openerp.com-20120305070634-li0eloj7vhsljguu
This commit is contained in:
Xavier Morel 2012-03-05 08:06:34 +01:00
commit e178185b4f
11 changed files with 56 additions and 38 deletions

View File

@ -814,11 +814,13 @@ class Menu(openerpweb.Controller):
Menus = s.model('ir.ui.menu')
# If a menu action is defined use its domain to get the root menu items
user_menu_id = s.model('res.users').read([s._uid], ['menu_id'], context)[0]['menu_id']
menu_domain = [('parent_id', '=', False)]
if user_menu_id:
menu_domain = s.model('ir.actions.act_window').read([user_menu_id[0]], ['domain'], context)[0]['domain']
menu_domain = ast.literal_eval(menu_domain)
else:
menu_domain = [('parent_id', '=', False)]
domain_string = s.model('ir.actions.act_window').read([user_menu_id[0]], ['domain'], context)[0]['domain']
if domain_string:
menu_domain = ast.literal_eval(domain_string)
return Menus.search(menu_domain, 0, False, False, context)
def do_load(self, req):

View File

@ -1228,11 +1228,11 @@ label.error {
.openerp input.oe-binary-file {
z-index: 0;
line-height: 0;
font-size: 50px;
font-size: 12px;
position: absolute;
/* Should be adjusted for all browsers */
top: -2px;
right: 0;
top: 1px;
right: 10px;
opacity: 0;
filter: alpha(opacity = 0);
-ms-filter: "alpha(opacity=0)";

View File

@ -455,7 +455,7 @@ openerp.web.Database = openerp.web.OldWidget.extend(/** @lends openerp.web.Datab
submitHandler: function (form) {
var $form = $(form),
fields = $form.serializeArray(),
$db_list = $form.find('select[name=drop_db]'),
$db_list = $form.find('[name=drop_db]'),
db = $db_list.val();
if (!confirm("Do you really want to delete the database: " + db + " ?")) {

View File

@ -760,9 +760,12 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
_(_.extend({}, options.data || {},
{session_id: this.session_id, token: token}))
.each(function (value, key) {
$('<input type="hidden" name="' + key + '">')
.val(value)
.appendTo($form_data);
var $input = $form.find('[name=' + key +']');
if (!$input.length) {
$input = $('<input type="hidden" name="' + key + '">')
.appendTo($form_data);
}
$input.val(value)
});
$form

View File

@ -336,7 +336,7 @@ openerp.web.format_cell = function (row_data, column, options) {
case 'progressbar':
return _.template(
'<progress value="<%-value%>" max="100"><%-value%>%</progress>', {
value: row_data[column.id].value
value: _.str.sprintf("%.0f", row_data[column.id].value)
});
}

View File

@ -263,9 +263,14 @@ openerp.web.SearchView = openerp.web.OldWidget.extend(/** @lends openerp.web.Sea
var filter = this.managed_filters[val];
this.do_clear(false).then(_.bind(function() {
select.val('get:' + val);
var groupbys = _.map(filter.context.group_by.split(","), function(el) {
return {"group_by": el};
});
var groupbys = [];
var group_by = filter.context.group_by;
if (group_by) {
groupbys = _.map(
group_by instanceof Array ? group_by : group_by.split(','),
function (el) { return { group_by: el }; });
}
this.on_search([filter.domain], [filter.context], groupbys);
}, this));
} else {

View File

@ -291,6 +291,10 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
*/
configure_pager: function (dataset) {
this.dataset.ids = dataset.ids;
// Not exactly clean
if (dataset._length) {
this.dataset._length = dataset._length;
}
var limit = this.limit(),
total = dataset.size(),
@ -540,19 +544,17 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
* @param {Array} records selected record values
*/
do_select: function (ids, records) {
this.$element.find('.oe-list-delete')
.attr('disabled', !ids.length);
if (this.sidebar) {
if (ids.length) {
this.sidebar.do_unfold();
} else {
this.sidebar.do_fold();
}
}
if (!records.length) {
this.$element.find('.oe-list-delete').attr('disabled', !ids.length);
if (!ids.length) {
this.dataset.index = 0;
if (this.sidebar) { this.sidebar.do_fold(); }
this.compute_aggregates();
return;
}
this.dataset.index = _(this.dataset.ids).indexOf(ids[0]);
if (this.sidebar) { this.sidebar.do_unfold(); }
this.compute_aggregates(_(records).map(function (record) {
return {count: 1, values: record};
}));
@ -1259,9 +1261,11 @@ openerp.web.ListView.Groups = openerp.web.Class.extend( /** @lends openerp.web.L
if (column.meta) {
// do not do anything
} else if (column.id in group.aggregates) {
var value = group.aggregates[column.id];
var r = {};
r[column.id] = {value: group.aggregates[column.id]};
$('<td class="oe-number">')
.html(openerp.web.format_value(value, column))
.html(openerp.web.format_cell(
r, column, {process_modifiers: false}))
.appendTo($row);
} else {
$row.append('<td>');

View File

@ -224,21 +224,25 @@ openerp.web.TreeView = openerp.web.View.extend(/** @lends openerp.web.TreeView#
active_model: self.dataset.model,
active_id: id,
active_ids: [id]};
this.rpc('/web/treeview/action', {
return this.rpc('/web/treeview/action', {
id: id,
model: this.dataset.model,
context: new openerp.web.CompoundContext(
this.dataset.get_context(), local_context)
}, function (actions) {
}).pipe(function (actions) {
if (!actions.length) { return; }
var action = actions[0][2];
var c = new openerp.web.CompoundContext(local_context);
if (action.context) {
c.add(action.context);
}
action.context = c;
self.do_action(action);
});
return self.rpc('/web/session/eval_domain_and_context', {
contexts: [c], domains: []
}).pipe(function (res) {
action.context = res.context;
return self.do_action(action);
}, null);
}, null);
},
// show & hide the contents

View File

@ -143,7 +143,7 @@
<option t-att-value="db"><t t-esc="db"/></option>
</t>
</select>
<input t-if="!db_list" name="drop_db" class="required"
<input t-if="!db_list" name="backup_db" class="required"
type="text" autofocus="autofocus"/>
</td>
</tr>

View File

@ -467,10 +467,10 @@ replace ``addons`` by the directory in which your own addon lives.
Python
++++++
.. autoclass:: web.common.backendrpc.OpenERPSession
.. autoclass:: web.common.session.OpenERPSession
:members:
.. autoclass:: web.common.backendrpc.OpenERPModel
.. autoclass:: web.common.openerplib.main.Model
:members:
* Addons lifecycle (loading, execution, events, ...)

View File

@ -391,12 +391,12 @@ Python
These classes should be moved to other sections of the doc as needed,
probably.
.. automodule:: web.common.dispatch
.. automodule:: web.common.http
:members:
:undoc-members:
See also: :class:`~web.common.backendrpc.OpenERPSession`,
:class:`~web.common.backendrpc.OpenERPModel`
See also: :class:`~web.common.session.OpenERPSession`,
:class:`~web.common.openerplib.main.OpenERPModel`
.. automodule:: web.controllers.main
:members: