[MERGE] Merge last trunk

bzr revid: fme@openerp.com-20120111085337-u65f0pyr1n60mkaw
This commit is contained in:
Fabien Meghazi 2012-01-11 09:53:37 +01:00
commit fe4526b2d8
9 changed files with 194 additions and 57 deletions

View File

@ -1184,23 +1184,40 @@ class Binary(openerpweb.Controller):
return open(os.path.join(addons_path, 'web', 'static', 'src', 'img', 'placeholder.png'), 'rb').read()
@openerpweb.httprequest
def saveas(self, req, model, id, field, fieldname, **kw):
def saveas(self, req, model, field, id=None, filename_field=None, **kw):
""" Download link for files stored as binary fields.
If the ``id`` parameter is omitted, fetches the default value for the
binary field (via ``default_get``), otherwise fetches the field for
that precise record.
:param req: OpenERP request
:type req: :class:`web.common.http.HttpRequest`
:param str model: name of the model to fetch the binary from
:param str field: binary field
:param str id: id of the record from which to fetch the binary
:param str filename_field: field holding the file's name, if any
:returns: :class:`werkzeug.wrappers.Response`
"""
Model = req.session.model(model)
context = req.session.eval_context(req.context)
fields = [field]
if filename_field:
fields.append(filename_field)
if id:
res = Model.read([int(id)], [field, fieldname], context)[0]
res = Model.read([int(id)], fields, context)[0]
else:
res = Model.default_get([field, fieldname], context)
res = Model.default_get(fields, context)
filecontent = base64.b64decode(res.get(field, ''))
if not filecontent:
return req.not_found()
else:
filename = '%s_%s' % (model.replace('.', '_'), id)
if fieldname:
filename = res.get(fieldname, '') or filename
if filename_field:
filename = res.get(filename_field, '') or filename
return req.make_response(filecontent,
[('Content-Type', 'application/octet-stream'),
('Content-Disposition', 'attachment; filename=' + filename)])
('Content-Disposition', 'attachment; filename="%s"' % filename)])
@openerpweb.httprequest
def upload(self, req, callback, ufile):

View File

