3
0
Fork 0

[FIX] web_m2x_options: Avoid constant RPC calls

Instead of calling interactively to the server to get the options, they are stored at the beginning of the session.
17.0
chien 2023-07-28 09:30:04 +07:00 committed by manu
parent aa582d1c50
commit d70acf8634
6 changed files with 23 additions and 30 deletions

View File

@ -6,7 +6,7 @@
{
"name": "web_m2x_options",
"version": "16.0.1.1.0",
"version": "16.0.1.1.1",
"category": "Web",
"author": "initOS GmbH,"
"ACSONE SA/NV, "

View File

@ -55,6 +55,11 @@ msgstr ""
msgid "Discard"
msgstr ""
#. module: web_m2x_options
#: model:ir.model,name:web_m2x_options.model_ir_http
msgid "HTTP Routing"
msgstr ""
#. module: web_m2x_options
#. odoo-javascript
#: code:addons/web_m2x_options/static/src/components/form.esm.js:0

View File

@ -1 +1,2 @@
from . import ir_config_parameter
from . import ir_http

View File

@ -0,0 +1,11 @@
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({"web_m2x_options": IrConfigSudo.get_web_m2x_options()})
return session_info

View File

@ -19,7 +19,7 @@ import {patch} from "@web/core/utils/patch";
import {sprintf} from "@web/core/utils/strings";
import {useService} from "@web/core/utils/hooks";
const {Component, onWillStart} = owl;
const {Component} = owl;
/**
* Patch Many2ManyTagsField
@ -157,16 +157,7 @@ CreateConfirmationDialog.template =
patch(Many2OneField.prototype, "web_m2x_options.Many2OneField", {
setup() {
this._super(...arguments);
const ormService = useService("orm");
this.user_context = Component.env.session.user_context;
onWillStart(async () => {
this.ir_options = await ormService.call(
"ir.config_parameter",
"get_web_m2x_options",
[],
{context: this.user_context}
);
});
this.ir_options = Component.env.session.web_m2x_options;
},
/**
* @override
@ -371,12 +362,7 @@ patch(FormController.prototype, "web_m2x_options.FormController", {
* add more method to add subview limit on formview
*/
async _setSubViewLimit() {
const ir_options = await this.model.orm.call(
"ir.config_parameter",
"get_web_m2x_options",
[],
{context: this.user_context}
);
const ir_options = Component.env.session.web_m2x_options;
const activeFields = this.archInfo.activeFields,
fields = this.props.fields,

View File

@ -3,8 +3,7 @@
import {Many2XAutocomplete} from "@web/views/fields/relational_utils";
import {patch} from "@web/core/utils/patch";
import {sprintf} from "@web/core/utils/strings";
import {useService} from "@web/core/utils/hooks";
const {Component, onWillStart} = owl;
const {Component} = owl;
export function is_option_set(option) {
if (_.isUndefined(option)) return false;
@ -16,16 +15,7 @@ export function is_option_set(option) {
patch(Many2XAutocomplete.prototype, "web_m2x_options.Many2XAutocomplete", {
setup() {
this._super(...arguments);
const ormService = useService("orm");
this.user_context = Component.env.session.user_context;
onWillStart(async () => {
this.ir_options = await ormService.call(
"ir.config_parameter",
"get_web_m2x_options",
[],
{context: this.user_context}
);
});
this.ir_options = Component.env.session.web_m2x_options;
},
async loadOptionsSource(request) {