mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
Add method to refresh a shuttle screen
Example of usage in an odoo shell, when a screen is open: >>> self.env['vertical.lift.shuttle'].browse(1)._operation_for_mode().operation_descr = 'foo' >>> self.env['vertical.lift.shuttle'].browse(1)._send_notification_refresh() >>> env.cr.commit() Provided the longpolling is correctly configured with a proxy, the screen should immediately refresh with 'foo' as operation description.
This commit is contained in:
committed by
Hai Lang
parent
06fa3da67f
commit
cf5848c2c3
@@ -5,6 +5,7 @@ var core = require('web.core');
|
||||
var KanbanRecord = require('web.KanbanRecord');
|
||||
var basicFields = require('web.basic_fields');
|
||||
var field_registry = require('web.field_registry');
|
||||
var FormController = require('web.FormController');
|
||||
var FieldInteger = basicFields.FieldInteger;
|
||||
|
||||
KanbanRecord.include({
|
||||
@@ -44,6 +45,53 @@ var ExitButton = FieldInteger.extend({
|
||||
clear_breadcrumbs: true,
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
|
||||
FormController.include({
|
||||
init: function (parent, model, renderer, params) {
|
||||
this._super.apply(this, arguments);
|
||||
if(this.modelName.startsWith('vertical.lift.operation.')) {
|
||||
this.call('bus_service', 'addChannel', 'notify_vertical_lift_screen');
|
||||
this.call(
|
||||
'bus_service', 'on', 'notification',
|
||||
this, this.vlift_bus_notification
|
||||
);
|
||||
this.call('bus_service', 'startPolling');
|
||||
}
|
||||
},
|
||||
vlift_bus_notification: function (notifications) {
|
||||
var self = this;
|
||||
_.each(notifications, function (notification) {
|
||||
var channel = notification[0];
|
||||
var message = notification[1];
|
||||
if(channel === 'notify_vertical_lift_screen') {
|
||||
switch(message['action']) {
|
||||
case 'refresh':
|
||||
self.vlift_bus_action_refresh(message['params']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
vlift_bus_action_refresh: function(params) {
|
||||
var selectedIds = this.getSelectedIds();
|
||||
if(!selectedIds.length){
|
||||
return;
|
||||
}
|
||||
var currentId = selectedIds[0];
|
||||
if(params['id'] === currentId && params['model'] == this.modelName){
|
||||
this.reload();
|
||||
}
|
||||
},
|
||||
destroy: function () {
|
||||
if(this.modelName.startsWith('vertical.lift.operation.')) {
|
||||
this.call('bus_service', 'deleteChannel', 'notify_vertical_lift_screen');
|
||||
}
|
||||
this._super.apply(this, arguments);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
field_registry.add('vlift_shuttle_exit_button', ExitButton);
|
||||
|
||||
Reference in New Issue
Block a user