In odoo 18 we can create custom form so in header side are by default show Save and Cancel button so how to hide for particular form ya module not global?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Účetnictví
- Sklad
- PoS
- Project
- MRP
This question has been flagged
<odoo>
<!-- Main form view -->
<record id="view_theappsherpa_registration_form" model="ir.ui.view">
<field name="name">theappsherpa.registration.form</field>
<field name="model">theappsherpa.registration</field>
<field name="arch" type="xml">
<form string="Registration" create="false" edit="true" readonly="0">
<sheet>
<notebook>
<page string="Existing Registration">
<group>
<field name="secret_key"/>
<field name="project_version"/>
<button name="save_registration"
string="Save"
type="object"
class="btn btn-primary"/>
<button name="reset_registration"
string="Reset"
type="object"
class="btn btn-secondary"/>
</group>
</page>
<page string="New Registration">
<group>
<field name="company_name"/>
<field name="username"/>
<field name="email"/>
<field name="password" password="True"/>
<field name="confirm_password" password="True"/>
<field name="phone"/>
<!-- Button dikhaye jab user REGISTER NAHI hua ho -->
<button name="submit_new_user_registration"
string="Register"
type="object"
class="btn btn-success"
invisible="is_registered"/>
<!-- Button dikhaye jab user REGISTER HO CHUKA ho (readonly) -->
<button name="dummy_registered_button"
string="Registered"
type="object"
class="btn btn-secondary"
disabled="1"
invisible="not is_registered"/>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<!-- Save and Discard button are hide -->
<!-- Inherited view to remove Save/Discard -->
<record id="view_theappsherpa_registration_form_inherit" model="ir.ui.view">
<field name="name">theappsherpa.registration.form.inherit</field>
<field name="model">theappsherpa.registration</field>
<field name="inherit_id" ref="theappsherpa.view_theappsherpa_registration_form"/>
<field name="arch" type="xml">
<form position="attributes">
<attribute name="save_on_edit">false</attribute>
<!-- <attribute name="edit">false</attribute> -->
</form>
</field>
</record>
<!-- Action -->
<record id="action_theappsherpa_registration_server" model="ir.actions.server">
<field name="name">Open Registration</field>
<field name="model_id" ref="model_theappsherpa_registration"/>
<field name="binding_model_id" ref="model_theappsherpa_registration"/>
<field name="state">code</field>
<field name="code">action = env['theappsherpa.registration'].get_registration_action()</field>
</record>
<!-- Menu -->
<menuitem id="menu_theappsherpa_registration"
name="Registration"
parent="menu_theappsherpa_root"
action="action_theappsherpa_registration_server"
sequence="110"/>
</odoo>
this is my code and i do not want to non editable form edit="false"
so what i do?
To hide the "Save" and "Discard" buttons on a specific custom form in Odoo 18, you can achieve this by customizing the form view using XML and adding a specific class or condition. Here's how you can do it: 1. **Identify the Form View**: Locate the form view that you want to customize. This is typically done in the form view XML file of your custom module. 2. **Override the Form View**: In your custom module, you can override the existing form view to add attributes or classes that will hide the buttons. You will need to use XPath to identify the buttons within the form view. 3. **Add Custom Attributes**: Use the `attrs` attribute to conditionally hide these buttons. You can apply conditions based on record data or simply hide them using CSS. Here's a basic example of how you might modify the form view in the XML: ```xml Custom Form your.model oe_hidden ``` 4. **Custom CSS (optional)**: If adding attributes is not sufficient, you may need to add custom CSS to hide these buttons: ```css .oe_hidden .o_form_buttons_edit { display: none !important; } ``` 5. **Restart Odoo and Update the Module**: After making these changes, restart the Odoo server and update your module to apply the changes. This approach specifically targets the form view you want to customize and hides the buttons without affecting other forms globally. Adjust the XPath expression and conditions as needed, based on your specific form structure and requirements.
Hi
In Odoo 18, the Save and Discard (Cancel) buttons in the form view header are added by default when the view is in edit mode.
If you want to hide them only for a particular form (or module) and not globally, you can do it by overriding the form view with create="false" and edit="false".
or
try this,
<form edit="0">
Hope it helps
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Přihlásit seRelated Posts | Odpovědi | Zobrazení | Aktivita | |
---|---|---|---|---|
|
0
srp 25
|
1 | ||
|
0
srp 25
|
116 | ||
|
1
srp 25
|
355 | ||
|
1
srp 25
|
390 | ||
|
1
srp 25
|
718 |