Skip to Content
Menu
This question has been flagged
15 Replies
12884 Views

Here in this screen shot products are adding one by one in orderlines by Add an item.

But, i want to import mutiple products at a time.

Avatar
Discard

Hi Divya, as per my understanding i hope you are looking for Product Bundling kind of functionality.Kindly please let me know if my understanding is correct so that I can expedite the same.

Best Answer

Hi Guys,

I Don't think converting o2m order lines field to a m2m or making the field product which is of m2o to an m2m. Here in the first case i don't think requirement will be acheived and comming to second case one orderline will have n number of products which doesn't seem to be correct.

Instead what i would prefer is to

Create a wizard which will pop up with a button click on form view and it will show the list of all products where you can select all the required products(Multiple products at once) and clicking on submit button in wizard will create an individual orderline in current order for every product selected.

This procedure is little bit lengthy, but i hope this will help you to acheive your requirement without disturbing the actual process or default modules.

Cheers

Kiran Kumar

Avatar
Discard
Best Answer

Hello,

You should change product_id in sale.order.line from many2one to many2many.

But if you change priduct_id many fields in order_line(in sale.order) are depending on it(like description,price etc). you should change them too.

Hope this helps

Avatar
Discard
Best Answer

Be cauitious: Making the product fields as m2m would break Odoo logic totally (procurement, invoicing etc.)

For sale orders we developed this app  - https://apps.odoo.com/apps/modules/10.0/product_selection_wizard_sale/- may help you. It let search products and then add them at once (but different lines). For purchases a similar app with same core is going for a release. It is a payable module, regretfullu


Avatar
Discard
Best Answer

Hello Divya,


For the same requirement I changed order_line field to many2many.

#'order_line': fields.many2many('sale.order.line', 'order_id', 'Order Lines', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, copy=True),

After that it lists all order lines.

As suggested by shahshank added following line in sale_order_line class

'm2m_prod': fields.many2many('product.product', 'm2m_table', 'order_lineid', 'product_id', 'M2M products'),

But still it lists all order lines.

do we have to modify sale_view.py also?

Avatar
Discard
Author Best Answer

when creating many to many field for order lines , It is showing the list of existing order lines but it must show existing products.

Avatar
Discard

'm2m_prod': fields.many2many('product.product', 'm2m_table', 'order_lineid', 'product_id', 'M2M products'), Use this defination in sale_order_line class

Author

Thanks @shashank

Hi Shashank, I don't know if you'd reply or not, but can you please help me on this?

I am on Odoo v9, and can't change sale.order line to many2many from GUI. And nothing happens when I use the codes above in Technical> Views.

Kindly help me with this. Let me know how I can do it in Odoo v9 ?

Thanks.

Best Answer

Hello Divya,

Default structure of orderline is one2many . Good choice would be to use many2many structure where u can add muliple product and then you can design your business logic according to many2many flow.
 

Avatar
Discard

Add Product one by one (one2many) is the best way because each sale Line product have different quantity, unit Price.

Author

But if we want to import 100 products at time, it is difficult way to form one by one. Is there any alternative way for it?

Author

yes the default structure of orderline is one2many @shashank, But changing it to many to many field will effect to any other forms in application?

Openerp using Import options csv file data import. Refer http://www.slideshare.net/Audaxis/opendays-import-csv-2013v5

@divya: If you are replacing o2m field by m2m field then it will effect other application. Because some of the modules might be refering to order_line(o2m field in sale_order class)