[merge]
bzr revid: nicolas.vanhoren@openerp.com-20110812143947-7l5d1acum5298j0s
This commit is contained in:
commit
fb29f3a97e
|
@ -793,8 +793,8 @@ class View(openerpweb.Controller):
|
|||
""" Parses an arbitrary string containing a domain, transforms it
|
||||
to either a literal domain or a :class:`openerpweb.nonliterals.Domain`
|
||||
|
||||
:param domain: the domain to parse, if the domain is not a string it is assumed to
|
||||
be a literal domain and is returned as-is
|
||||
:param domain: the domain to parse, if the domain is not a string it
|
||||
is assumed to be a literal domain and is returned as-is
|
||||
:param session: Current OpenERP session
|
||||
:type session: openerpweb.openerpweb.OpenERPSession
|
||||
"""
|
||||
|
@ -810,8 +810,8 @@ class View(openerpweb.Controller):
|
|||
""" Parses an arbitrary string containing a context, transforms it
|
||||
to either a literal context or a :class:`openerpweb.nonliterals.Context`
|
||||
|
||||
:param context: the context to parse, if the context is not a string it is assumed to
|
||||
be a literal domain and is returned as-is
|
||||
:param context: the context to parse, if the context is not a string it
|
||||
is assumed to be a literal domain and is returned as-is
|
||||
:param session: Current OpenERP session
|
||||
:type session: openerpweb.openerpweb.OpenERPSession
|
||||
"""
|
||||
|
|
|
@ -378,59 +378,6 @@ openerp.base.SessionAware = openerp.base.CallbackEnabled.extend({
|
|||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Base class for all visual components. Provides a lot of functionalities helpful
|
||||
* for the management of a part of the DOM.
|
||||
*
|
||||
* Widget handles:
|
||||
* - Rendering with QWeb.
|
||||
* - Life-cycle management and parenting (when a parent is destroyed, all its children are
|
||||
* destroyed too).
|
||||
* - Insertion in DOM.
|
||||
*
|
||||
* Widget also extends SessionAware for ease of use.
|
||||
*
|
||||
* Guide to create implementations of the Widget class:
|
||||
* ==============================================
|
||||
*
|
||||
* Here is a sample child class:
|
||||
*
|
||||
* MyWidget = openerp.base.Widget.extend({
|
||||
* // the name of the QWeb template to use for rendering
|
||||
* template: "MyQWebTemplate",
|
||||
* // identifier prefix, it is useful to put an obvious one for debugging
|
||||
* identifier_prefix: 'my-id-prefix-',
|
||||
*
|
||||
* init: function(parent) {
|
||||
* this._super(parent);
|
||||
* // stuff that you want to init before the rendering
|
||||
* },
|
||||
* start: function() {
|
||||
* this._super();
|
||||
* // stuff you want to make after the rendering, `this.$element` holds a correct value
|
||||
* this.$element.find(".my_button").click(/* an example of event binding * /);
|
||||
*
|
||||
* // if you have some asynchronous operations, it's a good idea to return
|
||||
* // a promise in start()
|
||||
* var promise = this.rpc(...);
|
||||
* return promise;
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* Now this class can simply be used with the following syntax:
|
||||
*
|
||||
* var my_widget = new MyWidget(this);
|
||||
* my_widget.appendTo($(".some-div"));
|
||||
*
|
||||
* With these two lines, the MyWidget instance was inited, rendered, it was inserted into the
|
||||
* DOM inside the ".some-div" div and its events were binded.
|
||||
*
|
||||
* And of course, when you don't need that widget anymore, just do:
|
||||
*
|
||||
* my_widget.stop();
|
||||
*
|
||||
* That will kill the widget in a clean way and erase its content from the dom.
|
||||
*/
|
||||
openerp.base.Widget = openerp.base.SessionAware.extend({
|
||||
/**
|
||||
* The name of the QWeb template that will be used for rendering. Must be
|
||||
|
|
|
@ -83,7 +83,7 @@ openerp.base.parse_time = function(str) {
|
|||
*/
|
||||
var zpad = function(str, size) {
|
||||
str = "" + str;
|
||||
return new Array(size - str.length).join('0') + str;
|
||||
return new Array(size - str.length + 1).join('0') + str;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -772,7 +772,7 @@ openerp.base.ListView.List = openerp.base.Class.extend( /** @lends openerp.base.
|
|||
var old_index = this.dataset.index;
|
||||
this.dataset.index = record_index;
|
||||
read_p = this.dataset.read_index(
|
||||
_.filter(_.pluck(this.columns, 'name'), _.identity),
|
||||
_.pluck(_(this.columns).filter(function (r) {return r.tag === 'field';}), 'name'),
|
||||
function (record) {
|
||||
var form_record = self.transform_record(record);
|
||||
self.rows.splice(record_index, 1, form_record);
|
||||
|
@ -1035,7 +1035,7 @@ openerp.base.ListView.Groups = openerp.base.Class.extend( /** @lends openerp.bas
|
|||
page = this.datagroup.openable ? this.page : view.page;
|
||||
|
||||
dataset.read_slice({
|
||||
fields: _.filter(_.pluck(_.select(this.columns, function(x) {return x.tag == "field";}), 'name'), _.identity),
|
||||
fields: _.pluck(_.select(this.columns, function(x) {return x.tag == "field"}), 'name'),
|
||||
offset: page * limit,
|
||||
limit: limit
|
||||
}, function (records) {
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
/*---------------------------------------------------------
|
||||
* OpenERP base_gantt
|
||||
*---------------------------------------------------------*/
|
||||
|
||||
openerp.base_gantt = function (openerp) {
|
||||
QWeb.add_template('/base_gantt/static/src/xml/base_gantt.xml');
|
||||
openerp.base.views.add('gantt', 'openerp.base_gantt.GanttView');
|
||||
openerp.base_gantt.GanttView = openerp.base.Widget.extend({
|
||||
openerp.base_gantt.GanttView = openerp.base.View.extend({
|
||||
|
||||
init: function(view_manager, session, element_id, dataset, view_id) {
|
||||
|
||||
this._super(session, element_id);
|
||||
this.view_manager = view_manager;
|
||||
init: function(parent, element_id, dataset, view_id) {
|
||||
this._super(parent, element_id);
|
||||
this.view_manager = parent || new openerp.base.NullViewManager();
|
||||
this.dataset = dataset;
|
||||
this.model = dataset.model;
|
||||
this.view_id = view_id;
|
||||
|
@ -29,7 +27,7 @@ init: function(view_manager, session, element_id, dataset, view_id) {
|
|||
this.calendar_fields = {};
|
||||
this.info_fields = [];
|
||||
this.domain = this.dataset._domain ? this.dataset._domain: [];
|
||||
this.context = {};
|
||||
this.context = this.dataset.context || {};
|
||||
},
|
||||
|
||||
start: function() {
|
||||
|
@ -52,8 +50,8 @@ init: function(view_manager, session, element_id, dataset, view_id) {
|
|||
this.color_field = this.fields_view.arch.attrs.color;
|
||||
this.day_length = this.fields_view.arch.attrs.day_length || 8;
|
||||
this.colors = this.fields_view.arch.attrs.colors;
|
||||
|
||||
this.text = this.fields_view.arch.children[0].children[0].attrs.name;
|
||||
var arch_children = this.fields_view.arch.children[0];
|
||||
this.text = arch_children.children[0] ? arch_children.children[0].attrs.name : arch_children.attrs.name;
|
||||
this.parent = this.fields_view.arch.children[0].attrs.link;
|
||||
|
||||
this.format = "yyyy-MM-dd";
|
||||
|
@ -100,7 +98,7 @@ init: function(view_manager, session, element_id, dataset, view_id) {
|
|||
|
||||
if (result.length != 0){
|
||||
var show_event = [];
|
||||
for (i in result){
|
||||
for (var i in result){
|
||||
var res = result[i];
|
||||
if (res[this.date_start] != false){
|
||||
|
||||
|
@ -132,7 +130,7 @@ init: function(view_manager, session, element_id, dataset, view_id) {
|
|||
var child_event = {};
|
||||
var temp_id = "";
|
||||
var final_events = [];
|
||||
for (i in show_event) {
|
||||
for (var i in show_event) {
|
||||
|
||||
var res = show_event[i];
|
||||
|
||||
|
@ -161,11 +159,8 @@ init: function(view_manager, session, element_id, dataset, view_id) {
|
|||
if (duration == false)
|
||||
duration = 0
|
||||
|
||||
if (self.grp.length == 0){
|
||||
self.grp.push({'group_by' : this.parent})
|
||||
}
|
||||
if (self.grp != undefined){
|
||||
for (j in self.grp){
|
||||
if (self.grp.length){
|
||||
for (var j in self.grp){
|
||||
var grp_key = res[self.grp[j]['group_by']];
|
||||
if (typeof(grp_key) == "object"){
|
||||
grp_key = res[self.grp[j]['group_by']][1];
|
||||
|
@ -175,7 +170,7 @@ init: function(view_manager, session, element_id, dataset, view_id) {
|
|||
}
|
||||
|
||||
if (grp_key == false){
|
||||
grp_key = "False";
|
||||
grp_key = "Undefined";
|
||||
}
|
||||
|
||||
if (j == 0){
|
||||
|
@ -207,9 +202,17 @@ init: function(view_manager, session, element_id, dataset, view_id) {
|
|||
all_events[id] = {'parent': temp_id, 'evt':[id , text, start_date, duration, 100, "", color_box[color]]};
|
||||
final_events.push(id);
|
||||
}
|
||||
else {
|
||||
if (i == 0) {
|
||||
var mod_id = "_" + i;
|
||||
all_events[mod_id] = {'parent': "", 'evt': [mod_id, this.name, start_date, start_date, 100, "", "white"]};
|
||||
}
|
||||
all_events[id] = {'parent': mod_id, 'evt':[id , text, start_date, duration, 100, "", color_box[color]]};
|
||||
final_events.push(id);
|
||||
}
|
||||
}
|
||||
|
||||
for (i in final_events){
|
||||
for (var i in final_events){
|
||||
var evt_id = final_events[i];
|
||||
var evt_date = all_events[evt_id]['evt'][2];
|
||||
while (all_events[evt_id]['parent'] != "") {
|
||||
|
@ -225,7 +228,7 @@ init: function(view_manager, session, element_id, dataset, view_id) {
|
|||
var evt_duration = "";
|
||||
var evt_end_date = "";
|
||||
|
||||
for (i in final_events){
|
||||
for (var i in final_events){
|
||||
evt_id = final_events[i];
|
||||
evt_date = all_events[evt_id]['evt'][2];
|
||||
evt_duration = all_events[evt_id]['evt'][3];
|
||||
|
@ -242,42 +245,27 @@ init: function(view_manager, session, element_id, dataset, view_id) {
|
|||
}
|
||||
}
|
||||
|
||||
for (j in self.grp){
|
||||
for (i in all_events){
|
||||
res = all_events[i];
|
||||
if ((typeof(res['evt'][3])) == "object"){
|
||||
res['evt'][3] = self.hours_between(res['evt'][2],res['evt'][3]);
|
||||
}
|
||||
|
||||
k = res['evt'][0].toString().indexOf('_');
|
||||
if (k != -1){
|
||||
if (res['evt'][0].substring(k) == "_"+j){
|
||||
if (j == 0){
|
||||
task = new GanttTaskInfo(res['evt'][0], res['evt'][1], res['evt'][2], res['evt'][3], res['evt'][4], "",res['evt'][6]);
|
||||
project.addTask(task);
|
||||
} else {
|
||||
task = new GanttTaskInfo(res['evt'][0], res['evt'][1], res['evt'][2], res['evt'][3], res['evt'][4], "",res['evt'][6]);
|
||||
prt = project.getTaskById(res['parent']);
|
||||
prt.addChildTask(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var j in self.grp) {
|
||||
self.render_events(all_events, j);
|
||||
}
|
||||
for (i in final_events){
|
||||
|
||||
if (!self.grp.length) {
|
||||
self.render_events(all_events, 0);
|
||||
}
|
||||
|
||||
for (var i in final_events){
|
||||
evt_id = final_events[i];
|
||||
res = all_events[evt_id];
|
||||
|
||||
task=new GanttTaskInfo(res['evt'][0], res['evt'][1], res['evt'][2], res['evt'][3], res['evt'][4], "",res['evt'][6]);
|
||||
prt = project.getTaskById(res['parent']);
|
||||
prt.addChildTask(task);
|
||||
}
|
||||
|
||||
oth_hgt = 264;
|
||||
min_hgt = 150;
|
||||
name_min_wdt = 150;
|
||||
gantt_hgt = jQuery(window).height() - oth_hgt;
|
||||
search_wdt = jQuery("#oe_app_search").width();
|
||||
var oth_hgt = 264;
|
||||
var min_hgt = 150;
|
||||
var name_min_wdt = 150;
|
||||
var gantt_hgt = jQuery(window).height() - oth_hgt;
|
||||
var search_wdt = jQuery("#oe_app_search").width();
|
||||
|
||||
if (gantt_hgt > min_hgt){
|
||||
jQuery('#GanttDiv').height(gantt_hgt).width(search_wdt);
|
||||
|
@ -291,13 +279,13 @@ init: function(view_manager, session, element_id, dataset, view_id) {
|
|||
ganttChartControl.attachEvent("onTaskEndDrag", function(task) {self.on_resize_drag_end(task, "drag");});
|
||||
ganttChartControl.attachEvent("onTaskDblClick", function(task) {self.open_popup(task);});
|
||||
|
||||
taskdiv = jQuery("div.taskPanel").parent();
|
||||
var taskdiv = jQuery("div.taskPanel").parent();
|
||||
taskdiv.addClass('ganttTaskPanel');
|
||||
taskdiv.prev().addClass('ganttDayPanel');
|
||||
$gantt_panel = jQuery(".ganttTaskPanel , .ganttDayPanel");
|
||||
var $gantt_panel = jQuery(".ganttTaskPanel , .ganttDayPanel");
|
||||
|
||||
ganttrow = jQuery('.taskPanel').closest('tr');
|
||||
gtd = ganttrow.children(':first-child');
|
||||
var ganttrow = jQuery('.taskPanel').closest('tr');
|
||||
var gtd = ganttrow.children(':first-child');
|
||||
gtd.children().addClass('task-name');
|
||||
|
||||
jQuery(".toggle-sidebar").click(function(e) {
|
||||
|
@ -319,9 +307,8 @@ init: function(view_manager, session, element_id, dataset, view_id) {
|
|||
$gantt_panel.width(1);
|
||||
jQuery(".ganttTaskPanel").parent().width(1);
|
||||
|
||||
search_wdt = jQuery("#oe_app_search").width();
|
||||
day_wdt = jQuery(".ganttDayPanel").children().children().width();
|
||||
name_wdt = jQuery('.task-name').width();
|
||||
var search_wdt = jQuery("#oe_app_search").width();
|
||||
var day_wdt = jQuery(".ganttDayPanel").children().children().width();
|
||||
jQuery('#GanttDiv').css('width','100%');
|
||||
|
||||
if (search_wdt - day_wdt <= name_min_wdt){
|
||||
|
@ -345,7 +332,7 @@ init: function(view_manager, session, element_id, dataset, view_id) {
|
|||
|
||||
var self = this;
|
||||
|
||||
dat = this.convert_str_date(dat);
|
||||
var dat = this.convert_str_date(dat);
|
||||
|
||||
var day = Math.floor(duration/self.day_length);
|
||||
var hrs = duration % self.day_length;
|
||||
|
@ -356,47 +343,98 @@ init: function(view_manager, session, element_id, dataset, view_id) {
|
|||
return dat;
|
||||
},
|
||||
|
||||
hours_between: function(date1, date2) {
|
||||
hours_between: function(date1, date2, parent_task) {
|
||||
|
||||
var ONE_DAY = 1000 * 60 * 60 * 24;
|
||||
var date1_ms = date1.getTime();
|
||||
var date2_ms = date2.getTime();
|
||||
var difference_ms = Math.abs(date1_ms - date2_ms);
|
||||
|
||||
d = Math.floor(difference_ms / ONE_DAY);
|
||||
h = (difference_ms % ONE_DAY)/(1000 * 60 * 60);
|
||||
num = (d * this.day_length) + h;
|
||||
var d = parent_task? Math.ceil(difference_ms / ONE_DAY) : Math.floor(difference_ms / ONE_DAY);
|
||||
var h = (difference_ms % ONE_DAY)/(1000 * 60 * 60);
|
||||
var num = (d * this.day_length) + h;
|
||||
return parseFloat(num.toFixed(2));
|
||||
|
||||
},
|
||||
|
||||
render_events : function(all_events, j) {
|
||||
|
||||
var self = this;
|
||||
for (var i in all_events){
|
||||
var res = all_events[i];
|
||||
if ((typeof(res['evt'][3])) == "object"){
|
||||
res['evt'][3] = self.hours_between(res['evt'][2],res['evt'][3], true);
|
||||
}
|
||||
|
||||
k = res['evt'][0].toString().indexOf('_');
|
||||
|
||||
if (k != -1) {
|
||||
if (res['evt'][0].substring(k) == "_"+j){
|
||||
if (j == 0){
|
||||
task = new GanttTaskInfo(res['evt'][0], res['evt'][1], res['evt'][2], res['evt'][3], res['evt'][4], "",res['evt'][6]);
|
||||
project.addTask(task);
|
||||
} else {
|
||||
task = new GanttTaskInfo(res['evt'][0], res['evt'][1], res['evt'][2], res['evt'][3], res['evt'][4], "",res['evt'][6]);
|
||||
prt = project.getTaskById(res['parent']);
|
||||
prt.addChildTask(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
open_popup : function(task) {
|
||||
var event_id = task.getId();
|
||||
|
||||
if(event_id.toString().search("_") != -1)
|
||||
return;
|
||||
if (event_id) {
|
||||
event_id = parseInt(event_id, 10);
|
||||
var dataset_event_index = jQuery.inArray(event_id, this.ids);
|
||||
} else {
|
||||
var dataset_event_index = null;
|
||||
if(event_id) event_id = parseInt(event_id, 10);
|
||||
|
||||
var action = {
|
||||
"res_model": this.dataset.model,
|
||||
"res_id": event_id,
|
||||
"views":[[false,"form"]],
|
||||
"type":"ir.actions.act_window",
|
||||
"view_type":"form",
|
||||
"view_mode":"form"
|
||||
}
|
||||
this.dataset.index = dataset_event_index;
|
||||
|
||||
action.flags = {
|
||||
search_view: false,
|
||||
sidebar : false,
|
||||
views_switcher : false,
|
||||
pager: false
|
||||
}
|
||||
var element_id = _.uniqueId("act_window_dialog");
|
||||
var dialog = jQuery('<div>',
|
||||
{'id': element_id
|
||||
}).dialog({
|
||||
title: 'Gantt Chart',
|
||||
modal: true,
|
||||
minWidth: 800,
|
||||
position: 'top'
|
||||
});
|
||||
var event_form = new openerp.base.FormView(this.view_manager, this.session, element_id, this.dataset, false);
|
||||
event_form.start();
|
||||
var dialog = jQuery('<div>', {
|
||||
'id': element_id
|
||||
}).dialog({
|
||||
modal: true,
|
||||
width: 'auto',
|
||||
height: 'auto',
|
||||
buttons: {
|
||||
Cancel: function() {
|
||||
$(this).dialog("destroy");
|
||||
},
|
||||
Save: function() {
|
||||
var view_manager = action_manager.viewmanager;
|
||||
var _dialog = this;
|
||||
view_manager.views[view_manager.active_view].controller.do_save(function(r) {
|
||||
$(_dialog).dialog("destroy");
|
||||
self.reload_gantt();
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
var action_manager = new openerp.base.ActionManager(this, element_id);
|
||||
action_manager.start();
|
||||
action_manager.do_action(action);
|
||||
|
||||
//Default_get
|
||||
if(!event_id) action_manager.viewmanager.dataset.index = null;
|
||||
},
|
||||
|
||||
on_drag_start : function(task){
|
||||
st_date = task.getEST();
|
||||
var st_date = task.getEST();
|
||||
if(st_date.getHours()){
|
||||
self.hh = st_date.getHours();
|
||||
self.mm = st_date.getMinutes();
|
||||
|
|
|
@ -113,6 +113,98 @@ initializing the addon.
|
|||
Creating new standard roles
|
||||
---------------------------
|
||||
|
||||
Widget
|
||||
++++++
|
||||
|
||||
This is the base class for all visual components. It provides a number of
|
||||
services for the management of a DOM subtree:
|
||||
|
||||
* Rendering with QWeb
|
||||
|
||||
* Parenting-child relations
|
||||
|
||||
* Life-cycle management (including facilitating children destruction when a
|
||||
parent object is removed)
|
||||
|
||||
* DOM insertion, via jQuery-powered insertion methods. Insertion targets can
|
||||
be anything the corresponding jQuery method accepts (generally selectors,
|
||||
DOM nodes and jQuery objects):
|
||||
|
||||
:js:func:`~openerp.base.Widget.appendTo`
|
||||
Renders the widget and inserts it as the last child of the target, uses
|
||||
`.appendTo()`_
|
||||
|
||||
:js:func:`~openerp.base.Widget.prependTo`
|
||||
Renders the widget and inserts it as the first child of the target, uses
|
||||
`.prependTo()`_
|
||||
|
||||
:js:func:`~openerp.base.Widget.insertAfter`
|
||||
Renders the widget and inserts it as the preceding sibling of the target,
|
||||
uses `.insertAfter()`_
|
||||
|
||||
:js:func:`~openerp.base.Widget.insertBefore`
|
||||
Renders the widget and inserts it as the following sibling of the target,
|
||||
uses `.insertBefore()`_
|
||||
|
||||
:js:class:`~openerp.base.Widget` inherits from
|
||||
:js:class:`~openerp.base.SessionAware`, so subclasses can easily access the
|
||||
RPC layers.
|
||||
|
||||
Subclassing Widget
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
:js:class:`~openerp.base.Widget` is subclassed in the standard manner (via the
|
||||
:js:func:`~openerp.base.Class.extend` method), and provides a number of
|
||||
abstract properties and concrete methods (which you may or may not want to
|
||||
override). Creating a subclass looks like this:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
var MyWidget = openerp.base.Widget.extend({
|
||||
// QWeb template to use when rendering the object
|
||||
template: "MyQWebTemplate",
|
||||
// autogenerated id prefix, specificity helps when debugging
|
||||
identifier_prefix: 'my-id-prefix-',
|
||||
|
||||
init: function(parent) {
|
||||
this._super(parent);
|
||||
// insert code to execute before rendering, for object
|
||||
// initialization
|
||||
},
|
||||
start: function() {
|
||||
this._super();
|
||||
// post-rendering initialization code, at this point
|
||||
// ``this.$element`` has been initialized
|
||||
this.$element.find(".my_button").click(/* an example of event binding * /);
|
||||
|
||||
// if ``start`` is asynchronous, return a promise object so callers
|
||||
// know when the object is done initializing
|
||||
return this.rpc(/* … */)
|
||||
}
|
||||
});
|
||||
|
||||
The new class can then be used in the following manner:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
// Create the instance
|
||||
var my_widget = new MyWidget(this);
|
||||
// Render and insert into DOM
|
||||
my_widget.appendTo(".some-div");
|
||||
|
||||
After these two lines have executed (and any promise returned by ``appendTo``
|
||||
has been resolved if needed), the widget is ready to be used.
|
||||
|
||||
If the widget is not needed anymore (because it's transient), simply terminate
|
||||
it:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
my_widget.stop();
|
||||
|
||||
will unbind all DOM events, remove the widget's content from the DOM and
|
||||
destroy all widget data.
|
||||
|
||||
Views
|
||||
+++++
|
||||
|
||||
|
@ -236,193 +328,6 @@ replace ``addons`` by the directory in which your own addon lives.
|
|||
and run ``nosetests addons`` instead of the ``unit2`` command,
|
||||
the result should be exactly the same.
|
||||
|
||||
APIs
|
||||
----
|
||||
|
||||
Javascript
|
||||
++++++++++
|
||||
|
||||
.. js:class:: openerp.base.Widget(view, node)
|
||||
|
||||
:param openerp.base.Controller view: The view to which the widget belongs
|
||||
:param Object node: the ``fields_view_get`` descriptor for the widget
|
||||
|
||||
.. js:attribute:: $element
|
||||
|
||||
The widget's root element as jQuery object
|
||||
|
||||
.. js:class:: openerp.base.DataSet(session, model)
|
||||
|
||||
:param openerp.base.Session session: the RPC session object
|
||||
:param String model: the model managed by this dataset
|
||||
|
||||
The DataSet is the abstraction for a sequence of records stored in
|
||||
database.
|
||||
|
||||
It provides interfaces for reading records based on search
|
||||
criteria, and for selecting and fetching records based on
|
||||
activated ids.
|
||||
|
||||
.. js:function:: fetch([offset][, limit])
|
||||
|
||||
:param Number offset: the index from which records should start
|
||||
being returned (section)
|
||||
:param Number limit: the maximum number of records to return
|
||||
:returns: the dataset instance it was called on
|
||||
|
||||
Asynchronously fetches the records selected by the DataSet's
|
||||
domain and context, in the provided sort order if any.
|
||||
|
||||
Only fetches the fields selected by the DataSet.
|
||||
|
||||
On success, triggers :js:func:`on_fetch`
|
||||
|
||||
.. js:function:: on_fetch(records, event)
|
||||
|
||||
:param Array records: an array of
|
||||
:js:class:`openerp.base.DataRecord`
|
||||
matching the DataSet's selection
|
||||
:param event: a data holder letting the event handler fetch
|
||||
meta-informations about the event.
|
||||
:type event: OnFetchEvent
|
||||
|
||||
Fired after :js:func:`fetch` is done fetching the records
|
||||
selected by the DataSet.
|
||||
|
||||
.. js:function:: active_ids
|
||||
|
||||
:returns: the dataset instance it was called on
|
||||
|
||||
Asynchronously fetches the active records for this DataSet.
|
||||
|
||||
On success, triggers :js:func:`on_active_ids`
|
||||
|
||||
.. js:function:: on_active_ids(records)
|
||||
|
||||
:param Array records: an array of
|
||||
:js:class:`openerp.base.DataRecord`
|
||||
matching the currently active ids
|
||||
|
||||
Fired after :js:func:`active_ids` fetched the records matching
|
||||
the DataSet's active ids.
|
||||
|
||||
.. js:function:: active_id
|
||||
|
||||
:returns: the dataset instance in was called on
|
||||
|
||||
Asynchronously fetches the current active record.
|
||||
|
||||
On success, triggers :js:func:`on_active_id`
|
||||
|
||||
.. js:function:: on_active_id(record)
|
||||
|
||||
:param Object record: the record fetched by
|
||||
:js:func:`active_id`, or ``null``
|
||||
:type record: openerp.base.DataRecord
|
||||
|
||||
Fired after :js:func:`active_id` fetched the record matching
|
||||
the dataset's active id
|
||||
|
||||
.. js:function:: set(options)
|
||||
|
||||
:param Object options: the options to set on the dataset
|
||||
:type options: DataSetOptions
|
||||
:returns: the dataset instance it was called on
|
||||
|
||||
Configures the data set by setting various properties on it
|
||||
|
||||
.. js:function:: prev
|
||||
|
||||
:returns: the dataset instance it was called on
|
||||
|
||||
Activates the id preceding the current one in the active ids
|
||||
sequence of the dataset.
|
||||
|
||||
If the current active id is at the start of the sequence,
|
||||
wraps back to the last id of the sequence.
|
||||
|
||||
.. js:function:: next
|
||||
|
||||
:returns: the dataset instance it was called on
|
||||
|
||||
Activates the id following the current one in the active ids
|
||||
sequence.
|
||||
|
||||
If the current active id is the last of the sequence, wraps
|
||||
back to the beginning of the active ids sequence.
|
||||
|
||||
.. js:function:: select(ids)
|
||||
|
||||
:param Array ids: the identifiers to activate on the dataset
|
||||
:returns: the dataset instance it was called on
|
||||
|
||||
Activates all the ids specified in the dataset, resets the
|
||||
current active id to be the first id of the new sequence.
|
||||
|
||||
The internal order will be the same as the ids list provided.
|
||||
|
||||
.. js:function:: get_active_ids
|
||||
|
||||
:returns: the list of current active ids for the dataset
|
||||
|
||||
.. js:function:: activate(id)
|
||||
|
||||
:param Number id: the id to activate
|
||||
:returns: the dataset instance it was called on
|
||||
|
||||
Activates the id provided in the dataset. If no ids are
|
||||
selected, selects the id in the dataset.
|
||||
|
||||
If ids are already selected and the provided id is not in that
|
||||
selection, raises an error.
|
||||
|
||||
.. js:function:: get_active_id
|
||||
|
||||
:returns: the dataset's current active id
|
||||
|
||||
Ad-hoc objects and structural types
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
These objects are not associated with any specific class, they're
|
||||
generally literal objects created on the spot. Names are merely
|
||||
convenient ways to refer to them and their properties.
|
||||
|
||||
.. js:class:: OnFetchEvent
|
||||
|
||||
.. js:attribute:: context
|
||||
|
||||
The context used for the :js:func:`fetch` call (domain set on
|
||||
the :js:class:`openerp.base.DataSet` when ``fetch`` was
|
||||
called)
|
||||
|
||||
.. js:attribute:: domain
|
||||
|
||||
The domain used for the :js:func:`fetch` call
|
||||
|
||||
.. js:attribute:: limit
|
||||
|
||||
The limit with which the original :js:func:`fetch` call was
|
||||
performed
|
||||
|
||||
.. js:attribute:: offset
|
||||
|
||||
The offset with which the original :js:func:`fetch` call was
|
||||
performed
|
||||
|
||||
.. js:attribute:: sort
|
||||
|
||||
The sorting criteria active on the
|
||||
:js:class:`openerp.base.DataSet` when :js:func:`fetch` was
|
||||
called
|
||||
|
||||
.. js:class:: DataSetOptions
|
||||
|
||||
.. js:attribute:: context
|
||||
|
||||
.. js:attribute:: domain
|
||||
|
||||
.. js:attribute:: sort
|
||||
|
||||
Python
|
||||
++++++
|
||||
|
||||
|
@ -499,3 +404,15 @@ Python
|
|||
|
||||
.. _promise object:
|
||||
http://api.jquery.com/deferred.promise/
|
||||
|
||||
.. _.appendTo():
|
||||
http://api.jquery.com/appendTo/
|
||||
|
||||
.. _.prependTo():
|
||||
http://api.jquery.com/prependTo/
|
||||
|
||||
.. _.insertAfter():
|
||||
http://api.jquery.com/insertAfter/
|
||||
|
||||
.. _.insertBefore():
|
||||
http://api.jquery.com/insertBefore/
|
||||
|
|
|
@ -374,11 +374,13 @@ Deletion can be overridden by replacing the
|
|||
calls :js:func:`~openerp.base.DataSet.unlink` in order to remove the records
|
||||
entirely.
|
||||
|
||||
.. note:: the list-wise deletion button (next to the record addition button)
|
||||
simply proxies to :js:func:`~openerp.base.ListView.do_delete` after
|
||||
obtaining all selected record ids, but it is possible to override it
|
||||
alone by replacing
|
||||
:js:func:`~openerp.base.ListView.do_delete_selected`.
|
||||
.. note::
|
||||
|
||||
the list-wise deletion button (next to the record addition button)
|
||||
simply proxies to :js:func:`~openerp.base.ListView.do_delete` after
|
||||
obtaining all selected record ids, but it is possible to override it
|
||||
alone by replacing
|
||||
:js:func:`~openerp.base.ListView.do_delete_selected`.
|
||||
|
||||
Internal API Doc
|
||||
----------------
|
||||
|
|
Loading…
Reference in New Issue