تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
لقد تم إغلاق هذا السؤال والسبب: Question / Code not indented
بواسطة Satish Prajapati في 06 أغسطس, 2025 02:35:27
963 أدوات العرض

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
نوفمبر 24
2062
3
أكتوبر 23
5109
1
نوفمبر 24
2382
0
مارس 25
995
1
أكتوبر 24
1412