def describe_item(self, client_view): details = [] birth_date = (client_view.birth_date and client_view.birth_date.strftime('%x')) for label, value in [ (_("Phone"), client_view.phone_number), (_("Mobile"), client_view.mobile_number), (self._person_l10n.label, client_view.cpf), (self._company_l10n.label, client_view.cnpj), (_("RG"), client_view.rg_number), (_("Birth date"), birth_date), (_("Category"), client_view.client_category), (_("Address"), format_address(client_view))]: if not value: continue details.append('%s: %s' % (label, api.escape(value))) name = "<big>%s</big>" % (api.escape(client_view.name), ) if details: short = name + '\n<span size="small">%s</span>' % ( api.escape(', '.join(details[:1]))) complete = name + '\n<span size="small">%s</span>' % ( api.escape('\n'.join(details))) else: short = name complete = name return short, complete
def _setup_widgets(self): self.sales_list.set_columns(self._get_sale_columns()) self.product_list.set_columns(self._get_product_columns()) self.services_list.set_columns(self._get_services_columns()) self.payments_list.set_columns(self._get_payments_columns()) self.calls_list.set_columns(self._get_calls_columns()) self.account_list.set_columns(self._get_account_columns()) self.sales_list.add_list(self.model.get_client_sales()) self.product_list.add_list(self.model.get_client_products()) self.services_list.add_list(self.model.get_client_services()) self.payments_list.add_list(self.model.get_client_payments()) self.calls_list.add_list(self.model.person.calls) self.account_list.add_list(self.model.get_credit_transactions()) value_format = '<b>%s</b>' total_label = "<b>%s</b>" % api.escape(_("Total:")) saldo_label = "<b>%s</b>" % api.escape(_("Saldo:")) sales_summary_label = SummaryLabel(klist=self.sales_list, column='total', label=total_label, value_format=value_format) account_summary_label = SummaryLabel(klist=self.account_list, column='value', label=saldo_label, value_format=value_format) sales_summary_label.show() account_summary_label.show() self.sales_vbox.pack_start(sales_summary_label, False) self.account_vbox.pack_start(account_summary_label, False)
def _setup_summary_labels(self): value_format = "<b>%s</b>" total_label = "<b>%s</b>" % api.escape(_("Total:")) total_summary_label = SummaryLabel(klist=self.payments_list, column='value', label=total_label, value_format=value_format) total_summary_label.show() self.payments_vbox.pack_start(total_summary_label, False) total_label = "<b>%s</b>" % api.escape(_("Total paid:")) total_paid_summary_label = SummaryLabel(klist=self.payments_list, column='paid_value', label=total_label, value_format=value_format) total_paid_summary_label.show() self.payments_vbox.pack_start(total_paid_summary_label, False) total_label = "<b>%s</b>" % api.escape(_("Total:")) transaction_summary_label = SummaryLabel( klist=self.stock_transactions_list, column='total', label=total_label, value_format=value_format) transaction_summary_label.show() self.stock_transactions_vbox.pack_start(transaction_summary_label, False) total_label = "<b>%s</b>" % api.escape(_("Total:")) sale_summary_label = SummaryLabel(klist=self.sales_list, column='total', label=total_label, value_format=value_format) sale_summary_label.show() self.sales_vbox.pack_start(sale_summary_label, False)
def _setup_widgets(self): self.sales_list.set_columns(self._get_sale_columns()) self.returned_sales_list.set_columns(self._get_returned_sale_columns()) self.product_list.set_columns(self._get_product_columns()) self.services_list.set_columns(self._get_services_columns()) self.work_order_list.set_columns(self._get_work_order_columns()) self.payments_list.set_columns(self._get_payments_columns()) self.calls_list.set_columns(self._get_calls_columns()) self.account_list.set_columns(self._get_account_columns()) self.sales_list.add_list(self.model.get_client_sales()) self.returned_sales_list.add_list(self.model.get_client_returned_sales()) self.product_list.add_list(self.model.get_client_products()) self.services_list.add_list(self.model.get_client_services()) self.work_order_list.add_list(self.model.get_client_work_orders()) self.payments_list.add_list(self.model.get_client_payments()) self.calls_list.add_list(self.model.person.calls) self.account_list.add_list(self.model.get_credit_transactions()) value_format = '<b>%s</b>' total_label = "<b>%s</b>" % api.escape(_("Total:")) saldo_label = "<b>%s</b>" % api.escape(_("Balance:")) sales_summary_label = SummaryLabel(klist=self.sales_list, column='total', label=total_label, value_format=value_format) account_summary_label = SummaryLabel(klist=self.account_list, column='paid_value', label=saldo_label, value_format=value_format, data_func=lambda p: p.is_outpayment()) sales_summary_label.show() account_summary_label.show() self.sales_vbox.pack_start(sales_summary_label, False) self.account_vbox.pack_start(account_summary_label, False)
def setup_proxies(self): receiving_date = self.model.get_receival_date_str() branch_name = self.model.get_branch_name() text = _('Received in <b>%s</b> for branch <b>%s</b>') header_text = text % (api.escape(receiving_date), api.escape(branch_name)) self.header_label.set_markup(header_text) self.add_proxy(self.model, ['notes'])
def __init__(self, cert_name, retry=False): super(CertificatePasswordDialog, self).__init__(None) text = _("Enter the password for <b>%s</b>:") % (api.escape(cert_name), ) if retry: error_text = '<b><span color="red">%s</span></b>' % ( api.escape(_("Wrong password provided...")), ) text = "%s\n%s" % (error_text, text) self.info_lbl.set_markup(text)
def _update_ui(self): running_action = self._manager.running_action self._refresh_btn.set_sensitive(running_action is None) for name, resource in self._manager.resources.iteritems(): img, lbl, buttonbox = self._widgets[name] status_stock, _ignored = _status_mapper[resource.status] img.set_from_stock(status_stock, gtk.ICON_SIZE_LARGE_TOOLBAR) if resource.reason and resource.reason_long: text = "<b>%s</b>: %s\n<i>%s</i>" % ( api.escape(resource.label), api.escape(resource.reason), api.escape(resource.reason_long)) elif resource.reason: text = "<b>%s</b>: %s" % ( api.escape(resource.label), api.escape(resource.reason)) else: text = _("Status not available...") for child in buttonbox.get_children(): buttonbox.remove(child) for action in resource.get_actions(): btn = gtk.Button(action.label) if running_action is not None: btn.set_sensitive(False) if action.admin_only and not self._is_admin: btn.set_sensitive(False) btn.set_tooltip_text( _("Only admins can execute this action")) # If the action is the running action, add a spinner together # with the label to indicate that it is running if action == running_action: spinner = gtk.Spinner() hbox = gtk.HBox(spacing=6) child = btn.get_child() btn.remove(child) hbox.add(child) hbox.add(spinner) btn.add(hbox) spinner.start() hbox.show_all() btn.show() btn.connect('clicked', self._on_action_btn__clicked, action) buttonbox.add(btn) lbl.set_markup(text)
def refresh(self): if stoq.trial_mode: self.status = ResourceStatus.STATUS_NA self.reason = (_('Online features are not available in trial mode')) self.reason_long = _('Online features require a subscription of Stoq.link') return if not api.sysparam.get_bool('ONLINE_SERVICES'): self.status = ResourceStatus.STATUS_NA self.reason = (_("Online services (Stoq.link integration, backup, " "etc) not enabled...")) self.reason_long = _('Enable the parameter "Online Services" ' 'on the "Admin" app to solve this issue') return if self._check_running(): self.status = self.STATUS_OK self.reason = _("Online services data hub is running fine.") self.reason_long = None else: self.status = ResourceStatus.STATUS_ERROR self.reason = _("Online services data hub not found...") package = '<a href="apt://stoq-server">stoq-server</a>' self.reason_long = safe_str( api.escape(_("Install and configure the %s package " "to solve this issue")) % (package, ))
def _setup_widgets(self): is_package = self.model.product.is_package component_list = list(self._get_products(additional_query=is_package)) if component_list: self.component_combo.prefill(component_list) else: self.sort_components_check.set_sensitive(False) self.yield_quantity.set_adjustment( gtk.Adjustment(lower=0, upper=MAX_INT, step_incr=1)) self.component_tree.set_columns(self._get_columns()) self._populate_component_tree() self.component_label = SummaryLabel( klist=self.component_tree, column='total_production_cost', label='<b>%s</b>' % api.escape(_(u'Total:')), value_format='<b>%s</b>') self.component_label.show() self.component_tree_vbox.pack_start(self.component_label, False) self.info_label.set_bold(True) self._update_widgets() if self.visual_mode: self.component_combo.set_sensitive(False) self.add_button.set_sensitive(False) self.sort_components_check.set_sensitive(False)
def update_total(self): SellableItemStep.update_total(self) quantities = {} missing = {} lead_time = 0 for i in self.slave.klist: sellable = i.sellable if sellable.service or not sellable.product.manage_stock: continue quantities.setdefault(sellable, 0) quantities[sellable] += i.quantity if quantities[sellable] > i._stock_quantity: _lead_time = sellable.product.get_max_lead_time( quantities[sellable], self.model.branch) max_lead_time = max(lead_time, _lead_time) missing[sellable] = Settable( description=sellable.get_description(), stock=i._stock_quantity, ordered=quantities[sellable], lead_time=_lead_time, ) self.missing = missing if missing: msg = _('Not enough stock. ' 'Estimated time to obtain missing items: %d days.') % max_lead_time self.slave.set_message( '<b>%s</b>' % (api.escape(msg)), self._show_missing_details) else: self.slave.clear_message()
def search_completed(self, results): # We are only interested in the workorders whose status are in one of our # columns results = results.find(WorkOrder.status.is_in(self.status_columns)) for work_order_view in results.order_by(WorkOrder.open_date): work_order = work_order_view.work_order status_name = WorkOrder.statuses.get(work_order.status) # Skip cancel/delivered etc if status_name is None: continue # Since this column isnt one of the |work_order| status if work_order.client_informed_date: status_name = _('Client informed') column = self.get_column_by_title(status_name) if column is None: continue if work_order_view.sellable: description = '%s - %s' % ( work_order_view.sellable, work_order_view.description) else: description = work_order_view.description # FIXME: Figure out a better way of rendering work_order_view.markup = '<b>%s</b>\n%s\n%s' % ( description, str(api.escape(work_order_view.client_name)), work_order_view.open_date.strftime('%x')) column.append_item(work_order_view)
def _update_account_type(self, account_type): if not self.account_type.get_sensitive(): return if account_type != Account.TYPE_BANK: self._remove_bank_widgets() self._remove_bank_option_widgets() self.code.set_sensitive(True) return self.code.set_sensitive(False) self.bank_type = ProxyComboBox() self._add_widget(api.escape(_("Bank:")), self.bank_type) self.bank_type.connect('content-changed', self._on_bank_type__content_changed) self.bank_type.show() banks = [(_('Generic'), None)] banks.extend([(b.description, b.bank_number) for b in get_all_banks()]) self.bank_type.prefill(banks) if self.model.bank: try: self.bank_type.select(self.model.bank.bank_number) except KeyError: self.bank_type.select(None) self._update_bank_type()
def _till_status_changed(self, closed, blocked): def large(s): return '<span weight="bold" size="xx-large">%s</span>' % ( api.escape(s), ) if closed: text = large(_("Till closed")) if not blocked: text += '\n\n<span size="large"><a href="open-till">%s</a></span>' % ( api.escape(_('Open till'))) elif blocked: text = large(_("Till blocked")) else: text = large(_("Till open")) self.till_status_label.set_use_markup(True) self.till_status_label.set_justify(gtk.JUSTIFY_CENTER) self.till_status_label.set_markup(text) self.set_sensitive([self.TillOpen], closed) self.set_sensitive([self.TillVerify], not closed and not blocked) self.set_sensitive([ self.TillClose, self.NewTrade, self.LoanClose, self.WorkOrderClose ], not closed or blocked) self._set_sale_sensitive(not closed and not blocked)
def _setup_summary_labels(self): summary_label = SummaryLabel(klist=self.payments_list, column='paid_value', label='<b>%s</b>' % api.escape(_(u"Total:")), value_format='<b>%s</b>') summary_label.show() self.payments_vbox.pack_start(summary_label, False)
def _update_title(self): # Workaround to get the current calendar date view = self.get_view() view.execute_script("document.title = $('.fc-header-title').text()") title = view.get_property('title') self.app.date_label.set_markup( '<big><b>%s</b></big>' % api.escape(title))
def setup_widgets(self): difference_label = gtk.Label() difference_label.set_markup("<small><b>%s</b></small>" % api.escape( _(u"The DIFFERENCE column is equal to " "IN STOCK minus MINIMUM columns"))) difference_label.show() self.search.vbox.pack_end(difference_label, False, False, 6)
def create_ui(self): if api.sysparam.get_bool('SMART_LIST_LOADING'): self.search.enable_lazy_search() self.window.add_print_items2([ (_("Print quote..."), 'work_order.PrintQuote'), (_("Print receipt..."), 'work_order.PrintReceipt'), ]) self.window.add_export_items() self.window.add_extra_items2([ (_("Send orders..."), 'work_order.SendOrders'), (_("Receive orders..."), 'work_order.ReceiveOrders'), ]) self.window.add_extra_items([self.ViewKanban, self.ViewList]) self.window.add_new_items2([ (_("Work order..."), 'work_order.NewOrder'), ]) self.window.add_search_items([ self.Products, self.Services, self.Categories, self.Clients, ]) self.search.set_summary_label( column='total', label=('<b>%s</b>' % api.escape(_('Total:'))), format='<b>%s</b>', parent=self.get_statusbar_message_area()) self.results.set_cell_data_func(self._on_results__cell_data_func)
def create_ui(self): self.search.enable_lazy_search() # XXX: What should we put on new items? self.window.add_new_items([ ]) self.window.add_search_items([ self.Products, self.Services, self.Transporters, self.Clients, ]) # FIXME: identifier is here because it needs an integer column. # The lazy summary will actually be taken from the view's # post_search_callback self.search.set_summary_label( column='identifier', label=('<b>%s</b>' % api.escape(_('Number of deliveries:'))), format='<b>%s</b>', parent=self.get_statusbar_message_area()) self.results.set_cell_data_func(self._on_results__cell_data_func)
def create_ui(self): if api.sysparam.get_bool('SMART_LIST_LOADING'): self.search.enable_lazy_search() self.window.add_print_items2([ (_("Print quote..."), 'work_order.PrintQuote'), (_("Print receipt..."), 'work_order.PrintReceipt'), ]) self.window.add_export_items() self.window.add_extra_items2([ (_("Send orders..."), 'work_order.SendOrders'), (_("Receive orders..."), 'work_order.ReceiveOrders'), ]) self.window.add_extra_items([self.ViewKanban, self.ViewList]) self.window.add_new_items2([ (_("Work order..."), 'work_order.NewOrder'), ]) self.window.add_search_items([ self.Products, self.Services, self.Categories, self.Clients, ]) self.search.set_summary_label(column='total', label=('<b>%s</b>' % api.escape(_('Total:'))), format='<b>%s</b>', parent=self.get_statusbar_message_area()) self.results.set_cell_data_func(self._on_results__cell_data_func)
def search_completed(self, results): # We are only interested in the workorders whose status are in one of our # columns results = results.find(WorkOrder.status.is_in(self.status_columns)) for work_order_view in results.order_by(WorkOrder.open_date): work_order = work_order_view.work_order status_name = WorkOrder.statuses.get(work_order.status) # Skip cancel/delivered etc if status_name is None: continue # Since this column isnt one of the |work_order| status if work_order.client_informed_date: status_name = _('Client informed') column = self.get_column_by_title(status_name) if column is None: continue if work_order_view.sellable: description = '%s - %s' % (work_order_view.sellable, work_order_view.description) else: description = work_order_view.description # FIXME: Figure out a better way of rendering work_order_view.markup = '<b>%s</b>\n%s\n%s' % ( description, str(api.escape(work_order_view.client_name)), work_order_view.open_date.strftime('%x')) column.append_item(work_order_view)
def _check_demo_mode(self): if not api.sysparam.get_bool('DEMO_MODE'): return if api.user_settings.get('hide-demo-warning'): return button_label = _('Use my own data') title = _('You are using Stoq with example data.') desc = (_("Some features are limited due to fiscal reasons. " "Click on '%s' to remove the limitations.") % button_label) msg = '<b>%s</b>\n%s' % (api.escape(title), api.escape(desc)) button = Gtk.Button(button_label) button.connect('clicked', self._on_enable_production__clicked) self.add_info_bar(Gtk.MessageType.WARNING, msg, action_widget=button)
def create_ui(self): if api.sysparam.get_bool('SMART_LIST_LOADING'): self.search.enable_lazy_search() self.window.add_new_items([ self.NewOrder, self.NewQuote, self.NewProduct, self.NewConsignment]) self.window.add_search_items([ self.Products, self.Suppliers, self.SearchQuotes, self.Services]) self.search.set_summary_label(column='total', label=('<b>%s</b>' % api.escape(_('Orders total:'))), format='<b>%s</b>', parent=self.get_statusbar_message_area()) self.results.set_selection_mode(gtk.SELECTION_MULTIPLE) self.Confirm.set_sensitive(False) self._inventory_widgets = [self.NewConsignment, self.CloseInConsignment] self.register_sensitive_group(self._inventory_widgets, lambda: not self.has_open_inventory())
def _update_total(self): SellableItemStep._update_total(self) quantities = {} missing = {} lead_time = 0 for i in self.slave.klist: sellable = i.sellable if sellable.service or not sellable.product.manage_stock: continue quantities.setdefault(sellable, 0) quantities[sellable] += i.quantity if quantities[sellable] > i._stock_quantity: _lead_time = sellable.product.get_max_lead_time( quantities[sellable], self.model.branch) max_lead_time = max(lead_time, _lead_time) missing[sellable] = Settable( description=sellable.get_description(), stock=i._stock_quantity, ordered=quantities[sellable], lead_time=_lead_time, ) self.missing = missing if missing: msg = _('Not enough stock. ' 'Estimated time to obtain missing items: %d days.' ) % max_lead_time self.slave.set_message('<b>%s</b>' % (api.escape(msg)), self._show_missing_details) else: self.slave.clear_message()
def _setup_summary_labels(self): summary_label = SummaryLabel(klist=self.payments_list, column='paid_value', label='<b>%s</b>' % api.escape(_(u"Total:")), value_format='<b>%s</b>') summary_label.show() self.payments_vbox.pack_start(summary_label, False, True, 0)
def _update_title(self): # Workaround to get the current calendar date view = self.get_view() view.execute_script("document.title = $('.fc-header-title').text()") title = view.get_property('title') self.app.date_label.set_markup('<big><b>%s</b></big>' % api.escape(title))
def search_completed(self, results): for work_order_view in results.order_by(WorkOrder.open_date): work_order = work_order_view.work_order status_name = WorkOrder.statuses.get(work_order.status) # Skip cancel/delivered etc if status_name is None: continue column = self.get_column_by_title(status_name) if column is None: continue if work_order_view.sellable: description = '%s - %s' % ( work_order_view.sellable, work_order_view.description) else: description = work_order_view.description # FIXME: Figure out a better way of rendering work_order_view.markup = '<b>%s</b>\n%s\n%s' % ( description, unicode(api.escape(work_order_view.client_name)), work_order_view.open_date.strftime('%x')) column.append_item(work_order_view)
class _WorkOrderItemSlave(SellableItemSlave): model_type = WorkOrder summary_label_text = '<b>%s</b>' % api.escape(_("Total:")) sellable_view = SellableFullStockView item_editor = _WorkOrderItemEditor validate_stock = True validate_value = True value_column = 'price' def __init__(self, store, model=None, visual_mode=False): super(_WorkOrderItemSlave, self).__init__(store, model=model, visual_mode=visual_mode) self.hide_add_button() # # SellableItemSlave # def on_confirm(self): self.model.sync_stock() def get_columns(self, editable=True): return [ Column('sellable.code', title=_(u'Code'), data_type=str, visible=False), Column('sellable.barcode', title=_(u'Barcode'), data_type=str, visible=False), Column('sellable.description', title=_(u'Description'), data_type=str, expand=True), Column('price', title=_(u'Price'), data_type=currency), Column('quantity', title=_(u'Quantity'), data_type=decimal.Decimal, format_func=format_quantity), Column('total', title=_(u'Total'), data_type=currency), ] def get_saved_items(self): return self.model.order_items def get_order_item(self, sellable, price, quantity): return self.model.add_sellable(sellable, price=price, quantity=quantity) def get_sellable_view_query(self): return ( self.sellable_view, # FIXME: How to do this using sellable_view.find_by_branch ? And( Or(ProductStockItem.branch_id == self.model.branch.id, Eq(ProductStockItem.branch_id, None)), Sellable.get_available_sellables_query(self.store)))
def _setup_widgets(self): is_package = self.model.product.is_package component_list = list(self._get_products(additional_query=is_package)) if component_list: self.component_combo.prefill(component_list) else: self.sort_components_check.set_sensitive(False) self.yield_quantity.set_adjustment( gtk.Adjustment(lower=0, upper=MAX_INT, step_incr=1)) self.component_tree.set_columns(self._get_columns()) self._populate_component_tree() self.component_label = SummaryLabel(klist=self.component_tree, column='total_production_cost', label='<b>%s</b>' % api.escape(_(u'Total:')), value_format='<b>%s</b>') self.component_label.show() self.component_tree_vbox.pack_start(self.component_label, False) self.info_label.set_bold(True) self._update_widgets() if self.visual_mode: self.component_combo.set_sensitive(False) self.add_button.set_sensitive(False) self.sort_components_check.set_sensitive(False)
def _setup_widgets(self): self.branch_label.set_markup( _(u"Fixing stock cost for products in <b>%s</b>") % api.escape(self._branch.person.name)) items = ProductWithStockView.find_by_branch(self.store, self._branch) self._storables = [_TemporaryItem(s) for s in items] self.slave.listcontainer.add_items(self._storables)
def _setup_summary_labels(self): order_summary_label = SummaryLabel(klist=self.ordered_items, column='total', label='<b>%s</b>' % api.escape(_(u"Total")), value_format='<b>%s</b>') order_summary_label.show() self.ordered_vbox.pack_start(order_summary_label, False)
def _check_demo_mode(self): if not api.sysparam.get_bool('DEMO_MODE'): return if api.user_settings.get('hide-demo-warning'): return button_label = _('Enable production mode') title = _('You are using Stoq in demonstration mode.') desc = (_("Some features are limited due to fiscal reasons. " "Click on '%s' to remove the limitations and finish the demonstration.") % button_label) msg = '<b>%s</b>\n%s' % (api.escape(title), api.escape(desc)) button = gtk.Button(button_label) button.connect('clicked', self._on_enable_production__clicked) self.add_info_bar(gtk.MESSAGE_WARNING, msg, action_widget=button)
def describe_item(self, view): details = [] for label, value in [(_("Name"), view.name), (_("CRM"), view.crm_number)]: if not value: continue details.append('%s: %s' % (label, api.escape(value))) name = "<big>%s</big>" % (api.escape(view.name), ) if details: short = name + '\n<span size="small">%s</span>' % ( api.escape(', '.join(details[:1]))) complete = name + '\n<span size="small">%s</span>' % ( api.escape('\n'.join(details))) else: short = name complete = name return short, complete
def _setup_summary_labels(self): order_summary_label = SummaryLabel( klist=self.ordered_items, column='total', label='<b>%s</b>' % api.escape(_(u"Total")), value_format='<b>%s</b>') order_summary_label.show() self.ordered_vbox.pack_start(order_summary_label, False)
def _setup_widgets(self): self.branch_label.set_markup( _(u"Fixing stock cost for products in <b>%s</b>") % api.escape(self._branch.get_description())) items = ProductWithStockView.find_by_branch(self.store, self._branch) self._storables = [_TemporaryItem(s) for s in items] self.slave.listcontainer.add_items(self._storables)
def setup_widgets(self): difference_label = gtk.Label() difference_label.set_markup( "<small><b>%s</b></small>" % api.escape(_(u"The DIFFERENCE column is equal to " "IN STOCK minus MINIMUM columns"))) difference_label.show() self.search.search.pack_end(difference_label, False, False, 6)
def _setup_widgets(self): self.receiving_list.set_columns(self._get_receiving_columns()) self.sales_list.set_columns(self._get_sale_columns()) self.transfer_list.set_columns(self._get_transfer_columns()) self.loan_list.set_columns(self._get_loan_columns()) self.decrease_list.set_columns(self._get_decrease_columns()) items = self.store.find(ReceivingItemView, sellable_id=self.model.id) self.receiving_list.add_list(list(items)) items = self.store.find(SaleItemsView, sellable_id=self.model.id) self.sales_list.add_list(list(items)) items = self.store.find(TransferOrderItem, sellable_id=self.model.id) self.transfer_list.add_list(list(items)) items = self.store.find(LoanItemView, sellable_id=self.model.id) self.loan_list.add_list(list(items)) items = self.store.find(StockDecreaseItemsView, sellable=self.model.id) self.decrease_list.add_list(list(items)) value_format = '<b>%s</b>' total_label = "<b>%s</b>" % api.escape(_("Total:")) receiving_summary_label = SummaryLabel(klist=self.receiving_list, column='quantity', label=total_label, value_format=value_format) receiving_summary_label.show() self.receiving_vbox.pack_start(receiving_summary_label, False) sales_summary_label = SummaryLabel(klist=self.sales_list, column='quantity', label=total_label, value_format=value_format) sales_summary_label.show() self.sales_vbox.pack_start(sales_summary_label, False) transfer_summary_label = SummaryLabel(klist=self.transfer_list, column='quantity', label=total_label, value_format=value_format) transfer_summary_label.show() self.transfer_vbox.pack_start(transfer_summary_label, False) loan_summary_label = SummaryLabel(klist=self.loan_list, column='quantity', label=total_label, value_format=value_format) self.loan_vbox.pack_start(loan_summary_label, False) decrease_summary_label = SummaryLabel(klist=self.decrease_list, column='quantity', label=total_label, value_format=value_format) decrease_summary_label.show() self.decrease_vbox.pack_start(decrease_summary_label, False)
def describe_item(self, person_view): details = [] for label, value in [(self._person_l10n.label, person_view.cpf)]: if not value: continue details.append('%s: %s' % (label, api.escape(value))) name = "<big>%s</big>" % (api.escape(person_view.get_description()), ) if details: short = name + '\n<span size="small">%s</span>' % (api.escape( ', '.join(details[:1]))) complete = name + '\n<span size="small">%s</span>' % (api.escape( '\n'.join(details))) else: short = name complete = name return short, complete
def update_status_unavailable_label(self): text = '' if self.statuses_combo.read() == Sellable.STATUS_UNAVAILABLE: text = ("<b>%s</b>" % api.escape( _("This status changes automatically when the\n" "product is purchased or an inicial stock is added."))) self.status_unavailable_label.set_text(text)
def _create_headerbar(self): # User/help menu user = api.get_current_user(self.store) xml = MENU_XML.format(username=api.escape(user.get_description()), preferences=_('Preferences...'), password=_('Change password...'), signout=_('Sign out...'), help=_('Help'), contents=_('Contents'), translate=_('Translate Stoq...'), get_support=_('Get support online...'), chat=_('Online chat...'), about=_('About'), quit=_('Quit')) builder = Gtk.Builder.new_from_string(xml, -1) # Header bar self.header_bar = Gtk.HeaderBar() self.toplevel.set_titlebar(self.header_bar) # Right side self.close_btn = self.create_button('fa-power-off-symbolic', action='stoq.quit') self.close_btn.set_relief(Gtk.ReliefStyle.NONE) self.min_btn = self.create_button('fa-window-minimize-symbolic') self.min_btn.set_relief(Gtk.ReliefStyle.NONE) #self.header_bar.pack_end(self.close_btn) #self.header_bar.pack_end(self.min_btn) box = Gtk.Box.new(orientation=Gtk.Orientation.HORIZONTAL, spacing=0) box.pack_start(self.min_btn, False, False, 0) box.pack_start(self.close_btn, False, False, 0) self.header_bar.pack_end(box) self.user_menu = builder.get_object('app-menu') self.help_section = builder.get_object('help-section') self.user_button = self.create_button('fa-cog-symbolic', menu_model=self.user_menu) self.search_menu = Gio.Menu() self.search_button = self.create_button('fa-search-symbolic', _('Searches'), menu_model=self.search_menu) self.main_menu = Gio.Menu() self.menu_button = self.create_button('fa-bars-symbolic', _('Actions'), menu_model=self.main_menu) self.header_bar.pack_end( ButtonGroup([self.menu_button, self.search_button, self.user_button])) self.sign_button = self.create_button('', _('Sign now'), style_class='suggested-action') #self.header_bar.pack_end(self.sign_button) # Left side self.home_button = self.create_button(STOQ_LAUNCHER, style_class='suggested-action') self.new_menu = Gio.Menu() self.new_button = self.create_button('fa-plus-symbolic', _('New'), menu_model=self.new_menu) self.header_bar.pack_start( ButtonGroup([self.home_button, self.new_button, ])) self.domain_header = None self.header_bar.show_all() self.notifications = NotificationCounter(self.home_button, blink=True)
def setup_widgets(self): value_format = '<b>%s</b>' total_label = "<b>%s</b>" % api.escape(_("Total:")) sales_summary_label = SummaryLabel(klist=self.klist, column='total', label=total_label, value_format=value_format) sales_summary_label.show() self.pack_start(sales_summary_label, False)
def describe_item(self, view): details = [] for label, value in [(_("Name"), view.name), (_("CRM"), view.crm_number)]: if not value: continue details.append('%s: %s' % (label, api.escape(value))) name = "<big>%s</big>" % (api.escape(view.name), ) if details: short = name + '\n<span size="small">%s</span>' % (api.escape( ', '.join(details[:1]))) complete = name + '\n<span size="small">%s</span>' % (api.escape( '\n'.join(details))) else: short = name complete = name return short, complete
def _setup_summary_labels(self): summary_label = SummaryLabel( klist=self.payments_list, column="paid_value", label="<b>%s</b>" % api.escape(_(u"Total:")), value_format="<b>%s</b>", ) summary_label.show() self.payments_vbox.pack_start(summary_label, False)
def create_filters(self): self.set_text_field_columns(["description"]) self.date_filter = DateSearchFilter(_("Date:")) self.date_filter.select(Today) self.add_filter(self.date_filter, columns=["date"]) # add summary label value_format = "<b>%s</b>" total_label = "<b>%s</b>" % api.escape(_(u"Total:")) self.search.set_summary_label("value", total_label, value_format)
def create_filters(self): self.set_text_field_columns(['description']) self.date_filter = DateSearchFilter(_('Date:')) self.date_filter.select(Today) self.add_filter(self.date_filter, columns=['date']) # add summary label value_format = '<b>%s</b>' total_label = '<b>%s</b>' % api.escape(_(u'Total:')) self.search.set_summary_label('value', total_label, value_format)
def search_completed(self, results, states): if len(results): return supplier, status = states[:2] if len(states) > 2 or (supplier.text == '' and status.value is None): self.search.set_message( "%s\n\n%s" % (_("No orders could be found."), _("Would you like to %s ?") % ('<a href="new_order">%s</a>' % (api.escape(_("create a new order"), )))))
def _create_summary_labels(self): parent = self.get_statusbar_message_area() self.search.set_summary_label(column='net_total', label=('<b>%s</b>' % api.escape(_('Gross total:'))), format='<b>%s</b>', parent=parent) # Add an extra summary beyond the main one # XXX: Should we modify the summary api to make it support more than one # summary value? This is kind of ugly if self._extra_summary: parent.remove(self._extra_summary) self._extra_summary = LazySummaryLabel(klist=self.search.result_view, column='net_total', label=('<b>%s</b>' % api.escape(_('Net total:'))), value_format='<b>%s</b>') parent.pack_start(self._extra_summary, False, False, 0) self._extra_summary.show()
def search_completed(self, results, states): if len(results): return base_msg = '' url_msg = '' state = states[1] if state and state.value is None: # Base search with no filters base_msg = _(u"No work orders could be found.") url = u"<a href='new_order'>%s</a>" % (api.escape( _(u"create a new work order")), ) url_msg = _(u"Would you like to %s ?") % (url, ) else: kind, value = state.value.value.split(':') # Search filtering by status if kind == 'status': if value == 'pending': base_msg = _(u"No pending work orders could be found.") elif value == 'in-progress': base_msg = _(u"No work orders in progress could be found.") elif value == 'finished': base_msg = _(u"No finished work orders could be found.") elif value == 'closed': base_msg = _(u"No closed or cancelled work " u"orders could be found.") # Search filtering by category elif kind == 'category': base_msg = _(u"No work orders in the category %s " u"could be found.") % ('<b>%s</b>' % (value, ), ) url = u"<a href='new_order?%s'>%s</a>" % ( urllib.quote(value.encode('utf-8')), api.escape(_(u"create a new work order")), ) url_msg = _(u"Would you like to %s ?") % (url, ) if not base_msg: return msg = '\n\n'.join([base_msg, url_msg]) self.search.set_message(msg)
def setup_widgets(self): value_format = '<b>%s</b>' balance_label = "<b>%s</b>" % api.escape(_("Balance:")) account_summary_label = SummaryLabel(klist=self.klist, column='paid_value', label=balance_label, value_format=value_format, data_func=lambda p: p.is_outpayment()) account_summary_label.show() self.pack_start(account_summary_label, False)
def create_ui(self): self.model.set_sort_column_id(COL_LABEL, Gtk.SortType.ASCENDING) self.iconview.set_markup_column(COL_LABEL) self.iconview.set_pixbuf_column(COL_PIXBUF) if hasattr(self.iconview, "set_item_orientation"): self.iconview.set_item_orientation(Gtk.Orientation.HORIZONTAL) self.iconview.set_selection_mode(Gtk.SelectionMode.BROWSE) self.iconview.set_item_padding(10) for app in self.window.get_available_applications(): pixbuf = self.get_toplevel().render_icon(app.icon, Gtk.IconSize.DIALOG) text = '<b>%s</b>\n<small>%s</small>' % (api.escape( app.fullname), api.escape(app.description)) self.model.append([text, pixbuf, app]) # FIXME: last opened application if len(self.model): self.iconview.select_path(self.model[0].path) self.iconview.grab_focus() self.iconview_vbox.show()
def _setup_widgets(self): self.branch_label.set_markup( _(u"Registering initial stock for products in <b>%s</b>") % api.escape(self._branch.person.name)) # XXX: Find out how we are going to handle the initial stock dialog self._storables = [ _TemporaryStorableItem(s) for s in self.store.find(Storable) if s.get_stock_item(self._branch, batch=None) is None ] self.slave.listcontainer.add_items(self._storables)
def _create_ui(self, model): client = '<b>%s</b>: %s' % (_('Client'), api.escape(model.client_name)) due_date = '' if model.estimated_finish: due_date = '%s: %s' % (_('Due date'), api.escape( model.estimated_finish.strftime('%x'))) identifier = '<b>%s</b>' % api.escape(str(model.identifier)) salesperson = '<b>%s</b>:' % _('Salesperson') if model.sale: identifier += ' (%s <a href="#">%s</a>)' % ( _('Sale'), api.escape(str(model.sale_identifier))) salesperson += ' %s' % api.escape( model.sale.get_salesperson_name()) self.due_date = self._new_label(due_date, xalign=1) self.client = self._new_label(client, expand=True) self.identifier = self._new_label(identifier, expand=True, halign=Gtk.Align.START) self.salesperson = self._new_label(salesperson, expand=False, halign=Gtk.Align.START) self.status = self._new_label('%s' % api.escape(model.status_str), xalign=1, halign=Gtk.Align.END) self.status.get_style_context().add_class('tag') self.status.get_style_context().add_class(model.status) eb = Gtk.EventBox() eb.set_halign(Gtk.Align.END) eb.add(self.status) button = Gtk.Button() button.connect('clicked', self._on_button__clicked) button.set_relief(Gtk.ReliefStyle.NONE) button.set_valign(Gtk.Align.CENTER) box = Gtk.HBox(spacing=6) button.add(box) image = Gtk.Image.new_from_icon_name('view-more-symbolic', Gtk.IconSize.BUTTON) box.pack_start(image, False, False, 0) grid = Gtk.Grid() grid.props.margin = 5 grid.set_row_spacing(1) grid.set_column_spacing(3) grid.attach(self.identifier, 0, 0, 1, 1) grid.attach(self.salesperson, 0, 1, 1, 1) grid.attach(self.client, 0, 2, 1, 1) grid.attach(eb, 1, 0, 1, 1) grid.attach(self.due_date, 1, 2, 1, 1) grid.attach(button, 3, 0, 1, 3) self.add(grid) eb.connect('realize', self._on_realize) eb.connect('button-release-event', self._on_status__clicked) self.identifier.connect('activate_link', self._on_sale__clicked)
def create_ui(self): self.model.set_sort_column_id(COL_LABEL, gtk.SORT_ASCENDING) self.iconview.set_markup_column(COL_LABEL) self.iconview.set_pixbuf_column(COL_PIXBUF) if hasattr(self.iconview, "set_item_orientation"): self.iconview.set_item_orientation(gtk.ORIENTATION_HORIZONTAL) self.iconview.set_item_width(300) self.iconview.set_selection_mode(gtk.SELECTION_BROWSE) self.iconview.set_spacing(10) for app in self.window.get_available_applications(): pixbuf = self.get_toplevel().render_icon(app.icon, gtk.ICON_SIZE_DIALOG) text = '<b>%s</b>\n<small>%s</small>' % (api.escape( app.fullname), api.escape(app.description)) self.model.append([text, pixbuf, app]) # FIXME: last opened application if len(self.model): self.iconview.select_path(self.model[0].path) self.iconview.grab_focus() self.iconview_vbox.show()