예제 #1
0
    def _update_view(self):
        self._update_list_aware_widgets(len(self.results))
        selection = self.results.get_selected_rows()
        can_edit = one_selected = len(selection) == 1
        can_finish = False
        if selection:
            can_send_supplier = all(order.status == PurchaseOrder.ORDER_PENDING
                                    for order in selection)
            can_cancel = all(order_view.purchase.can_cancel()
                             for order_view in selection)
        else:
            can_send_supplier = False
            can_cancel = False

        if one_selected:
            can_edit = (selection[0].status == PurchaseOrder.ORDER_PENDING
                        or selection[0].status == PurchaseOrder.ORDER_QUOTING)
            can_finish = (selection[0].status == PurchaseOrder.ORDER_CONFIRMED
                          and selection[0].received_quantity > 0)

        self.Cancel.set_sensitive(can_cancel)
        self.Edit.set_sensitive(can_edit)
        self.Confirm.set_sensitive(can_send_supplier)
        self.Details.set_sensitive(one_selected)
        self.Finish.set_sensitive(can_finish)
예제 #2
0
    def _update_view(self):
        self._update_list_aware_widgets(len(self.results))
        selection = self.results.get_selected_rows()
        can_edit = one_selected = len(selection) == 1
        can_finish = False
        if selection:
            can_send_supplier = all(
                order.status == PurchaseOrder.ORDER_PENDING
                for order in selection)
            can_cancel = all(order_view.purchase.can_cancel()
                             for order_view in selection)
        else:
            can_send_supplier = False
            can_cancel = False

        if one_selected:
            can_edit = (selection[0].status == PurchaseOrder.ORDER_PENDING or
                        selection[0].status == PurchaseOrder.ORDER_QUOTING or
                        selection[0].status == PurchaseOrder.ORDER_CONFIRMED)
            can_finish = (selection[0].status == PurchaseOrder.ORDER_CONFIRMED and
                          selection[0].received_quantity > 0)

        self.Cancel.set_sensitive(can_cancel)
        self.Edit.set_sensitive(can_edit)
        self.Confirm.set_sensitive(can_send_supplier)
        self.Details.set_sensitive(one_selected)
        self.Finish.set_sensitive(can_finish)
예제 #3
0
파일: payable.py 프로젝트: tmaxter/stoq
    def _same_sale(self, payable_views):
        """Determines if a list of payable_views are in the same sale"""
        if not payable_views:
            return False

        sale = payable_views[0].sale
        if sale is None:
            return False
        return all(view.sale == sale for view in payable_views)
예제 #4
0
파일: payable.py 프로젝트: barkinet/stoq
    def _same_sale(self, payable_views):
        """Determines if a list of payable_views are in the same sale"""
        if not payable_views:
            return False

        sale = payable_views[0].sale
        if sale is None:
            return False
        return all(view.sale == sale for view in payable_views)
예제 #5
0
파일: payable.py 프로젝트: barkinet/stoq
    def _same_purchase(self, payable_views):
        """Determines if a list of payable_views are in the same purchase"""
        if not payable_views:
            return False

        purchase = payable_views[0].purchase_id
        if purchase is None:
            return False
        return all(view.purchase_id == purchase for view in payable_views)
예제 #6
0
파일: payable.py 프로젝트: tmaxter/stoq
    def _same_purchase(self, payable_views):
        """Determines if a list of payable_views are in the same purchase"""
        if not payable_views:
            return False

        purchase = payable_views[0].purchase_id
        if purchase is None:
            return False
        return all(view.purchase_id == purchase for view in payable_views)
예제 #7
0
    def _can_edit(self, views):
        """Determines if we can edit the selected payments
        """
        if not views:
            return False
        # Installments of renegotiated payments can not be edited.
        if views[0].group.renegotiation:
            return False

        sale_id = views[0].sale_id
        # Lonely payments are not created as sales, and it's installments
        # are edited differently.
        if not sale_id:
            return False
        can_edit = all(rv.sale_id == sale_id for rv in views)
        return can_edit
