def import_to_partnerv2(): partner = Partner.mgr().Q().data() for i in partner: s = Partnerv2.new() try: s.partner_id = i['partner_id'] s.factory_id = i['factory_id'] s.proportion = 1.0 s.save() except Exception, e: print i logging.error('%s\n', str(e), exc_info=True)
def import_to_partnerv2(): partner = Partner.mgr().Q().data() for i in partner: s = Partnerv2.new() try: s.partner_id = i['partner_id'] s.factory_id = i['factory_id'] s.proportion = 1.0 s.save() except Exception,e: print i logging.error('%s\n',str(e),exc_info=True)
def save(self): id = int(self.get_argument('pid', 0)) #id = int(self.get_argument('id',0)) #factory_id = int(self.get_argument('factory_id')) partner_id = int(self.get_argument('partner_id')) factory_name = self.get_argument('factory_name') factory = Factory.mgr().Q().filter(name=factory_name) factory_id = factory[0]['id'] if id: p = Partner.mgr(ismaster=True).Q().filter(id=id)[0] p2 = Partnerv2.mgr(ismaster=True).Q().filter( factory_id=p['factory_id'])[0] else: p = Partner.new() p2 = Partnerv2.new() p.factory_id, p.partner_id = factory_id, partner_id p2.factory_id, p2.partner_id = factory_id, partner_id p = p.save() p2.save() self.json2dwz('200', 'closeCurrent', 'dlist', forwardUrl='partner/list?id=%s' % p.id)