Beispiel #1
0
    def gen_companies(self):
        """
        Generate companies as expected
        """
        from autonomie.models.company import Company
        companies = []
        for data in self.activity_companydatas:
            # Try to retrieve an existing company (and avoid duplicates)
            company = Company.query().filter(
                Company.name == data.name
            ).first()

            if company is None:
                company = Company(
                    name=data.name,
                    goal=data.title,
                    email=self.coordonnees_email1,
                    phone=self.coordonnees_tel,
                    mobile=self.coordonnees_mobile,
                )
                if data.activity is not None:
                    company.activities.append(data.activity)

            company.employees.append(self.user)
            companies.append(company)
        return companies
Beispiel #2
0
 def add_company(self, name, user):
     """
         Add a company 'name' in the database
         ( set its goal by default )
     """
     log.info(u"Adding company : %s" % name)
     company = Company()
     company.name = name
     company.goal = u"Entreprise de {0}".format(format_account(user))
     company.contribution = self.request.config.get('contribution_cae')
     company = self.dbsession.merge(company)
     self.dbsession.flush()
     return company
def company2(dbsession, user):
    from autonomie.models.company import Company
    company = Company(
        name=u"Company 2",
        email=u"*****@*****.**",
    )
    company.employees = [user]
    dbsession.add(company)
    dbsession.flush()
    user.companies = [company]
    user = dbsession.merge(user)
    dbsession.flush()
    return company
Beispiel #4
0
def company2(dbsession, user):
    from autonomie.models.company import Company
    company = Company(
        name=u"Company 2",
        email=u"*****@*****.**",
    )
    company.employees = [user]
    dbsession.add(company)
    dbsession.flush()
    user.companies = [company]
    user = dbsession.merge(user)
    dbsession.flush()
    return company
 def _mk_company(name, email, code_compta):
     from autonomie.models.company import Company
     company = Company(
         name=name,
         email=email,
         code_compta=code_compta,
     )
     company.employees = [user]
     dbsession.add(company)
     dbsession.flush()
     user.companies = [company]
     dbsession.merge(user)
     dbsession.flush()
     return company
Beispiel #6
0
 def _add_company(self, name, user):
     """
         Add a company 'name' in the database
         ( set its goal by default )
     """
     logger.info(u"Adding company : %s" % name)
     company = Company()
     company.name = name
     company.goal = u"Entreprise de {0}".format(
         format_account(user, reverse=False))
     company.contribution = self.request.config.get('contribution_cae')
     company = self.dbsession.merge(company)
     self.dbsession.flush()
     return company
Beispiel #7
0
 def _mk_company(name, email, code_compta):
     from autonomie.models.company import Company
     company = Company(
         name=name,
         email=email,
         code_compta=code_compta,
     )
     company.employees = [user]
     dbsession.add(company)
     dbsession.flush()
     user.companies = [company]
     dbsession.merge(user)
     dbsession.flush()
     return company
class TestCompanyModel(BaseTestCase):
    def setUp(self):
        BaseTestCase.setUp(self)
        self.company = Company(name=u"Test", id=1)
        self.company.logo = dict(filename=u"logo.png")
        self.company.header = dict(filename=u"header.png")

    def test_get_path(self):
        self.assertEqual(self.company.get_path(), "company/1")
        self.assertEqual(self.company.get_logo_filepath(), "company/1/logo/logo.png")
        self.assertEqual(self.company.get_header_filepath(), "company/1/header/header.png")

    def test_get_company_id(self):
        self.assertEqual(self.company.get_company_id(), 1)
Beispiel #9
0
def other_company(dbsession, other_user):
    from autonomie.models.company import Company
    company = Company(
        name=u"Company2",
        email=u"*****@*****.**",
        code_compta="0USER2",
    )
    company.employees = [other_user]
    dbsession.add(company)
    dbsession.flush()
    other_user.companies = [company]
    other_user = dbsession.merge(other_user)
    dbsession.flush()
    return company
Beispiel #10
0
def add_company(user, company_name, goal=""):
    company = Company()
    company.name = company_name
    company.goal = goal or u"Entreprise de %s" % user.login

    user.companies.append(company)

    session = DBSESSION()
    session.add(company)

    session.flush()

    print "Added company for %s: %s" % (user.login, company_name)

    return company
Beispiel #11
0
def get_company_by_code(code_compta):
    """
    Return the company associated to this code_compta
    :param str code_compta: The analytic code of the company to find
    """
    query = Company.query().filter(Company.code_compta==code_compta)
    return query.first()
