Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
949 Vizualizări

Hello,


Here is my problem :

I've got a one2many field with 2 many2one fields inside.I want when i select a value in the first column, fill the column 2 with values linked to the first column.

Of course, if the value is different in the first column on line 1 and line 2, i want to have specific values in column 2 according what is selected on the first column of the concerned line.


Is anybody know how to do that?

Imagine profil
Abandonează
Cel mai bun răspuns

Hi Vincent,

You can do it using onchange method. You need to add an onchange method in the object of One2many field.

Ex:

class MyO2mClass(models.Model):
_name = 'my.one2many.obj'

@api.onchange('my_first_field')
def my_first_field_onchange(self):
self.my_second_field = self.my_first_field

Reference: Odoo Onchange


Imagine profil
Abandonează
Autor Cel mai bun răspuns

Hi Sudhir,

Thank you for your answer but this is not my request.

I don't want to report the value of column 1 in column 2.

I want to condition the filling of my column 2 according to the choice made in column 1, which, I remind you, are many2one both.

I give you an example :

First line : Column 1, i choose Brand, in column 2, i can choose Apple, Samsung, Xiaomi,...

Second line : Column 2, i choose Type, in column 2, i can choose Phone, Laptop, headphones,...

I don't want to have a column 2 with all those values (Apple, Samsung,Xiaomi,Phone, Laptop, headphones,...) but fill the column 2 with values according the choice made in column 1

Hope it is clear enough, if not don't hesitate

Imagine profil
Abandonează