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

Hi,

How to prevent the "Add an item" of One2Many widget from showing a popup form if the parent form is not saved?

Regards,

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

Hello Emad,

We can do a simple trick. Every model has ID field, will generated automatically after saving, before saving this field has no value.

So in your form view of the parent add

<field name="id" invisible="1"/>

then in your o2m field add attrs like :


<field name="o2m_ids" attrs="{'readonly': [('id','=',False)]}">
<tree editable="bottom">
    ....


I hope it'll help you 


Regards ....

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

Thank you Ahmed. It has worked perfectly.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 4 15
4863
1
thg 9 20
2998
0
thg 6 18
3307
0
thg 3 15
5562
2
thg 7 25
6583