Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
402 Widoki

How can i disable create and edit functionality in many2one field for specific modal like product.template  

following code is disable functionality for all many2one field but i need to disable for specific modal like product.template 


/** @odoo-module **/
import {patch} from "@web/core/utils/patch";
import {many2OneField} from "@web/views/fields/many2one/many2one_field";


patch(many2OneField, {
    extractProps({ attrs, context, decorations, options, string }, dynamicInfo) {
        var res = super.extractProps({ attrs, context, decorations, options, string }, dynamicInfo)
        res.canQuickCreate = false
        res.canCreateEdit = false
        return res
    },
});
Awatar
Odrzuć
Najlepsza odpowiedź

Hii,


Here's the modified version of your code:
/** @odoo-module **/


import { patch } from "@web/core/utils/patch";

import { many2OneField } from "@web/views/fields/many2one/many2one_field";


patch(many2OneField, {

    extractProps({ attrs, context, decorations, options, string }, dynamicInfo) {

        const res = super.extractProps({ attrs, context, decorations, options, string }, dynamicInfo);


        if (res.resModel === 'product.template') {

            res.canQuickCreate = false;

            res.canCreateEdit = false;

        }


        return res;

    },

});

i hope it is usefull

Awatar
Odrzuć

I am interested this .. but is there any way do by STUDIO

Autor

it is still not working...can you please give me another solution ?