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.

1

How to integrate identical fields from different models into one

By
Lucas Huber
on 4/5/16, 9:21 AM 527 views

I have one model, that I use to show and edit my values/fields and two or more models that are generated always with identical fields through other modules.

This sub-models containing different transaction engines. I want to integrate the fields of the sub-models into my main model depending on a field that contains the sub-model name. The clue is that some of my fields in the main model should than point to the corresponding fields in the sub-models. 

I tried different things as switching the environment, inheritance or using referenced fields. But nothing seems to work in a way that is useful. 

Any ideas how to get this to work.?

For a better understanding I place here some code of my trial with fields.Reference:

class ExchangeProvider(models.Model):
    ref_provider = fields.Reference(
        [('exchange.provider.internal', 'Internal'), ('exchange.provider.dumy', 'Dumy')],
        'Accounts PR')
    balance = fields.Float(
    'Balance Pr', related='ref_provider.balance') # NOT WORKING!!!


With the field ref_provider I declare witch transaction engine (Account) I will use. The Balance field should then show the Balance of this Account. But this creates an error because it is not a normal relation. I could try to get out the model and the id separat from re_provider and then merge it together for the related field.

I find it hard to understand what you actually want to do. What is the example using the names of the models you want to combine, and the fields you want to see?

Bista Solutions US, Ray Carnes
on 4/15/16, 4:21 PM

Hi Ray, hope that example helps? ;)

Lucas Huber
on 4/16/16, 8:53 AM

Meanwhile I believe with related field it should work. The Reference field is not really necessary if I can get the model name from somewhere. But it must be possible to use related="" with changing relations?

Lucas Huber
on 4/16/16, 9:00 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

1 follower(s)

Stats

Asked: 4/5/16, 9:21 AM
Seen: 527 times
Last updated: 9/2/16, 5:00 AM