Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to access data from foreign models via foreign-key inside .xml-views ?

By
NSC
on 2/8/14, 2:30 PM 1,779 views

I want to access data from foreign models via foreign-key from inside .xml-views.

Concrete example: account.invoice.tree

account.invoice model "knows" partner_id as foreign key. I also want to display res.partner.cust_id inside account.invoice.tree. From inside .rml reports, I can simply do o.partner_id.cust_id and the field desired is displayed without needing to inherit the appropriate python class. Can this be achieved like that from within .xml view files and if yes, how?

0

Ray Carnes

--Ray Carnes--
15717
| 9 7 9
Greater Los Angeles, United States
--Ray Carnes--

Senior Odoo Analyst

OpenERP 6.1, 7.0 and Odoo 8.0, 9.0 (Since 2012)

Completed Functional and Technical Training.

Major Skills:

  • Needs Discovery and Requirements Analysis;

  • Function and Technical Specifications;

  • Project Planning;

  • Prototyping and Proof of concepts;

  • Data migration;

  • Configuration & Customization (UI and modules);

  • Integration - data, business logic and service levels;

  • Training and Knowledge transfer;

  • Go Live support;

  • Help desk;

  • Version Migration.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

Ray Carnes
On 2/9/14, 11:47 PM

A view can only display data from a single model.

You can create a new model, which combines information from two others, and is defined by a SQL statement.

See https://accounts.openerp.com/forum/Help-1/question/12350

Thank you very much! I will try that. I had another idea: Inherit account.invoice model and add a function field for every additional field from foreign model I need. These fields could have store="False" property, as their values are already available and needn't be entered/stored. Would this approach work, too?

NSC
on 2/10/14, 5:21 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 2/8/14, 2:30 PM
Seen: 1779 times
Last updated: 3/16/15, 8:10 AM