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

I have made two drop-downs. Second dropdown's data is dependent on first drop-down's chosen value.

I have tried multiple methods, but didn't find any relevant solution.

Those are my three lists:

SELECTION_LIST = (('sela','Selected a'), ('selb','Selected b')) SELECTION_LIST_2 = (('selc','Selected c'), ('seld','Selected d')) SELECTION_LIST_3 = (('sele','Selected e'), ('self','Selected f'))

And I defined my fields this way:

'type_selection': fields.selection( [ ('selection1', 'Selection 1'), ('selection2', 'Selection 2'), ('selection3', 'Selection 3'), ], 'Category 1', required=False), 'type_selection_2': fields.selection( type_selection={ 'selection1': [{SELECTION_LIST}], 'selection2': [{SELECTION_LIST_2}], 'selection3': [{SELECTION_LIST_3}], }, "Category 2", required=False)

Unfortunately I get an error.

아바타
취소
베스트 답변

It is better to use an Onchange method in these cases.

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

have also used onchange function like this

In xml file ->

<field name="type_selection" on_change="_set_list_data(type_selection)"/> -->

<field name="type_selection_2"/>

In python file ->

'type_selection': fields.selection([
                                  ('selection1','Selection 1'),
                                  ('selection2','Selection 2'),
                                  ('selection3','Selection 3')
                                  ],'Select Call Reason',required=False),
        'type_selection_2': fields.selection(
                                             _get_selection,
                                             'What do you want ?')

 

python function 

 def _set_list_data(self,cr,uid,selected,context=None):
        if selected == 'selection1':
            SELECTION_LIST = SELECTION_LIST_2
            vals = {'type_selection_2': SELECTION_LIST_2}        
            return {'type_selection_2': SELECTION_LIST_2}
        else:
            vals = {'type_selection_2': SELECTION_LIST_3}
            SELECTION_LIST = SELECTION_LIST_3        
            return {'type_selection_2': SELECTION_LIST_3}
        
    def _get_selection(self, cr, uid, context=None):
        return SELECTION_LIST

아바타
취소

In your .py file move the function definition before the _columns (fields definitions)

which function?

Warm Regards,

Himanshu Mittal | Trainee,Technology |himanshu.mittal@nagarro.com| 09649417940


Nagarro Software (P) Ltd, Plot No-14, Sec-18, Electronic City, Gurgaon, Haryana-122015, India

Visit our facebook page : https://www.facebook.com/nagarrocampus

  

P Please consider the environment and do not print this email unless absolutely necessary



On Wed, Oct 29, 2014 at 5:33 PM, Med Said BARA <diassynthesis@mail.odoo.com> wrote:

In your .py file move the function definition before the _columns (fields definitions)

--
Med Said BARA
Sent by Odoo Inc. using Odoo about Forum Post False

Le 29/10/2014 13:19, HImanshu Mittal a écrit :
<blockquote cite="mid:CAEZJQWfuK8P-nK-KuYPyZbWEPign4bq0jONMfdB1=QiLpN_-AQ@mail.gmail.com" type="cite">
which function?

Warm Regards,

Himanshu Mittal | Trainee,Technology |himanshu.mittal@nagarro.com| 09649417940


Nagarro Software (P) Ltd, Plot No-14, Sec-18, Electronic City, Gurgaon, Haryana-122015, India

Visit our facebook page : https://www.facebook.com/nagarrocampus

  

P Please consider the environment and do not print this email unless absolutely necessary



On Wed, Oct 29, 2014 at 5:33 PM, Med Said BARA <diassynthesis@mail.odoo.com> wrote:

In your .py file move the function definition before the _columns (fields definitions)

--
Med Said BARA
Sent by Odoo Inc. using Odoo about Forum Post False

--
Himanshu Mittal
Sent by OpenERP S.A. using Odoo about Forum Post False Both: def _set_list_data and def _get_selection.

Can you post the error message you are getting?

Best regards.
베스트 답변

At first glance, there is a smell of (python) " Nested Lists".

But it will be helpful, if you give a concrete example, like for product's categories and subcategories, or Brand and Models of cars ...

아바타
취소
작성자

Like We Say.. List 1 has Items -> Mobile,Laptop, Tablets List 2.1 (For Mobile) -> Samsung, Apple List 2.2 (For Laptop) -> Apple, Dell List 2.3 (For Tablet) -> Samsung, Dell, Apple How can I achieve the same

작성자

Any update on this??

작성자

Any update on this??