예제 #1
0
파일: pp2lino.py 프로젝트: khchine5/welfare
    def row2obj(self, row):
        kw = {}
        kw.update(id=int(row['IDEndroitMiseAuTravail']) + OFFSET_JOBPROVIDER)
        kw.update(name=row['EndroitMiseAuTravail'])
        companyType = CboStatutJuridique.get(row['IDStatutJuridique'], None)
        if companyType:
            kw.update(type=CompanyType.objects.get(id=companyType))
        # see contacts/fixtures/std.py

        #~ kw.update(street_prefix=row[u'Rue'])
        kw.update(street=row[u'AdresseSiegeSocial'])
        kw.update(street_no=row[u'N'])
        kw.update(street_box=row[u'Bte'])
        kw.update(phone=row[u'Tel'])
        kw.update(gsm=row[u'GSM'])
        kw.update(fax=row[u'Fax'])
        kw.update(remarks="""
        NumeroInitiativeEconomieSociale : %(NumeroInitiativeEconomieSociale)s
        NONSS : %(NONSS)s
        """ % row)
        url = row[u'Internet']
        if url:
            if not url.startswith('http'):
                url = 'http://' + url
            if is_valid_url(url):
                kw.update(url=url)
        kw.update(remarks=row[u'Remarque'])
        if is_valid_email(row[u'EMail']):
            kw.update(email=row[u'EMail'])
        yield self.model(**kw)
예제 #2
0
파일: pp2lino.py 프로젝트: khchine5/welfare
    def row2obj(self, row):
        kw = {}
        kw.update(id=int(row['IDClient']) + OFFSET_PERSON)
        title = row['Titre']
        if not title in ("Monsieur", "Madame"):
            kw.update(title=title)
        if row['Nom']:
            kw.update(last_name=row['Nom'])
        else:
            kw.update(last_name="?")

        kw.update(gender=row['Sexe'])

        #~ sex = row['Sexe']
        #~ if sex == "M"
            #~ kw.update(sex='M')
        #~ elif sex == "F"
            #~ kw.update(sex='F')
        #~ else:
            #~ kw.update(sex='M')
        kw.update(first_name=row[u'Prénom'])
        kw.update(street_prefix=row[u'Rue'])
        kw.update(street=row[u'Adresse'])
        kw.update(street_no=row[u'Numero'])
        kw.update(street_box=row[u'Boite'])
        kw.update(gesdos_id=row[u'NumeroDossier'])
        kw.update(phone=row[u'Tel1'])
        kw.update(gsm=row[u'GSM1'])

        kw.update(birth_country_id=pays2iso(row[u'IDPays']))
        kw.update(nationality_id=nation2iso(row[u'IDNationalite']))
        kw.update(national_id=row[u'NumeroNational'])

        kw.update(coach1=get_by_id(User, row[u'IDASISP'], OFFSET_USER_ISP))
        kw.update(coach2=get_by_id(User, row[u'IDASSSG']))

        #~ kw.update(coach1=code2user(row[u'IDASISP'],OFFSET_USER_ISP))
        #~ kw.update(coach2=code2user(row[u'IDASSSG']))

        kw.update(group=phase2group(row[u'Phase']))

        city_id = row[u'IDCommuneCodePostal']
        if city_id:
            city_id = int(city_id)
            kw.update(city_id=city_id)

        if is_valid_email(row[u'Email']):
            kw.update(email=row[u'Email'])
        if row[u'DateNaissance']:
            kw.update(birth_date=self.parsedate(row[u'DateNaissance']))
        if row[u'DateArrivee']:
            kw.update(coached_from=self.parsedate(row[u'DateArrivee']))
        kw.update(remarks="""
        Tel2 : %(Tel2)s
        GSM2 : %(GSM2)s
        Remarques : %(Remarques)s
        """ % row)
        yield self.model(**kw)
