跳至內容
選單
此問題已被標幟
問題已關閉 原因: 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
2020
3
10月 23
5084
1
11月 24
2322
0
3月 25
974
1
10月 24
1396