예제 #8
0
파일: receivable.py 프로젝트: sarkis89/stoq
    def _can_edit(self, views):
        """Determines if we can edit the selected payments
        """
        if not views:
            return False
        # Installments of renegotiated payments can not be edited.
        if views[0].group.renegotiation:
            return False

        sale_id = views[0].sale_id
        # Lonely payments are not created as sales, and it's installments
        # are edited differently.
        if not sale_id:
            return False
        can_edit = all(rv.sale_id == sale_id for rv in views)
        return can_edit
예제 #9
0
파일: payable.py 프로젝트: tmaxter/stoq
    def _are_paid(self, payable_views, respect_purchase=True):
        """
        Determines if a list of payables_views are paid.
        To do so they must meet the following conditions:
          - Be in the same purchase order.
            (This will be satistied only if respect_purchase is True)
          - The payment status needs to be set to PAID
        """
        if not payable_views:
            return False

        purchase = payable_views[0].purchase_id
        if not purchase and len(payable_views) > 1:
            return False

        return all((view.purchase_id == purchase or not respect_purchase)
                   and view.is_paid() for view in payable_views)
예제 #10
0
파일: payable.py 프로젝트: barkinet/stoq
    def _are_paid(self, payable_views, respect_purchase=True):
        """
        Determines if a list of payables_views are paid.
        To do so they must meet the following conditions:
          - Be in the same purchase order.
            (This will be satistied only if respect_purchase is True)
          - The payment status needs to be set to PAID
        """
        if not payable_views:
            return False

        purchase = payable_views[0].purchase_id
        if not purchase and len(payable_views) > 1:
            return False

        return all((view.purchase_id == purchase or not respect_purchase) and
                   view.is_paid() for view in payable_views)
예제 #11
0
    def _can_show_details(self, receivable_views):
        """Determines if we can show the receiving details for a list of
        receivable views.
        To do so they must meet the following conditions:
          - Be in the same sale or
          - One receiving that not belong to any sale
        """
        if not receivable_views:
            return False

        sale = receivable_views[0].sale_id
        if sale is None:
            if len(receivable_views) == 1:
                return True
            else:
                return False

        return all(view.sale_id == sale for view in receivable_views[1:])
예제 #12
0
 def _cancel_order(self):
     order_views = self.results.get_selected_rows()
     assert all(ov.purchase.can_cancel() for ov in order_views)
     cancel_label = stoqlib_ngettext(_("Cancel order"),
                                     _("Cancel orders"), len(order_views))
     select_label = stoqlib_ngettext(_('The selected order will be cancelled.'),
                                     _('The selected orders will be cancelled.'),
                                     len(order_views))
     if not yesno(select_label, gtk.RESPONSE_YES,
                  cancel_label, _("Don't cancel")):
         return
     with api.new_store() as store:
         for order_view in order_views:
             order = store.fetch(order_view.purchase)
             order.cancel()
     self._update_totals()
     self.refresh()
     self.select_result(order_views)
예제 #13
0
파일: receivable.py 프로젝트: sarkis89/stoq
    def _can_show_details(self, receivable_views):
        """Determines if we can show the receiving details for a list of
        receivable views.
        To do so they must meet the following conditions:
          - Be in the same sale or
          - One receiving that not belong to any sale
        """
        if not receivable_views:
            return False

        sale = receivable_views[0].sale_id
        if sale is None:
            if len(receivable_views) == 1:
                return True
            else:
                return False

        return all(view.sale_id == sale for view in receivable_views[1:])
예제 #14
0
 def _cancel_order(self):
     order_views = self.results.get_selected_rows()
     assert all(ov.purchase.can_cancel() for ov in order_views)
     cancel_label = stoqlib_ngettext(_("Cancel order"), _("Cancel orders"),
                                     len(order_views))
     select_label = stoqlib_ngettext(
         _('The selected order will be cancelled.'),
         _('The selected orders will be cancelled.'), len(order_views))
     if not yesno(select_label, gtk.RESPONSE_YES, cancel_label,
                  _("Don't cancel")):
         return
     with api.trans() as store:
         for order_view in order_views:
             order = store.fetch(order_view.purchase)
             order.cancel()
     self._update_totals()
     self.refresh()
     self.select_result(order_views)
