[WIP] Resequence

bzr revid: fme@openerp.com-20120814221334-8arihwthpwictk3y
This commit is contained in:
Fabien Meghazi 2012-08-15 00:13:34 +02:00
parent cc406bc692
commit f1531572de
2 changed files with 9 additions and 5 deletions

View File

@ -1139,7 +1139,10 @@ class DataSet(openerpweb.Controller):
@openerpweb.jsonrequest
def resequence(self, req, model, ids):
m = req.session.model(model)
print "TODO: write resequencing"
if not len(m.fields_get(['sequence'])):
return False
for i in range(len(ids)):
m.write([ids[i]], { 'sequence': i })
return True
class DataGroup(openerpweb.Controller):

View File

@ -307,7 +307,9 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
self.groups.splice(stop_index, 0, tmp_group);
var new_sequence = _.pluck(self.groups, 'value');
(new instance.web.DataSet(self, self.group_by_field.relation)).resequence(new_sequence).then(function(r) {
console.log(r);
if (r === false) {
console.error("Kanban: could not resequence model '%s'. Probably no 'sequence' field.", self.group_by_field.relation);
}
});
}
self.$('.oe_kanban_record').show();
@ -555,9 +557,8 @@ instance.web_kanban.KanbanGroup = instance.web.Widget.extend({
do_save_sequences: function() {
var self = this;
if (_.indexOf(this.view.fields_keys, 'sequence') > -1) {
_.each(this.records, function(record, index) {
self.view.dataset.write(record.id, { sequence : index });
});
var new_sequence = _.pluck(this.records, 'id');
self.view.dataset.resequence(new_sequence);
}
},
/**