Cross-model data referencing in Odoo SaaS views.

Using Odoo SaaS is extremely limiting and most of the solutions to most of the issues you find online are programmatic solutions for when you have access to the models themselves. These, however, do not help you if you’re stuck on the SaaS platform. So many times I have wanted to display related data in one view from another model. Thanks to some help from a

user, I understand how to do it now.. here’s the beta. In the model res.partner I created 2 new fields of type ‘Selection’ named ‘x_invoice_preference’ and ‘x_payment_preference’. I needed to display these preferences inside of the account.invoice tree and form views, and I definitely didn’t want the values to be copied, but referenced. I will explain the ‘x_payment_preferences’ solution in this example, but just rinse and repeat for your fields. The solution is to create a new field in account.invoice with the same name as the field in res.partner (this is not required, but is best practice). Give it a Field Label and click on the “Advanced Properties” tab.  Then put partner_id.x_payment_preference as the value for ‘Related Field’. This will automatically set the field type, same as the related field. You then need to copy/paste the “Selection Options” to be the same as the res.partner field’s selection options. This will pull the data from the res.partner model using the relation through partner_id. Now that field is available for you to use in your views. Just reference it as you would any other view. It’s that simple! Hopefully this helps.. it wasn’t obvious to me and the Odoo SaaS documentation and examples are definitely lacking IMO.

Aly Chiman

Aly Chiman is a Blogger & Reporter at AlyChiTech.com which covers a wide variety of topics from local news from digital world fashion and beauty . AlyChiTech covers the top notch content from the around the world covering a wide variety of topics. Aly is currently studying BS Mass Communication at University.

Leave a Reply

Your email address will not be published.