diff --git a/addons/web/common/openerplib/main.py b/addons/web/common/openerplib/main.py index 2cbf9692063..93c2d1da69d 100644 --- a/addons/web/common/openerplib/main.py +++ b/addons/web/common/openerplib/main.py @@ -50,15 +50,6 @@ class Connector(object): __logger = _getChildLogger(_logger, 'connector') - def __init__(self, hostname, port): - """ - Initilize by specifying an hostname and a port. - :param hostname: Host name of the server. - :param port: Port for the connection to the server. - """ - self.hostname = hostname - self.port = port - def get_service(self, service_name): """ Returns a Service instance to allow easy manipulation of one of the services offered by the remote server. @@ -81,8 +72,7 @@ class XmlRPCConnector(Connector): :param hostname: The hostname of the computer holding the instance of OpenERP. :param port: The port used by the OpenERP instance for XMLRPC (default to 8069). """ - Connector.__init__(self, hostname, port) - self.url = 'http://%s:%d/xmlrpc' % (self.hostname, self.port) + self.url = 'http://%s:%d/xmlrpc' % (hostname, port) def send(self, service_name, method, *args): url = '%s/%s' % (self.url, service_name) @@ -97,9 +87,9 @@ class XmlRPCSConnector(XmlRPCConnector): __logger = _getChildLogger(_logger, 'connector.xmlrpcs') - def __init__(self, hostname, port=8071): + def __init__(self, hostname, port=8069): super(XmlRPCSConnector, self).__init__(hostname, port) - self.url = 'https://%s:%d/xmlrpc' % (self.hostname, self.port) + self.url = 'https://%s:%d/xmlrpc' % (hostname, port) class Service(object): """ @@ -294,7 +284,7 @@ def get_connector(hostname=None, protocol="xmlrpc", port="auto"): :param port: The number of the port. Defaults to auto. """ if port == 'auto': - port = 8069 if protocol=="xmlrpc" else 8071 + port = 8069 if protocol == "xmlrpc": return XmlRPCConnector(hostname, port) elif protocol == "xmlrpcs": diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 852d5138177..b6405873f80 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -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): diff --git a/addons/web/po/ru.po b/addons/web/po/ru.po index beecb0203c1..0347a9e6c25 100644 --- a/addons/web/po/ru.po +++ b/addons/web/po/ru.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: openerp-web\n" "Report-Msgid-Bugs-To: FULL NAME \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 \n" +"PO-Revision-Date: 2012-01-10 10:48+0000\n" +"Last-Translator: Aleksei Motsik \n" "Language-Team: Russian \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 diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index df6d78e8aa5..6da9f1bbe8d 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -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; } diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 34b413526f0..520345e1e23 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -44,9 +44,9 @@ openerp.web.Dialog = openerp.web.OldWidget.extend(/** @lends openerp.web.Dialog# * @extends openerp.web.OldWidget * * @param parent - * @param dialog_options + * @param options */ - init: function (parent, dialog_options) { + init: function (parent, options) { var self = this; this._super(parent); this.dialog_options = { @@ -57,10 +57,9 @@ openerp.web.Dialog = openerp.web.OldWidget.extend(/** @lends openerp.web.Dialog# max_width: '95%', height: 'auto', min_height: 0, - max_height: '95%', + max_height: this.get_height('100%') - 140, autoOpen: false, position: [false, 50], - autoResize : 'auto', buttons: {}, beforeClose: function () { self.on_close(); }, resizeStop: this.on_resized @@ -70,31 +69,24 @@ openerp.web.Dialog = openerp.web.OldWidget.extend(/** @lends openerp.web.Dialog# this.dialog_options.buttons[f.substr(10)] = this[f]; } } - if (dialog_options) { - this.set_options(dialog_options); + if (options) { + _.extend(this.dialog_options, options); } }, - set_options: function(options) { - options = options || {}; - options.width = this.get_width(options.width || this.dialog_options.width); - options.min_width = this.get_width(options.min_width || this.dialog_options.min_width); - options.max_width = this.get_width(options.max_width || this.dialog_options.max_width); - options.height = this.get_height(options.height || this.dialog_options.height); - options.min_height = this.get_height(options.min_height || this.dialog_options.min_height); - options.max_height = this.get_height(options.max_height || this.dialog_options.max_height); - - if (options.width !== 'auto') { - if (options.width > options.max_width) options.width = options.max_width; - if (options.width < options.min_width) options.width = options.min_width; + get_options: function(options) { + var self = this, + o = _.extend({}, this.dialog_options, options || {}); + _.each(['width', 'height'], function(unit) { + o[unit] = self['get_' + unit](o[unit]); + o['min_' + unit] = self['get_' + unit](o['min_' + unit] || 0); + o['max_' + unit] = self['get_' + unit](o['max_' + unit] || 0); + if (o[unit] !== 'auto' && o['min_' + unit] && o[unit] < o['min_' + unit]) o[unit] = o['min_' + unit]; + if (o[unit] !== 'auto' && o['max_' + unit] && o[unit] > o['max_' + unit]) o[unit] = o['max_' + unit]; + }); + if (!o.title && this.dialog_title) { + o.title = this.dialog_title; } - if (options.height !== 'auto') { - if (options.height > options.max_height) options.height = options.max_height; - if (options.height < options.min_height) options.height = options.min_height; - } - if (!options.title && this.dialog_title) { - options.title = this.dialog_title; - } - _.extend(this.dialog_options, options); + return o; }, get_width: function(val) { return this.get_size(val.toString(), $(window.top).width()); @@ -116,13 +108,16 @@ openerp.web.Dialog = openerp.web.OldWidget.extend(/** @lends openerp.web.Dialog# this._super(); return this; }, - open: function(dialog_options) { + open: function(options) { // TODO fme: bind window on resize if (this.template) { this.$element.html(this.render()); } - this.set_options(dialog_options); - this.$element.dialog(this.dialog_options).dialog('open'); + var o = this.get_options(options); + this.$element.dialog(o).dialog('open'); + if (o.height === 'auto' && o.max_height) { + this.$element.css({ 'max-height': o.max_height, 'overflow-y': 'auto' }); + } return this; }, close: function() { @@ -134,9 +129,7 @@ openerp.web.Dialog = openerp.web.OldWidget.extend(/** @lends openerp.web.Dialog# } }, on_resized: function() { - if (openerp.connection.debug) { - console.log("Dialog resized to %d x %d", this.$element.width(), this.$element.height()); - } + openerp.log("Dialog resized to %d x %d", this.$element.width(), this.$element.height()); }, stop: function () { // Destroy widget @@ -481,7 +474,10 @@ openerp.web.Database = openerp.web.Widget.extend(/** @lends openerp.web.Database error: error[1] }); }, - complete: $.proxy(self, 'unblockUI') + complete: function() { + self.unblockUI(); + self.do_notify(_t("Backed"), _t("Database backed up successfully")); + } }); } }); @@ -517,7 +513,10 @@ openerp.web.Database = openerp.web.Widget.extend(/** @lends openerp.web.Database }) } }, - complete: $.proxy(self, 'unblockUI') + complete: function() { + self.unblockUI(); + self.do_notify(_t("Restored"), _t("Database restored successfully")); + } }); } }); diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index c24325a9327..3b444dffc78 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -322,16 +322,17 @@ openerp.web.DataSet = openerp.web.Widget.extend( /** @lends openerp.web.DataSet * Reads the current dataset record (from its index) * * @params {Array} [fields] fields to read and return, by default all fields are returned + * @param {Object} [options.context] context data to add to the request payload, on top of the DataSet's own context * @params {Function} callback function called with read_index result * @returns {$.Deferred} */ - read_index: function (fields, callback) { + read_index: function (fields, options, callback) { var def = $.Deferred().then(callback); if (_.isEmpty(this.ids)) { def.reject(); } else { fields = fields || false; - this.read_ids([this.ids[this.index]], fields).then(function(records) { + this.read_ids([this.ids[this.index]], fields, options).then(function(records) { def.resolve(records[0]); }, function() { def.reject.apply(def, arguments); diff --git a/addons/web/static/src/js/data_export.js b/addons/web/static/src/js/data_export.js index 78dc3bef1f9..c6fe96432ea 100644 --- a/addons/web/static/src/js/data_export.js +++ b/addons/web/static/src/js/data_export.js @@ -114,7 +114,7 @@ openerp.web.DataExport = openerp.web.Dialog.extend({ if (value) { self.do_save_export_list(value); } else { - alert("Pleae Enter Save Field List Name"); + alert(_t("Please enter save field list name")); } }); } else { @@ -349,24 +349,24 @@ openerp.web.DataExport = openerp.web.Dialog.extend({ export_field.push($(this).val()); }); if (!export_field.length) { - alert('Please select fields to save export list...'); + alert(_t("Please select fields to save export list...")); } return export_field; }, on_click_export_data: function() { - $.blockUI(this.$element); var exported_fields = [], self = this; this.$element.find("#fields_list option").each(function() { var fieldname = self.records[$(this).val()]; exported_fields.push({name: fieldname, label: $(this).text()}); }); if (_.isEmpty(exported_fields)) { - alert('Please select fields to export...'); + alert(_t("Please select fields to export...")); return; } exported_fields.unshift({name: 'id', label: 'External ID'}); var export_format = this.$element.find("#export_format").val(); + $.blockUI(); this.session.get_file({ url: '/web/export/' + export_format, data: {data: JSON.stringify({ diff --git a/addons/web/static/src/js/formats.js b/addons/web/static/src/js/formats.js index 37d1e4cf7b5..7f220d0aa54 100644 --- a/addons/web/static/src/js/formats.js +++ b/addons/web/static/src/js/formats.js @@ -102,10 +102,6 @@ openerp.web.format_value = function (value, descriptor, value_if_empty) { return _.str.sprintf("%02d:%02d", Math.floor(value), Math.round((value % 1) * 60)); - case 'progressbar': - return _.str.sprintf( - '%.2f%%', - value, value); case 'many2one': // name_get value format return value[1]; @@ -237,7 +233,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 ``