You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Odoo 10的one2many表单视图中移除/隐藏保存并新建按钮?

Hiding/Removing the "Save & New" Button in Odoo 10 One2Many Form Views

Hey there! Let me walk you through how to hide or remove the "Save & New" button from a one2many sub-form in Odoo 10. I’ve tackled this scenario a few times, so here are the most practical approaches depending on your needs:

Method 1: XML View Inheritance (Permanent Hide)

The simplest way is to modify the sub-form’s XML view to mark the button as invisible. You’ll need to inherit the form view of the model linked via your one2many field.

For example, if your one2many field points to sale.order.line, create an inherited view like this:

<odoo>
    <record id="inherit_sale_order_line_form" model="ir.ui.view">
        <field name="name">sale.order.line.form.inherit</field>
        <field name="model">sale.order.line</field>
        <field name="inherit_id" ref="sale.view_order_line_form"/>
        <field name="arch" type="xml">
            <!-- Target the "Save & New" button and set it to invisible -->
            <button name="save_and_new" position="attributes">
                <attribute name="invisible">1</attribute>
            </button>
        </field>
    </record>
</odoo>
  • Replace sale.order.line with your target model.
  • Update ref="sale.view_order_line_form" to match the external ID of the original form view for your model.
  • After adding this code to your module’s XML file, upgrade the module to apply the changes.

Method 2: Dynamic Visibility Control

If you need to hide the button based on specific conditions (like a field’s value), use the attrs attribute instead of a static invisible flag:

<button name="save_and_new" position="attributes">
    <attribute name="attrs">{'invisible': [('state', '=', 'done')]}</attribute>
</button>

In this example, the button will be hidden when the state field equals done. Adjust the condition to match your model’s fields and business logic.

Method 3: Restrict by User Groups

If you only want certain users to see the button (and hide it from everyone else), use the groups attribute. Assign it to a group that’s not accessible to most users, like base.group_no_one (which has no members by default):

<button name="save_and_new" position="attributes">
    <attribute name="groups">base.group_no_one</attribute>
</button>

This effectively hides the button from all users unless you explicitly add someone to that group.

Quick Notes:

  • Always make sure you’re inheriting the correct form view for your one2many-linked model. You can find the view’s external ID by checking the original module’s XML files or via Odoo’s developer mode (View > Manage Views).
  • After making changes, don’t forget to upgrade your module or refresh the view in developer mode to see the updates take effect.

内容的提问来源于stack exchange,提问作者Lakshminarayanan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:15:08