Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
3817 มุมมอง

On clicking the button action we are opening the popup window.


Pop up window


Empty record inserted to the database



we want to prevent this empty record save in the database.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hello Gopal,

You have to use TransientModel to open popup.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hello, 

Your view shows that , there is no required field in you table (class) , in xml of your wizard , make any field view mandatory , so empty  record wont be created in db. for example 

<field name="gender" required="1"/>

Hope it helps,

Thank you

อวตาร
ละทิ้ง
ผู้เขียน

if i set required ="1" pop up not open so that only i did not set the required attribute

I understand your issue, in your button get waiting list make sure that you fetch all the data for the columns in tree view. If any data is missing raise User Error so that no new empty record will be created. If you allow this for every iteration your doing if there is no data a new empty record will be created which is waste of db space.

ผู้เขียน

It is a action button (button type is action) . on clicking the action button it was go to the create action method (odoo create method ) then call the popup so in that create action empty record is inserting.

You can also call the same action in py file and give the button type as object... and you can raise error if data is not filled.

action = self.env.ref('module.action_view').read()[0]

if fields:

action['views'] = [(self.env.ref('module.wizard_form_view').id, 'form')]

action['res_id'] = wizard_ids and wizard_ids[0] or False

else:

raise UserError(_("Warning!.\n"))

return action

ผู้เขียน

Type=object also same problem. we tried deleted the empty record after insert before popup. delete working fine.

thanks for your suggestion and help

Related Posts ตอบกลับ มุมมอง กิจกรรม
3
ต.ค. 24
17507
1
ก.พ. 20
4801
0
มี.ค. 15
3579
2
มี.ค. 15
4880
1
พ.ย. 24
1054