Skip to Content
Menu
This question has been flagged

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.

Avatar
Discard

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?

Author

Hi Ray, hope that example helps? ;)

Author

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?

Related Posts Replies Views Activity
1
Jun 25
4994
3
Jul 20
11605
4
Oct 24
5197
0
Nov 16
3986
4
Oct 16
4092