Beispiel #12
0
    def submit_success(self, appstruct):
        """
            Insert config informations into database
        """
        # la table config étant un stockage clé valeur
        # le merge_session_with_post ne peut être utilisé
        dbdatas = Config.query().all()

        log.debug(u"Cae configuration submission")
        log.debug(appstruct)

        new_dbdatas = merge_config_datas(dbdatas, appstruct)
        for dbdata in new_dbdatas:
            log.debug(dbdata.name)
            if dbdata in dbdatas:
                self.dbsession.merge(dbdata)
            else:
                self.dbsession.add(dbdata)
            # If we set the contribution_cae value, we want it to be the default
            # for every company that has no contribution value set
            if dbdata.name == 'contribution_cae':
                for comp in Company.query():
                    if comp.contribution is None:
                        comp.contribution = dbdata.value
                        self.dbsession.merge(comp)
        self.dbsession.flush()
        self.request.session.flash(self.validation_msg)
        return HTTPFound(self.request.route_path("admin_cae"))
    def gen_companies(self):
        """
        Generate companies as expected
        """
        from autonomie.models.company import Company
        companies = []
        for data in self.activity_companydatas:
            # Try to retrieve an existing company (and avoid duplicates)
            company = Company.query().filter(
                Company.name == data.name
            ).first()

            if company is None:
                company = Company(
                    name=data.name,
                    goal=data.title,
                    email=self.coordonnees_email1,
                    phone=self.coordonnees_tel,
                    mobile=self.coordonnees_mobile,
                )
                if data.activity is not None:
                    company.activities.append(data.activity)

            company.employees.append(self.user)
            companies.append(company)
        return companies
Beispiel #14
0
    def submit_success(self, appstruct):
        """
            Insert config informations into database
        """
        # la table config étant un stockage clé valeur
        # le merge_session_with_post ne peut être utilisé
        dbdatas = Config.query().all()

        log.debug(u"Cae configuration submission")
        log.debug(appstruct)

        new_dbdatas = merge_config_datas(dbdatas, appstruct)
        for dbdata in new_dbdatas:
            log.debug(dbdata.name)
            if dbdata in dbdatas:
                self.dbsession.merge(dbdata)
            else:
                self.dbsession.add(dbdata)
            # If we set the contribution_cae value, we want it to be the default
            # for every company that has no contribution value set
            if dbdata.name == 'contribution_cae':
                for comp in Company.query():
                    if comp.contribution is None:
                        comp.contribution = dbdata.value
                        self.dbsession.merge(comp)
        self.dbsession.flush()
        self.request.session.flash(self.validation_msg)
        return HTTPFound(self.request.route_path("admin_cae"))
Beispiel #15
0
def get_company_by_code(code_compta):
    """
    Return the company associated to this code_compta
    :param str code_compta: The analytic code of the company to find
    """
    query = Company.query().filter(Company.code_compta == code_compta)
    return query.first()
Beispiel #16
0
 def submit_success(self, appstruct):
     """
     Edit the database entry and return redirect
     """
     user_id = appstruct.get("user_id")
     company = Company()
     company.activities = fetch_activities_objects(appstruct)
     company = merge_session_with_post(company, appstruct)
     if user_id is not None:
         user_account = User.get(user_id)
         if user_account is not None:
             company.employees.append(user_account)
     self.dbsession.add(company)
     self.dbsession.flush()
     message = u"L'entreprise '{0}' a bien été ajoutée".format(company.name)
     self.session.flash(message)
     return HTTPFound(self.request.route_path("company", id=company.id))
Beispiel #17
0
def get_company(request, cid):
    """
        Retrieve the current company object
    """
    if not hasattr(request, "_company"):
        company = Company.get(cid)
        request._company = company
    return request._company
Beispiel #18
0
 def submit_success(self, appstruct):
     """
     Edit the database entry and return redirect
     """
     user_id = appstruct.get('user_id')
     company = Company()
     company.activities = fetch_activities_objects(appstruct)
     company = merge_session_with_post(company, appstruct)
     if user_id is not None:
         user_account = User.get(user_id)
         if user_account is not None:
             company.employees.append(user_account)
     self.dbsession.add(company)
     self.dbsession.flush()
     message = u"L'entreprise '{0}' a bien été ajoutée".format(company.name)
     self.session.flash(message)
     return HTTPFound(self.request.route_path("company", id=company.id))
