Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
4 Відповіді
22174 Переглядів

By default limit for number records per page - 80. Is it possible change this limit to another default value for field x2many? For example to 10.

It is usefull for popup window, if we have long list, better go through pages.

Аватар
Відмінити
Найкраща відповідь

You can change the default limit in this file:

web/addons/web/static/src/js/view_list.js

If you want to set the default limit to 10, the you can change the paragraph

defaults: {
    // records can be selected one by one
    'selectable': true,
    // list rows can be deleted
    'deletable': false,
    // whether the column headers should be displayed
    'header': true,
    // display addition button, with that label
    'addable': _lt("Create"),
    // whether the list view can be sorted, note that once a view has been
    // sorted it can not be reordered anymore
    'sortable': true,
    // whether the view rows can be reordered (via vertical drag & drop)
    'reorderable': true,
    'action_buttons': true,
    //whether the editable property of the view has to be disabled
    'disable_editable_mode': false,
},

to

defaults: {
    // records can be selected one by one
    'selectable': true,
    // list rows can be deleted
    'deletable': false,
    // whether the column headers should be displayed
    'header': true,
    // display addition button, with that label
    'addable': _lt("Create"),
    // whether the list view can be sorted, note that once a view has been
    // sorted it can not be reordered anymore
    'sortable': true,
    // whether the view rows can be reordered (via vertical drag & drop)
    'reorderable': true,
    'action_buttons': true,
    //whether the editable property of the view has to be disabled
    'disable_editable_mode': false,
    'limit': 10,
},
Аватар
Відмінити
Автор

Thanks, it work! BTW what "defaults.limit" and "options.limit". Where it setup?

I have updated my answer. It is better to use the defaults-value for the limit. I was not able to find howto setup the "options".

Найкраща відповідь

Hi guys, this code is great but why don't you use standard functionality instead of editing in core web? There is already limit parameter predefined you can use declaring x2many field, for instance to limit number of sale order lines shown in sale order you can define:

        'order_line': fields.one2many('sale.order.line', 'order_id', 'Order Lines', limit=10, readonly=True, states={'draft': [('readonly', False)]}),

Let's use standard functionality!

Аватар
Відмінити

Yes, but with this solution you doesn't have the possibility to change page. You only display 10 entries and you can't see the next entries.

Найкраща відповідь

Change view_form.js​ > instance.web.form.FieldMany2Many​ in your branch to include the limit​:

initialize_content: function() {
var self = this;

this.$el.addClass('oe_form_field oe_form_field_many2many');

this.list_view = new instance.web.form.Many2ManyListView(this, this.dataset, false, {
'addable': null,
'deletable': this.get("effective_readonly") ? false : true,
'selectable': this.multi_selection,
'sortable': false,
'reorderable': false,
'import_enabled': false,
'limit': self.options.limit,
});
var embedded = (this.field.views || {}).tree;

Then specify the required limit in your field declaration in XML: options="{'no_create': True, 'limit': 3}"


Now each field can have its own limit of records.

Аватар
Відмінити
Найкраща відповідь

You can change in view_form.js. _.extend(view.options, { ....., limit: self.options.limit || 5, //5 is default value }

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
0
черв. 15
4160
0
черв. 15
4473
0
черв. 16
6291
0
бер. 15
4536
4
жовт. 24
4258