[MERGE] Merge with trup upto revision no 817.

bzr revid: ysa@tinyerp.com-20110817084248-p5uucsp7ueqyleq0
bzr revid: ysa@tinyerp.com-20110818050739-82t6xwob3b44ndum
This commit is contained in:
Yogesh (OpenERP) 2011-08-18 10:37:39 +05:30
commit 16b84913e0
25 changed files with 1312 additions and 216 deletions

View File

@ -18,6 +18,7 @@ import openerpweb
import openerpweb.ast
import openerpweb.nonliterals
from babel.messages.pofile import read_po
# Should move to openerpweb.Xml2Json
class Xml2Json:
@ -156,6 +157,43 @@ class WebClient(openerpweb.Controller):
'css': css
}
return r
@openerpweb.jsonrequest
def translations(self, req, mods, lang):
lang_model = req.session.model('res.lang')
ids = lang_model.search([("code", "=", lang)])
if ids:
lang_obj = lang_model.read(ids[0], ["direction", "date_format", "time_format",
"grouping", "decimal_point", "thousands_sep"])
else:
lang_obj = None
if lang.count("_") > 0:
separator = "_"
else:
separator = "@"
langs = lang.split(separator)
langs = [separator.join(langs[:x]) for x in range(1, len(langs) + 1)]
transs = {}
for addon_name in mods:
transl = {"messages":[]}
transs[addon_name] = transl
for l in langs:
f_name = os.path.join(openerpweb.path_addons, addon_name, "po", l + ".po")
if not os.path.exists(f_name):
continue
try:
with open(f_name) as t_file:
po = read_po(t_file)
except:
continue
for x in po:
if x.id and x.string:
transl["messages"].append({'id': x.id, 'string': x.string})
return {"modules": transs,
"lang_parameters": lang_obj}
class Database(openerpweb.Controller):
_cp_path = "/base/database"
@ -251,16 +289,18 @@ class Session(openerpweb.Controller):
@openerpweb.jsonrequest
def login(self, req, db, login, password):
req.session.login(db, login, password)
ctx = req.session.get_context()
return {
"session_id": req.session_id,
"uid": req.session._uid,
"context": ctx
}
@openerpweb.jsonrequest
def sc_list(self, req):
return req.session.model('ir.ui.view_sc').get_sc(req.session._uid, "ir.ui.menu",
req.session.eval_context(req.context))
return req.session.model('ir.ui.view_sc').get_sc(
req.session._uid, "ir.ui.menu", req.session.eval_context(req.context))
@openerpweb.jsonrequest
def get_lang_list(self, req):
@ -907,7 +947,7 @@ class Binary(openerpweb.Controller):
_cp_path = "/base/binary"
@openerpweb.httprequest
def image(self, request, session_id, model, id, field, **kw):
def image(self, request, model, id, field, **kw):
cherrypy.response.headers['Content-Type'] = 'image/png'
Model = request.session.model(model)
context = request.session.eval_context(request.context)
@ -923,7 +963,7 @@ class Binary(openerpweb.Controller):
return open(os.path.join(openerpweb.path_addons, 'base', 'static', 'src', 'img', 'placeholder.png'), 'rb').read()
@openerpweb.httprequest
def saveas(self, request, session_id, model, id, field, fieldname, **kw):
def saveas(self, request, model, id, field, fieldname, **kw):
Model = request.session.model(model)
context = request.session.eval_context(request.context)
res = Model.read([int(id)], [field, fieldname], context)[0]
@ -939,7 +979,7 @@ class Binary(openerpweb.Controller):
return base64.decodestring(filecontent)
@openerpweb.httprequest
def upload(self, request, session_id, callback, ufile=None):
def upload(self, request, callback, ufile=None):
cherrypy.response.timeout = 500
headers = {}
for key, val in cherrypy.request.headers.iteritems():
@ -966,7 +1006,7 @@ class Binary(openerpweb.Controller):
return out % (simplejson.dumps(callback), simplejson.dumps(args))
@openerpweb.httprequest
def upload_attachment(self, request, session_id, callback, model, id, ufile=None):
def upload_attachment(self, request, callback, model, id, ufile=None):
cherrypy.response.timeout = 500
context = request.session.eval_context(request.context)
Model = request.session.model('ir.attachment')

482
addons/base/po/base.pot Normal file
View File

