p.ry
p.ry

Reputation: 489

Replacing form view that appears elsewhere too in odoo 12

By default, the create contact form from Contacts and create Vendor form from Purchase appears to have the same External ID ie, base.view_partner_form. I want to replace the form view for create contact. Now, i know that to replace a view i'll have to do this in my custom form view.

<field name="inherit_id" ref="external_id_of_form"/>

So how can i replace the form view in this case so that only the contact create form gets replaced? Can i replace the form view based on action? `

Upvotes: 0

Views: 198

Answers (1)

CZoellner
CZoellner

Reputation: 14801

You're not "replacing" by inheriting, but changing/extending other views.

Indeed you should change the menu actions, because it is possible to set the target views.

But there is more than one approach. I'll try to list some of them, plus you can combine them.

full single views

  • one or more ir.ui.view of same type for the same model
  • can be referenced in actions and code
  • only one of them can be the default view of that type, which odoo will use for example in actions without a view reference, keep that in mind!

one base form with different extension views

  • one base view for a model
  • multiple primary extension views to that base view
  • you can either use those primary extensions as reference in actions
  • or you can set security groups in those extensions to show these extensions only to users of those groups

one view with extension views

  • that's the usual approach
  • you have a base view and lot of extensions
  • visibility is defined in the arch with groups, attrs, invisible, etc.

IMO the best approach for you is the first one. An Odoo example are the views for model account.invoice, because there are two form views: one for customer invoices and one for supplier invoices.

Upvotes: 3

Related Questions