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

Hi, my objective is to limit the visibility of the Cancel Sales Order button to Sales Orders in draft state:

User Group 'All Documents': Should be able to cancel quotes

User Group 'Sales Manager': Should be able to cancel SOs even when confirmed

I did some research on domains and this is what I came up with:

<record id="so_cancel_restrict" model="ir.ui.view">
        <field name="name">sale.order.cancel.restrict</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
            <xpath expr="//button[@name='action_cancel']" position="attributes">
                <attribute name="domain">['|', '&' ('states','=', 'draft'), ('groups', '=', 'sales_team.group_sale_salesman_all_leads'), '|', ('states' , '!=', 'draft'), ('groups', '=', ' sales_team.group_sale_manager')]</attribute>
            </xpath>
        </field>
    </record>


However, this does not work and there seems to be something substantial about domains I don't seem to understand. Hope somebody can help. Thanks!

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

Try this,
This is not using the domain. But will satisfy your need

<record id="so_cancel_restrict" model="ir.ui.view">
        <field name="name">sale.order.cancel.restrict</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
            <xpath expr="//button[@name='action_cancel']" position="replace">
<button name="action_cancel" states="draft,sent" type="object" string="Cancel" groups="sales_team.group_sale_salesman_all_leads"/>
<button name="action_cancel" states="sale" type="object" string="Cancel" groups="sales_team.group_sale_manager"/>
            </xpath>
        </field>
    </record>


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

works like a charme, thanks a lot fasluca!

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 9 17
5518
1
thg 5 25
889
2
thg 11 24
2102
4
thg 2 24
12245
sale / delivery Đã xử lý
1
thg 1 24
1608