Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
1294 Visualizzazioni

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

Avatar
Abbandona
Risposta migliore

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

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
gen 24
19815
0
mag 23
448
1
ago 21
4651
2
dic 19
3917
2
ago 23
4125