Beispiel #19
0
 def get_company(self, name, user):
     """
         Return a company object, create a new one if needed
     """
     company = Company.query().filter(Company.name==name).first()
     #avoid creating duplicate companies
     if company is None:
         company = self.add_company(name, user)
     return company
def upgrade():
    from autonomie.models.company import Company
    from autonomie.models.files import File
    from autonomie.models import DBSESSION
    from alembic.context import get_bind
    from autonomie.models.config import ConfigFiles

    for i in ('header_id', 'logo_id',):
        col = sa.Column(i, sa.Integer, sa.ForeignKey('file.id'))
        op.add_column('company', col)

    query = "select id, header, logo from company;"
    conn = get_bind()
    result = conn.execute(query)

    session = DBSESSION()

    for id_, header, logo in result:
        company = Company.get(id_)
        basepath = u"%scompany/%s" % (BASEFILEPATH, id_,)

        if header:
            header_path = u"%s/header/%s" % (basepath, header)
            try:
                file_datas = load_file_struct(header_path, header)
            except:
                print("Error while loading a header")
                print(id_)
                file_datas = None
            if file_datas:
                company.header = file_datas
                session.add(company.header_file)
                session.flush()

        if logo:
            logo_path = u"%s/logo/%s" % (basepath, logo)
            try:
                file_datas = load_file_struct(logo_path, logo)
            except:
                print("Error while loading a logo")
                print(id_)
                file_datas = None
            if file_datas:
                company.logo = file_datas
                company = session.merge(company)
                session.flush()

    filepath = u"%s/main/logo.png" % BASEFILEPATH
    if os.path.isfile(filepath):
        ConfigFiles.set('logo.png', load_file_struct(filepath, 'logo.png'))

    filepath = u"%s/main/accompagnement_header.png" % BASEFILEPATH
    if os.path.isfile(filepath):
        ConfigFiles.set(
            'accompagnement_header.png',
            load_file_struct(filepath, 'accompagnement_header.png')
        )
def upgrade():
    from autonomie.models.company import Company
    from autonomie.models.files import File
    from autonomie_base.models.base import DBSESSION
    from alembic.context import get_bind
    from autonomie.models.config import ConfigFiles

    for i in ('header_id', 'logo_id',):
        col = sa.Column(i, sa.Integer, sa.ForeignKey('file.id'))
        op.add_column('company', col)

    query = "select id, header, logo from company;"
    conn = get_bind()
    result = conn.execute(query)

    session = DBSESSION()

    for id_, header, logo in result:
        company = Company.get(id_)
        basepath = u"%scompany/%s" % (BASEFILEPATH, id_,)

        if header:
            header_path = u"%s/header/%s" % (basepath, header)
            try:
                file_datas = load_file_struct(header_path, header)
            except:
                print("Error while loading a header")
                print(id_)
                file_datas = None
            if file_datas:
                company.header = file_datas
                session.add(company.header_file)
                session.flush()

        if logo:
            logo_path = u"%s/logo/%s" % (basepath, logo)
            try:
                file_datas = load_file_struct(logo_path, logo)
            except:
                print("Error while loading a logo")
                print(id_)
                file_datas = None
            if file_datas:
                company.logo = file_datas
                company = session.merge(company)
                session.flush()

    filepath = u"%s/main/logo.png" % BASEFILEPATH
    if os.path.isfile(filepath):
        ConfigFiles.set('logo.png', load_file_struct(filepath, 'logo.png'))

    filepath = u"%s/main/accompagnement_header.png" % BASEFILEPATH
    if os.path.isfile(filepath):
        ConfigFiles.set(
            'accompagnement_header.png',
            load_file_struct(filepath, 'accompagnement_header.png')
        )
Beispiel #22
0
 def _get_company(self, name, user):
     """
         Return a company object, create a new one if needed
     """
     query = Company.query()
     company = query.filter(Company.name == name).first()
     # avoid creating duplicate companies
     if company is None:
         company = self._add_company(name, user)
     return company
Beispiel #23
0
def customer(config, content, get_csrf_request_with_db):
    config.add_route('customer', '/')
    request = get_csrf_request_with_db()
    comp = Company.query().first()
    comp.__name__ = 'company'
    request.context = comp
    request.user = Dummy()
    view = CustomerAdd(request)
    view.submit_success(APPSTRUCT)
    return getOne()
