def update_order_line_from_product(pricing_context, order_line, product, quantity=1, supplier=None):
 if order_line.pk:
  raise Exception('set_from_product may not be used on saved lines')
 if (not product):
  raise Exception('set_from_product may not be used without product')
 order_line.supplier = supplier
 order_line.type = OrderLineType.PRODUCT
 order_line.product = product
 order_line.quantity = quantity
 order_line.sku = product.sku
 order_line.text = (product.safe_translation_getter('name') or product.sku)
 order_line.accounting_identifier = product.accounting_identifier
 order_line.require_verification = bool(getattr(product, 'require_verification', False))
 order_line.verified = False
 if pricing_context:
  price_info = product.get_price_info(pricing_context, quantity=quantity)
  order_line.base_unit_price = price_info.base_unit_price
  order_line.discount_amount = price_info.discount_amount
  assert (order_line.price == price_info.price)
 else:
  order_line.base_unit_price_value = 0
  order_line.discount_amount_value = 0

def update_order_line_from_product ( pricing_context , order_line , product , quantity = 1 , supplier = None ) : if order_line . pk : raise Exception ( 'set_from_product may not be used on saved lines' ) if ( not product ) : raise Exception ( 'set_from_product may not be used without product' ) order_line . supplier = supplier order_line . type = OrderLineType . PRODUCT order_line . product = product order_line . quantity = quantity order_line . sku = product . sku order_line . text = ( product . safe_translation_getter ( 'name' ) or product . sku ) order_line . accounting_identifier = product . accounting_identifier order_line . require_verification = bool ( getattr ( product , 'require_verification' , False ) ) order_line . verified = False if pricing_context : price_info = product . get_price_info ( pricing_context , quantity = quantity ) order_line . base_unit_price = price_info . base_unit_price order_line . discount_amount = price_info . discount_amount assert ( order_line . price == price_info . price ) else : order_line . base_unit_price_value = 0 order_line . discount_amount_value = 0
update orderline data from a product .