예제 #3
0
def country2kw(row, kw):
    # for both PAR and ADR

    if row.has_key('PROF'):
        activity = row['PROF']
        if activity:
            try:
                activity = int(activity)
            except ValueError:
                dblogger.debug("Ignored invalid value PROF = %r", activity)
            else:
                if activity:
                    try:
                        activity = Activity.objects.get(pk=activity)
                    except Activity.DoesNotExist:
                        activity = Activity(
                            id=activity, name=unicode(activity))
                        activity.save(force_insert=True)
                    kw.update(activity=activity)

    country = row['PAYS']
    if country:
        try:
            country = Country.objects.get(short_code__exact=country)
        except Country.DoesNotExist:
            country = Country(isocode=country, name=country,
                              short_code=country)
            country.save()
        kw.update(country=country)

    email = row['EMAIL']
    if email and is_valid_email(email):
        kw.update(email=email)
    store(kw,
          phone=row['TEL'],
          fax=row['FAX'],
          )

    kw.update(street2kw(join_words(row['RUE'], row['RUENUM'], row['RUEBTE'])))

    zip_code = row['CP']
    if zip_code:
        kw.update(zip_code=zip_code)
        try:
            city = Place.objects.get(
                country=country,
                zip_code__exact=zip_code,
            )
            kw.update(city=city)
        except Place.DoesNotExist, e:
            city = Place(zip_code=zip_code, name=zip_code, country=country)
            city.save()
            kw.update(city=city)
            #~ dblogger.warning("%s-%s : %s",row['PAYS'],row['CP'],e)
        except Place.MultipleObjectsReturned, e:
            dblogger.warning("%s-%s : %s", row['PAYS'], row['CP'], e)
예제 #4
0
    def row2instance(self, nr, title, last_name, first_name, street,
                     zip_code, city_name, phone, gsm, birth_date, bez, datum,
                     mg, mgnr, email):
        Place = rt.models.countries.Place
        Pupil = rt.models.courses.Pupil

        kw = dict(last_name=last_name, first_name=first_name)
        if nr:
            kw.update(id=1000 + int(nr))
        kw.update(phone=phone)
        kw.update(gsm=gsm)
        try:
            kw.update(zip_code=str(int(zip_code)))
        except ValueError:
            kw.update(zip_code=zip_code)

        if email:
            if isinstance(email, basestring) and is_valid_email(email):
                kw.update(email=email)
            else:
                dd.logger.warning("Ignored invalid email address %r", email)

        kw.update(street2kw(street))

        if title == "Herr":
            kw.update(gender=dd.Genders.male)
        elif title == "Frau":
            kw.update(gender=dd.Genders.female)
        elif title:
            kw.update(title=title)
        city_name = city_name.strip()
        if city_name:
            #~ Place.objects.get(name)
            kw.update(city=Place.lookup_or_create(
                'name', city_name, country=self.country))
        #~ print birth_date
        kw.update(birth_date=self.date_converter(birth_date))
        return Pupil(**kw)