예제 #15
0
파일: receivable.py 프로젝트: sarkis89/stoq
    def _can_renegotiate(self, receivable_views):
        """whether or not we can renegotiate this payments

        This do to much queries. Dont call inside _update_widgets to avoid
        unecessary queries. Instead, call before the user actually tries to
        renegotiate.
        """
        if not len(receivable_views):
            return False

        # Parent is a Sale or a PaymentRenegotiation
        parent = receivable_views[0].get_parent()

        if not parent:
            return False

        client = parent.client

        return all(view.get_parent() and view.get_parent().client is client
                   and view.get_parent().can_set_renegotiated()
                   for view in receivable_views)
예제 #16
0
    def _can_renegotiate(self, receivable_views):
        """whether or not we can renegotiate this payments

        This do to much queries. Dont call inside _update_widgets to avoid
        unecessary queries. Instead, call before the user actually tries to
        renegotiate.
        """
        if not len(receivable_views):
            return False

        # Parent is a Sale or a PaymentRenegotiation
        parent = receivable_views[0].get_parent()

        if not parent:
            return False

        client = parent.client

        return all(view.get_parent() and
                   view.get_parent().client is client and
                   view.get_parent().can_set_renegotiated()
                   for view in receivable_views)
예제 #17
0
    def _can_pay(self, payable_views):
        """
        Determines if a list of payables_views can be paid.
        To do so they must meet the following conditions:
          - Be in the same purchase order
          - The payment status needs to be set to PENDING
        """
        if not payable_views:
            return False

        if not any(view.operation.can_pay(view.payment)
                   for view in payable_views):
            return False

        if len(payable_views) == 1:
            return payable_views[0].status == Payment.STATUS_PENDING

        purchase = payable_views[0].purchase_id
        if purchase is None:
            return False
        return all(view.purchase_id == purchase and
                   view.status == Payment.STATUS_PENDING
                   for view in payable_views)
예제 #18
0
파일: payable.py 프로젝트: barkinet/stoq
    def _can_pay(self, payable_views):
        """
        Determines if a list of payables_views can be paid.
        To do so they must meet the following conditions:
          - Be in the same purchase order
          - The payment status needs to be set to PENDING
        """
        if not payable_views:
            return False

        if not any(view.operation.can_pay(view.payment)
                   for view in payable_views):
            return False

        if len(payable_views) == 1:
            return payable_views[0].status == Payment.STATUS_PENDING

        purchase = payable_views[0].purchase_id
        if purchase is None:
            return False
        return all(view.purchase_id == purchase and
                   view.status == Payment.STATUS_PENDING
                   for view in payable_views)
예제 #19
0
    def _can_receive(self, receivable_views):
        """
        Determines if a list of receivable_views can be received.
        To do so they must meet the following conditions:
          - Be in the same sale
          - The payment status needs to be set to PENDING
        """

        if not receivable_views:
            return False

        if not any(view.operation.can_pay(view.payment)
                   for view in receivable_views):
            return False

        if len(receivable_views) == 1:
            return receivable_views[0].status == Payment.STATUS_PENDING

        sale = receivable_views[0].sale
        if sale is None:
            return False
        return all(view.sale == sale and
                   view.status == Payment.STATUS_PENDING
                   for view in receivable_views)
예제 #20
0
파일: receivable.py 프로젝트: sarkis89/stoq
    def _can_receive(self, receivable_views):
        """
        Determines if a list of receivable_views can be received.
        To do so they must meet the following conditions:
          - Be in the same sale
          - The payment status needs to be set to PENDING
        """

        if not receivable_views:
            return False

        if not any(
                view.operation.can_pay(view.payment)
                for view in receivable_views):
            return False

        if len(receivable_views) == 1:
            return receivable_views[0].status == Payment.STATUS_PENDING

        sale = receivable_views[0].sale
        if sale is None:
            return False
        return all(view.sale == sale and view.status == Payment.STATUS_PENDING
                   for view in receivable_views)
예제 #21
0
 def _can_set_not_paid(self, receivable_views):
     return all(view.payment.method.operation.can_set_not_paid(view.payment)
                for view in receivable_views)
예제 #22
0
파일: payable.py 프로젝트: tmaxter/stoq
 def _can_set_not_paid(self, payable_views):
     return all(
         view.payment.method.operation.can_set_not_paid(view.payment)
         for view in payable_views)