跳至内容
菜单
此问题已终结
该问题已被关闭 原因: Question / Code not indented
Satish Prajapati2025年08月06日 02时35分27秒

I am not understanding how can i Migrate BasicController in Odoo 18. 
This functionality is to keep the scroll position intact when user reloads the page, and show dialog when user closes odoo tab. 

If you can give just a method names from below code which are available in odoo 18 that would be great.

Below code is version 15.0

/** @odoo-module **/

import BasicController from 'web.BasicController';
import FormController from 'web.FormController';
import { patch } from 'web.utils';
import core from 'web.core';
import Dialog from 'web.Dialog';

var qweb = core.qweb;
var _t = core._t;

patch(BasicController.prototype, 'BasicController', {
reload: function () {
const prom = this._super.apply(this, arguments);
const $content = this.$('.o_content');
prom.finally($content.scrollTop.bind($content, $content.scrollTop()))
return prom;
},
leavePageConfirmation: async function(){
var self = this;
return new Promise(function (resolve, reject) {
var buttons = [{
classes: 'btn-primary',
click: () => {
resolve(true);
},
close: true,
text: _t('Leave'),
},
{
close: true,
text: _t('Stay'),
click: () => {
reject();
},
}];
new Dialog(self, _.extend({
size: 'medium',
buttons: buttons,
$content: $(qweb.render('leavePageConfirmation')),
title: _t("Alert"),
})).open({shouldFocusButtons:true});
});
},
saveChanges: async function (recordId) {
// waits for _applyChanges to finish
await this.mutex.getUnlockedDef();
recordId = recordId || this.handle;

if (this.isDirty(recordId)) {
if(this.mode == "edit"){
await this.leavePageConfirmation();
return Promise.resolve();
}
await this.savingDef;
await this.saveRecord(recordId, {
stayInEdit: true,
reload: false,
});
}
},
});

patch(FormController.prototype, 'FormController', {
update: function () {
const prom = this._super.apply(this, arguments);
const $content = this.$('.o_content');
prom.finally($content.scrollTop.bind($content, $content.scrollTop()))
return prom;
},
});
形象
丢弃
相关帖文 回复 查看 活动
0
11月 24
2032
3
10月 23
5086
1
11月 24
2351
0
3月 25
977
1
10月 24
1398