콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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?

작성자

Hi Ray, hope that example helps? ;)

작성자

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?

관련 게시물 답글 화면 활동
1
6월 25
5717
3
7월 20
12517
4
10월 24
5867
0
11월 16
4973
4
10월 16
4850