Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
3 Antwoorden
8717 Weergaven

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? 


Avatar
Annuleer
Beste antwoord

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


Avatar
Annuleer
Auteur Beste antwoord

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

Avatar
Annuleer

Pls Check the answer ...

Auteur

I try it but it doesn't resolve the problem

Auteur

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?

Beste antwoord

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


Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
0
sep. 19
98
0
nov. 18
5861
0
okt. 18
3792
1
jul. 17
4198
4
aug. 16
8410