merge from trunk

bzr revid: mit@openerp.com-20120831145033-js8hdb8b4vg93vnh
This commit is contained in:
Minh Tran 2012-08-31 16:50:33 +02:00
commit 5523096061
6 changed files with 63 additions and 93 deletions

View File

@ -23,6 +23,7 @@ This module provides the core of the OpenERP Web Client.
"static/lib/jquery.validate/jquery.validate.js",
"static/lib/jquery.ba-bbq/jquery.ba-bbq.js",
"static/lib/spinjs/spin.js",
"static/lib/jquery.autosize/jquery.autosize.js",
"static/lib/jquery.blockUI/jquery.blockUI.js",
"static/lib/jquery.ui/js/jquery-ui-1.8.17.custom.min.js",
"static/lib/jquery.ui.timepicker/js/jquery-ui-timepicker-addon.js",
@ -37,8 +38,7 @@ This module provides the core of the OpenERP Web Client.
"static/lib/underscore/underscore.string.js",
"static/lib/backbone/backbone.js",
"static/lib/cleditor/jquery.cleditor.js",
"static/lib/py.js/lib/py.js",
"static/lib/jquery.autosize/jquery.autosize.js",
"static/lib/py.js/lib/py.js",
"static/src/js/boot.js",
"static/src/js/corelib.js",
"static/src/js/coresetup.js",
@ -68,60 +68,5 @@ This module provides the core of the OpenERP Web Client.
],
'qweb' : [
"static/src/xml/*.xml",
'static/lib/datejs/globalization/en-US.js',
'static/lib/datejs/core.js',
'static/lib/datejs/parser.js',
'static/lib/datejs/sugarpak.js',
'static/lib/datejs/extras.js',
'static/lib/jquery/jquery-1.7.2.js',
'static/lib/jquery.MD5/jquery.md5.js',
'static/lib/jquery.form/jquery.form.js',
'static/lib/jquery.validate/jquery.validate.js',
'static/lib/jquery.ba-bbq/jquery.ba-bbq.js',
'static/lib/spinjs/spin.js',
'static/lib/jquery.blockUI/jquery.blockUI.js',
'static/lib/jquery.ui/js/jquery-ui-1.8.17.custom.min.js',
'static/lib/jquery.ui.timepicker/js/jquery-ui-timepicker-addon.js',
'static/lib/jquery.ui.notify/js/jquery.notify.js',
'static/lib/jquery.deferred-queue/jquery.deferred-queue.js',
'static/lib/jquery.scrollTo/jquery.scrollTo-min.js',
'static/lib/jquery.tipsy/jquery.tipsy.js',
'static/lib/jquery.textext/jquery.textext.js',
'static/lib/jquery.timeago/jquery.timeago.js',
'static/lib/qweb/qweb2.js',
'static/lib/underscore/underscore.js',
'static/lib/underscore/underscore.string.js',
'static/lib/backbone/backbone.js',
'static/lib/cleditor/jquery.cleditor.js',
'static/lib/py.js/lib/py.js',
'static/src/js/boot.js',
'static/src/js/corelib.js',
'static/src/js/coresetup.js',
'static/src/js/dates.js',
'static/src/js/formats.js',
'static/src/js/chrome.js',
'static/src/js/views.js',
'static/src/js/data.js',
'static/src/js/data_export.js',
'static/src/js/data_import.js',
'static/src/js/search.js',
'static/src/js/view_form.js',
'static/src/js/view_list.js',
'static/src/js/view_list_editable.js',
'static/src/js/view_tree.js',
],
'css': [
'static/lib/jquery.ui.bootstrap/css/custom-theme/jquery-ui-1.8.16.custom.css',
'static/lib/jquery.ui.timepicker/css/jquery-ui-timepicker-addon.css',
'static/lib/jquery.ui.notify/css/ui.notify.css',
'static/lib/jquery.tipsy/tipsy.css',
'static/lib/jquery.textext/jquery.textext.css',
'static/src/css/base.css',
'static/src/css/data_export.css',
'static/src/css/data_import.css',
'static/lib/cleditor/jquery.cleditor.css',
],
'qweb': [
'static/src/xml/*.xml',
],
}

