コンテンツへスキップ
メニュー
この質問にフラグが付けられました
質問は終了しました 理由: Question / Code not indented
次により: Satish Prajapati on 2025年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
2049
3
10月 23
5099
1
11月 24
2364
0
3月 25
990
1
10月 24
1407