@ -8,14 +8,14 @@ msgstr ""
"Project-Id-Version: openerp-web\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2011-12-20 18:48+0100\n"
"PO-Revision-Date: 2011-12-06 08:05+0000\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"PO-Revision-Date: 2012-01-10 10:48+0000\n"
"Last-Translator: Aleksei Motsik <Unknown>\n"
"Language-Team: Russian <ru@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2012-01-04 05:17+0000\n"
"X-Generator: Launchpad (build 14616)\n"
"X-Launchpad-Export-Date: 2012-01-11 04:55+0000\n"
"X-Generator: Launchpad (build 14640)\n"
#: addons/web/static/src/js/chrome.js:162
#: addons/web/static/src/js/chrome.js:175
@ -28,15 +28,15 @@ msgstr ""
#: addons/web/static/src/js/chrome.js:668
msgid "About"
msgstr ""
msgstr "О программе"
#: addons/web/static/src/js/chrome.js:748
msgid "Preferences"
msgstr ""
msgstr "Настройки"
#: addons/web/static/src/js/chrome.js:752
msgid "Change password"
msgstr ""
msgstr "Изменить пароль"
#: addons/web/static/src/js/chrome.js:753
#: addons/web/static/src/js/search.js:235
@ -47,21 +47,21 @@ msgstr ""
#: addons/web/static/src/js/view_form.js:1085
#: addons/web/static/src/xml/base.xml:0
msgid "Cancel"
msgstr ""
msgstr "Отмена"
#: addons/web/static/src/js/chrome.js:754
#: addons/web/static/src/js/view_editor.js:75
#: addons/web/static/src/js/views.js:871 addons/web/static/src/xml/base.xml:0
msgid "Save"
msgstr ""
msgstr "Сохранить"
#: addons/web/static/src/js/chrome.js:774 addons/web/static/src/xml/base.xml:0
msgid "Change Password"
msgstr ""
msgstr "Изменить пароль"
#: addons/web/static/src/js/data_export.js:6
msgid "Export Data"
msgstr ""
msgstr "Экспорт данных"
#: addons/web/static/src/js/data_export.js:23
#: addons/web/static/src/js/data_import.js:73
@ -70,7 +70,7 @@ msgstr ""
#: addons/web/static/src/js/view_form.js:2775
#: addons/web/static/src/js/views.js:872
msgid "Close"
msgstr ""
msgstr "Закрыть"
#: addons/web/static/src/js/data_export.js:24
msgid "Export To File"
@ -78,32 +78,32 @@ msgstr ""
#: addons/web/static/src/js/data_import.js:34
msgid "Import Data"
msgstr ""
msgstr "Импорт данных"
#: addons/web/static/src/js/data_import.js:74
msgid "Import File"
msgstr ""
msgstr "Импортировать файл"
#: addons/web/static/src/js/data_import.js:109
msgid "External ID"
msgstr ""
msgstr "Внешний идентификатор"
#: addons/web/static/src/js/search.js:233
msgid "Filter Entry"
msgstr ""
msgstr "Входящий фильтр"
#: addons/web/static/src/js/search.js:238
#: addons/web/static/src/js/search.js:279
msgid "OK"
msgstr ""
msgstr "OK"
#: addons/web/static/src/js/search.js:274 addons/web/static/src/xml/base.xml:0
msgid "Add to Dashboard"
msgstr ""
msgstr "Добавить на Панель"
#: addons/web/static/src/js/search.js:403
msgid "Invalid Search"
msgstr ""
msgstr "Ошибка поиска"
#: addons/web/static/src/js/search.js:403
msgid "triggered from search view"
@ -113,30 +113,31 @@ msgstr ""
#, python-format
msgid "Incorrect value for field %(fieldname)s: [%(value)s] is %(message)s"
msgstr ""
"Некорректное значение для поля %(fieldname)s: [%(value)s] в %(message)s"
#: addons/web/static/src/js/search.js:822
msgid "not a valid integer"
msgstr ""
msgstr "не является целым числом"
#: addons/web/static/src/js/search.js:836
msgid "not a valid number"
msgstr ""
msgstr "не является числом"
#: addons/web/static/src/js/search.js:898
msgid "Yes"
msgstr ""
msgstr "Да"
#: addons/web/static/src/js/search.js:899
msgid "No"
msgstr ""
msgstr "Нет"
#: addons/web/static/src/js/search.js:1252
msgid "contains"
msgstr ""
msgstr "содержит"
#: addons/web/static/src/js/search.js:1253
msgid "doesn't contain"
msgstr ""
msgstr "не содержит"
#: addons/web/static/src/js/search.js:1254
#: addons/web/static/src/js/search.js:1269
@ -144,7 +145,7 @@ msgstr ""
#: addons/web/static/src/js/search.js:1309
#: addons/web/static/src/js/search.js:1331
msgid "is equal to"
msgstr ""
msgstr "соответствует"
#: addons/web/static/src/js/search.js:1255
#: addons/web/static/src/js/search.js:1270
@ -152,7 +153,7 @@ msgstr ""
#: addons/web/static/src/js/search.js:1310
#: addons/web/static/src/js/search.js:1332
msgid "is not equal to"
msgstr ""
msgstr "не соответствует"
#: addons/web/static/src/js/search.js:1256
#: addons/web/static/src/js/search.js:1271
@ -160,7 +161,7 @@ msgstr ""
#: addons/web/static/src/js/search.js:1311
#: addons/web/static/src/js/search.js:1333
msgid "greater than"
msgstr ""
msgstr "больше чем"
#: addons/web/static/src/js/search.js:1257
#: addons/web/static/src/js/search.js:1272
@ -168,7 +169,7 @@ msgstr ""
#: addons/web/static/src/js/search.js:1312
#: addons/web/static/src/js/search.js:1334
msgid "less than"
msgstr ""
msgstr "меньше чем"
#: addons/web/static/src/js/search.js:1258
#: addons/web/static/src/js/search.js:1273
@ -176,7 +177,7 @@ msgstr ""
#: addons/web/static/src/js/search.js:1313
#: addons/web/static/src/js/search.js:1335
msgid "greater or equal than"
msgstr ""
msgstr "больше или равен"
#: addons/web/static/src/js/search.js:1259
#: addons/web/static/src/js/search.js:1274

