28
28
_name = 'product.pack.line'
29
29
_rec_name = 'product_id'
31
'parent_product_id': fields.many2one( 'product.product', 'Parent Product', ondelete='cascade', required=True ),
32
'quantity': fields.float( 'Quantity', required=True ),
33
'product_id': fields.many2one( 'product.product', 'Product', required=True ),
31
'parent_product_id': fields.many2one('product.product', 'Parent Product', ondelete='cascade', required=True),
32
'quantity': fields.float('Quantity', required=True),
33
'product_id': fields.many2one('product.product', 'Product', required=True),
36
36
class product_product(orm.Model):
37
37
_inherit = 'product.product'
39
'stock_depends': fields.boolean( 'Stock depends of components', help='Mark if pack stock is calcualted from component stock' ),
40
'pack_fixed_price': fields.boolean( 'Pack has fixed price', help='Mark this field if the public price of the pack should be fixed. Do not mark it if the price should be calculated from the sum of the prices of the products in the pack.' ),
41
'pack_line_ids': fields.one2many( 'product.pack.line','parent_product_id', 'Pack Products', help='List of products that are part of this pack.' ),
39
'stock_depends': fields.boolean('Stock depends of components', help='Mark if pack stock is calcualted from component stock'),
40
'pack_fixed_price': fields.boolean('Pack has fixed price', help='Mark this field if the public price of the pack should be fixed. Do not mark it if the price should be calculated from the sum of the prices of the products in the pack.'),
41
'pack_line_ids': fields.one2many('product.pack.line','parent_product_id', 'Pack Products', help='List of products that are part of this pack.'),
44
44
def get_product_available(self, cr, uid, ids, context=None):
45
45
""" Calulate stock for packs, return maximum stock that lets complete pack """
47
for product in self.browse( cr, uid, ids, context=context ):
47
for product in self.browse(cr, uid, ids, context=context):
48
48
stock = super(product_product, self).get_product_available(cr, uid, [product.id], context=context)
50
50
# Check if product stock depends on it's subproducts stock.
145
145
last_had_children = False
146
146
for line in order.order_line:
147
147
if last_had_children and not line.pack_parent_line_id:
148
reorder.append( line.id )
148
reorder.append(line.id)
149
149
if line.product_id.pack_line_ids and not order.id in updated_orders:
150
updated_orders.append( order.id )
150
updated_orders.append(order.id)
232
232
# It's a control for the case that the nan_external_prices was installed with the product pack
233
233
if 'prices_used' in line:
234
vals[ 'prices_used' ] = line.prices_used
234
vals['prices_used'] = line.prices_used
236
236
self.pool.get('sale.order.line').create(cr, uid, vals, context)
237
237
if not order.id in updated_orders:
238
updated_orders.append( order.id )
238
updated_orders.append(order.id)
240
240
for id in reorder:
248
248
# Try to expand again all those orders that had a pack in this iteration.
249
249
# This way we support packs inside other packs.
250
self.expand_packs(cr, uid, ids, context, depth+1)
250
self.expand_packs(cr, uid, ids, context, depth + 1)
301
301
last_had_children = False
302
302
for line in order.order_line:
303
303
if last_had_children and not line.pack_parent_line_id:
304
reorder.append( line.id )
304
reorder.append(line.id)
305
305
if line.product_id.pack_line_ids and not order.id in updated_orders:
306
updated_orders.append( order.id )
306
updated_orders.append(order.id)
353
353
'order_id': order.id,
354
'name': '%s%s' % ('> '* (line.pack_depth+1), subproduct_name),
354
'name': '%s%s' % ('> '* (line.pack_depth + 1), subproduct_name),
355
355
'date_planned': line.date_planned or 0.0,
356
356
'sequence': sequence,
357
357
'product_id': subproduct.id,
369
369
# It's a control for the case that the nan_external_prices was installed with the product pack
370
370
if 'prices_used' in line:
371
vals[ 'prices_used' ] = line.prices_used
371
vals['prices_used'] = line.prices_used
373
373
self.pool.get('purchase.order.line').create(cr, uid, vals, context)
374
374
if not order.id in updated_orders:
375
updated_orders.append( order.id )
375
updated_orders.append(order.id)
377
377
for id in reorder:
385
385
# Try to expand again all those orders that had a pack in this iteration.
386
386
# This way we support packs inside other packs.
387
self.expand_packs(cr, uid, ids, context, depth+1)
387
self.expand_packs(cr, uid, ids, context, depth + 1)
b'\\ No newline at end of file'