Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
8706 Widoki

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? 


Awatar
Odrzuć
Najlepsza odpowiedź

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


Awatar
Odrzuć
Autor Najlepsza odpowiedź

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

Awatar
Odrzuć

Pls Check the answer ...

Autor

I try it but it doesn't resolve the problem

Autor

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?

Najlepsza odpowiedź

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


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
wrz 19
98
0
lis 18
5858
0
paź 18
3781
1
lip 17
4189
4
sie 16
8404