예제 #5
0
    def row2instance(self, legacy_id, title, last_name, first_name, street,
                     street_box,
                     zip_code, city_name, country_name,
                     phone, gsm, email, birth_date, erfasser,
                     remark,
                     eiche_mg, sektion, ckk, lfv, raviva,
                     nicht_mitglied, national_id, sex):
        Place = rt.models.countries.Place
        Pupil = rt.models.courses.Pupil
        Sections = rt.models.courses.Sections
        MEMBER_UNTIL = datetime.date(2016, 12, 31)

        update_fields = (
            'member_until', 'section', 'is_ckk', 'is_lfv', 'is_raviva')

        kw = dict(last_name=last_name, first_name=first_name)

        if legacy_id:
            kw.update(legacy_id=legacy_id)
        kw.update(is_raviva=raviva)
        kw.update(is_ckk=ckk)
        kw.update(is_lfv=lfv)
        kw.update(is_member=eiche_mg)
        kw.update(member_until=MEMBER_UNTIL if eiche_mg else None)
        kw.update(national_id=national_id)

        sektion = sektion.strip().lower()
        if sektion and sektion not in ("nein", "0", 'ja', '-1'):
            if sektion in ('wywertz', 'weywerz'):
                sektion = "weywertz"
            if sektion in ('heregenrath', ):
                sektion = "hergenrath"
            kw.update(section=Sections.get_by_name(sektion))

        kw.update(phone=phone)
        kw.update(gsm=gsm)
        try:
            kw.update(zip_code=str(int(zip_code)))
        except ValueError:
            kw.update(zip_code=zip_code)

        if email:
            if isinstance(email, basestring) and is_valid_email(email):
                kw.update(email=email)
            else:
                dd.logger.warning("Ignored invalid email address %r", email)

        kw.update(street2kw(street))
        kw.update(street_box=street_box)
        kw.update(remarks=remark)

        if title == "Herr":
            kw.update(gender=dd.Genders.male)
        elif title == "Frau":
            kw.update(gender=dd.Genders.female)
        elif title:
            kw.update(title=title)

        if sex == "Weiblich":
            kw.update(gender=dd.Genders.female)
        elif sex == "Männlich":
            kw.update(gender=dd.Genders.male)
        city_name = city_name.strip()
        if city_name:
            kw.update(city=Place.lookup_or_create(
                'name', city_name, country=self.country))
        #~ print birth_date
        kw.update(birth_date=self.date_converter(birth_date))

        try:
            obj = Pupil.objects.get(legacy_id=legacy_id)
            # for k, v in kw.items():
            changed = []
            for k in update_fields:
                if k in kw:
                    v = kw[k]
                    setattr(obj, k, v)
                    changed.append(v)
            uvalues = [eiche_mg, sektion, ckk, lfv, raviva]
            dd.logger.info("Updated %s (%s from %s)", obj, changed, uvalues)
        except Pupil.DoesNotExist:
            obj = Pupil(**kw)
            dd.logger.info("Created %s", obj)
        if eiche_mg and nicht_mitglied:
            dd.logger.warning("%s : Mitglied und Nicht-Mitglied zugleich", obj)
        return obj
예제 #6
0
        if zip_code:
            kw.update(zip_code=zip_code)
            try:
                city = Place.objects.get(country=country, zip_code__exact=zip_code)
                kw.update(city=city)
            except Place.DoesNotExist, e:
                city = Place(zip_code=zip_code, name=zip_code, country=country)
                city.save()
                kw.update(city=city)
                # ~ dblogger.warning("%s-%s : %s",row['PAYS'],row['CP'],e)
            except Place.MultipleObjectsReturned, e:
                dblogger.warning("%s-%s : %s", row["PAYS"], row["CP"], e)

    email = row["EMAIL"]
    if email:
        if is_valid_email(email):
            kw.update(email=email)
        else:
            dblogger.warning("Ignoring invalid email address %s", email)
    store(kw, phone=row["TEL"], fax=row["FAX"])

    kw.update(street2kw(join_words(row["RUE"], row["RUENUM"], row["RUEBTE"])))


# ~ def is_company(data):
def PAR_model(data):
    """
    - wer eine SSIN oder Gesdos-Nr hat ist ein Klient, selbst wenn er auch eine Mwst-Nummer hat.
    - Neuzugänge (Attribut N) sind ebenfalls immer Klienten
    
    """