Beispiel #24
0
def customer(config, content, get_csrf_request_with_db):
    config.add_route('customer', '/')
    request = get_csrf_request_with_db()
    comp = Company.query().first()
    comp.__name__ = 'company'
    request.context = comp
    request.user = get_user()
    view = CustomerAdd(request)
    view.submit_success(APPSTRUCT)
    return getOne()
Beispiel #25
0
def get_companies(request):
    """
        Retrieve the companies the current user has access to
    """
    companies = []
    if request.has_permission('manage'):
        companies = Company.query().all()
    else:
        companies = request.user.active_companies
    return companies
Beispiel #26
0
def get_companies(request):
    """
        Retrieve the companies the current user has access to
    """
    companies = []
    if request.user.is_admin() or request.user.is_manager():
        companies = Company.query().all()
    else:
        companies = request.user.companies
    return companies
Beispiel #27
0
def get_companies(request):
    """
        Retrieve the companies the current user has access to
    """
    companies = []
    if request.user.is_admin() or request.user.is_manager():
        companies = Company.query().all()
    else:
        companies = request.user.companies
    return companies
Beispiel #28
0
def project(config, get_csrf_request_with_db):
    from autonomie.views.project import ProjectAdd
    config.add_route('project', '/')
    req = get_csrf_request_with_db()
    company = Company.query().first()
    company.__name__ = 'company'
    req.context = company
    view = ProjectAdd(req)
    appstruct = APPSTRUCT.copy()
    view.submit_success(appstruct)
    return getone()
Beispiel #29
0
    def submit_success(self, appstruct):
        for name in appstruct.get('companies', []):
            company = Company.query().filter(Company.name == name).first()
            if company is not None:
                self.context.user.companies.append(company)
                self.request.dbsession.merge(self.context.user)

        url = self.request.route_path("userdata",
                                      id=self.context.id,
                                      _anchor="tab5")
        return HTTPFound(url)
Beispiel #30
0
def project(config, get_csrf_request_with_db):
    from autonomie.views.project import ProjectAdd
    config.add_route('project', '/')
    req = get_csrf_request_with_db()
    company = Company.query().first()
    company.__name__ = 'company'
    req.context = company
    view = ProjectAdd(req)
    appstruct = APPSTRUCT.copy()
    view.submit_success(appstruct)
    return getone()
Beispiel #31
0
def get_companies(request):
    """
        Retrieve the companies the current user has access to
    """
    companies = []
    if request.has_permission('manage'):
        print(u"Has the permission")
        companies = Company.query().all()
    else:
        companies = request.user.companies
    return companies
Beispiel #32
0
def belongs_to_company(filename):
    """
    Check if a file belongs to a company

    :param str filename: The filename we want to check
    """
    try:
        code_compta = get_code_compta(filename)
        result = Company.query().filter(Company.code_compta==code_compta).count() > 0
    except:
        result = False
    return result
Beispiel #33
0
    def submit_success(self, appstruct):
        for name in appstruct.get('companies', []):
            company = Company.query().filter(Company.name == name).first()
            if company is not None and \
                    company not in self.current_user.companies:
                self.current_user.companies.append(company)
                self.request.dbsession.merge(self.current_user)

        url = self.request.route_path(
            "/users/{id}/companies",
            id=self.current_user.id,
        )
        return HTTPFound(url)
Beispiel #34
0
    def submit_success(self, appstruct):
        for name in appstruct.get('companies', []):
            company = Company.query().filter(Company.name == name).first()
            if company is not None:
                self.context.user.companies.append(company)
                self.request.dbsession.merge(self.context.user)

        url = self.request.route_path(
            "userdata",
            id=self.context.id,
            _anchor="tab5"
        )
        return HTTPFound(url)
Beispiel #35
0
    def submit_success(self, appstruct):
        for name in appstruct.get('companies', []):
            company = Company.query().filter(Company.name == name).first()
            if company is not None and \
                    company not in self.current_user.companies:
                self.current_user.companies.append(company)
                self.request.dbsession.merge(self.current_user)

        url = self.request.route_path(
            "/users/{id}/companies",
            id=self.current_user.id,
        )
        return HTTPFound(url)
