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

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 

アバター
破棄
最善の回答

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

アバター
破棄
著作者

Many thanks Niyas

Thanks for this preposition.

関連投稿 返信 ビュー 活動
4
5月 24
12613
1
4月 24
3250
0
11月 23
1994
1
9月 23
2084
2
8月 23
4479