예제 #7
0
    def load_par(self, row):
        kw = {}
        # kw.update(
        #     street2kw(join_words(
        #         row['RUE'],
        #         row['RUENUM'],
        #         row['RUEBTE'])))

        self.store(kw, id=self.par_pk(row.idpar))

        email = row.email.strip()
        if email and is_valid_email(email):
            self.store(kw, email=email)

        if 'idreg' in row:
            self.store(kw, vat_regime=vat_regime(row.idreg.strip()))
        cl = self.par_class(row)
        if cl is Company:
            cl = Company
            self.store(
                kw,
                vat_id=row['notva'].strip(),
                prefix=row['allo'].strip(),
                name=row.firme,
            )
        elif cl is Person:
            # self.store(kw, prefix=row.allo)
            # kw.update(**name2kw(self.decode_string(row.firme)))
            self.store(
                kw,
                first_name=row['vorname'].strip(),
                last_name=row.firme,
                # birth_date=row['gebdat'],
                title=row['allo'].strip(),
            )
            if 'sex' in row:
                sex = row.get('sex', None)
                self.store(kw, gender=convert_gender(sex))
        elif cl is Household:
            self.store(
                kw,
                name=row.firme.strip() + ' ' + row.vorname.strip(),
            )
        elif cl is List:
            self.store(
                kw,
                name=row.firme,
            )
        else:
            dblogger.warning("Ignored PAR record %s (IdPrt %r)" %
                             (row.idpar, row.idprt))
            return
        if cl is not List:
            if 'datcrea' in row:
                created = row.get('datcrea', None)
                if created:
                    kw.update(created=created)

            language = isolang(row['langue'])

            if settings.SITE.get_language_info(language):
                self.store(kw, language=language)

            if 'memo' in row:
                self.store(kw, remarks=self.dbfmemo(row.get('memo') or ''))

            isocode = self.short2iso(row.pays.strip())
            if isocode:
                try:
                    country = Country.objects.get(isocode=isocode)
                except Country.DoesNotExist:
                    country = Country(isocode=isocode, name=isocode)
                    country.save()
                kw.update(country=country)

                zip_code = row['cp'].strip()
                if zip_code:
                    kw.update(zip_code=zip_code)
                    qs = Place.objects.filter(
                        country=country,
                        zip_code__exact=zip_code,
                    )
                    if qs.count() == 0:
                        city = Place(zip_code=zip_code,
                                     name=zip_code,
                                     country=country)
                        city.save()
                        kw.update(city=city)
                    else:
                        kw.update(city=qs[0])
                        s = self.duplicate_zip_codes.get(country, set([]))
                        s.add(zip_code)

            self.store(
                kw,
                phone=row['tel'].strip(),
                fax=row['fax'].strip(),
                street=row['rue'].strip(),
                street_no=row['ruenum'],
                street_box=row['ruebte'].strip(),
            )

            # kw.update(street2kw(join_words(row['RUE'],
            # row['RUENUM'],row['RUEBTE'])))

        try:
            obj = cl(**kw)
        except Exception:
            dblogger.warning("Failed to instantiate %s from %s", cl, kw)
            raise
        yield obj

        def compte2iban(s, **kw):
            a = s.split(':')
            if len(a) == 1:
                kw.update(iban=s)
            elif len(a) == 2:
                kw.update(bic=a[0])
                kw.update(iban=a[1])
            else:
                kw.update(iban=s)
            return kw

        compte1 = row['compte1'].strip()
        if compte1:
            obj.full_clean()
            obj.save()
            kw = compte2iban(compte1, partner=obj, primary=True)
            if kw['iban']:
                obj = sepa.Account(**kw)
                try:
                    obj.full_clean()
                    yield obj
                except ValidationError:
                    dblogger.warning("Ignored invalid PAR->Compte1 %r",
                                     compte1)
