コンテンツへスキップ
メニュー
この質問にフラグが付けられました
3 返信
8738 ビュー

Hello,

I want to make relation one2one in the same model 'person' which inherit from 'res.partner' .
I know that one2one is not available any more so what's the solution?
The relation is "married_with". So i want when i change the field of the person A to B. B "married_with" field automatically changes

class person
       inherit = 'res.partner'
       married_with =.........


Is it possible to do it and how? 


アバター
破棄
最善の回答

Dear Mohamed,

Try to use Related Field Related Field Link


Hoping to Solve the issue,


You can Use Onchange Function :

married is Many2one with same model:


@api.onchange('married')

def onchange_married(self):

    self.married.married= self.id


Try it


アバター
破棄
著作者 最善の回答

Dear Boubaker and Aymen

I don't think that related field will solve my problem because what i am looking for is not how to get the field of the other record.

I want when i link the record A with record B, record B will be linked with A.
A.married_with(B)   ====>   B.married_with(A)
I hope that my problem is clear

アバター
破棄

Pls Check the answer ...

著作者

I try it but it doesn't resolve the problem

著作者

Dear Aymen

I have an idea. But i don't know how to do it.

How about adding a one2many to my "married_with" many2one field, make relation and when the one2many is changed i will use the first line to update my many2one field is it possible?

最善の回答

Hi Mohamed Ali 

When you change for example   the customer, you want to change it with another field

1- You can link it to Related

for example 

    partner_id = fields.Many2one('res.parner', string="Partner")

    phone = fields.Char( string="Phone", related='partner_id .phone')

phone This field is present in the model 'res.parner' 

2- the other solution by Methode On_change 

@api.onchange('partner_id')
def on_change_field(self):
    self.phone = self.partner_id.phone


アバター
破棄
関連投稿 返信 ビュー 活動
0
9月 19
98
0
11月 18
5877
0
10月 18
3825
1
7月 17
4219
4
8月 16
8428