本文整理汇总了Python中stoqlib.api.api.trans函数的典型用法代码示例。如果您正苦于以下问题:Python trans函数的具体用法?Python trans怎么用?Python trans使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了trans函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_details_button_clicked
def on_details_button_clicked(self, *args):
# FIXME: Person editor/slaves are depending on the store being a
# StoqlibStore. See bug 5012
with api.trans() as store:
selected = self.results.get_selected()
user = store.fetch(selected.user)
run_dialog(UserEditor, self, store, user, visual_mode=True)
示例2: _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)
示例3: _run_client_editor
def _run_client_editor(self, client=None):
with api.trans() as store:
rv = run_person_role_dialog(ClientEditor, self, store, client,
visual_mode=self.visual_mode)
if rv:
self._fill_clients_combo()
self.client.select(self.store.fetch(rv))
示例4: _work
def _work(self):
selection = self.search.get_selected_item()
with api.trans() as store:
work_order = store.fetch(selection.work_order)
work_order.work()
self._update_view(select_item=selection)
示例5: _run_category_editor
def _run_category_editor(self, category=None):
with api.trans() as store:
rv = run_dialog(WorkOrderCategoryEditor, self, store, category,
visual_mode=self.visual_mode)
if rv:
self._fill_categories_combo()
self.category.select(self.store.fetch(rv))
示例6: _run_medic_editor
def _run_medic_editor(self, medic=None, visual_mode=False):
with api.trans() as store:
medic = run_person_role_dialog(MedicEditor, self, store, medic, visual_mode=True)
if medic:
self._medic_combo_prefill()
medic = self.store.fetch(medic)
self.medic_combo.select(medic)
示例7: _pay
def _pay(self, payable_views):
"""
Pay a list of items from a payable_views, note that
the list of payable_views must reference the same order
@param payables_views: a list of payable_views
"""
assert self._can_pay(payable_views)
# Do not allow confirming the payment if the purchase was not
# completely received.
purchase_order = payable_views[0].purchase
if (purchase_order and
api.sysparam(self.store).BLOCK_INCOMPLETE_PURCHASE_PAYMENTS and
not purchase_order.status == PurchaseOrder.ORDER_CLOSED):
return warning(_("Can't confirm the payment if the purchase "
"is not completely received yet."))
with api.trans() as store:
payments = [store.fetch(view.payment) for view in payable_views]
run_dialog(PurchasePaymentConfirmSlave, self, store,
payments=payments)
if store.committed:
# We need to refresh the whole list as the payment(s) can possibly
# disappear for the selected view
self.refresh()
self._update_widgets()
示例8: _receive
def _receive(self):
with api.trans() 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()
示例9: _open_inventory
def _open_inventory(self):
with api.trans() as store:
rv = self.run_dialog(InventoryOpenEditor, store)
if rv:
self.refresh()
self._update_widgets()
示例10: _edit
def _edit(self, payable_views):
with api.trans() as store:
order = store.fetch(payable_views[0].purchase)
run_dialog(PurchasePaymentsEditor, self, store, order)
if store.committed:
self.refresh()
示例11: _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.trans() as store:
for order_view in valid_order_views:
order = store.fetch(order_view.purchase)
order.confirm()
self.refresh()
self.select_result(orders)
示例12: on_ProductsPriceSearch__activate
def on_ProductsPriceSearch__activate(self, action):
from stoqlib.domain.person import ClientCategory
if not self.store.find(ClientCategory).count():
warning(_("Can't use prices editor without client categories"))
return
with api.trans() as store:
self.run_dialog(SellablePriceDialog, store)
示例13: _new_consignment
def _new_consignment(self):
with api.trans() as store:
self.run_dialog(ConsignmentWizard, store, model=None)
if store.committed:
self.refresh()
res = self.store.find(PurchaseOrderView, id=store.retval.id).one()
self.select_result(res)
示例14: _run_editor
def _run_editor(self, button, editor_class):
with api.trans() as store:
run_dialog(editor_class, self, store)
if store.committed:
self.search.refresh()
self.results.unselect_all()
if len(self.results):
self.results.select(self.results[-1])
示例15: _quote_order
def _quote_order(self, quote=None):
with api.trans() as store:
quote = store.fetch(quote)
self.run_dialog(QuotePurchaseWizard, store, quote)
if store.committed:
self.refresh()
res = self.store.find(PurchaseOrderView, id=store.retval.id).one()
self.select_result(res)