def clone_transaction(transaction, new_portfolio = None):
  """Return a copy of the given transaction, optionally overriding which portfolio the transaction belongs to."""
  
  out = Transaction()
  out.portfolio = (new_portfolio if new_portfolio != None else transaction.portfolio)
  out.type = transaction.type
  out.as_of_date = transaction.as_of_date
  out.symbol = transaction.symbol
  out.quantity = transaction.quantity
  out.price = transaction.price
  out.total = transaction.total
  out.linked_symbol = transaction.linked_symbol
  
  return out
dataset/ETHPy150Open fxdemolisher/frano/frano/transactions/models.py/clone_transaction/original