예제 #8
0
파일: timloader1.py 프로젝트: khchine5/cosi
    def load_par(self, row):
        kw = {}
        # kw.update(
        #     street2kw(join_words(
        #         row['RUE'],
        #         row['RUENUM'],
        #         row['RUEBTE'])))

        self.store(kw, id=self.par_pk(row.idpar))

        email = row.email.strip()
        if email and is_valid_email(email):
            self.store(kw, email=email)

        if 'idreg' in row:
            self.store(kw, vat_regime=vat_regime(row.idreg.strip()))
        cl = self.par_class(row)
        if cl is Company:
            cl = Company
            self.store(
                kw,
                vat_id=row['notva'].strip(),
                prefix=row['allo'].strip(),
                name=row.firme,
            )
        elif cl is Person:
            # self.store(kw, prefix=row.allo)
            # kw.update(**name2kw(self.decode_string(row.firme)))
            self.store(
                kw,
                first_name=row['vorname'].strip(),
                last_name=row.firme,
                # birth_date=row['gebdat'],
                title=row['allo'].strip(),
            )
            if 'sex' in row:
                sex = row.get('sex', None)
                self.store(
                    kw, gender=convert_gender(sex))
        elif cl is Household:
            self.store(
                kw,
                name=row.firme.strip() + ' ' + row.vorname.strip(),
            )
        elif cl is List:
            self.store(
                kw,
                name=row.firme,
            )
        else:
            dblogger.warning(
                "Ignored PAR record %s (IdPrt %r)" % (
                    row.idpar, row.idprt))
            return
        if cl is not List:
            if 'datcrea' in row:
                created = row.get('datcrea', None)
                if created:
                    kw.update(created=created)

            language = isolang(row['langue'])
            
            if settings.SITE.get_language_info(language):
                self.store(kw, language=language)

            if 'memo' in row:
                self.store(
                    kw, remarks=self.dbfmemo(row.get('memo') or ''))

            isocode = self.short2iso(row.pays.strip())
            if isocode:
                try:
                    country = Country.objects.get(
                        isocode=isocode)
                except Country.DoesNotExist:
                    country = Country(isocode=isocode,
                                      name=isocode)
                    country.save()
                kw.update(country=country)

                zip_code = row['cp'].strip()
                if zip_code:
                    kw.update(zip_code=zip_code)
                    qs = Place.objects.filter(
                        country=country,
                        zip_code__exact=zip_code,
                    )
                    if qs.count() == 0:
                        city = Place(zip_code=zip_code,
                                     name=zip_code,
                                     country=country)
                        city.save()
                        kw.update(city=city)
                    else:
                        kw.update(city=qs[0])
                        s = self.duplicate_zip_codes.get(country, set([]))
                        s.add(zip_code)
                    
            self.store(
                kw,
                phone=row['tel'].strip(),
                fax=row['fax'].strip(),
                street=row['rue'].strip(),
                street_no=row['ruenum'],
                street_box=row['ruebte'].strip(),
            )

            # kw.update(street2kw(join_words(row['RUE'],
            # row['RUENUM'],row['RUEBTE'])))

        try:
            obj = cl(**kw)
        except Exception:
            dblogger.warning("Failed to instantiate %s from %s",
                             cl, kw)
            raise
        yield obj

        def compte2iban(s, **kw):
            a = s.split(':')
            if len(a) == 1:
                kw.update(iban=s)
            elif len(a) == 2:
                kw.update(bic=a[0])
                kw.update(iban=a[1])
            else:
                kw.update(iban=s)
            return kw
        
        compte1 = row['compte1'].strip()
        if compte1:
            obj.full_clean()
            obj.save()
            kw = compte2iban(compte1, partner=obj, primary=True)
            if kw['iban']:
                obj = sepa.Account(**kw)
                try:
                    obj.full_clean()
                    yield obj
                except ValidationError:
                    dblogger.warning(
                        "Ignored invalid PAR->Compte1 %r", compte1)
