Beispiel #1
0
    def process_one(self, data, fields, store):
        person = Person(store=store,
                        name=data.name,
                        phone_number=data.phone_number,
                        mobile_number=data.mobile_number)

        Company(person=person,
                store=store,
                cnpj=data.cnpj,
                fancy_name=data.name,
                state_registry=data.state_registry)

        ctloc = CityLocation.get_or_create(store=store,
                                           city=data.city,
                                           state=data.state,
                                           country=data.country)
        streetnumber = data.streetnumber and int(data.streetnumber) or None
        Address(is_main_address=True,
                person=person,
                city_location=ctloc,
                store=store,
                street=data.street,
                streetnumber=streetnumber,
                district=data.district)

        Supplier(person=person, store=store)
Beispiel #2
0
 def create_supplier(self, name=u'Supplier', fancy_name=u'Company Name'):
     from stoqlib.domain.person import Company, Person, Supplier
     person = Person(name=name, store=self.store)
     Company(person=person, fancy_name=fancy_name,
             cnpj=u'90.117.749/7654-80',
             store=self.store)
     return Supplier(person=person, store=self.store)
Beispiel #3
0
    def find_or_create_supplier(self, nfe_supplier):
        # FIXME: Need to do the same thing to Individual suppliers
        person = Person.get_or_create_by_document(
            self.store,
            nfe_supplier.cnpj,
            name=nfe_supplier.name,
            phone_number=nfe_supplier.phone_number,
            notes=u"Automatically created by Stoq-Link")

        person.company.state_registry = nfe_supplier.state_registry
        person.company.fancy_name = nfe_supplier.fancy_name or nfe_supplier.name

        if person.supplier is None:
            supplier = Supplier(store=self.store, person=person)
            nfe_supplier.supplier = supplier

        return person.supplier
Beispiel #4
0
 def create_model(self, store):
     person = BasePersonRoleEditor.create_model(self, store)
     supplier = person.supplier
     if supplier is None:
         supplier = Supplier(person=person, store=store)
     return supplier