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 ?