Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
13274 Lượt xem

I am inheriting a view and I want to add a group to it:

  

        <record id="inherited_view_attendance_tree" model="ir.ui.view&qout;>
           <field name="name">my_inherited_hr_attendance_view</field>
            <field name="model">hr.attendance</field>
            <field name="inherit_id" ref="hr_attendance.view_attendance_tree"/>
            <field name="groups_id" eval="[(4, ref('hr_attendance.group_hr_attendance_user'))]"/>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='worked_hours']" position="attributes">
                    <attribute name="invisible">True</attribute>
                </xpath>
            </field>
        </record>








And I am getting an error like this


odoo.tools.convert.ParseError: while parsing /mnt/extra-addons/my_project_name/views/hr_attendance.xml:5
Inherited view cannot have 'Groups' define on the record. Use 'groups' attributes inside the view definition

How to solve this issue?

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

I found the answer like this


<record id="inherited_view_attendance_tree" model="ir.ui.view&qout;>           <field name="name">my_inherited_hr_attendance_view</field>
            <field name="model">hr.attendance</field>
            <field name="inherit_id" ref="hr_attendance.view_attendance_tree"/>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='worked_hours']" position="attributes">
                    <t groups="hr_attendance.group_hr_attendance_user">
                        <attribute name="invisible">True</attribute>
                    </t>
                </xpath>
            </field>
        </record>


Ảnh đại diện
Huỷ bỏ

I don't think this is a proper solution. It's not working as expected.

Câu trả lời hay nhất

Hello RamaAltayed,

I tested your solution, but the element became hidden for all groups !!
can you help me ?

Below my code:

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


    <field name="name">hide.order.line.for.pss.group</field>


    <field name="model">sale.order</field>


    <field name="inherit_id" ref="sale.view_order_form"/>


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


        <xpath expr="//page[@name='order_lines']" position="attributes">


            <t groups="ns_crm.ns_crm_pss_team">


                <attribute name="invisible">True</attribute>


            </t>


        </xpath>


        <xpath expr="//page[@name='customer_signature']" position="attributes">


            <t groups="ns_crm.ns_crm_pss_team">


                <attribute name="invisible">True</attribute>


            </t>


        </xpath>


    </field>


</record>




Ảnh đại diện
Huỷ bỏ
Tác giả

Yes of course,
Please share your code

below my code:
<pre style="background-color:#2b2b2b;color:#a9b7c6;font-family:'JetBrains Mono',monospace;font-size:9,8pt;"><span style="color:#e8bf6a;">&lt;record </span><span style="color:#bababa;">id</span><span style="color:#6a8759;">=&quot;inherit_view_quotation_form_pss_hide_element&quot; </span><span style="color:#bababa;">model</span><span style="color:#6a8759;">=&quot;ir.ui.view&quot;</span><span style="color:#e8bf6a;">&gt;
</span><span style="color:#e8bf6a;"> &lt;field </span><span style="color:#bababa;">name</span><span style="color:#6a8759;">=&quot;name&quot;</span><span style="color:#e8bf6a;">&gt;</span>Hide Order line for PSS<span style="color:#e8bf6a;">&lt;/field&gt;
</span><span style="color:#e8bf6a;"> &lt;field </span><span style="color:#bababa;">name</span><span style="color:#6a8759;">=&quot;model&quot;</span><span style="color:#e8bf6a;">&gt;</span>sale.order<span style="color:#e8bf6a;">&lt;/field&gt;
</span><span style="color:#e8bf6a;"> &lt;field </span><span style="color:#bababa;">name</span><span style="color:#6a8759;">=&quot;inherit_id&quot; </span><span style="color:#bababa;">ref</span><span style="color:#6a8759;">=&quot;sale.view_order_form&quot;</span><span style="color:#e8bf6a;">/&gt;
</span><span style="color:#e8bf6a;"> &lt;field </span><span style="color:#bababa;">name</span><span style="color:#6a8759;">=&quot;arch&quot; </span><span style="color:#bababa;">type</span><span style="color:#6a8759;">=&quot;xml&quot;</span><span style="color:#e8bf6a;">&gt;
</span><span style="color:#e8bf6a;"> &lt;xpath </span><span style="color:#bababa;">expr</span><span style="color:#6a8759;">=&quot;//page[@name=&apos;order_lines&apos;]&quot; </span><span style="color:#bababa;">position</span><span style="color:#6a8759;">=&quot;attributes&quot;</span><span style="color:#e8bf6a;">&gt;
</span><span style="color:#e8bf6a;"> &lt;t </span><span style="color:#bababa;">groups</span><span style="color:#6a8759;">=&quot;ns_crm.ns_crm_pss_team&quot;</span><span style="color:#e8bf6a;">&gt;
</span><span style="color:#e8bf6a;"> &lt;attribute </span><span style="color:#bababa;">name</span><span style="color:#6a8759;">=&quot;invisible&quot;</span><span style="color:#e8bf6a;">&gt;</span>True<span style="color:#e8bf6a;">&lt;/attribute&gt;
</span><span style="color:#e8bf6a;"> &lt;/t&gt;
</span><span style="color:#e8bf6a;"> &lt;/xpath&gt;
</span><span style="color:#e8bf6a;"> &lt;xpath </span><span style="color:#bababa;">expr</span><span style="color:#6a8759;">=&quot;//page[@name=&apos;customer_signature&apos;]&quot; </span><span style="color:#bababa;">position</span><span style="color:#6a8759;">=&quot;attributes&quot;</span><span style="color:#e8bf6a;">&gt;
</span><span style="color:#e8bf6a;"> &lt;t </span><span style="color:#bababa;">groups</span><span style="color:#6a8759;">=&quot;ns_crm.ns_crm_pss_team&quot;</span><span style="color:#e8bf6a;">&gt;
</span><span style="color:#e8bf6a;"> &lt;attribute </span><span style="color:#bababa;">name</span><span style="color:#6a8759;">=&quot;invisible&quot;</span><span style="color:#e8bf6a;">&gt;</span>True<span style="color:#e8bf6a;">&lt;/attribute&gt;
</span><span style="color:#e8bf6a;"> &lt;/t&gt;
</span><span style="color:#e8bf6a;"> &lt;/xpath&gt;
</span><span style="color:#e8bf6a;"> &lt;/field&gt;
</span><span style="color:#e8bf6a;">&lt;/record&gt;</span></pre>

Tác giả

Are you sure of the groups' external id "ns_crm.ns_crm_pss_team"?
I can't find the "ns_crm" module

Tác giả

I tested your code but with a different group external id and its working very well on odoo16

I have the same issue it's working if I use field like add a new field inside <t but always working for attribute

Câu trả lời hay nhất

Hi,

You can try like below, in the following code the action_cancel button will replace only for the user with group base.group_no_one

<?xml version="1.0" encoding="utf-8"?>


<odoo>


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


        <field name="name">sale.order.inherit.form.view</field>


        <field name="model">sale.order</field>


        <field name="inherit_id" ref="sale.view_order_form"/>


        <field name="groups_id" eval="[(6,0,[ref('base.group_no_one')])]"/>


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


            <button name="action_cancel" position="replace">


            </button>


        </field>


    </record>


</odoo>


Regards

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 8 24
3145
2
thg 1 24
1134
1
thg 11 23
1541
1
thg 7 19
9798
1
thg 12 24
3786