本文整理汇总了Python中stoqlib.lib.translation._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_quantity__validate
def on_quantity__validate(self, widget, value):
if self._expanded_edition:
return
if value <= 0:
return ValidationError(_(u'The quantity should be positive.'))
if value and not self._has_stock(value):
return ValidationError(_(u'Quantity not available in stock.'))
示例2: _get_sales_columns
def _get_sales_columns(self):
return [IdentifierColumn('identifier', title=_('Sale #'), sorted=True),
Column('salesperson', title=_('Sales Person'), data_type=str),
Column('client', title=_('Client'), data_type=str, expand=True),
Column('branch', title=_('Branch'), data_type=str, visible=False),
Column('value', title=_('Value'), data_type=str,
justify=Gtk.Justification.RIGHT)]
示例3: _get_account_columns
def _get_account_columns(self):
def format_withdrawal(value):
if value < 0:
return currency(abs(value)).format(symbol=True, precision=2)
def format_deposit(value):
if value > 0:
return currency(value).format(symbol=True, precision=2)
if self.model.account_type == Account.TYPE_INCOME:
color_func = lambda x: False
else:
color_func = lambda x: x < 0
return [Column('date', title=_("Date"), data_type=datetime.date, sorted=True),
Column('code', title=_("Code"), data_type=unicode),
Column('description', title=_("Description"),
data_type=unicode, expand=True),
Column('account', title=_("Account"), data_type=unicode),
Column('value',
title=self.model.account.get_type_label(out=False),
data_type=currency,
format_func=format_deposit),
Column('value',
title=self.model.account.get_type_label(out=True),
data_type=currency,
format_func=format_withdrawal),
ColoredColumn('total', title=_("Total"), data_type=currency,
color='red',
data_func=color_func)]
示例4: _check_param_online_services
def _check_param_online_services(self):
from stoqlib.database.runtime import new_store
from stoqlib.lib.parameters import sysparam
from gi.repository import Gtk
if sysparam.get_bool('ONLINE_SERVICES') is None:
from kiwi.ui.dialogs import HIGAlertDialog
# FIXME: All of this is to avoid having to set markup as the default
# in kiwi/ui/dialogs:HIGAlertDialog.set_details, after 1.0
# this can be simplified when we fix so that all descriptions
# sent to these dialogs are properly escaped
dialog = HIGAlertDialog(
parent=None,
flags=Gtk.DialogFlags.MODAL,
type=Gtk.MessageType.WARNING)
dialog.add_button(_("Not right now"), Gtk.ResponseType.NO)
dialog.add_button(_("Enable online services"), Gtk.ResponseType.YES)
dialog.set_primary(_('Do you want to enable Stoq online services?'))
dialog.set_details(PRIVACY_STRING, use_markup=True)
dialog.set_default_response(Gtk.ResponseType.YES)
response = dialog.run()
dialog.destroy()
store = new_store()
sysparam.set_bool(store, 'ONLINE_SERVICES', response == Gtk.ResponseType.YES)
store.commit()
store.close()
示例5: _maybe_create_database
def _maybe_create_database(self):
logger.info('_maybe_create_database (db_is_local=%s, remove_demo=%s)'
% (self.wizard.db_is_local, self.wizard.remove_demo))
if self.wizard.db_is_local:
self._launch_stoqdbadmin()
return
elif self.wizard.remove_demo:
self._launch_stoqdbadmin()
return
self.wizard.write_pgpass()
settings = self.wizard.settings
self.wizard.config.load_settings(settings)
# store = settings.get_super_store()
# version = store.dbVersion()
# if version < (8, 1):
# info(_("Stoq requires PostgresSQL 8.1 or later, but %s found") %
# ".".join(map(str, version)))
# store.close()
# return False
# Secondly, ask the user if he really wants to create the database,
dbname = settings.dbname
if yesno(_(u"The specified database '%s' does not exist.\n"
u"Do you want to create it?") % dbname,
gtk.RESPONSE_YES, _(u"Create database"), _(u"Don't create")):
self.process_view.feed("** Creating database\r\n")
self._launch_stoqdbadmin()
else:
self.process_view.feed("** Not creating database\r\n")
self.wizard.disable_next()
示例6: _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()
示例7: _get_columns
def _get_columns(self):
return [Column('description', title=_(u'Product'),
data_type=str, expand=True),
Column('ordered', title=_(u'Ordered'),
data_type=int),
Column('stock', title=_(u'Stock'),
data_type=int)]
示例8: run_wizard
def run_wizard(cls, parent):
"""Run the wizard to create a product
This will run the wizard and after finishing, ask if the user
wants to create another product alike. The product will be
cloned and `stoqlib.gui.editors.producteditor.ProductEditor`
will run as long as the user chooses to create one alike
"""
with api.new_store() as store:
rv = run_dialog(cls, parent, store)
if rv:
inner_rv = rv
while yesno(_("Would you like to register another product alike?"),
gtk.RESPONSE_NO, _("Yes"), _("No")):
with api.new_store() as store:
template = store.fetch(rv)
inner_rv = run_dialog(ProductEditor, parent, store,
product_type=template.product_type,
template=template)
if not inner_rv:
break
# We are insterested in the first rv that means that at least one
# obj was created.
return rv
示例9: _check_param_online_services
def _check_param_online_services(self):
from stoqlib.database.runtime import get_default_store, new_store
from stoqlib.lib.parameters import sysparam
import gtk
sparam = sysparam(get_default_store())
if sparam.ONLINE_SERVICES is None:
from kiwi.ui.dialogs import HIGAlertDialog
# FIXME: All of this is to avoid having to set markup as the default
# in kiwi/ui/dialogs:HIGAlertDialog.set_details, after 1.0
# this can be simplified when we fix so that all descriptions
# sent to these dialogs are properly escaped
dialog = HIGAlertDialog(
parent=None,
flags=gtk.DIALOG_MODAL,
type=gtk.MESSAGE_WARNING)
dialog.add_button(_("Not right now"), gtk.RESPONSE_NO)
dialog.add_button(_("Enable online services"), gtk.RESPONSE_YES)
dialog.set_primary(_('Do you want to enable Stoq online services?'))
dialog.set_details(PRIVACY_STRING, use_markup=True)
dialog.set_default_response(gtk.RESPONSE_YES)
response = dialog.run()
dialog.destroy()
store = new_store()
sysparam(store).ONLINE_SERVICES = int(bool(response == gtk.RESPONSE_YES))
store.commit()
store.close()
示例10: validate_invoice_number
def validate_invoice_number(invoice_number, store):
if not 0 < invoice_number <= 999999999:
return ValidationError(
_("Invoice number must be between 1 and 999999999"))
if not store.find(Invoice, invoice_number=invoice_number).is_empty():
return ValidationError(_(u'Invoice number already used.'))
示例11: _write_account_cells
def _write_account_cells(self, sheet, cells):
for y, cell in enumerate(cells):
sheet.write(2 + y, 0, cell, HEADER_LEFT_STYLE)
n_rows = len(cells)
sheet.write(n_rows + 2, 0, _(u"Average"), HEADER_LEFT_STYLE)
sheet.write(n_rows + 3, 0, _(u"Total"), HEADER_LEFT_STYLE)
示例12: _write_headers
def _write_headers(self, sheet, n_columns):
for x in range(n_columns):
month_name = get_month_names()[x]
sheet.write(1, 1 + x, month_name, HEADER_TOP_STYLE)
sheet.write(1, n_columns + 1, _(u"Average"), HEADER_TOP_STYLE)
sheet.write(1, n_columns + 2, _(u"Total"), HEADER_TOP_STYLE)
示例13: on_return_quantity__validate
def on_return_quantity__validate(self, widget, value):
if value < self._original_return_qty:
return ValidationError(_(u'Can not decrease this quantity.'))
total = value + self.model.sale_quantity
if total > self.model.quantity:
return ValidationError(_(u'Sale and return quantity is greater '
'than the total quantity.'))
示例14: create_ui
def create_ui(self):
if api.sysparam(self.store).SMART_LIST_LOADING:
self.search.enable_lazy_search()
self.popup = self.uimanager.get_widget('/StockSelection')
self.window.add_new_items([self.NewReceiving, self.NewTransfer,
self.NewStockDecrease, self.LoanNew])
self.window.add_search_items([
self.SearchStockItems,
self.SearchStockDecrease,
self.SearchClosedStockItems,
self.SearchProductHistory,
self.SearchPurchasedStockItems,
self.SearchTransfer,
])
self.window.Print.set_tooltip(
_("Print a report of these products"))
self._inventory_widgets = [self.NewTransfer, self.NewReceiving,
self.StockInitial, self.NewStockDecrease,
self.LoanNew, self.LoanClose]
self.register_sensitive_group(self._inventory_widgets,
lambda: not self.has_open_inventory())
self.image_viewer = None
self.image = gtk.Image()
self.edit_button = self.uimanager.get_widget('/toolbar/AppToolbarPH/EditProduct')
self.edit_button.set_icon_widget(self.image)
self.image.show()
self.search.set_summary_label(column='stock',
label=_('<b>Stock Total:</b>'),
format='<b>%s</b>',
parent=self.get_statusbar_message_area())
示例15: on_SalesCancel__activate
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()