This question has been flagged
2 Replies
6593 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