Beispiel #36
0
def belongs_to_company(filename):
    """
    Check if a file belongs to a company

    :param str filename: The filename we want to check
    """
    try:
        code_compta = get_code_compta(filename)
        result = Company.query().filter(
            Company.code_compta == code_compta).count() > 0
    except:
        result = False
    return result
    def test_user_id(self, config, get_csrf_request_with_db, user):
        from autonomie.views.company import CompanyAdd

        post = DATAS.copy()
        post['user_id'] = str(user.id)
        req = get_csrf_request_with_db(post=post)
        req.referrer = "/test"

        view = CompanyAdd(req)
        view.__call__()

        company = Company.query().filter_by(name=u"Compané $& test").first()
        assert company is not None
        assert user in company.employees
Beispiel #38
0
    def test_add(self, config, get_csrf_request_with_db):
        from autonomie.views.company import CompanyAdd

        config.add_route('company', 'company')

        post = DATAS.copy()
        req = get_csrf_request_with_db(post=post)
        view = CompanyAdd(req)
        view.__call__()

        company = Company.query().filter_by(name=u"Compané $& test").first()
        assert company is not None
        assert company.goal == u"Be the best"
        assert company.contribution == 80
Beispiel #39
0
    def test_user_id(self, config, get_csrf_request_with_db, user):
        from autonomie.views.company import CompanyAdd

        post = DATAS.copy()
        post['user_id'] = str(user.id)
        req = get_csrf_request_with_db(post=post)
        req.referrer = "/test"

        view = CompanyAdd(req)
        view.__call__()

        company = Company.query().filter_by(name=u"Compané $& test").first()
        assert company is not None
        assert user in company.employees
def test_unique_ccode(dbsession, content):
    # A IMDD exists in the database for the company with id 1
    company = Company.query().first()
    company.__name__ = 'company'
    validator = makeOne(company)
    with pytest.raises(colander.Invalid):
        validator('nutt', u'C001')
    validator('nutt', u'C002')

    company = Company(
        name="company2",
        goal="Company of user2",
        phone='0457858586',
    )
    company.__name__ = 'company'
    validator = makeOne(company)
    validator('nutt', u'C001')

    # In edit mode, no error is raised for the current_customer
    customer = dbsession.query(Customer).first()
    customer.__name__ = 'customer'
    validator = makeOne(customer)
    validator('nutt', u'C001')
    def test_add(self, config, get_csrf_request_with_db):
        from autonomie.views.company import CompanyAdd

        config.add_route('company', 'company')

        post = DATAS.copy()
        req = get_csrf_request_with_db(post=post)
        view = CompanyAdd(req)
        view.__call__()

        company = Company.query().filter_by(name=u"Compané $& test").first()
        assert company is not None
        assert company.goal == u"Be the best"
        assert company.contribution == 80
Beispiel #42
0
    def post_format(self, entry, edit, attributes):
        """
        Set company id if possible after datas validation and model creation

        :param obj entry: The newly created model
        :param bool edit: Is it edition ?
        :param dict attributes: The validated form attributes
        :returns: The entry
        """
        if 'analytical_account' in attributes:
            entry.company_id = Company.get_id_by_analytical_account(
                entry.analytical_account
            )
        return entry
Beispiel #43
0
def populate_db(session):
    from autonomie.models.user import User
    user = User(
        login='******',
        firstname='user1_firstname',
        lastname="user1_lastname",
        email="*****@*****.**"
    )
    user.set_password('o')
    session.add(user)

    from autonomie.models.project import Project
    project = Project(
        name='Projet 1',
        code='P001',
        definition="Projet 1"
    )
    session.add(project)

    from autonomie.models.customer import Customer
    cust = Customer(
        code='C001',
        name='Client1',
        contactLastName=u'Client Lastname',
        address=u'15 rue Victore Hugo',
        zipCode='69003',
        city='Lyon',
    )
    cust.projects.append(project)
    session.add(cust)

    from autonomie.models.project import Phase
    phase = Phase(name='Phase de test')
    phase.project = project
    session.add(phase)


    from autonomie.models.company import Company
    c = Company(
        name="company1",
        goal="Company of user1",
        phone='0457858585',
    )
    c.employees.append(user)
    c.customers.append(cust)
    c.projects.append(project)
    session.add(c)
    from autonomie.scripts import fake_database
    fake_database.set_configuration()