View File

@ -2033,6 +2033,7 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after {
.openerp .oe_vm_switch_form,
.openerp .oe_vm_switch_page,
.openerp .oe_vm_switch_tree,
.openerp .oe_vm_switch_list,
.openerp .oe_vm_switch_graph,
.openerp .oe_vm_switch_gantt,
@ -2049,6 +2050,7 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after {
.openerp .oe_vm_switch_form span,
.openerp .oe_vm_switch_page span,
.openerp .oe_vm_switch_tree span,
.openerp .oe_vm_switch_list span,
.openerp .oe_vm_switch_graph span,
.openerp .oe_vm_switch_gantt span,
@ -2068,6 +2070,16 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after {
background-position: 0px -21px;
}
.openerp .oe_vm_switch_tree {
background-position: 0px 0px;
}
.openerp .oe_vm_switch_tree:active,
.openerp .oe_vm_switch_tree:hover,
.openerp .oe_vm_switch_tree:focus,
.openerp .oe_vm_switch_tree[disabled="disabled"] {
background-position: 0px -21px;
}
.openerp .oe_vm_switch_form {
background-position: -22px 0px;
}
@ -2078,6 +2090,15 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after {
background-position: -22px -21px;
}
.openerp .oe_vm_switch_page {
background-position: -22px 0px;
}
.openerp .oe_vm_switch_page:active,
.openerp .oe_vm_switch_page:hover,
.openerp .oe_vm_switch_page:focus,
.openerp .oe_vm_switch_page[disabled="disabled"] {
background-position: -22px -21px;
}
.openerp .oe_vm_switch_graph {
background-position: -44px 0px;
}

View File

@ -237,7 +237,15 @@ openerp.web.auto_date_to_str = function(value, type) {
};
/**
* Formats a provided cell based on its field type
* Formats a provided cell based on its field type. Most of the field types
* return a correctly formatted value, but some tags and fields are
* special-cased in their handling:
*
* * buttons will return an actual ``<button>`` tag with a bunch of error handling
*
* * boolean fields will return a checkbox input, potentially disabled
*
* * binary fields will return a link to download the binary data as a file
*
* @param {Object} row_data record whose values should be displayed in the cell
* @param {Object} column column descriptor
@ -245,21 +253,21 @@ openerp.web.auto_date_to_str = function(value, type) {
* @param {String} column.type widget type for a field control
* @param {String} [column.string] button label
* @param {String} [column.icon] button icon
* @param {String} [value_if_empty=''] what to display if the field's value is ``false``
* @param {Boolean} [process_modifiers=true] should the modifiers be computed ?
* @param {Object} [options]
* @param {String} [options.value_if_empty=''] what to display if the field's value is ``false``
* @param {Boolean} [options.process_modifiers=true] should the modifiers be computed ?
* @param {String} [options.model] current record's model
* @param {Number} [options.id] current record's id
*
*/
openerp.web.format_cell = function (row_data, column, value_if_empty, process_modifiers) {
openerp.web.format_cell = function (row_data, column, options) {
options = options || {};
var attrs = {};
if (process_modifiers !== false) {
if (options.process_modifiers !== false) {
attrs = column.modifiers_for(row_data);
}
if (attrs.invisible) { return ''; }
if (column.type === "boolean") {
return _.str.sprintf('<input type="checkbox" %s disabled="disabled"/>',
row_data[column.id].value ? 'checked="checked"' : '');
}
if (column.tag === 'button') {
return _.template('<button type="button" title="<%-title%>" <%=additional_attributes%> >' +
'<img src="<%-prefix%>/web/static/src/img/icons/<%-icon%>.png" alt="<%-alt%>"/>' +
@ -269,14 +277,36 @@ openerp.web.format_cell = function (row_data, column, value_if_empty, process_mo
'disabled="disabled" class="oe-listview-button-disabled"' : '',
prefix: openerp.connection.prefix,
icon: column.icon,
alt: column.string || '',
alt: column.string || ''
});
}
if (!row_data[column.id]) {
return value_if_empty === undefined ? '' : value_if_empty;
return options.value_if_empty === undefined ? '' : options.value_if_empty;
}
switch (column.type) {
case "boolean":
return _.str.sprintf('<input type="checkbox" %s disabled="disabled"/>',
row_data[column.id].value ? 'checked="checked"' : '');
case "binary":
var text = _t("Download"),
download_url = _.str.sprintf('/web/binary/saveas?session_id=%s&model=%s&field=%s&id=%d', openerp.connection.session_id, options.model, column.id, options.id);
if (column.filename) {
download_url += '&filename_field=' + column.filename;
if (row_data[column.filename]) {
text = _.str.sprintf(_t("Download \"%s\""), openerp.web.format_value(
row_data[column.filename].value, {type: 'char'}));
}
}
return _.str.sprintf('<a href="%(href)s">%(text)s</a> (%(size)s)', {
text: text,
href: download_url,
size: row_data[column.id].value
});
}
return openerp.web.format_value(
row_data[column.id].value, column, value_if_empty);
row_data[column.id].value, column, options.value_if_empty);
}
};

View File

@ -2739,7 +2739,7 @@ openerp.web.form.SelectCreatePopup = openerp.web.OldWidget.extend(/** @lends ope
var $nbutton = $buttons.find(".oe_selectcreatepopup-form-save-new");
$nbutton.click(function() {
$.when(self.view_form.do_save()).then(function() {
self.view_form.reload_lock.then(function() {
self.view_form.reload_mutex.exec(function() {
self.view_form.on_button_new();
});
});
@ -2747,7 +2747,7 @@ openerp.web.form.SelectCreatePopup = openerp.web.OldWidget.extend(/** @lends ope
var $nbutton = $buttons.find(".oe_selectcreatepopup-form-save");
$nbutton.click(function() {
$.when(self.view_form.do_save()).then(function() {
self.view_form.reload_lock.then(function() {
self.view_form.reload_mutex.exec(function() {
self.check_exit();
});
});
@ -3009,7 +3009,7 @@ openerp.web.form.FieldBinary = openerp.web.form.Field.extend({
on_save_as: function() {
var url = '/web/binary/saveas?session_id=' + this.session.session_id + '&model=' +
this.view.dataset.model +'&id=' + (this.view.datarecord.id || '') + '&field=' + this.name +
'&fieldname=' + (this.node.attrs.filename || '') + '&t=' + (new Date().getTime());
'&filename_field=' + (this.node.attrs.filename || '') + '&t=' + (new Date().getTime());
window.open(url);
},
on_clear: function() {

View File

@ -685,6 +685,7 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
this.display_aggregates(aggregates);
},
display_aggregates: function (aggregation) {
var self = this;
var $footer_cells = this.$element.find('.oe-list-footer');
_(this.aggregate_columns).each(function (column) {
if (!column['function']) {
@ -692,7 +693,9 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
}
$footer_cells.filter(_.str.sprintf('[data-field=%s]', column.id))
.html(openerp.web.format_cell(aggregation, column, undefined, false));
.html(openerp.web.format_cell(aggregation, column, {
process_modifiers: false
}));
});
},
get_selected_ids: function() {
@ -846,6 +849,9 @@ openerp.web.ListView.List = openerp.web.Class.extend( /** @lends openerp.web.Lis
return self.reload_record(self.records.get(record_id));
}]);
})
.delegate('a', 'click', function (e) {
e.stopPropagation();
})
.delegate('tr', 'click', function (e) {
e.stopPropagation();
var row_id = self.row_id(e.currentTarget);
@ -905,7 +911,10 @@ openerp.web.ListView.List = openerp.web.Class.extend( /** @lends openerp.web.Lis
});
}
}
return openerp.web.format_cell(record.toForm().data, column);
return openerp.web.format_cell(record.toForm().data, column, {
model: this.dataset.model,
id: record.get('id')
});
},
render: function () {
if (this.$current) {
@ -1210,7 +1219,10 @@ openerp.web.ListView.Groups = openerp.web.Class.extend( /** @lends openerp.web.L
return column.id === group.grouped_on; });
try {
$group_column.html(openerp.web.format_cell(
row_data, group_column, _t("Undefined"), false));
row_data, group_column, {
value_if_empty: _t("Undefined"),
process_modifiers: false
}));
} catch (e) {
$group_column.html(row_data[group_column.id].value);
}
@ -1288,7 +1300,7 @@ openerp.web.ListView.Groups = openerp.web.Class.extend( /** @lends openerp.web.L
page = this.datagroup.openable ? this.page : view.page;
var fields = _.pluck(_.select(this.columns, function(x) {return x.tag == "field"}), 'name');
var options = { offset: page * limit, limit: limit };
var options = { offset: page * limit, limit: limit, context: {bin_size: true} };
//TODO xmo: investigate why we need to put the setTimeout
$.async_when().then(function() {dataset.read_slice(fields, options).then(function (records) {
// FIXME: ignominious hacks, parents (aka form view) should not send two ListView#reload_content concurrently

View File

@ -748,7 +748,7 @@
<li t-foreach="attachments" t-as="attachment">
<t t-if="attachment.type == 'binary'" t-set="attachment.url" t-value="_s + '/web/binary/saveas?session_id='
+ session.session_id + '&amp;model=ir.attachment&amp;id=' + attachment.id
+ '&amp;field=datas&amp;fieldname=name&amp;t=' + (new Date().getTime())"/>
+ '&amp;field=datas&amp;filename_field=name&amp;t=' + (new Date().getTime())"/>
<a class="oe-sidebar-attachments-link" t-att-href="attachment.url" target="_blank">
<t t-esc="attachment.name"/>
</a>

View File

@ -0,0 +1,34 @@
# Brazilian Portuguese translation for openerp-web
# Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012
# This file is distributed under the same license as the openerp-web package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2012.
#
msgid ""
msgstr ""
"Project-Id-Version: openerp-web\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2011-12-20 18:48+0100\n"
"PO-Revision-Date: 2012-01-10 11:02+0000\n"
"Last-Translator: Rafael Sales <Unknown>\n"
"Language-Team: Brazilian Portuguese <pt_BR@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2012-01-11 04:55+0000\n"
"X-Generator: Launchpad (build 14640)\n"
#: addons/web_calendar/static/src/js/calendar.js:11
msgid "Calendar"
msgstr ""
#: addons/web_calendar/static/src/js/calendar.js:446
msgid "Responsible"
msgstr "Responsável"
#: addons/web_calendar/static/src/js/calendar.js:475
msgid "Navigator"
msgstr ""
#: addons/web_calendar/static/src/xml/web_calendar.xml:0
msgid "&nbsp;"
msgstr ""

View File

@ -0,0 +1,22 @@
# Brazilian Portuguese translation for openerp-web
# Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012
# This file is distributed under the same license as the openerp-web package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2012.
#
msgid ""
msgstr ""
"Project-Id-Version: openerp-web\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2011-12-20 18:48+0100\n"
"PO-Revision-Date: 2012-01-10 11:03+0000\n"
"Last-Translator: Rafael Sales <Unknown>\n"
"Language-Team: Brazilian Portuguese <pt_BR@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2012-01-11 04:55+0000\n"
"X-Generator: Launchpad (build 14640)\n"
#: addons/web_graph/static/src/js/graph.js:19
msgid "Graph"
msgstr "Gráfico"