mirror of https://github.com/OCA/web.git
[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.pull/2575/head
parent
aa7be82225
commit
b36b8b804e
|
@ -1 +1,2 @@
|
||||||
from . import ir_config_parameter
|
from . import ir_config_parameter
|
||||||
|
from . import ir_http
|
||||||
|
|
|
@ -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
|
|
@ -19,7 +19,7 @@ import {patch} from "@web/core/utils/patch";
|
||||||
import {sprintf} from "@web/core/utils/strings";
|
import {sprintf} from "@web/core/utils/strings";
|
||||||
import {useService} from "@web/core/utils/hooks";
|
import {useService} from "@web/core/utils/hooks";
|
||||||
|
|
||||||
const {Component, onWillStart} = owl;
|
const {Component} = owl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Patch Many2ManyTagsField
|
* Patch Many2ManyTagsField
|
||||||
|
@ -157,16 +157,7 @@ CreateConfirmationDialog.template =
|
||||||
patch(Many2OneField.prototype, "web_m2x_options.Many2OneField", {
|
patch(Many2OneField.prototype, "web_m2x_options.Many2OneField", {
|
||||||
setup() {
|
setup() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
const ormService = useService("orm");
|
this.ir_options = Component.env.session.web_m2x_options;
|
||||||
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}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* @override
|
* @override
|
||||||
|
@ -371,12 +362,7 @@ patch(FormController.prototype, "web_m2x_options.FormController", {
|
||||||
* add more method to add subview limit on formview
|
* add more method to add subview limit on formview
|
||||||
*/
|
*/
|
||||||
async _setSubViewLimit() {
|
async _setSubViewLimit() {
|
||||||
const ir_options = await this.model.orm.call(
|
const ir_options = Component.env.session.web_m2x_options;
|
||||||
"ir.config_parameter",
|
|
||||||
"get_web_m2x_options",
|
|
||||||
[],
|
|
||||||
{context: this.user_context}
|
|
||||||
);
|
|
||||||
|
|
||||||
const activeFields = this.archInfo.activeFields,
|
const activeFields = this.archInfo.activeFields,
|
||||||
fields = this.props.fields,
|
fields = this.props.fields,
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
import {Many2XAutocomplete} from "@web/views/fields/relational_utils";
|
import {Many2XAutocomplete} from "@web/views/fields/relational_utils";
|
||||||
import {patch} from "@web/core/utils/patch";
|
import {patch} from "@web/core/utils/patch";
|
||||||
import {sprintf} from "@web/core/utils/strings";
|
import {sprintf} from "@web/core/utils/strings";
|
||||||
import {useService} from "@web/core/utils/hooks";
|
const {Component} = owl;
|
||||||
const {Component, onWillStart} = owl;
|
|
||||||
|
|
||||||
export function is_option_set(option) {
|
export function is_option_set(option) {
|
||||||
if (_.isUndefined(option)) return false;
|
if (_.isUndefined(option)) return false;
|
||||||
|
@ -16,16 +15,7 @@ export function is_option_set(option) {
|
||||||
patch(Many2XAutocomplete.prototype, "web_m2x_options.Many2XAutocomplete", {
|
patch(Many2XAutocomplete.prototype, "web_m2x_options.Many2XAutocomplete", {
|
||||||
setup() {
|
setup() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
const ormService = useService("orm");
|
this.ir_options = Component.env.session.web_m2x_options;
|
||||||
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}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async loadOptionsSource(request) {
|
async loadOptionsSource(request) {
|
||||||
|
|
Loading…
Reference in New Issue