mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[FIX] web_auto_paginate: servers can respond in their own time, don't rely on timeouts
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
# from . import test
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
'complexity': 'expert',
|
'complexity': 'expert',
|
||||||
'depends': [
|
'depends': [
|
||||||
'web',
|
'web',
|
||||||
|
# 'stock', # Only for testing
|
||||||
],
|
],
|
||||||
'data': [
|
'data': [
|
||||||
'views/web_views.xml',
|
'views/web_views.xml',
|
||||||
|
|||||||
@@ -5,15 +5,21 @@ odoo.define('web_auto_paginate.action_manager', function (require) {
|
|||||||
|
|
||||||
ActionManager.include({
|
ActionManager.include({
|
||||||
_executeCloseAction: function (action, options) {
|
_executeCloseAction: function (action, options) {
|
||||||
|
var res = this._super(action, options);
|
||||||
if (action.auto_paginate) {
|
if (action.auto_paginate) {
|
||||||
var $_o_pager_next = $('button.o_pager_next');
|
res.then(auto_next_record);
|
||||||
if ($_o_pager_next.length >= 1) {
|
|
||||||
setTimeout(function(){$_o_pager_next[0].click()}, 500)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return this._super(action, options);
|
return res;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function auto_next_record() {
|
||||||
|
var $_o_pager_next = $('button.o_pager_next');
|
||||||
|
if ($_o_pager_next.length >= 1) {
|
||||||
|
$_o_pager_next = $_o_pager_next[0];
|
||||||
|
$_o_pager_next.click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ActionManager;
|
return ActionManager;
|
||||||
});
|
});
|
||||||
|
|||||||
25
web_auto_paginate/test.py
Normal file
25
web_auto_paginate/test.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# include this file and depend on 'stock' to test on cancel button
|
||||||
|
# This intentionally introduces a lot of delay around stock pickings
|
||||||
|
# to help test the UI's responsiveness.
|
||||||
|
|
||||||
|
from time import sleep
|
||||||
|
from odoo import api, models
|
||||||
|
|
||||||
|
import logging
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class StockPicking(models.Model):
|
||||||
|
_inherit = 'stock.picking'
|
||||||
|
|
||||||
|
def action_cancel(self):
|
||||||
|
super().action_cancel()
|
||||||
|
return {
|
||||||
|
'auto_paginate': True,
|
||||||
|
}
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def read(self, fields=None, load='_classic_read'):
|
||||||
|
_logger.warn('sleeping')
|
||||||
|
sleep(1)
|
||||||
|
return super().read(fields=fields, load=load)
|
||||||
Reference in New Issue
Block a user