def __init__(self): self._ui = None self.default_store = get_default_store() self._printer_verified = False # Delay printer creation until we are accessing pos or till app. Other # applications should still be accessible without a printer self._printer = None SaleStatusChangedEvent.connect(self._on_SaleStatusChanged) SaleAvoidCancelEvent.connect(self._on_SaleAvoidCancel) TillOpenEvent.connect(self._on_TillOpen) TillCloseEvent.connect(self._on_TillClose) TillAddCashEvent.connect(self._on_TillAddCash) TillAddTillEntryEvent.connect(self._on_AddTillEntry) TillRemoveCashEvent.connect(self._on_TillRemoveCash) StartApplicationEvent.connect(self._on_StartApplicationEvent) StopApplicationEvent.connect(self._on_StopApplicationEvent) CouponCreatedEvent.connect(self._on_CouponCreatedEvent) GerencialReportPrintEvent.connect(self._on_GerencialReportPrintEvent) GerencialReportCancelEvent.connect(self._on_GerencialReportCancelEvent) CheckECFStateEvent.connect(self._on_CheckECFStateEvent) HasPendingReduceZ.connect(self._on_HasPendingReduceZ) HasOpenCouponEvent.connect(self._on_HasOpenCouponEvent) EditorCreateEvent.connect(self._on_EditorCreateEvent) self._till_summarize_action = gtk.Action( 'Summary', _('Summary'), None, None) self._till_summarize_action.connect( 'activate', self._on_TillSummary__activate) add_bindings([ ('plugin.ecf.read_memory', '<Primary>F9'), ('plugin.ecf.summarize', '<Primary>F11'), ])
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
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()
def return_sale(parent, sale, store): from stoq.lib.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( api.get_current_branch(store), api.get_current_user(store), api.get_current_station(store)) 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
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): 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()
def _setup_events(self): SaleStatusChangedEvent.connect(self._on_SaleStatusChanged) SaleAvoidCancelEvent.connect(self._on_SaleAvoidCancel) TillOpenEvent.connect(self._on_TillOpen) TillCloseEvent.connect(self._on_TillClose) TillAddCashEvent.connect(self._on_TillAddCash) TillAddTillEntryEvent.connect(self._on_AddTillEntry) TillRemoveCashEvent.connect(self._on_TillRemoveCash) StartApplicationEvent.connect(self._on_StartApplicationEvent) CouponCreatedEvent.connect(self._on_CouponCreatedEvent) GerencialReportPrintEvent.connect(self._on_GerencialReportPrintEvent) GerencialReportCancelEvent.connect(self._on_GerencialReportCancelEvent) CheckECFStateEvent.connect(self._on_CheckECFStateEvent) HasPendingReduceZ.connect(self._on_HasPendingReduceZ) HasOpenCouponEvent.connect(self._on_HasOpenCouponEvent) EditorCreateEvent.connect(self._on_EditorCreateEvent) ECFGetPrinterUserNumberEvent.connect(self._on_ECFGetPrinterUserNumberEvent)
def _setup_events(self): SaleStatusChangedEvent.connect(self._on_SaleStatusChanged) SaleAvoidCancelEvent.connect(self._on_SaleAvoidCancel) TillOpenEvent.connect(self._on_TillOpen) TillCloseEvent.connect(self._on_TillClose) TillAddCashEvent.connect(self._on_TillAddCash) TillAddTillEntryEvent.connect(self._on_AddTillEntry) TillRemoveCashEvent.connect(self._on_TillRemoveCash) StartApplicationEvent.connect(self._on_StartApplicationEvent) StopApplicationEvent.connect(self._on_StopApplicationEvent) CouponCreatedEvent.connect(self._on_CouponCreatedEvent) GerencialReportPrintEvent.connect(self._on_GerencialReportPrintEvent) GerencialReportCancelEvent.connect(self._on_GerencialReportCancelEvent) CheckECFStateEvent.connect(self._on_CheckECFStateEvent) HasPendingReduceZ.connect(self._on_HasPendingReduceZ) HasOpenCouponEvent.connect(self._on_HasOpenCouponEvent) EditorCreateEvent.connect(self._on_EditorCreateEvent)
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()