Odoo Help

1

How to integrate identical fields from different models into one

By
Lucas Huber
on 4/5/16, 9:21 AM 772 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

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

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