Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
1288 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
led 24
19814
0
kvě 23
448
1
srp 21
4650
2
pro 19
3915
2
srp 23
4125