예제 #9
0
파일: timloader1.py 프로젝트: khchine5/xl
    def load_par(self, row):
        kw = {}
        # kw.update(
        #     street2kw(join_words(
        #         row['RUE'],
        #         row['RUENUM'],
        #         row['RUEBTE'])))

        # the following code needs the top-level (possibly abstract)
        # models:
        from lino_xl.lib.contacts.models import Person, Company
        from lino_xl.lib.households.models import Household

        self.store(kw, id=self.par_pk(row.idpar))

        cl = self.par_class(row)
        
        if cl is None:
            dblogger.warning(
                "Ignored PAR record %s (IdPrt %r)" % (
                    row.idpar, row.idprt))
            return
        
        if issubclass(cl, (Company, Person, Household)):
            email = row.email.strip()
            if email and is_valid_email(email):
                self.store(kw, email=email)

        if 'idreg' in row:
            self.store(kw, vat_regime=vat_regime(row.idreg.strip()))
            
        if 'idgen' in row:
            self.store(kw, purchase_account=self.get_account(row.idgen))
            
        if issubclass(cl, Company):
            # cl = Company
            self.store(
                kw,
                prefix=row['allo'].strip(),
                name=row.firme.strip() + ' ' + row.vorname,
            )
            if dd.is_installed('vat'):
                self.store(
                    kw, vat_id=row['notva'].strip())
                
        if issubclass(cl, Person):
            # self.store(kw, prefix=row.allo)
            # kw.update(**name2kw(self.decode_string(row.firme)))
            last_name = row.firme.strip()
            if row.name2.strip():
                last_name += '-' + row.name2.strip()
            self.store(
                kw,
                first_name=row['vorname'].strip(),
                last_name=last_name,
                # birth_date=row['gebdat'],
                title=row['allo'].strip(),
            )
            assert kw['first_name'] or kw['last_name']
            # depends on which dbf module is being used:
            # if 'sex' in row:
            if hasattr(row, 'sex'):
                # sex = row.get('sex', None)
                sex = row.sex
                self.store(
                    kw, gender=convert_gender(sex))
        if issubclass(cl, Household):
            self.store(
                kw,
                name=row.firme.strip() + ' ' + row.vorname.strip(),
            )
        if dd.is_installed('lists') and issubclass(cl, List):
            self.store(kw, designation=row.firme)
        
        if issubclass(cl, Created):
            if 'datcrea' in row:
                created = row.get('datcrea', None)
                if created:
                    created = datetime.datetime.combine(
                        created, datetime.time(0, 0, 0))
                    if settings.USE_TZ:
                        created = make_aware(created)
                    kw.update(created=created)

        # if cl is not List:
        if issubclass(cl, rt.models.contacts.Partner):
            language = isolang(row['langue'])
            
            if settings.SITE.get_language_info(language):
                self.store(kw, language=language)

            if 'memo' in row:
                self.store(
                    kw, remarks=self.dbfmemo(row.get('memo') or ''))

            isocode = self.short2iso(row.pays.strip())
            if isocode:
                try:
                    country = Country.objects.get(
                        isocode=isocode)
                except Country.DoesNotExist:
                    country = Country(isocode=isocode,
                                      name=isocode)
                    country.save()
                kw.update(country=country)

                zip_code = row['cp'].strip()
                if zip_code:
                    kw.update(zip_code=zip_code)
                    qs = Place.objects.filter(
                        country=country,
                        zip_code__exact=zip_code,
                    )
                    if qs.count() == 0:
                        city = Place(zip_code=zip_code,
                                     name=zip_code,
                                     country=country)
                        city.save()
                        kw.update(city=city)
                    else:
                        kw.update(city=qs[0])
                        s = self.duplicate_zip_codes.get(country, set([]))
                        s.add(zip_code)
                    
            self.store(
                kw,
                phone=row['tel'].strip(),
                fax=row['fax'].strip(),
                street=row['rue'].strip(),
                street_no=row['ruenum'],
                street_box=row['ruebte'].strip(),
            )

            # kw.update(street2kw(join_words(row['RUE'],
            # row['RUENUM'],row['RUEBTE'])))

        try:
            obj = cl(**kw)
        except Exception:
            dblogger.warning("Failed to instantiate %s from %s",
                             cl, kw)
            raise
        yield obj

        def compte2iban(s, **kw):
            a = s.split(':')
            if len(a) == 1:
                kw.update(iban=s)
            elif len(a) == 2:
                kw.update(bic=a[0])
                kw.update(iban=a[1])
            else:
                kw.update(iban=s)
            return kw

        if not dd.is_installed('sepa'):
            return
        
        compte1 = row['compte1'].strip()
        if compte1:
            obj.full_clean()
            obj.save()
            kw = compte2iban(compte1, partner=obj, primary=True)
            if kw['iban']:
                obj = sepa.Account(**kw)
                try:
                    obj.full_clean()
                    yield obj
                except ValidationError:
                    dblogger.warning(
                        "Ignored invalid PAR->Compte1 %r", compte1)
