Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UPD] web_dialog_size: reduce rpc call to get config #1

Open
wants to merge 1 commit into
base: 15.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions web_dialog_size/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import ir_config_parameter
from . import ir_http
14 changes: 14 additions & 0 deletions web_dialog_size/models/ir_http.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2023 Camptocamp
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class Http(models.AbstractModel):
_inherit = 'ir.http'

def session_info(self):
IrConfigSudo = self.env['ir.config_parameter'].sudo()
session_info = super().session_info()
session_info.update(IrConfigSudo.get_web_dialog_size_config())
return session_info
26 changes: 11 additions & 15 deletions web_dialog_size/static/src/js/web_dialog_size.esm.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
/** @odoo-module **/

var session = require('web.session');
import {ActionDialog} from "@web/webclient/actions/action_dialog";
import {patch} from "@web/core/utils/patch";
import rpc from "web.rpc";
const {Component} = owl;
const {onMounted} = owl.hooks;

export class ExpandButton extends Component {
setup() {
this.last_size = this.props.getsize();
this.config = rpc.query({
model: "ir.config_parameter",
method: "get_web_dialog_size_config",
});

onMounted(() => {
var self = this;
this.config.then(function (r) {
if (r.default_maximize && stop) {
self.dialog_button_extend();
}
});
});
if (session.default_maximize) {
this.last_size = "modal-lg";
} else {
this.last_size = this.props.getsize();
}
}

dialog_button_extend() {
Expand All @@ -40,6 +31,11 @@ patch(ActionDialog.prototype, "web_dialog_size.ActionDialog", {
this._super(...arguments);
this.setSize = this.setSize.bind(this);
this.getSize = this.getSize.bind(this);

if (session.default_maximize) {
this.last_size = "modal-lg";
this.size = "dialog_full_screen";
}
},

setSize(size) {
Expand Down
14 changes: 1 addition & 13 deletions web_dialog_size/static/src/js/web_dialog_size.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
odoo.define("web_dialog_size.web_dialog_size", function (require) {
"use strict";

var rpc = require("web.rpc");
var Dialog = require("web.Dialog");

var config = rpc.query({
model: "ir.config_parameter",
method: "get_web_dialog_size_config",
});

Dialog.include({
willStart: function () {
var self = this;
Expand All @@ -19,13 +13,6 @@ odoo.define("web_dialog_size.web_dialog_size", function (require) {
self.$modal
.find(".dialog_button_restore")
.on("click", self.proxy("_restore"));
return config.then(function (r) {
if (r.default_maximize) {
self._extending();
} else {
self._restore();
}
});
});
},

Expand Down Expand Up @@ -66,4 +53,5 @@ odoo.define("web_dialog_size.web_dialog_size", function (require) {
dialog.find(".dialog_button_extend").show();
},
});

});