コンテンツへスキップ
メニュー
この質問にフラグが付けられました
5982 ビュー

Hai to all.......

  I created to field (field1, and field2) in order line of Sale Order module. In onchange method of  field1 , get corresponding value of field2 and return it by using 'domain', but if I select field2 without selecting field1, previously selected value can not cleared. How can clear the previously selected value

This is the Code

XML file

<field name="accom_date" >

<field name="accom_type" domain="[('is_accom_type','=',1)]" options="{'create': false, 'create_edit': false}"/>                                     <field name="bed_type" domain="[('is_room','=',1),('categ_id', '=', accom_type)]" options="{'create': false, 'create_edit': false}"/>

<field name="cost"/>


.Py file

@api.onchange('accom_type')

    def change_accom_type(self):

        bed_list = []

        room_list = []

        vacant_list = []


        if self.accom_type and self.accom_date:

            pid = self.env['product.product'].search([('categ_id', '=', self.accom_type.id)])

            print 'PID: ', pid

            for record in pid:

                room_list.append(record.id)

                roomid = self.search([('bed_type', '=', record.id)])

                for val in roomid:

                    if val.status == 'occupied' and val.accom_date == self.accom_date:

                        bed_list.append(record.id)

            print 'List: ', bed_list

            print 'Room List: ', room_list

            for item in room_list:

                if item not in bed_list:

                    vacant_list.append(item)

            print 'Vaccant Rooms: ', vacant_list

            domain = {'bed_type': [('id', 'in', vacant_list)]}

            return {'domain': domain, 'value': {'bed_type': False}}



アバター
破棄
関連投稿 返信 ビュー 活動
0
2月 19
5799
1
4月 15
4067
1
7月 19
3315
0
11月 18
4213
2
11月 18
4017