This question has been flagged
10 Replies
17491 Views

Hi all,

I have created one2many field for selecting products, i click search more option it is showing the tree view, for this i need to select multiple products at a time in this tree view(one2many). is it possible in one2many field?

Can you provide me any suggestions.

Thanks in advance.

Avatar
Discard

can you please explain your use of that field??

Author

Hi Baiju, In purchase order form=> purchase order tab need to select multiple products at a time. please provide me any code to do that.

We can do that by modifying that field. but to understand what to do,,, you have to specify me the correct use, i mean your need to do that.. so that i can understand what to do correctly...
waiting for reply.
thank you


Subject: Re: How to select multiple products in one2many field ?
From: madhubabu.chitveli@gmail.com
To: baijuks@hotmail.com
Date: Tue, 4 Nov 2014 10:48:44 +0000

Hi Baiju, In purchase order form=> purchase order tab need to select multiple products at a time. please provide me any code to do that.


Thanks in Advance.


Sent by OpenERP S.A. using Odoo about Forum Post How to select multiple products in one2many field ?
Best Answer

To select multiple items you can use many2many field.

In view you have to specify mamy2many tag widget

Eg:

'field_name' : fields.many2many('object.name', string='Details'),

                                <field name="field_name" widget="many2many_tags" />

 

Avatar
Discard
Author

Thanks Baiju, but my question is different.

Best Answer

Although the question is quite old, but still I am answering it for those who are still searching for the solution:

You can use this module to add checkboxes and a button to perform and action on selected records for x2many fields tree view:

https://apps.odoo.com/apps/modules/9.0/web_x2many_selectable/

Avatar
Discard
Best Answer

Assuming you have created a lines for an object, now those lines are defined in the List/Tree View.

Suppose if you created a field for Product say (many2one), then yes it will show you list of products from which you can select only one at a time.

So instead change the datatype of the product to Many2Many.


Example:

Object A (parent)

lines = fields.One2Many(ObjectB)


Object B (child)

product_ids = fields.Many2Many(product.product)


This way it will let add multiple products into your lines (one2many lines). Hope this helps you


Avatar
Discard
Best Answer

Hi

One2Many field is the virtual field which is used relative to Many2One relationship.

For Example:

Object X:

f1:ManytoOne in OBject Y

Object Y:

f2:ManytoOne in OBject X.f1

It is better to create the Many2Many relationship for storing the multiple values.

Avatar
Discard
Author

Thanks for answer Rajiv, but in many2one relationship also we will select only one item, but i want to select multiple items using one2many field.

I have no idea of selecting multiple items with one2many as its virtual field for the many2one field. Let us expect the answers for this.