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

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?

아바타
취소
베스트 답변

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


아바타
취소
작성자 베스트 답변

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

아바타
취소