1
votes

I want to order Kanban Items in Odoo with drag and drop. I have own integer field 'k_order' and used this field for the model _order="k_order".

Kanban Items are displayed(sorted) correctly according to the k_order fields. But when I change the order(vertically), it does not save it. After refreshing the browser , it goes to the old position.

How can I achieve above behavior(sorting)? I have also used widget="handel" for field k_order.

This sorting in tree view works as desired.

2

2 Answers

1
votes

Seems that the kanban widget resequencing only works with field sequence, the default sequencing field for odoo models.

You can see that part here -> module web_kanban

    resequence: function (ids) {
        if ((ids.length <= 1) || !this.relation) {
            return;
        }
        new data.DataSet(this, this.relation).resequence(ids).done(function (r) {
            if (!r) {
                console.warn('Resequence could not be complete. ' +
                    'Maybe the model does not have a "sequence" field?');
            }
        });
    },

    resequence_column: function (col) {
        if (_.indexOf(this.fields_keys, 'sequence') > -1) {
            this.dataset.resequence(col.get_ids());
        }
    },
0
votes

Thanks for the tip. I have done a workaround and posting here as it may be useful for someone else. I have mapped 'sequence' field to my own field 'order' with inverse function as below;

my_order = fields.Integer(string="My order field", compute='_compute_order', inverse='_inverse_order',store=True )



@api.depends('sequence')
def _compute_order(self):
    for rec in self:
        rec.my_order =rec.sequence


def _inverse_order(self):
    for rec in self:
        rec.sequence = rec.my_order