Search code examples
odooodoo-8

Disable or hide save button in Odoo


I'm trying to hide the save button from the top of a form in Odoo v8. Or instead I need to overwrite the save button.

I tried with write = "false". My code on the form view:

<record id="plan_settlement_contract_view_form" 
model="ir.ui.view">
<field name="name">plan.settlement.contract.view.form</field>
<field name="model">plan.settlement</field>
<field name="arch" type="xml">
<form string="Settlement Contract"  write='false'>
</form>

This is what I have now:
enter image description here

And this is what I need: enter image description here


Solution

  • You don't need to override anything, but have to configure the access rights for the business object. In this case you have to change the "write" access right or even more (create, unlink) for a specific access group.

    First thing to read should be the official documentation. The linked one is for Odoo V12, but access control hasn't changed that much since Version 7, so it should be okay for you.

    You should start with model access rights, because records rules are a bit more complex:

    Managed by the ir.model.access records, defines access to a whole model.

    Each access control has a model to which it grants permissions, the permissions it grants and optionally a group.

    Access controls are additive, for a given model a user has access all permissions granted to any of its groups: if the user belongs to one group which allows writing and another which allows deleting, they can both write and delete.

    If no group is specified, the access control applies to all users, otherwise it only applies to the members of the given group.

    Available permissions are creation (perm_create), searching and reading (perm_read), updating existing records (perm_write) and deleting existing records (perm_unlink)

    You'll find the most access rights in every module/app in a .csv file called ir.model.access.csv or in Odoo itself under Settings/Security/Access Controls List. Since Version 9 you have to activate the developer mode to see that menu.

    Edit/Save button won't show for users without write rights. Create button won't show without create rights. Delete action should'nt be there without unlink rights. And so on.

    The topic is too complex to explain everything on this answer.