def upgrade():
    disable_listeners()
    op.add_column('task', sa.Column('date', sa.Date()))
    from autonomie.models.task import Task
    from autonomie_base.models.base import DBSESSION

    session = DBSESSION()
    for task in Task.query().filter(Task.type_!='manualinvoice'):
        task.date = task.taskDate
        session.merge(task)
    session.flush()

    op.execute("alter table groups modify label VARCHAR(255);")
    op.execute("alter table payment modify remittance_amount VARCHAR(255);")
    from autonomie.models.user import User, Group
    for group_id, group_name, group_label in GROUPS:
        group = session.query(Group).filter(Group.name==group_name).first()
        if group is None:
            group = Group(name=group_name, label=group_label)
            session.add(group)
            session.flush()

        users = session.query(User).filter(User.primary_group==group_id)
        for user in users:
            user._groups.append(group)
            session.merge(user)

    label = u"Peut saisir/modifier/supprimer les paiements de ses factures"
    group_name = "payment_admin"
    group = Group.query().filter(Group.name==group_name).first()
    if group is not None:
        group.label = label
        session.merge(group)
def upgrade():
    disable_listeners()
    op.add_column('task', sa.Column('date', sa.Date()))
    from autonomie.models.task import Task
    from autonomie.models.base import DBSESSION

    session = DBSESSION()
    for task in Task.query().filter(Task.type_!='manualinvoice'):
        task.date = task.taskDate
        session.merge(task)
    session.flush()

    op.execute("alter table groups modify label VARCHAR(255);")
    op.execute("alter table payment modify remittance_amount VARCHAR(255);")
    from autonomie.models.user import User, Group
    for group_id, group_name, group_label in GROUPS:
        group = session.query(Group).filter(Group.name==group_name).first()
        if group is None:
            group = Group(name=group_name, label=group_label)
            session.add(group)
            session.flush()

        users = session.query(User).filter(User.primary_group==group_id)
        for user in users:
            user._groups.append(group)
            session.merge(user)

    label = u"Peut saisir/modifier/supprimer les paiements de ses factures"
    group_name = "payment_admin"
    group = Group.query().filter(Group.name==group_name).first()
    if group is not None:
        group.label = label
        session.merge(group)
Ejemplo n.º 3
0
def manage(request):
    """
    The manage view
    """
    estimations = Task.get_waiting_estimations().all()

    invoices = Task.get_waiting_invoices().all()

    for item in estimations:
        item.url = request.route_path(item.type_, id=item.id)

    for item in invoices:
        item.url = request.route_path(item.type_, id=item.id)

    expenses = ExpenseSheet.query()\
        .filter(ExpenseSheet.status == 'wait')\
        .order_by(ExpenseSheet.month)\
        .order_by(ExpenseSheet.status_date).all()
    for expense in expenses:
        expense.url = request.route_path("expensesheet", id=expense.id)

    user_id = request.user.id
    query = Activity.query()
    query = query.join(Activity.conseillers)
    query = query.filter(
        Activity.conseillers.any(User.id == user_id)
    )
    query = query.filter(Activity.status == 'planned')
    query = query.order_by(Activity.datetime).limit(10)
    activities = query.all()

    for activity in activities:
        activity.url = request.route_path("activity", id=activity.id)

    return dict(
        title=u"Documents en attente de validation",
        invoices=invoices,
        estimations=estimations,
        expenses=expenses,
        activities=activities,
    )
Ejemplo n.º 4
0
def manage(request):
    """
        The manage view
    """
    query = Estimation.query()
    query = query.join(Estimation.phase)
    query = query.filter(
        and_(
            Estimation.CAEStatus == 'wait',
            Phase.name is not None
        )
    )
    estimations = query.order_by(Task.statusDate).all()
    for item in estimations:
        item.url = request.route_path(item.type_, id=item.id)

    invoices = Task.query()\
            .filter(Task.type_.in_(('invoice', 'cancelinvoice',)))\
            .join(Task.phase)\
            .filter(and_(Task.CAEStatus == 'wait', Phase.name is not None))\
            .order_by(Task.type_).order_by(Task.statusDate).all()

    for item in invoices:
        item.url = request.route_path(item.type_, id=item.id)

    expenses = ExpenseSheet.query()\
        .filter(ExpenseSheet.status == 'wait')\
        .order_by(ExpenseSheet.month)\
        .order_by(ExpenseSheet.status_date).all()
    for expense in expenses:
        expense.url = request.route_path("expensesheet", id=expense.id)


    user_id = request.user.id
    query = Activity.query()
    query = query.join(Activity.conseillers)
    query = query.filter(
        Activity.conseillers.any(User.id==user_id)
    )
    query = query.filter(Activity.status=='planned')
    query = query.order_by(Activity.datetime).limit(10)
    activities = query.all()

    for activity in activities:
        activity.url = request.route_path("activity", id=activity.id)

    return dict(title=u"Documents en attente de validation",
                invoices=invoices,
                estimations=estimations,
                expenses = expenses,
                activities=activities)
Ejemplo n.º 5
0
 def query(self):
     query = Task.query()\
             .with_polymorphic([Invoice, CancelInvoice, ManualInvoice])\
                  .outerjoin(p1, Invoice.project)\
                  .outerjoin(p2, CancelInvoice.project)\
                  .outerjoin(c1, Invoice.customer)\
                  .outerjoin(c2, CancelInvoice.customer)\
                  .outerjoin(c3, ManualInvoice.customer)
     if self.request.context == 'company':
         company_id = self.request.context.id
         query = query.filter(or_(p1.company_id == company_id,
                                 p2.company_id == company_id,
                                 ManualInvoice.company_id == company_id))
     return query
Ejemplo n.º 6
0
def manage(request):
    """
        The manage view
    """
    query = Estimation.query()
    query = query.join(Estimation.phase)
    query = query.filter(
        and_(Estimation.CAEStatus == 'wait', Phase.name is not None))
    estimations = query.order_by(Task.statusDate).all()
    for item in estimations:
        item.url = request.route_path(item.type_, id=item.id)

    invoices = Task.query()\
            .filter(Task.type_.in_(('invoice', 'cancelinvoice',)))\
            .join(Task.phase)\
            .filter(and_(Task.CAEStatus == 'wait', Phase.name is not None))\
            .order_by(Task.type_).order_by(Task.statusDate).all()

    for item in invoices:
        item.url = request.route_path(item.type_, id=item.id)

    expenses = ExpenseSheet.query()\
            .filter(ExpenseSheet.status == 'wait')\
            .order_by(ExpenseSheet.month).all()
    for expense in expenses:
        expense.url = request.route_path("expensesheet", id=expense.id)

    user_id = request.user.id
    query = Activity.query()
    query = query.join(Activity.conseillers)
    query = query.filter(Activity.conseillers.any(User.id == user_id))
    query = query.filter(Activity.status == 'planned')
    query = query.order_by(Activity.datetime).limit(10)
    activities = query.all()

    for activity in activities:
        activity.url = request.route_path("activity", id=activity.id)

    return dict(title=u"Documents en attente de validation",
                invoices=invoices,
                estimations=estimations,
                expenses=expenses,
                activities=activities)