Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
1275 Представления

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

Аватар
Отменить
Лучший ответ

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

Аватар
Отменить
Related Posts Ответы Просмотры Активность
2
янв. 24
19797
0
мая 23
448
1
авг. 21
4641
2
дек. 19
3908
2
авг. 23
4114