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 StackOverflow 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.Ā