View File

@ -1190,12 +1190,26 @@ class DataSet(openerpweb.Controller):
return req.session.exec_workflow(model, id, signal)
@openerpweb.jsonrequest
def resequence(self, req, model, ids):
def resequence(self, req, model, ids, field='sequence', offset=0):
""" Re-sequences a number of records in the model, by their ids
The re-sequencing starts at the first model of ``ids``, the sequence
number is incremented by one after each record and starts at ``offset``
:param ids: identifiers of the records to resequence, in the new sequence order
:type ids: list(id)
:param str field: field used for sequence specification, defaults to
"sequence"
:param int offset: sequence number for first record in ``ids``, allows
starting the resequencing from an arbitrary number,
defaults to ``0``
"""
m = req.session.model(model)
if not len(m.fields_get(['sequence'])):
if not m.fields_get([field]):
return False
for i in range(len(ids)):
m.write([ids[i]], { 'sequence': i })
# python 2.6 has no start parameter
for i, id in enumerate(ids):
m.write(id, { field: i + offset })
return True
class DataGroup(openerpweb.Controller):

View File

@ -59,7 +59,12 @@
} else {
mirror = $(copy).data('ismirror', true).addClass(className || 'autosizejs')[0];
resize = $ta.css('resize') === 'none' ? 'none' : 'horizontal';
// Changed allowed resize only in edit mode by VTA (31/8/2012)
if ($ta.attr('disabled')) {
$ta.css('resize', 'none');
}
// Changed horizontal to vertical by VTA (31/8/2012)
resize = $ta.css('resize') === 'none' ? 'none' : 'vertical';
$ta.data('mirror', $(mirror)).css({
overflow: hidden,

View File

@ -2322,12 +2322,16 @@ instance.web.form.FieldDate = instance.web.form.FieldDatetime.extend({
instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, {
template: 'FieldText',
init: function (field_manager, node) {
this._super(field_manager, node);
},
initialize_content: function() {
var self = this;
this.$textarea = this.$el.find('textarea');
this.default_height = this.$textarea.css('height');
if (!this.get("effective_readonly")) {
this.$textarea.change(_.bind(function() {
this.set({'value': instance.web.parse_value(this.$textarea.val(), this)});
self.set({'value': instance.web.parse_value(self.$textarea.val(), self)});
}, this));
} else {
this.$textarea.attr('disabled', 'disabled');
@ -2340,14 +2344,17 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we
this.setupFocus(this.$textarea);
},
set_value: function(value_) {
this._super.apply(this, arguments);
this._super(value_);
this.render_value();
$(window).resize();
},
render_value: function() {
var show_value = instance.web.format_value(this.get('value'), this, '');
if (show_value === '') {
this.$textarea.css('height', parseInt(this.default_height)+"px");
}
this.$textarea.val(show_value);
this.$textarea.autosize();
this.$textarea.css('height', parseInt(this.default_height)+"px");
this.$textarea.autosize();
},
is_syntax_valid: function() {
if (!this.get("effective_readonly")) {

View File

@ -120,7 +120,7 @@
</tr>
<tr>
<td><label for="db_name">New database name:</label></td>
<td><input type="text" name="db_name" class="required" matches="^[a-zA-Z][a-zA-Z0-9_]+$" autofocus="true"/></td>
<td><input type="text" name="db_name" class="required" matches="^[a-zA-Z][a-zA-Z0-9_-]+$" autofocus="true"/></td>
</tr>
<tr>
<td><label for="demo_data">Load Demonstration data:</label></td>
@ -726,12 +726,14 @@
<t t-if="widget.options.action_buttons !== false">
<span class="oe_form_buttons_view">
<div style="display: inline-block;"> <!-- required for the bounce effect on button -->
<button type="button" class="oe_button oe_form_button_edit">Edit</button>
<button type="button" class="oe_button oe_form_button_edit" accesskey="E">Edit</button>
</div>
<button type="button" class="oe_button oe_form_button_create">Create</button>
<button type="button" class="oe_button oe_form_button_create" accesskey="C">Create</button>
</span>
<span class="oe_form_buttons_edit">
<button type="button" class="oe_button oe_form_button_save oe_highlight">Save</button> <span class="oe_fade">or</span> <a href="#" class="oe_bold oe_form_button_cancel">Discard</a>
<button type="button" class="oe_button oe_form_button_save oe_highlight" accesskey="S">Save</button>
<span class="oe_fade">or</span>
<a href="#" class="oe_bold oe_form_button_cancel" accesskey="D">Discard</a>
</span>
</t>
</div>
@ -817,7 +819,7 @@
<div class="oe_clear">
<ul t-attf-class="oe_notebook #{classnames}">
<li t-foreach="pages" t-as="page" t-att-modifiers="page.modifiers">
<a t-attf-href="##{page.id}">
<a t-attf-href="##{page.id}" t-att-accesskey="page.accesskey">
<t t-esc="page.string"/>
</a>
</li>
@ -1165,7 +1167,8 @@
<button type="button" class="oe_button oe_form_button"
t-att-style="widget.node.attrs.style"
t-att-tabindex="widget.node.attrs.tabindex"
t-att-autofocus="widget.node.attrs.autofocus">
t-att-autofocus="widget.node.attrs.autofocus"
t-att-accesskey="widget.node.attrs.accesskey">
<img t-if="widget.node.attrs.icon" t-att-src="_s + widget.node.attrs.icon" width="16" height="16"/>
<span t-if="widget.string"><t t-esc="widget.string"/></span>
</button>

View File

@ -18,38 +18,34 @@
<script type="text/javascript">
$(function() {
$("body").on('click','button',function(ev){
eval($("pre.run").text());
console.log($("textarea").val());
eval($("textarea").val());
});
});
</script>
</head>
<body>
<h1>OpenERP web_api examples</h1>
<h2>Example 1: Load the list of defined ir.model <button>Run it !</button></h2>
<blockquote>
<h3>Code: </h3>
<h1>OpenERP web_api test</h1>
<h2>Example: Load the content of ir.model <button>Run it !</button></h2>
<pre>
&lt;script type="text/javascript" src="/web/webclient/js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
<pre id="ex1" class="run">
var instance = openerp.init(["web"]); // get a new instance
instance.session.session_bind(); // bind it to the right hostname
instance.session.session_authenticate("trunk", "admin", "admin", false).then(function() {
var ds = new instance.web.DataSetSearch(null, "ir.model");
ds.read_slice(['name','model'], {}).then(function(models){
_.each(models,function(m,i){
$("#ex1res").append("&lt;li&gt;" + m.model + " (" + m.name + ") &lt;/li&gt;")
});
<textarea rows="12" cols="100"id="ex1" class="run">
var instance = openerp.init(["web"]); // get a new instance
instance.session.session_bind(); // bind it to the right hostname
instance.session.session_authenticate("trunk", "admin", "admin", false).then(function() {
var ds = new instance.web.DataSetSearch(null, "ir.model");
ds.read_slice(['name','model'], {}).then(function(models){
_.each(models,function(m,i){
$("#result").append("&lt;li&gt;" + m.model + " (" + m.name + ") &lt;/li&gt;")
});
});
</pre>&lt;/script&gt;
});
</textarea>
&lt;/script&gt;</pre>
<h3>Result:</h3>
<pre id="result" class="result">
</pre>
<h3>Div for output:</h3>
<div id="ex1res" class="result">
&nbsp;
</div>
</blockquote>
<h2>Help me to complete this examples on <a href="http://bazaar.launchpad.net/~openerp/openerp-web/trunk/view/head:/addons/web_api/static/src/example.html">launchpad</a></h2>
</body>
</html>