无法将组sale_manger添加到action_invoice_cancel按钮 [英] Not able to add the group sale_manger to action_invoice_cancel button

查看:111
本文介绍了无法将组sale_manger添加到action_invoice_cancel按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将sale_manager组添加到customer invoice中的action_invoice_cancel(发票取消)按钮.我的目标是仅在sale_manager中为用户看到该按钮. 我这样尝试过:

I want to add sale_manager group to the action_invoice_cancel (Invoice Cancel) button in the customer invoice . My aim is to see that button only for the users in the sale_manager. I tried like this :

代码

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <record id="orchid_invoice_cancel_request_inherit" model="ir.ui.view">
        <field name="name">invoice_cancel_request</field>
        <field name="model">account.invoice</field>
        <field name="inherit_id" ref="account.invoice_form"/>
        <field name="arch" type="xml">
             <button name="action_invoice_cancel" position="after">
                <button string="Cancel Request" type="object" name="cancel_request" attrs="{'invisible':[('state','not in',('open','paid'))]}"/>
             </button>
             <field name = "move_id" position="after">
                <field name = "od_cancel_reason" />
             </field>

             <button name="action_invoice_cancel" position="replace">
                <button name="action_invoice_cancel" type="object" states="draft,proforma2,open" string="Cancel Invoice" groups="base.group_no_one,sales_team.group_sale_manager"/>
             </button>

        </field>
    </record>
</odoo>

但是它不起作用.该怎么办 ? 预先感谢.

But its not working. What to do ? Thanks in advance.

推荐答案

发票表单的取消发票按钮可以修改(通过attributes替换或更新).根据您的问题,您的模块很可能没有加载您的视图,或者您没有重新升级模块.

The invoice form's Cancel Invoice button can certainly be modified (replaced or updated via attributes). Based on your question, it seems most likely that your module either does not load your view or maybe you did not re-upgrade your module.

关于您的方法,我将展示如何使用attributes来更改该按钮的groups而不需要完全替换它(如@Cherif所建议的那样).

As for your approach, I will show how to use attributes to change the groups of that button without needing to replace it entirely (as @Cherif suggested).

这将更新现有元素的一个属性",而无需重新定义整个元素.您应该可以更改元素的任何一个(或多个)属性,但是我们只想更改您的情况下的groups.

This will update one "attribute" of an existing element without needing to redefine the entire element. You should be able to change any one (or more) of the attributes for an element, however we just want to change groups in your case.

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <record id="orchid_invoice_cancel_request_inherit" model="ir.ui.view">
        <field name="name">invoice_cancel_request</field>
        <field name="model">account.invoice</field>
        <field name="inherit_id" ref="account.invoice_form"/>
        <field name="arch" type="xml">
             <button name="action_invoice_cancel" position="attributes">
                <attribute name="groups">sales_team.group_sale_manager"</attribute>
             </button>
        </field>
    </record>
</odoo>

视图文档

这篇关于无法将组sale_manger添加到action_invoice_cancel按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