@ -0,0 +1,482 @@
# Translations template for PROJECT.
# Copyright (C) 2011 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2011-08-17 13:28+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"
#: addons/base/static/src/js/form.js:1459
msgid "<em>   Search More...</em>"
msgstr ""
#: addons/base/static/src/js/form.js:1472
#, python-format
msgid "<em>   Create \"<strong>%s</strong>\"</em>"
msgstr ""
#: addons/base/static/src/js/form.js:1478
msgid "<em>   Create and Edit...</em>"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "x"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "#{title}"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "#{text}"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Powered by"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "openerp.com"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "."
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Loading..."
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Create"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Drop"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Backup"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Restore"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Password"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Back to Login"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "CREATE DATABASE"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Master password:"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "New database name:"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Load Demonstration data:"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Default language:"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Admin password:"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Confirm password:"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "DROP DATABASE"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Database:"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Master Password:"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "BACKUP DATABASE"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "RESTORE DATABASE"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "File:"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "CHANGE MASTER PASSWORD"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "New master password:"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Confirm new master password:"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "User:"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Password:"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Database"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Login"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Bad username or password"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid ""
"We think that daily job activities can be more intuitive, efficient, "
"automated, .. and even fun."
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "OpenERP's vision to be:"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Full featured"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid ""
"Today's enterprise challenges are multiple. We provide one module for "
"each need."
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Open Source"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid ""
"To Build a great product, we rely on the knowledge of thousands of "
"contributors."
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "User Friendly"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "In order to be productive, people need clean and easy to use interface."
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "-"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "rpc_session_id:"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "1"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "LOGOUT"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "h3"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "<"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid ">"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "</"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "h4"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Delete"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "First"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Last"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "♻"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "xml"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Save & Edit"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Create & Edit"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "New"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "<<"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "0"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "/"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid ">>"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Add"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Unhandled widget"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "?"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid ":"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Open..."
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Create..."
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Search..."
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "One2Many widget"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Uploading ..."
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Select"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Save As"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Clear"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Advanced Filter"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "-- Filters --"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "-- Actions --"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Save Filter"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Manage Filters"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Filter Name:"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "(Any existing filter with the same name will be replaced)"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "(?)"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Any of the following conditions must match"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "All the following conditions must match"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "None of the following conditions must match"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Add condition"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "and"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Cancel"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Save"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Save & New"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Save & Close"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Export"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid ""
"This wizard will export all data that matches the current search criteria"
" to a CSV file.\n"
" You can export all data or only the fields that can be "
"reimported after modification."
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Export Type:"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Import Compatible Export"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Export all Data"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Export Format"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "CSV"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Excel"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Available fields"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Fields to export"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Save fields list"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Remove"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Remove All"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Name"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "&nbsp;"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Save as:"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Ok"
msgstr ""
#: addons/base/static/src/xml/base.xml:0
msgid "Saved exports:"
msgstr ""

33
addons/base/po/fr_FR.po Normal file
View File

@ -0,0 +1,33 @@
# Translations template for PROJECT.
# Copyright (C) 2011 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# niv <nicolas.vanhoren@openerp.com>, 2011.
#
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2011-08-09 17:30+0200\n"
"PO-Revision-Date: 2011-08-09 17:31+0200\n"
"Last-Translator: niv <nicolas.vanhoren@openerp.com>\n"
"Language-Team: French\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.4\n"
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: addons/base/static/src/js/form.js:1459
msgid "<em>   Search More...</em>"
msgstr "<em>   Chercher plus...</em>"
#: addons/base/static/src/js/form.js:1472
#, python-format
msgid "<em>   Create \"<strong>%s</strong>\"</em>"
msgstr "<em>   Créer \"<strong>%s</strong>\"</em>"
#: addons/base/static/src/js/form.js:1478
msgid "<em>   Create and Edit...</em>"
msgstr "<em>   Créer et éditer...</em>"

View File

