This question has been flagged
6 Replies
4128 Views

Hi all,

I have this question:

I 've override purchase.order views and now I want, in Products, to insert the "Add an item" button, like in the default behaviour.

In products page I've inserted only

<page name="purchase_lines" string="Products">
<field name="order_line"/>
</page>

I know this feature is inserted by static/src/js/views/form_relational_widgets.js if there is 'one to many' field like "order_line".

My custom view is correctly rendered but there isn't "add an item".

Is there anyone can help me? How works exaclty "Add an item" and form_relational_widgets.js?


Avatar
Discard
Best Answer

<edit> Deleted mistyped answer

Avatar
Discard
Author Best Answer

Hi all, my problem was that in form referred there was create="false".

Deleting create="false" it works.

Anyone know if is possible have "add an item" with m2m fields?


Avatar
Discard
Best Answer

HI! You must enter 

<page name="purchase_lines" string="Products">
<field name="order_line"/>
    <tree create="0">
        <field name=""/>
        <field name=""/>
    </tree>
</page

 

Avatar
Discard
Best Answer

Hi,

don't make things difficult, you can simply disable the add an item on one2many fields my making read-only or

define a view under One2many field and make the add  attribute under each view as " create='false' "

eg:

1.

<page name="purchase_lines" string="Products">
  <field name="order_line"/>
</page>

2.
<page name="purchase_lines" string="Products">
<field name="order_line">
        <tree create="false">
            ....
            ....
        </tree>
        <form create="false" edit="false">
            ....
            ...
        </form>
    </field>
</page>


All examples hides add_an_item on One2many field.



Avatar
Discard
Best Answer

Hi,

The add an item button comes when you add a one2many field in the view.

There is no need to do any work in the js file.

If you want to add same page like products then add it in <notebook> tag not in <page>.



Avatar
Discard