Exemplo n.º 1
0
Arquivo: demo2.py Projeto: khchine5/xl
def objects():
    AddressTypes = rt.models.addresses.AddressTypes
    Address = rt.models.addresses.Address
    # Partner = rt.models.contacts.Partner
    Partner = dd.plugins.addresses.partner_model
    Place = rt.models.countries.Place
    eupen = Place.objects.get(name__exact='Eupen')
    STREETS = Cycler(streets_of_eupen())
    TYPES = Cycler(AddressTypes.objects())

    def create_addr_from_owner(o, **kw):
        kw.update(partner=o)
        for k in Address.ADDRESS_FIELDS:
            kw[k] = getattr(o, k)
        return Address(**kw)

    nr = 1
    for p in Partner.objects.filter(city=eupen):
        if nr % 3:
            yield create_addr_from_owner(
                p, primary=True, address_type=AddressTypes.official)
            kw = dict(partner=p)
            kw.update(address_type=TYPES.pop())
            kw.update(street=STREETS.pop())
            kw.update(street_no=str(nr % 200))
            yield Address(**kw)
        nr += 1
Exemplo n.º 2
0
Arquivo: demo.py Projeto: khchine5/xl
"""
Adds a series of fictive persons and companies.
"""

from __future__ import unicode_literals
from builtins import str


from django.conf import settings
from lino.utils.instantiator import Instantiator
from lino.utils import Cycler
from lino.api import dd, rt

from lino.utils.demonames.bel import streets_of_eupen
STREETS = Cycler(streets_of_eupen())

def site_company_objects():

    company = Instantiator(
        'contacts.Company',
        "name zip_code city:name street street_no",
        country='EE').build
    rumma = company(
        # 'Rumma & Ko OÜ', '10115', 'Tallinn', 'Tartu mnt', '71',
        'Rumma & Ko OÜ', '78003', 'Vigala', 'Uus tn', '1',
        url="http://www.saffre-rumma.net/")
    if dd.is_installed('vat'):
        rumma.vat_id = "EE100588749"
        # a vat_id is required for generating valid XML from payment order
    yield rumma