Skip to Content
Menu
This question has been flagged
2 Replies
6943 Views

I am trying to create a module that creates new type of product, the new type act as a bundle of products, so that when this bundle is selected in the purchase order , it is automatically removed and replaced by all the products in the bundle. instead of selecting each product manually.


right now I'm stuck in the on_change function of product id to remove the bundle and add its child products

if product.is_package:
     for child_product in product.product_ids:
         active_id = context.get('active_id', [])
         line_vals = {'product_id' : child_product.product_id,}
         order_lines = []
         order_lines = order_lines.append([0,False,line_vals])
         po_line_obj = self.pool.get('purchase.order.line')
         po_line_id = po_line_obj.write(cr,uid,active_id, {'order_line' : order_lines})

But it isn't working any clue ?

Avatar
Discard
Best Answer

Odoo have almost same functionality...if you are aware of the BOM type 'Set', it will be easy.
Suppose you have a product 'ABC' with a type 'Set' BOM contains products A ,B & C
When you make a sale order for ABC Sale order line will remain as ABC, But the delivery of ABC will be as a set of product A, B & C.

So i hope you can use the same method with slight modification for your case

Avatar
Discard
Best Answer

In the first step, you create a line, like:

line_id = po_line_obj.create(cr, uid, line_vals, context=context)

then you can manipulate it.

Avatar
Discard
Related Posts Replies Views Activity
1
Mar 15
2448
1
May 24
253
3
Feb 24
919
2
Nov 22
10500
1
Dec 16
4732