コード例 #1
0
ファイル: saleslave.py プロジェクト: hackedbellini/stoq
def return_sale(parent, sale, store):
    from stoqlib.gui.wizards.salereturnwizard import SaleReturnWizard

    # A plugin (e.g. ECF) can avoid the cancelation of a sale
    # because it wants it to be cancelled using another way
    if SaleAvoidCancelEvent.emit(sale, Sale.STATUS_RETURNED):
        return

    if sale.can_return():
        need_document = not sysparam.get_bool('ACCEPT_SALE_RETURN_WITHOUT_DOCUMENT')
        if need_document and not sale.get_client_document():
            warning(_('It is not possible to accept a returned sale from clients '
                      'without document. Please edit the client document or change '
                      'the sale client'))
            return

        returned_sale = sale.create_sale_return_adapter()
        retval = run_dialog(SaleReturnWizard, parent, store, returned_sale)
    elif sale.can_cancel():
        reason = _(u'Sale cancelled due to client return.')
        retval = cancel_sale(sale, reason)
    else:
        retval = False

    return retval
コード例 #2
0
def return_sale(parent, sale, store):
    from stoqlib.gui.wizards.salereturnwizard import SaleReturnWizard

    # A plugin (e.g. ECF) can avoid the cancelation of a sale
    # because it wants it to be cancelled using another way
    if SaleAvoidCancelEvent.emit(sale, Sale.STATUS_RETURNED):
        return

    if sale.can_return():
        need_document = not sysparam.get_bool(
            'ACCEPT_SALE_RETURN_WITHOUT_DOCUMENT')
        if need_document and not sale.get_client_document():
            warning(
                _('It is not possible to accept a returned sale from clients '
                  'without document. Please edit the client document or change '
                  'the sale client'))
            return

        returned_sale = sale.create_sale_return_adapter()
        retval = run_dialog(SaleReturnWizard, parent, store, returned_sale)
    elif sale.can_cancel():
        reason = _('Sale cancelled due to client return.')
        retval = cancel_sale(sale, reason)
    else:
        retval = False

    return retval
コード例 #3
0
ファイル: sales.py プロジェクト: Guillon88/stoq
    def on_SalesCancel__activate(self, action):
        sale_view = self.results.get_selected()
        can_cancel = api.sysparam.get_bool('ALLOW_CANCEL_LAST_COUPON')
        # A plugin (e.g. ECF) can avoid the cancelation of a sale
        # because it wants it to be cancelled using another way
        if can_cancel and SaleAvoidCancelEvent.emit(sale_view.sale):
            return

        store = api.new_store()
        sale = store.fetch(sale_view.sale)
        msg_text = _(u"This will cancel the sale, Are you sure?")
        model = SaleComment(store=store, sale=sale,
                            author=api.get_current_user(store))

        retval = self.run_dialog(
            NoteEditor, store, model=model, attr_name='comment',
            message_text=msg_text, label_text=_(u"Reason"),
            mandatory=True, ok_button_label=_(u"Cancel sale"),
            cancel_button_label=_(u"Don't cancel"))

        if not retval:
            store.rollback()
            return

        sale.cancel()
        store.commit(close=True)
        self.refresh()
コード例 #4
0
    def on_SalesCancel__activate(self, action):
        sale_view = self.results.get_selected()
        can_cancel = api.sysparam.get_bool('ALLOW_CANCEL_LAST_COUPON')
        # A plugin (e.g. ECF) can avoid the cancelation of a sale
        # because it wants it to be cancelled using another way
        if can_cancel and SaleAvoidCancelEvent.emit(sale_view.sale):
            return

        store = api.new_store()
        sale = store.fetch(sale_view.sale)
        msg_text = _(u"This will cancel the sale, Are you sure?")
        model = SaleComment(store=store,
                            sale=sale,
                            author=api.get_current_user(store))

        retval = self.run_dialog(NoteEditor,
                                 store,
                                 model=model,
                                 attr_name='comment',
                                 message_text=msg_text,
                                 label_text=_(u"Reason"),
                                 mandatory=True,
                                 ok_button_label=_(u"Cancel sale"),
                                 cancel_button_label=_(u"Don't cancel"))

        if not retval:
            store.rollback()
            return

        sale.cancel()
        store.commit(close=True)
        self.refresh()
コード例 #5
0
    def on_SalesCancel__activate(self, action):
        sale_view = self.results.get_selected()
        # A plugin (e.g. ECF) can avoid the cancelation of a sale
        # because it wants it to be cancelled using another way
        if SaleAvoidCancelEvent.emit(sale_view.sale, Sale.STATUS_CANCELLED):
            return

        store = api.new_store()
        sale = store.fetch(sale_view.sale)
        msg_text = _(u"This will cancel the sale, Are you sure?")
        model = SaleComment(store=store,
                            sale=sale,
                            author=api.get_current_user(store))

        # nfce plugin cancellation event requires a minimum length for the
        # cancellation reason note. We can't set this in the plugin because it's
        # not possible to identify unically this NoteEditor.
        if get_plugin_manager().is_active('nfce'):
            note_min_length = 15
        else:
            note_min_length = 0

        retval = self.run_dialog(NoteEditor,
                                 store,
                                 model=model,
                                 attr_name='comment',
                                 message_text=msg_text,
                                 label_text=_(u"Reason"),
                                 mandatory=True,
                                 ok_button_label=_(u"Cancel sale"),
                                 cancel_button_label=_(u"Don't cancel"),
                                 min_length=note_min_length)

        if not retval:
            store.rollback()
            return

        # Try to cancel the sale with sefaz. Don't cancel the sale if sefaz
        # reject it.
        if StockOperationTryFiscalCancelEvent.emit(sale) is False:
            warning(
                _("The cancellation was not authorized by SEFAZ. You should "
                  "do a sale return."))
            return

        sale.cancel()
        store.commit(close=True)
        self.refresh()