本文整理汇总了Python中stoqlib.lib.message.warning函数的典型用法代码示例。如果您正苦于以下问题:Python warning函数的具体用法?Python warning怎么用?Python warning使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了warning函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _update_list
def _update_list(self, sellable):
assert isinstance(sellable, Sellable)
try:
sellable.check_taxes_validity()
except TaxError as strerr:
# If the sellable icms taxes are not valid, we cannot sell it.
warning(strerr)
return
quantity = self.sellableitem_proxy.model.quantity
is_service = sellable.service
if is_service and quantity > 1:
# It's not a common operation to add more than one item at
# a time, it's also problematic since you'd have to show
# one dialog per service item. See #3092
info(_("It's not possible to add more than one service "
"at a time to an order. So, only one was added."))
sale_item = TemporarySaleItem(sellable=sellable,
quantity=quantity)
if is_service:
with api.trans() as store:
rv = self.run_dialog(ServiceItemEditor, store, sale_item)
if not rv:
return
self._update_added_item(sale_item)
示例2: _add_sellable
def _add_sellable(self, sellable, batch=None):
quantity = self._read_quantity()
if quantity == 0:
return
if not sellable.is_valid_quantity(quantity):
warning(
_(u"You cannot sell fractions of this product. "
u"The '%s' unit does not allow that") %
sellable.unit_description)
return
if sellable.product:
# If the sellable has a weight unit specified and we have a scale
# configured for this station, go and check what the scale says.
if (sellable and sellable.unit
and sellable.unit.unit_index == UnitType.WEIGHT
and self._scale_settings):
self._read_scale(sellable)
storable = sellable.product_storable
if storable is not None:
if not self._check_available_stock(storable, sellable):
info(
_("You cannot sell more items of product %s. "
"The available quantity is not enough.") %
sellable.get_description())
self.barcode.set_text('')
self.barcode.grab_focus()
return
self._update_list(sellable, batch=batch)
self.barcode.grab_focus()
示例3: on_add_product_button__clicked
def on_add_product_button__clicked(self, widget):
if not self.model.description:
warning(_('You should fill the description first'))
return False
self.model.add_grid_child(self._option_list.values())
self.product_list.add_list(self.model.children)
self.add_product_button.set_sensitive(False)
示例4: validate_confirm
def validate_confirm(self):
if not self.model.change_reason:
msg = self.get_validate_message()
if bool(msg):
warning(msg)
return False
return True
示例5: add_item
def add_item(self, item):
"""
@param item: A :class:`SellableItem` subclass
@returns: id of the item.:
0 >= if it was added successfully
-1 if an error happend
0 if added but not printed (gift certificates, free deliveries)
"""
sellable = item.sellable
max_len = self._get_capability("item_description").max_len
description = sellable.description[:max_len]
unit_desc = ''
if not sellable.unit:
unit = UnitType.EMPTY
else:
if sellable.unit.unit_index == UnitType.CUSTOM:
unit_desc = sellable.unit.description
unit = sellable.unit.unit_index or UnitType.EMPTY
max_len = self._get_capability("item_code").max_len
code = sellable.code[:max_len]
try:
tax_constant = self._printer.get_tax_constant_for_device(sellable)
except DeviceError, e:
warning(_("Could not print item"), str(e))
return -1
示例6: _receive
def _receive(self):
with api.new_store() as store:
till = Till.get_current(store)
assert till
in_payment = self.results.get_selected()
payment = store.fetch(in_payment.payment)
assert self._can_receive(payment)
retval = run_dialog(SalePaymentConfirmSlave, self, store,
payments=[payment], show_till_info=False)
if not retval:
return
try:
TillAddCashEvent.emit(till=till, value=payment.value)
except (TillError, DeviceError, DriverError) as e:
warning(str(e))
return
till_entry = till.add_credit_entry(payment.value,
_(u'Received payment: %s') % payment.description)
TillAddTillEntryEvent.emit(till_entry, store)
if store.committed:
self.search.refresh()
示例7: _send_selected_items_to_supplier
def _send_selected_items_to_supplier(self):
orders = self.results.get_selected_rows()
valid_order_views = [
order for order in orders
if order.status == PurchaseOrder.ORDER_PENDING]
if not valid_order_views:
warning(_("There are no pending orders selected."))
return
msg = stoqlib_ngettext(
_("The selected order will be marked as sent."),
_("The %d selected orders will be marked as sent.")
% len(valid_order_views),
len(valid_order_views))
confirm_label = stoqlib_ngettext(_("Confirm order"),
_("Confirm orders"),
len(valid_order_views))
if not yesno(msg, gtk.RESPONSE_YES, confirm_label, _("Don't confirm")):
return
with api.new_store() as store:
for order_view in valid_order_views:
order = store.fetch(order_view.purchase)
order.confirm()
self.refresh()
self.select_result(orders)
示例8: _read_import_file
def _read_import_file(self):
data = {}
not_found = set()
with open(self.import_file.get_filename()) as fh:
for line in fh:
# The line should have 1 or 2 parts
parts = line[:-1].split(',')
assert 1 <= len(parts) <= 2
if len(parts) == 2:
barcode, quantity = parts
elif len(parts) == 1:
barcode = parts[0]
if not barcode:
continue
quantity = 1
sellable = self.store.find(Sellable, barcode=str(barcode)).one()
if not sellable:
sellable = self.store.find(Sellable, code=str(barcode)).one()
if not sellable:
not_found.add(barcode)
continue
data.setdefault(sellable, 0)
data[sellable] += int(quantity)
if not_found:
warning(_('Some barcodes were not found'), ', '.join(not_found))
self.wizard.imported_count = data
示例9: summarize
def summarize(self):
"""sends a summarize (leituraX) command to the printer"""
try:
self._register_emitted_document(ECFDocumentHistory.TYPE_SUMMARY)
self._driver.summarize()
except DriverError as details:
warning(_("Could not print summary"), str(details))
示例10: on_PrintProductListing__activate
def on_PrintProductListing__activate(self, button):
selected = self.results.get_selected()
sellables = list(self._get_sellables_by_inventory(selected))
if not sellables:
warning(_("No products found in the inventory."))
return
self.print_report(ProductCountingReport, sellables)
示例11: confirm
def confirm(self, sale, store, savepoint=None, subtotal=None):
"""Confirms a |sale| on fiscalprinter and database
If the sale is confirmed, the store will be committed for you.
There's no need for the callsite to call store.confirm().
If the sale is not confirmed, for instance the user cancelled the
sale or there was a problem with the fiscal printer, then the
store will be rolled back.
:param sale: the |sale| to be confirmed
:param trans: a store
:param savepoint: if specified, a database savepoint name that
will be used to rollback to if the sale was not confirmed.
:param subtotal: the total value of all the items in the sale
"""
# Actually, we are confirming the sale here, so the sale
# confirmation process will be available to others applications
# like Till and not only to the POS.
total_paid = sale.group.get_total_confirmed_value()
model = run_dialog(ConfirmSaleWizard, self._parent, store, sale,
subtotal=subtotal,
total_paid=total_paid)
if not model:
CancelPendingPaymentsEvent.emit()
store.rollback(name=savepoint, close=False)
return False
if sale.client and not self.is_customer_identified():
self.identify_customer(sale.client.person)
if not self.totalize(sale):
store.rollback(name=savepoint, close=False)
return False
if not self.setup_payments(sale):
store.rollback(name=savepoint, close=False)
return False
if not self.close(sale, store):
store.rollback(name=savepoint, close=False)
return False
try:
sale.confirm()
except SellError as err:
warning(str(err))
store.rollback(name=savepoint, close=False)
return False
if not self.print_receipts(sale):
warning(_("The sale was cancelled"))
sale.cancel()
print_cheques_for_payment_group(store, sale.group)
# Only finish the transaction after everything passed above.
store.confirm(model)
return True
示例12: _remove_work_order
def _remove_work_order(self, holder, name, work_order, work_order_id):
if work_order.is_finished():
warning(_("You cannot remove workorder with the status '%s'")
% work_order.status_str)
return
if not work_order.get_items().find().is_empty():
warning(_("This workorder already has items and cannot be removed"))
return
# We cannot remove the WO from the database (since it already has some
# history), but we can disassociate it from the sale, cancel and leave
# a reason for it.
reason = (_(u'Removed from sale %s') % work_order.sale.identifier)
work_order.sale = None
work_order.cancel(reason=reason)
self._work_order_ids.remove(work_order_id)
# Remove the tab
self.detach_slave(name)
pagenum = self.work_orders_nb.page_num(holder)
self.work_orders_nb.remove_page(pagenum)
# And remove the WO
self.wizard.workorders.remove(work_order)
self.force_validation()
示例13: check_serial
def check_serial(self):
driver_serial = self._driver.get_serial()
if self._printer.device_serial != driver_serial:
warning(_("Invalid serial number for fiscal printer connected to %s") % (self._printer.device_name))
return False
return True
示例14: _can_add_payment
def _can_add_payment(self):
if self.base_value.read() is ValueUnset:
return False
if self._outstanding_value <= 0:
return False
payments = self.model.group.get_valid_payments()
payment_count = payments.find(
Payment.method_id == self._method.id).count()
if payment_count >= self._method.max_installments:
info(_(u'You can not add more payments using the %s '
'payment method.') % self._method.description)
return False
# If we are creaing out payments (PurchaseOrder) or the Sale does not
# have a client, assume all options available are creatable.
if (isinstance(self.model, (PurchaseOrder, StockDecrease))
or not self.model.client):
return True
method_values = {self._method: self._holder.value}
for i, payment in enumerate(self.model.group.payments):
method_values.setdefault(payment.method, 0)
method_values[payment.method] += payment.value
for method, value in method_values.items():
try:
self.model.client.can_purchase(method, value)
except SellError as e:
warning(str(e))
return False
return True
示例15: return_sale
def return_sale(parent, sale, store):
from stoqlib.gui.wizards.salereturnwizard import SaleReturnWizard
cancel_last_coupon = sysparam.get_bool('ALLOW_CANCEL_LAST_COUPON')
if cancel_last_coupon and ECFIsLastSaleEvent.emit(sale):
info(_("That is last sale in ECF. Return using the menu "
"ECF - Cancel Last Document"))
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():
retval = cancel_sale(sale)
else:
retval = False
return retval