@ -264,7 +264,7 @@ label.error {
background: -ms-linear-gradient(top, #bd5e54 0%,#90322a 60%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#BD5E54', endColorstr='#90322A',GradientType=0 ); /* IE6-9 */
background: linear-gradient(top, #bd5e54 0%,#90322a 60%); /* W3C */
border: 1px solid #6E2A24;
border-radius: 4px;
-moz-border-radius: 4px;
@ -1054,14 +1054,14 @@ label.error {
padding-right: 21px;
height: 21px;
background: #ffffff; /* Old browsers */
background: -moz-linear-gradient(top, #ffffff 0%, #ebe9e9 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#ebe9e9)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#FFFFFF', endColorstr='#EBE9E9',GradientType=0 ); /* IE6-9 */
background: linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* W3C */
background: #ffffff; /* Old browsers */
background: -moz-linear-gradient(top, #ffffff 0%, #ebe9e9 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#ebe9e9)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#FFFFFF', endColorstr='#EBE9E9',GradientType=0 ); /* IE6-9 */
background: linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* W3C */
border: 1px solid #D2CFCF;
border-right-width: 0;
@ -1170,6 +1170,7 @@ background: linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* W3C */
.parent_top {
vertical-align: text-top;
}
.openerp .oe-dialog-warning p {
padding-left: 1em;
font-size: 1.2em;
@ -1182,7 +1183,6 @@ background: linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* W3C */
-webkit-box-shadow: none;
box-shadow: none;
}
.openerp .oe-treeview-table {
width: 100%;
}
@ -1209,3 +1209,52 @@ background: linear-gradient(top, #ffffff 0%,#ebe9e9 100%); /* W3C */
text-align: left;
vertical-align: top;
}
/* Shortcuts*/
.oe-shortcut-toggle {
height: 20px;
padding: 0;
width: 24px;
cursor: pointer;
display: block;
background: url(/base/static/src/img/add-shortcut.png) no-repeat bottom;
float: left;
}
.oe-shortcut-remove{
background: url(/base/static/src/img/remove-shortcut.png) no-repeat bottom;
}
/* ================ */
.oe-shortcuts {
position: absolute;
margin: 0;
padding: 6px 5px;
top: 37px;
left: 197px;
right: 0;
height: 17px;
line-height: 1.2;
}
.oe-shortcuts ul {
display: block;
overflow: hidden;
list-style: none;
white-space: nowrap;
padding: 0;
margin: 0;
}
.oe-shortcuts li {
cursor: pointer;
display: -moz-inline-stack;
display: inline-block;
display: inline; /*IE7 */
color: #fff;
text-align: center;
border-left: 1px solid #909090;
padding: 4px;
font-size: 90%;
font-weight: normal;
}
.oe-shortcuts li:first-child {
border-left: none;
padding-left: 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 559 B

View File

@ -573,13 +573,66 @@ openerp.base.Header = openerp.base.Widget.extend({
this._super(parent, element_id);
},
start: function() {
this.do_update();
return this.do_update();
},
do_update: function() {
do_update: function () {
this.$element.html(QWeb.render("Header", this));
this.$element.find(".logout").click(this.on_logout);
return this.shortcut_load();
},
on_logout: function() {}
shortcut_load :function(){
var self = this,
sc = self.session.shortcuts,
shortcuts_ds = new openerp.base.DataSet(this, 'ir.ui.view_sc');
// TODO: better way to communicate between sections.
// sc.bindings, because jquery does not bind/trigger on arrays...
if (!sc.binding) {
sc.binding = {};
$(sc.binding).bind({
'add': function (e, attrs) {
var $shortcut = $('<li>', {
'data-id': attrs.res_id
}).text(attrs.name)
.appendTo(self.$element.find('.oe-shortcuts ul'));
shortcuts_ds.create(attrs, function (out) {
$shortcut.data('shortcut-id', out.result);
});
},
'remove-current': function () {
var menu_id = self.session.active_id;
var $shortcut = self.$element
.find('.oe-shortcuts li[data-id=' + menu_id + ']');
var shortcut_id = $shortcut.data('shortcut-id');
$shortcut.remove();
shortcuts_ds.unlink([shortcut_id]);
}
});
}
return this.rpc('/base/session/sc_list', {}, function(shortcuts) {
sc.splice(0, sc.length);
sc.push.apply(sc, shortcuts);
self.$element.find('.oe-shortcuts')
.html(QWeb.render('Shortcuts', {'shortcuts': shortcuts}))
.undelegate('li', 'click')
.delegate('li', 'click', function(e) {
e.stopPropagation();
var id = $(this).data('id');
self.session.active_id = id;
self.rpc('/base/menu/action', {'menu_id':id}, function(ir_menu_data) {
if (ir_menu_data.action.length){
self.on_action(ir_menu_data.action[0][2]);
}
});
});
});
},
on_action: function(action) {
},
on_logout: function() {
this.$element.find('.oe-shortcuts ul').empty();
}
});
openerp.base.Menu = openerp.base.Widget.extend({
@ -641,6 +694,7 @@ openerp.base.Menu = openerp.base.Widget.extend({
$secondary.show();
if (id) {
this.session.active_id = id;
this.rpc('/base/menu/action', {'menu_id': id},
this.on_menu_action_loaded);
}
@ -681,7 +735,7 @@ openerp.base.WebClient = openerp.base.Widget.extend({
}
this.$element.html(QWeb.render("Interface", params));
this.session = new openerp.base.Session(this,"oe_errors");
this.session = new openerp.base.Session();
this.loading = new openerp.base.Loading(this,"oe_loading");
this.crashmanager = new openerp.base.CrashManager(this);
this.crashmanager.start();
@ -699,7 +753,7 @@ openerp.base.WebClient = openerp.base.Widget.extend({
this.menu = new openerp.base.Menu(this, "oe_menu", "oe_secondary_menu");
this.menu.on_action.add(this.on_menu_action);
this.header.on_action.add(this.on_menu_action);
},
start: function() {
this.session.start();

View File

@ -305,16 +305,8 @@ openerp.base.Registry = openerp.base.Class.extend( /** @lends openerp.base.Regis
}
});
/**
* Utility class that any class is allowed to extend to easy common manipulations.
*
* It provides rpc calls, callback on all methods preceded by "on_" or "do_" and a
* logging facility.
*/
openerp.base.SessionAware = openerp.base.Class.extend({
init: function(session) {
this.session = session;
openerp.base.CallbackEnabled = openerp.base.Class.extend({
init: function() {
// Transform on_* method into openerp.base.callbacks
for (var name in this) {
if(typeof(this[name]) == "function") {
@ -325,6 +317,19 @@ openerp.base.SessionAware = openerp.base.Class.extend({
}
}
}
}
});
/**
* Utility class that any class is allowed to extend to easy common manipulations.
*
* It provides rpc calls, callback on all methods preceded by "on_" or "do_" and a
* logging facility.
*/
openerp.base.SessionAware = openerp.base.CallbackEnabled.extend({
init: function(session) {
this._super();
this.session = session;
},
/**
* Performs a JSON-RPC call
@ -558,15 +563,65 @@ openerp.base.OldWidget = openerp.base.Widget.extend({
}
});
openerp.base.Session = openerp.base.Widget.extend( /** @lends openerp.base.Session# */{
openerp.base.TranslationDataBase = openerp.base.Class.extend({
init: function() {
this.db = {};
this.parameters = {"direction": 'ltr',
"date_format": '%m/%d/%Y',
"time_format": '%H:%M:%S',
"grouping": "[]",
"decimal_point": ".",
"thousands_sep": ","};
},
set_bundle: function(translation_bundle) {
var self = this;
this.db = {};
var modules = _.keys(translation_bundle.modules).sort();
if (_.include(modules, "base")) {
modules = ["base"].concat(_.without(modules, "base"));
}
_.each(modules, function(name) {
self.add_module_translation(translation_bundle.modules[name]);
});
if (translation_bundle.lang_parameters) {
this.parameters = translation_bundle.lang_parameters;
}
},
add_module_translation: function(mod) {
var self = this;
_.each(mod.messages, function(message) {
if (self.db[message.id] === undefined) {
self.db[message.id] = message.string;
}
});
},
build_translation_function: function() {
var self = this;
var fcnt = function(str) {
var tmp = self.get(str);
return tmp === undefined ? str : tmp;
}
fcnt.database = this;
return fcnt;
},
get: function(key) {
if (this.db[key])
return this.db[key];
return undefined;
}
});
openerp.base._t = new openerp.base.TranslationDataBase().build_translation_function();
openerp.base.Session = openerp.base.CallbackEnabled.extend( /** @lends openerp.base.Session# */{
/**
* @constructs
* @param element_id to use for exception reporting
* @param server
* @param port
*/
init: function(parent, element_id, server, port) {
this._super(parent, element_id);
init: function(server, port) {
this._super();
this.server = (server == undefined) ? location.hostname : server;
this.port = (port == undefined) ? location.port : port;
this.rpc_mode = (server == location.hostname) ? "ajax" : "jsonp";
@ -574,11 +629,14 @@ openerp.base.Session = openerp.base.Widget.extend( /** @lends openerp.base.Sessi
this.db = "";
this.login = "";
this.password = "";
this.user_context= {};
this.uid = false;
this.session_id = false;
this.module_list = [];
this.module_loaded = {"base": true};
this.context = {};
this.shortcuts = [];
this.active_id = null;
},
start: function() {
this.session_restore();
@ -700,6 +758,7 @@ openerp.base.Session = openerp.base.Widget.extend( /** @lends openerp.base.Sessi
this.rpc("/base/session/login", params, function(result) {
self.session_id = result.session_id;
self.uid = result.uid;
self.user_context = result.context;
self.session_save();
self.on_session_valid();
if (success_callback)
@ -717,6 +776,7 @@ openerp.base.Session = openerp.base.Widget.extend( /** @lends openerp.base.Sessi
this.session_id = this.get_cookie('session_id');
this.db = this.get_cookie('db');
this.login = this.get_cookie('login');
this.user_context = this.get_cookie("user_context");
// we should do an rpc to confirm that this session_id is valid and if it is retrieve the information about db and login
// then call on_session_valid
this.on_session_valid();
@ -729,6 +789,7 @@ openerp.base.Session = openerp.base.Widget.extend( /** @lends openerp.base.Sessi
this.set_cookie('session_id', this.session_id);
this.set_cookie('db', this.db);
this.set_cookie('login', this.login);
this.set_cookie('user_context', this.user_context);
},
logout: function() {
delete this.uid;
@ -781,15 +842,22 @@ openerp.base.Session = openerp.base.Widget.extend( /** @lends openerp.base.Sessi
var self = this;
this.rpc('/base/session/modules', {}, function(result) {
self.module_list = result;
var modules = self.module_list.join(',');
if(self.debug || true) {
self.rpc('/base/webclient/csslist', {"mods": modules}, self.do_load_css);
self.rpc('/base/webclient/jslist', {"mods": modules}, self.do_load_js);
} else {
self.do_load_css(["/base/webclient/css?mods="+modules]);
self.do_load_js(["/base/webclient/js?mods="+modules]);
}
openerp._modules_loaded = true;
var lang = self.user_context.lang;
self.rpc('/base/webclient/translations',{
mods: ["base"].concat(result),
lang: lang})
.then(function(transs) {
openerp.base._t.database.set_bundle(transs);
var modules = self.module_list.join(',');
if(self.debug || true) {
self.rpc('/base/webclient/csslist', {"mods": modules}, self.do_load_css);
self.rpc('/base/webclient/jslist', {"mods": modules}, self.do_load_js);
} else {
self.do_load_css(["/base/webclient/css?mods="+modules]);
self.do_load_js(["/base/webclient/js?mods="+modules]);
}
openerp._modules_loaded = true;
});
});
},
do_load_css: function (files) {

View File

@ -1,4 +1,6 @@
openerp.base.form = function (openerp) {
var _t = openerp.base._t;
openerp.base.views.add('form', 'openerp.base.FormView');
openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormView# */{
@ -1455,7 +1457,7 @@ openerp.base.form.FieldMany2One = openerp.base.form.Field.extend({
// search more... if more results that max
if (values.length > self.limit) {
values = values.slice(0, self.limit);
values.push({label: "<em>   Search More...</em>", action: function() {
values.push({label: _t("<em>   Search More...</em>"), action: function() {
dataset.name_search(search_val, self.build_domain(), 'ilike'
, false, function(data) {
self._change_int_value(null);
@ -1468,13 +1470,13 @@ openerp.base.form.FieldMany2One = openerp.base.form.Field.extend({
if (search_val.length > 0 &&
!_.include(raw_result, search_val) &&
(!self.value || search_val !== self.value[1])) {
values.push({label: '<em>   Create "<strong>' +
$('<span />').text(search_val).html() + '</strong>"</em>', action: function() {
values.push({label: _.sprintf(_t('<em>   Create "<strong>%s</strong>"</em>'),
$('<span />').text(search_val).html()), action: function() {
self._quick_create(search_val);
}});
}
// create...
values.push({label: "<em>   Create and Edit...</em>", action: function() {
values.push({label: _t("<em>   Create and Edit...</em>"), action: function() {
self._change_int_value(null);
self._search_create_popup("form", undefined, {"default_name": search_val});
}});

View File

@ -92,7 +92,7 @@ openerp.base.ActionManager = openerp.base.Widget.extend({
ir_actions_client: function (action) {
this.client_widget = openerp.base.client_actions.get_object(action.tag);
new this.client_widget(this, this.element_id, action.params).start();
},
}
});
openerp.base.ViewManager = openerp.base.Widget.extend({
@ -285,13 +285,53 @@ openerp.base.ViewManagerAction = openerp.base.ViewManager.extend({
var searchview_loaded = this.setup_search_view(
searchview_id || false, search_defaults);
// schedule auto_search
if (searchview_loaded != null && this.action['auto_search']) {
$.when(searchview_loaded, inital_view_loaded)
.then(this.searchview.do_search);
}
}
},
on_mode_switch: function (view_type) {
this._super(view_type);
this.shortcut_check(this.views[view_type]);
},
shortcut_check : function(view) {
var self = this;
var grandparent = this.widget_parent && this.widget_parent.widget_parent;
// display shortcuts if on the first view for the action
var $shortcut_toggle = this.$element.find('.oe-shortcut-toggle');
if (!(grandparent instanceof openerp.base.WebClient) ||
!(view.view_type === this.views_src[0].view_type
&& view.view_id === this.views_src[0].view_id)) {
$shortcut_toggle.hide();
return;
}
$shortcut_toggle.removeClass('oe-shortcut-remove').show();
if (_(this.session.shortcuts).detect(function (shortcut) {
return shortcut.res_id === self.session.active_id; })) {
$shortcut_toggle.addClass("oe-shortcut-remove");
}
this.shortcut_add_remove();
},
shortcut_add_remove: function() {
var self = this;
var $shortcut_toggle = this.$element.find('.oe-shortcut-toggle');
$shortcut_toggle.click(function() {
if ($shortcut_toggle.hasClass("oe-shortcut-remove")) {
$(self.session.shortcuts.binding).trigger('remove-current');
$shortcut_toggle.removeClass("oe-shortcut-remove");
} else {
$(self.session.shortcuts.binding).trigger('add', {
'user_id': self.session.uid,
'res_id': self.session.active_id,
'resource': 'ir.ui.menu',
'name': self.action.name
});
$shortcut_toggle.addClass("oe-shortcut-remove");
}
});
}
});

View File

@ -359,7 +359,15 @@
</div>
</div>
<div class="oe-shortcuts"> </div>
</t>
<ul t-name="Shortcuts">
<li t-foreach="shortcuts" t-as="shortcut"
t-att-data-id="shortcut.res_id"
t-att-data-shortcut-id="shortcut.id"
><t t-esc="shortcut.name"/></li>
</ul>
<t t-name="Menu">
<table align="center">
<tr>
@ -408,7 +416,8 @@
<table class="view-manager-main-table">
<tr>
<td class="view-manager-main-content">
<!-- TODO prefix id with the element_id of the controller t-attf-id="#{prefix}_localid" -->
<a class="oe-shortcut-toggle" title="Add / Remove Shortcut..."
href="javascript: void(0)"> </a>
<div class="oe_vm_switch">
<t t-if="views.length != 1" t-foreach="views" t-as="view">
<button type="button" t-att-data-view-type="view.view_type">

View File

@ -0,0 +1,23 @@
# Translations template for PROJECT.
# Copyright (C) 2011 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2011-08-17 13:28+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"
#: addons/base_calendar/static/src/xml/base_calendar.xml:0
msgid "&nbsp;"
msgstr ""

View File

@ -0,0 +1,47 @@
# Translations template for PROJECT.
# Copyright (C) 2011 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2011-08-17 13:28+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"
#: addons/base_dashboard/static/src/xml/base_dashboard.xml:0
msgid "Reset"
msgstr ""
#: addons/base_dashboard/static/src/xml/base_dashboard.xml:0
msgid "Undo"
msgstr ""
#: addons/base_dashboard/static/src/xml/base_dashboard.xml:0
msgid "Add Widget"
msgstr ""
#: addons/base_dashboard/static/src/xml/base_dashboard.xml:0
msgid "Change layout"
msgstr ""
#: addons/base_dashboard/static/src/xml/base_dashboard.xml:0
msgid "Choose dashboard layout"
msgstr ""
#: addons/base_dashboard/static/src/xml/base_dashboard.xml:0
msgid "progress:"
msgstr ""
#: addons/base_dashboard/static/src/xml/base_dashboard.xml:0
msgid "%"
msgstr ""

View File

@ -0,0 +1,41 @@
# Translations template for PROJECT.
# Copyright (C) 2011 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2011-08-17 13:28+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"
#: addons/base_default_home/static/src/xml/base_default_home.xml:0
msgid "Welcome to OpenERP"
msgstr ""
#: addons/base_default_home/static/src/xml/base_default_home.xml:0
msgid ""
"Don't forget to bookmark your application address to come back\n"
" later:"
msgstr ""
#: addons/base_default_home/static/src/xml/base_default_home.xml:0
msgid "URL:"
msgstr ""
#: addons/base_default_home/static/src/xml/base_default_home.xml:0
msgid "login:"
msgstr ""
#: addons/base_default_home/static/src/xml/base_default_home.xml:0
msgid "Install"
msgstr ""

View File

@ -0,0 +1,19 @@
# Translations template for PROJECT.
# Copyright (C) 2011 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2011-08-17 13:28+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"

View File

@ -0,0 +1,19 @@
# Translations template for PROJECT.
# Copyright (C) 2011 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2011-08-17 13:28+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"

View File

@ -0,0 +1,19 @@
# Translations template for PROJECT.
# Copyright (C) 2011 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2011-08-17 13:28+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"

View File

@ -0,0 +1,19 @@
# Translations template for PROJECT.
# Copyright (C) 2011 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2011-08-17 13:28+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"

View File

@ -0,0 +1,19 @@
# Translations template for PROJECT.
# Copyright (C) 2011 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2011-08-17 13:28+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"

View File

@ -0,0 +1,71 @@
# Translations template for PROJECT.
# Copyright (C) 2011 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2011-08-17 13:28+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"
#: addons/web_mobile/static/src/xml/web_mobile.xml:0
msgid "OpenERP"
msgstr ""
#: addons/web_mobile/static/src/xml/web_mobile.xml:0
msgid "Home"
msgstr ""
#: addons/web_mobile/static/src/xml/web_mobile.xml:0
msgid "Database:"
msgstr ""
#: addons/web_mobile/static/src/xml/web_mobile.xml:0
msgid "Choose Database..."
msgstr ""
#: addons/web_mobile/static/src/xml/web_mobile.xml:0
msgid "Login:"
msgstr ""
#: addons/web_mobile/static/src/xml/web_mobile.xml:0
msgid "Password:"
msgstr ""
#: addons/web_mobile/static/src/xml/web_mobile.xml:0
msgid "Login"
msgstr ""
#: addons/web_mobile/static/src/xml/web_mobile.xml:0
msgid ":"
msgstr ""
#: addons/web_mobile/static/src/xml/web_mobile.xml:0
msgid "Shortcuts"
msgstr ""
#: addons/web_mobile/static/src/xml/web_mobile.xml:0
msgid "Menu"
msgstr ""
#: addons/web_mobile/static/src/xml/web_mobile.xml:0
msgid "Options"
msgstr ""
#: addons/web_mobile/static/src/xml/web_mobile.xml:0
msgid "Logout"
msgstr ""
#: addons/web_mobile/static/src/xml/web_mobile.xml:0
msgid "Preferences"
msgstr ""

8
babel.cfg Normal file
View File

@ -0,0 +1,8 @@
[extractors]
qweb = npybabel:extract_qweb
xmljs = npybabel:extract_xmljs
[javascript: static/src/js/**.js]
[qweb: static/src/xml/**.xml]
[xmljs: static/src/xml/**.xml]

53
gen_translations.sh Executable file
View File

@ -0,0 +1,53 @@
#!/bin/sh
usage() {
cat << EOF
usage: $0 -a
usage: $0 DIR OUTPUT_FILE
OPTIONS:
-a recreate the .pot file for all addons
-h print this message
EOF
exit 0
}
do_all=
while getopts "a" opt
do
case "$opt" in
a)
do_all=true;;
h)
usage;;
\?)
usage;;
esac
done
shift $((OPTIND-1))
if [ -n "$do_all" ]
then
echo "Extracting all the translations"
executable=$0
extract_module() {
$executable addons/$1 addons/$1/po/$1.pot
}
extract_module base
extract_module base_calendar
extract_module base_dashboard
extract_module base_default_home
extract_module base_diagram
extract_module base_gantt
extract_module base_graph
extract_module base_hello
extract_module web_chat
extract_module web_mobile
elif [ -n "$2" ]
then
./npybabel.py extract -F babel.cfg -o $2 -k _t --no-default-keywords $1
else
usage
fi

65
npybabel.py Executable file
View File

@ -0,0 +1,65 @@
#!/usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'Babel==0.9.6','console_scripts','pybabel'
__requires__ = 'Babel==0.9.6'
import sys
from pkg_resources import load_entry_point
import re
import json
import xml.etree.ElementTree as elt
if __name__ == '__main__':
sys.exit(
load_entry_point('Babel==0.9.6', 'console_scripts', 'pybabel')()
)
XMLJS_EXPR = re.compile(r"""(?:\_t *\( *((?:"(?:[^"\\]|\\.)*")|(?:'(?:[^'\\]|\\.)*')) *\))""")
def extract_xmljs(fileobj, keywords, comment_tags, options):
content = fileobj.read()
found = XMLJS_EXPR.finditer(content)
result = []
index = 0
line_nbr = 0
for f in found:
mes = f.group(1)
mes = json.loads(mes)
while index < f.start():
if content[index] == "\n":
line_nbr += 1
index += 1
result.append((line_nbr, None, mes, ""))
return result
def extract_qweb(fileobj, keywords, comment_tags, options):
"""Extract messages from XXX files.
:param fileobj: the file-like object the messages should be extracted
from
:param keywords: a list of keywords (i.e. function names) that should
be recognized as translation functions
:param comment_tags: a list of translator tags to search for and
include in the results
:param options: a dictionary of additional options (optional)
:return: an iterator over ``(lineno, funcname, message, comments)``
tuples
:rtype: ``iterator``
"""
result = []
def handle_text(str):
str = (str or "").strip()
if not str:
return
result.append((0, None, str, ""))
def iter_elements(current_element):
for el in current_element:
if "t-js" not in el.attrib and \
not ("t-jquery" in el.attrib and "t-operation" not in el.attrib) and \
not ("t-trad" in el.attrib and el.attrib["t-trad"].strip() == "off"):
handle_text(el.text)
iter_elements(el)
handle_text(el.tail)
tree = elt.parse(fileobj)
iter_elements(tree.getroot())
return result

View File

@ -371,7 +371,8 @@ class HttpRequest(object):
self.context = kw.get('context', {})
host = cherrypy.config['openerp.server.host']
port = cherrypy.config['openerp.server.port']
self.session = self.httpsession.setdefault(kw.pop('session_id', None), OpenERPSession(host, port))
self.session_id = kw.pop('session_id', None)
self.session = self.httpsession.setdefault(self.session_id, OpenERPSession(host, port))
self.result = ""
if request.method == 'GET':
print "GET --> %s.%s %s %r" % (controller.__class__.__name__, f.__name__, request, kw)

245
setup.py Executable file → Normal file
View File

@ -1,174 +1,89 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# setup from TinERP
# taken from straw http://www.nongnu.org/straw/index.html
# taken from gnomolicious http://www.nongnu.org/gnomolicious/
# adapted by Nicolas Évrard <nicoe@altern.org>
#
# doc/migrate is not included since about 6.1-dev
# doc/tests is not included
# python25-compat/*py should be in the openerp (and imported appropriately)
import sys
import os
from os.path import join, isfile
import glob
import re
import sys
from setuptools import setup
from setuptools import setup, find_packages
name = 'openerp-web-proto'
version = '6.0.1'
description = "Web Client of OpenERP, the Enterprise Management Software"
long_description = "OpenERP Web is the web client of the OpenERP, a free enterprise management software"
author = "OpenERP S.A."
author_email = "info@openerp.com"
support_email = 'support@openerp.com'
url = "http://www.openerp.com/"
download_url = ''
license = "OEPL"
# Backports os.walk with followlinks from python 2.6.
# Needed to add all addons files to data_files for Windows packaging.
def walk_followlinks(top, topdown=True, onerror=None, followlinks=False):
from os.path import join, isdir, islink
from os import listdir, error
try:
names = listdir(top)
except error, err:
if onerror is not None:
onerror(err)
return
dirs, nondirs = [], []
for name in names:
if isdir(join(top, name)):
dirs.append(name)
else:
nondirs.append(name)
if topdown:
yield top, dirs, nondirs
for name in dirs:
path = join(top, name)
if followlinks or not islink(path):
for x in walk_followlinks(path, topdown, onerror, followlinks):
yield x
if not topdown:
yield top, dirs, nondirs
if sys.version_info < (2, 6):
os.walk = walk_followlinks
py2exe_keywords = {}
py2exe_data_files = []
if os.name == 'nt':
version_dash_incompatible = False
if 'bdist_rpm' in sys.argv:
version_dash_incompatible = True
try:
import py2exe
py2exe_keywords['console'] = [
{ "script": "openerp-server",
"icon_resources": [(1, join("pixmaps","openerp-icon.ico"))],
}]
py2exe_keywords['options'] = {
"py2exe": {
"skip_archive": 1,
"optimize": 2,
"dist_dir": 'dist',
"packages": [
"lxml", "lxml.builder", "lxml._elementpath", "lxml.etree",
"lxml.objectify", "decimal", "xml", "xml", "xml.dom", "xml.xpath",
"encodings", "dateutil", "pychart", "PIL", "pyparsing",
"pydot", "asyncore","asynchat", "reportlab", "vobject",
"HTMLParser", "select", "mako", "poplib",
"imaplib", "smtplib", "email", "yaml", "DAV",
"uuid", "commands", "openerp",
],
"excludes" : ["Tkconstants","Tkinter","tcl"],
}
}
# TODO is it still necessary now that we don't use the library.zip file?
def data_files():
'''For Windows, we consider all the addons as data files.
It seems also that package_data below isn't honored by py2exe.'''
files = []
os.chdir('openerp')
for (dp, dn, names) in os.walk('addons'):
files.append((join('openerp',dp), map(lambda x: join('openerp', dp, x), names)))
os.chdir('..')
files.append(('openerp', [join('openerp', 'import_xml.rng'),]))
from py2exe_utils import opts
version_dash_incompatible = True
except ImportError:
opts = {}
if version_dash_incompatible:
version = version.split('-')[0]
# copy pytz/timzeone
# TODO check if we have to also copy dateutil's timezone data.
import pytz
# Make sure the layout of pytz hasn't changed
assert (pytz.__file__.endswith('__init__.pyc') or
pytz.__file__.endswith('__init__.py')), pytz.__file__
pytz_dir = os.path.dirname(pytz.__file__)
FILE_PATTERNS = \
r'.+\.(py|cfg|po|pot|mo|txt|rst|gif|png|jpg|ico|mako|html|js|css|htc|swf)$'
def find_data_files(source, patterns=FILE_PATTERNS):
file_matcher = re.compile(patterns, re.I)
out = []
for base, _, files in os.walk(source):
cur_files = []
for f in files:
if file_matcher.match(f):
cur_files.append(os.path.join(base, f))
if cur_files:
out.append(
(base, cur_files))
saved_dir = os.getcwd()
os.chdir(pytz_dir)
for dp, dn, names in os.walk('zoneinfo'):
files.append((join('pytz',dp), map(lambda x: join(pytz_dir, dp, x), names)))
os.chdir(saved_dir)
return out
return files
py2exe_data_files = data_files()
execfile(join('openerp', 'release.py'))
setup(name = name,
version = version,
description = description,
long_description = long_desc,
url = url,
author = author,
author_email = author_email,
classifiers = filter(None, classifiers.split("\n")),
license = license,
data_files = [
(join('man', 'man1'), ['man/openerp-server.1']),
(join('man', 'man5'), ['man/openerp_serverrc.5']),
('doc', filter(isfile, glob.glob('doc/*'))),
] + py2exe_data_files,
scripts = ['openerp-server'],
packages = find_packages(),
include_package_data = True,
package_data = {
'': ['*.yml', '*.xml', '*.po', '*.pot', '*.csv'],
},
dependency_links = ['http://download.gna.org/pychart/'],
install_requires = [
# We require the same version as caldav for lxml.
'lxml==2.1.5',
'mako',
'python-dateutil',
'psycopg2',
# TODO the pychart package we include in openerp corresponds to PyChart 1.37.
# It seems there is a single difference, which is a spurious print in generate_docs.py.
# It is probably safe to move to PyChart 1.39 (the latest one).
# (Let setup.py choose the latest one, and we should check we can remove pychart from
# our tree.)
'pychart',
'pydot',
'pytz',
'reportlab',
'caldav',
'pyyaml',
'pywebdav',
'feedparser',
'simplejson >= 2.0',
],
extras_require = {
'SSL' : ['pyopenssl'],
},
**py2exe_keywords
setup(
name=name,
version=version,
description=description,
long_description=long_description,
author=author,
author_email=author_email,
url=url,
download_url=download_url,
license=license,
install_requires=[
"CherryPy >= 3.1.2",
"Babel >= 0.9.6",
"simplejson >= 2.0.9",
"python-dateutil >= 1.4.1",
"pytz",
],
tests_require=[
'unittest2',
'mock',
],
test_suite = 'unittest2.collector',
zip_safe=False,
packages=[
'addons',
'addons.base',
'addons.base.controllers',
'addons.base_calendar',
'addons.base_hello',
'openerpweb',
],
classifiers=[
'Development Status :: 6 - Production/Stable',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Environment :: Web Environment',
'Topic :: Office/Business :: Financial',
],
scripts=['scripts/openerp-web'],
data_files=(find_data_files('addons')
+ opts.pop('data_files', [])
),
**opts
)