예제 #10
0
파일: timloader1.py 프로젝트: einarfelix/xl
    def load_par(self, row):
        kw = {}
        # kw.update(
        #     street2kw(join_words(
        #         row['RUE'],
        #         row['RUENUM'],
        #         row['RUEBTE'])))

        # the following code needs the top-level (possibly abstract)
        # models:
        from lino_xl.lib.contacts.models import Person, Company
        partner_models = (Person, Company)
        if dd.is_installed('households'):
            from lino_xl.lib.households.models import Household
            partner_models = (Person, Company, Household)

        self.store(kw, id=self.par_pk(row.idpar))

        cl = self.par_class(row)
        
        if cl is None:
            dblogger.warning(
                "Ignored PAR record %s (IdPrt %r)" % (
                    row.idpar, row.idprt))
            return
        
        if issubclass(cl, partner_models):
            email = row.email.strip()
            if email and is_valid_email(email):
                self.store(kw, email=email)

        # if 'idreg' in row:
        if row.idreg:
            self.store(kw, vat_regime=vat_regime(row.idreg.strip()))
            
        # if 'idgen' in row:
        if row.idgen:
            self.store(kw, purchase_account=self.get_account(row.idgen))
            
        if issubclass(cl, Company):
            # cl = Company
            self.store(
                kw,
                prefix=row['allo'].strip(),
                name=row.firme.strip() + ' ' + row.vorname,
            )
            if dd.is_installed('vat'):
                self.store(
                    kw, vat_id=row['notva'].strip())
                
        if issubclass(cl, Person):
            # self.store(kw, prefix=row.allo)
            # kw.update(**name2kw(self.decode_string(row.firme)))
            last_name = row.firme.strip()
            if row.name2.strip():
                last_name += '-' + row.name2.strip()
            self.store(
                kw,
                first_name=row['vorname'].strip(),
                last_name=last_name,
                # birth_date=row['gebdat'],
                title=row['allo'].strip(),
            )
            assert kw['first_name'] or kw['last_name']
            # depends on which dbf module is being used:
            # if 'sex' in row:
            if hasattr(row, 'sex'):
                # sex = row.get('sex', None)
                sex = row.sex
                self.store(
                    kw, gender=convert_gender(sex))
        if dd.is_installed('households'):
            if issubclass(cl, Household):
                self.store(
                    kw,name=row.firme.strip() + ' ' + row.vorname.strip())
        if dd.is_installed('lists') and issubclass(cl, List):
            self.store(kw, designation=row.firme)
        
        if issubclass(cl, Created):
            if 'datcrea' in row:
                created = row.get('datcrea', None)
                if created:
                    created = datetime.datetime.combine(
                        created, datetime.time(0, 0, 0))
                    if settings.USE_TZ:
                        created = make_aware(created)
                    kw.update(created=created)

        # if cl is not List:
        if issubclass(cl, rt.models.contacts.Partner):
            language = isolang(row['langue'])
            
            if settings.SITE.get_language_info(language):
                self.store(kw, language=language)

            # if 'memo' in row:
            if row.memo:
                self.store(
                    kw, remarks=self.dbfmemo(row.get('memo') or ''))

            isocode = self.short2iso(row.pays.strip())
            if isocode:
                try:
                    country = Country.objects.get(
                        isocode=isocode)
                except Country.DoesNotExist:
                    country = Country(isocode=isocode,
                                      name=isocode)
                    country.save()
                kw.update(country=country)

                zip_code = row['cp'].strip()
                if zip_code:
                    kw.update(zip_code=zip_code)
                    qs = Place.objects.filter(
                        country=country,
                        zip_code__exact=zip_code,
                    )
                    if qs.count() == 0:
                        city = Place(zip_code=zip_code,
                                     name=zip_code,
                                     country=country)
                        city.save()
                        kw.update(city=city)
                    else:
                        kw.update(city=qs[0])
                        s = self.duplicate_zip_codes.get(country, set([]))
                        s.add(zip_code)
                    
            self.store(
                kw,
                phone=row['tel'].strip(),
                fax=row['fax'].strip(),
                street=row['rue'].strip(),
                street_no=row['ruenum'],
                street_box=row['ruebte'].strip(),
            )

            # kw.update(street2kw(join_words(row['RUE'],
            # row['RUENUM'],row['RUEBTE'])))

        try:
            obj = cl(**kw)
        except Exception:
            dblogger.warning("Failed to instantiate %s from %s",
                             cl, kw)
            raise
        yield obj

        def compte2iban(s, **kw):
            a = s.split(':')
            if len(a) == 1:
                kw.update(iban=s)
            elif len(a) == 2:
                kw.update(bic=a[0])
                kw.update(iban=a[1])
            else:
                kw.update(iban=s)
            return kw

        if not dd.is_installed('sepa'):
            return
        
        compte1 = row['compte1'].strip()
        if compte1:
            obj.full_clean()
            obj.save()
            kw = compte2iban(compte1, partner=obj, primary=True)
            if kw['iban']:
                obj = sepa.Account(**kw)
                try:
                    obj.full_clean()
                    yield obj
                except ValidationError:
                    dblogger.warning(
                        "Ignored invalid PAR->Compte1 %r", compte1)