I am using odoo 17, I have a form view for managing bank transactions. I want the credit and debit fields to be visible when creating a new transaction. However, after saving the transaction, I want these fields to be hidden and no longer visible on the form.
here's the form view:
<record id="view_oui_finance_transaction_form" model="ir.ui.view">
<field name="name">oui.finance.transaction.form</field>
<field name="model">oui.finance.transaction</field>
<field name="arch" type="xml">
<form string="Transactions">
<sheet>
<div class="oe_title">
<label for="reference" class="oe_edit_only"/>
<h1><field name="reference"/></h1>
</div>
<group>
<group>
<field name="date"/>
<field name="debit" modifiers="{'invisible': [['__mode', '!=', 'create']]}"/>
<field name="operation"/>
</group>
<group>
<field name="value_date"/>
<field name="credit" modifiers="{'invisible': [['__mode', '!=', 'create']]}"/>
<field name="account_id"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
thank you for your solution, i added the code you gave me but i got this error:
Error while validating view near:
<form string="Transactions" __validate__="1">
<sheet>
<div class="oe_title">
Field '__mode' used in modifier 'invisible' (__mode != 'create') must be present in view but is missing.
View error context:
{'file': '/mnt/extra-addons/ouifinance/views/transaction_views.xml',
'line': 1,
'name': 'oui.finance.transaction.form',
'view': ir.ui.view(1186,),
'view.model': 'oui.finance.transaction',
'view.parent': ir.ui.view(),
'xmlid': 'view_oui_finance_transaction_form'}