Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to prevent "Add an item" if parent is not saved?

By
Emad
on 4/26/15, 8:35 AM 363 views

Hi,

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

Regards,

1

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


Ahmed M.Elmubarak
On 4/27/15, 3:14 AM

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 ....

0
Emad
On 4/27/15, 3:53 AM

Thank you Ahmed. It has worked perfectly.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/26/15, 8:35 AM
Seen: 363 times
Last updated: 4/27/15, 3:53 AM