Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
8768 Lượt xem

i want to disable the "add one line" in a many2many tags tree after adding one single line ? is that possible ? i tried 

                                    <field name="indication_ids" >

                                    <tree editable="bottom"  options="{'no_create_edit': True}" >

                                        <field name="motor_vehicule"/>

                                        <field name="steel_griders"/>

                                        <field name="wood"/>

                                            </tree>

                                </field>



but it disables the "add one line" totally, not allowing me to add a single line 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

You can do something like this, add a constrains to one2many field, such a way that it will throw validation error, if there is multiple lines in the one2many line.

@api.constrains('o2m_field')
def _check_o2m_field(self):
if len(self.o2m_field.ids) > 1:
raise ValidationError(_('Warning! You cannot add multiple lines.'))

Thanks

Ảnh đại diện
Huỷ bỏ
Tác giả

Many thanks Niyas

Thanks for this preposition.

Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 5 24
12609
1
thg 4 24
3244
0
thg 11 23
1989
1
thg 9 23
2080
2
thg 8 23
4471