Beispiel #44
0
 def __call__(self):
     """
         the stats view
     """
     ret_dict = dict(title=u"Statistiques")
     companies = Company.query([Company.id, Company.name]).all()
     ret_dict['companies'] = companies
     current_year = 2000
     years = range(2000, datetime.date.today().year + 1)
     ret_dict['years'] = years
     if self.request.context.__name__ == 'company':
         if 'year' in self.request.params:
             try:
                 year = int(self.request.params['year'])
                 if year not in years:
                     raise ValueError
             except:
                 year = 2000
             current_year = year
         company = self.request.context
         projects = company.projects
         customers = company.customers
         invoices = []
         estimations = []
         for proj in projects:
             invoices.extend(
                 [inv
                  for inv in proj.invoices
                  if inv.taskDate.year >= current_year]
             )
             estimations.extend(
                 [est
                  for est in proj.estimations
                  if est.taskDate.year >= current_year]
             )
         prospects = [cli
                      for cli in customers
                      if True not in [len(proj.invoices) > 0
                                      for proj in cli.projects]]
         #Return the stats
         ret_dict['current_company'] = company
         ret_dict['projects'] = projects
         ret_dict['customers'] = customers
         ret_dict['prospects'] = prospects
         ret_dict['invoices'] = invoices
         ret_dict['estimations'] = estimations
     ret_dict['current_year'] = current_year
     return ret_dict
Beispiel #45
0
def get_companies(request, cid):
    """
    Retrieve the companies the current user has access to

    :param obj request: The current pyramid request
    :param int cid: The current company id
    :returns: The list of companies
    :rtype: list
    """
    companies = []
    if request.has_permission('manage'):
        companies = Company.label_query().filter(
            or_(Company.active == True, Company.id == cid)).all()
    else:
        companies = request.user.active_companies
    return companies
Beispiel #46
0
    def deferred_customer_widget(node, kw):
        if is_admin:
            # All customers, grouped by Company
            for comp in Company.query().options(load_only("id", "name")):
                customers = Customer.label_query().filter_by(
                    company_id=comp.id, )
                values.append(
                    deform.widget.OptGroup(comp.name,
                                           *build_customer_values(customers)))
        else:
            # Company customers only
            company = kw['request'].context
            for cust in company.customers:
                values.append((cust.id, u"%s (%s)" % (cust.name, cust.code)))

        return deform.widget.Select2Widget(values=values,
                                           **(widget_options or {}))
    def test_come_from(self, config, get_csrf_request_with_db, user):
        from autonomie.views.company import CompanyAdd

        post = DATAS.copy()
        post['come_from'] = "/test"
        req = get_csrf_request_with_db(post=post)
        req.referrer = "/test"

        view = CompanyAdd(req)
        result = view.__call__()

        assert result.location == "/test"

        company = Company.query().filter_by(name=u"Compané $& test").first()
        assert company is not None
        assert company.goal == u"Be the best"
        assert company.contribution == 80
Beispiel #48
0
    def test_come_from(self, config, get_csrf_request_with_db, user):
        from autonomie.views.company import CompanyAdd

        post = DATAS.copy()
        post['come_from'] = "/test"
        req = get_csrf_request_with_db(post=post)
        req.referrer = "/test"

        view = CompanyAdd(req)
        result = view.__call__()

        assert result.location == "/test"

        company = Company.query().filter_by(name=u"Compané $& test").first()
        assert company is not None
        assert company.goal == u"Be the best"
        assert company.contribution == 80
Beispiel #49
0
def get_companies(request, cid):
    """
    Retrieve the companies the current user has access to

    :param obj request: The current pyramid request
    :param int cid: The current company id
    :returns: The list of companies
    :rtype: list
    """
    companies = []
    if request.has_permission('manage'):
        companies = Company.label_query().filter(
            or_(
                Company.active == True,
                Company.id == cid
            )
        ).all()
    else:
        companies = request.user.active_companies
    return companies
def company(content):
    return Company.query().first()
Beispiel #51
0
 def query(self):
     return Company.query(active=False)
Beispiel #52
0
 def query(self):
     return Company.query(active=False)
Beispiel #53
0
def get_company(code_compta):
    """
    Return the company associated to this code_compta
    """
    return Company.query().filter(Company.code_compta == code_compta).first()
Beispiel #54
0
def getOne():
    return Company.query().filter(Company.name==APPSTRUCT['name']).first()
Beispiel #55
0
def getOne():
    return Company.query().filter(Company.name == APPSTRUCT['name']).first()
Beispiel #56
0
def get_companies_choices():
    """
        Return companies choices for autocomplete
    """
    return [comp.name for comp in Company.query([Company.name]).all()]