Reputation: 593
In register payment wizard , I added 2 fields. I want to make fields invisibles according to 'move_type'
if move_type == 'in_invoice' --> field1 : invisible
if move_type == 'out_invoice' --> field2 : invisible
<record id="view_account_payment_register_form_inherit_payment_test" model="ir.ui.view">
<field name="name">account.payment.register.form.inherit.payment.test</field>
<field name="model">account.payment.register</field>
<field name="inherit_id" ref="account.view_account_payment_register_form"/>
<field name="arch" type="xml">
<xpath expr="//group/field[@name='communication']" position="after">
<field name="field1"/>
<field name="field2"/>
</xpath>
</field>
</record>
How can I do it ? Thanks.
Upvotes: 2
Views: 1369
Reputation: 2428
You should use attrs
attribute.
<field name="move_type" invisible="1" /> <!-- you need this for attrs domain work -->
<field name="field1" attrs='{"invisible":[("move_type","=","in_invoice")]}' />
<field name="field2" attrs='{"invisible":[("move_type","=","out_invoice")]}' />
You need to have move_type
in your datamodel for this to work. If not, add it as relative field. You can do it like this in your wizard code
move_type = fields.String(related="account_move.move_type")
Upvotes: 1
Reputation: 26698
You can use the payment_type
, the payment type will be Send Money
for vendor bills and Receive Money
for customer invoices.
Example:
<!-- move_type == in_invoice (Vendor Bill) -> payment_type == outbound (Send Money) -->
<field name="field1" attrs="{'invisible': [('payment_type', '=', 'outbound')]}"/>
<!-- move_type == out_invoice (Customer Invoice) -> payment_type == inbound (Receive Money) -->
<field name="field2" attrs="{'invisible': [('payment_type', '=', 'inbound')]}"/>
Upvotes: 3