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

This is Odoo 14 code that inherit the group and make create and edit False Which Works Great
<record id="product_template_merch_only_form_view" model="ir.ui.view">

<field name="name">product.template.readonly.form</field>

<field name="model">product.template</field>

<field name="inherit_id" ref="product.product_template_form_view"/>

<field name="groups_id" eval="[(4, ref('group_nocreateedit_user'))]"/>

<field name="arch" type="xml">

<data><xpath expr="//form" position="attributes">

<attribute name="edit">false</attribute>

<attribute name="create">false</attribute>

<attribute name="name">Product Template</attribute>

</xpath>

</data>

</field>

</record>

now this same i want to work with odoo17 but from odoo16 "groups_id" remove from "ir.ui.view" so how to do that in odoo17 if any other field then we can make it readonly based on _compute function but i did not get anything for this

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

groups_id is no longer directly used in ir.ui.view in Odoo 16 and later.  The way to control view access based on groups has changed.

 Here's how you can achieve the same "no create/edit" functionality for your product template view in Odoo 17:

* Create a new access control rule:


<record id="access_product_template_merch_only" model="ir.model.access">

    <field name="name">Product Template Merch Only </field>

    <field name="model_id" ref="model_product_template"/>  

    <field name="group_id" ref="group_nocreateedit_user"/>

     <field name="perm_read">1</field>

    <field name="perm_create">0</field>

    <field name="perm_write">0</field>

    <field name="perm_unlink">0</field>

</record>


*  Hide Create Button :


<record id="product_template_merch_only_form_view" model="ir.ui.view">

    <field name="name">product.template.readonly.form</field>

    <field name="model">product.template</field>

    <field name="inherit_id" ref="product.product_template_form_view"/>

    <field name="arch" type="xml">

        <xpath expr="//form" position="attributes">

                <attribute name="create">0</attribute>

            </xpath>

    </field>

</record>


Hope it helps

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
sty 24
19814
0
maj 23
448
1
sie 21
4649
2
gru 19
3915
2
sie 23
4125