Example #1
0
  def test_opportunity(self):
    account = Account(name="John SARL")
    opty = Opportunity(name="1000 widgets")
    opty.account = account
    self.check_editable(opty)

    d = opty.to_dict()
    j = opty.to_json()
Example #2
0
  def load_opportunities(self):
    reader = self.get_reader("Opportunities.csv")
    for line in reader:
      d = {}
      for col in ['Name', 'Description', 'Type']:
        d[col.lower().replace(" ", "_")] = line[col]
      d['stage'] = line['Sales Stage']
      d['amount'] = line['Opportunity Amount'][3:]
      d['close_date'] = self.parse_date(line['Expected Close Date'])
      d['probability'] = line['Probability (%)']
      opportunity = Opportunity(**d)

      opportunity.creator_id = choice(self.users).id
      opportunity.owner_id = choice(self.users).id

      account = self.accounts_map.get(line['Account Name'])
      if not account:
        print "Skipping account", line['Account Name']
        continue
      opportunity.account = account

      db.session.add(opportunity)