def refresh_ok(self, value): BaseEditor.refresh_ok(self, value) account_type = self.account_type.get_selected() if account_type != Account.TYPE_BANK: value = False self._test_button.set_sensitive(value)
def __init__(self, store, branch=None): if branch is None: self._branch = api.get_current_branch(store) else: self._branch = branch BaseEditor.__init__(self, store, model=object()) self._setup_widgets()
def __init__(self, store, model=None, visual_mode=False): """ Creates a new SaleDetailsDialog object :param store: a store :param model: a :class:`stoqlib.domain.sale.SaleView` object """ BaseEditor.__init__(self, store, model, visual_mode=visual_mode)
def __init__(self, store, model=None, visual_mode=False, attribute=None): self._attribute = attribute BaseEditor.__init__(self, store, model, visual_mode) if model: self.set_description(model.description) self.active_check_box.set_property('sensitive', bool(model))
def __init__(self, store, model, visual_mode=False): self.slave_model = None self.edit_mode = bool(model) if model: self.slave_model = model.get_tax_model() BaseEditor.__init__(self, store, model, visual_mode)
def __init__(self, store, model=None, parent_category=None, visual_mode=False): self._parent_category = parent_category BaseEditor.__init__(self, store, model, visual_mode) self.set_description(self.model.get_description())
def __init__(self, store, model): # Cache the data. this will save all storables, products and sellables # in cache, avoiding future quries when populating the list bellow. self._data = list(model.get_inventory_data()) self._has_adjusted_any = False BaseEditor.__init__(self, store, model) self._setup_widgets()
def __init__(self, store, person, address=None, visual_mode=False): self.person = store.fetch(person) if not isinstance(person, Person): raise TypeError("Invalid type for person argument. It should " "be of type Person, got %s instead" % type(person)) self.current_main_address = self.person.get_main_address() BaseEditor.__init__(self, store, address, visual_mode=visual_mode) self.set_description(self.model_name)
def __init__(self, store, model=None, visual_mode=False): BaseEditor.__init__(self, store, model, visual_mode) # do not let the user change the current station if model and get_current_station(store) == model: self.name.set_sensitive(False) self.is_active.set_sensitive(False) self.set_description(self.model.name)
def __init__(self, store, model): """An editor for a loan item. :param store: a store. :param model: a loan item. """ self.manager = None self.proxy = None BaseEditor.__init__(self, store, model)
def __init__(self, store, model=None, category_type=None, visual_mode=False): self._category_type = category_type or PaymentCategory.TYPE_PAYABLE BaseEditor.__init__(self, store, model, visual_mode=visual_mode) if category_type is not None: self.category_type.set_sensitive(False)
def __init__(self, store, sellable, model=None, max_quantity=None, visual_mode=False): self.sellable = sellable self.max_quantity = max_quantity BaseEditor.__init__(self, store, model, visual_mode) self._setup_widgets()
def __init__(self, store, model=None, visual_mode=False, group=None): self._group = group BaseEditor.__init__(self, store, model, visual_mode) # Only let the user edit if its a new attribute if model: self.set_description(model.description) self.fields['group'].set_sensitive(not bool(model) and not self._group) self.fields['is_active'].set_sensitive(bool(model))
def __init__(self, store, model, device): self.device = device if model: assert model.device == device model = _TemporaryOperationCost(model) card_method = store.find(PaymentMethod, method_name=u'card').one() self.max_installments = card_method.max_installments BaseEditor.__init__(self, store, model)
def __init__(self, store, model): manager = get_plugin_manager() self.nfe_is_active = manager.is_any_active(['nfe', 'nfce']) self.proxy = None self.icms_slave = None self.ipi_slave = None self.pis_slave = None self.cofins_slave = None BaseEditor.__init__(self, store, model)
def __init__(self, store, model=None, station=None): if station is not None and not isinstance(station, BranchStation): raise TypeError("station should be a BranchStation") self._branch_station = station # This attribute is set to True when setup_proxies is finished self._is_initialized = False BaseEditor.__init__(self, store, model) self._original_brand = self.model.brand self._original_model = self.model.model self.test_button = self.add_button(_('Test device'))
def __init__(self, store, model=None, category=None): """ A base class for additional payments :param store: a store :param model: a :class:`stoqlib.domain.payment.payment.Payment` object or None """ BaseEditor.__init__(self, store, model) self._setup_widgets() if category: self.category.select_item_by_label(category) self.description.grab_focus()
def __init__(self, store, model=None, printer=None, constant_type=None): if not isinstance(printer, ECFPrinter): raise TypeError("printer should be a ECFPrinter, not %s" % printer) self.printer = printer self.constant_type = constant_type BaseEditor.__init__(self, store, model) # Hide value label/entry for non tax types if constant_type != DeviceConstant.TYPE_TAX: self.label_value.hide() self.constant_value.hide()
def __init__(self, store, model, branch): self._branch = branch assert self._branch self._product = model # model here is the product, but we will create a settable later if model.storable: # We dont support editing batch products yet. assert not model.storable.is_batch self._stock_item = model.storable.get_stock_item(branch, batch=None) else: self._stock_item = None BaseEditor.__init__(self, store=store)
def __init__(self, store, model, person, person_type): self.person = person self.person_type = person_type BaseEditor.__init__(self, store, model) # If person is not None, this means we already are in this person # details dialog. No need for this option if person: self.details_button.hide() self.details_button.set_sensitive(self.model.person is not None) if self.model.person: self.set_description(_('Call to %s') % self.model.person.name) else: self.set_description(_('call'))
def __init__(self, store, model=None, items=None, person_type=Client): self.items = items self._deliver_items = [] self.person_type = person_type if not model: for item in items: item.deliver = True else: model.create_savepoint() # Store this information for later rollback. for item in items: self._deliver_items.append(item.deliver) BaseEditor.__init__(self, store, model) self._setup_widgets()
def __init__(self, store, model, client, visual_mode=None): self._client = client BaseEditor.__init__(self, store, model, visual_mode) if visual_mode or client: self.client_id_add_button.hide() self.client_id_edit_button.hide() if self.model.client: self.set_description( _('client credit check history for %s') % self.model.client.person.name) self.client_id.set_sensitive(False) else: self.set_description(_('client credit check history'))
def __init__(self, store, model=None, parent_account=None): self._last_account_type = None self._bank_number = -1 self._bank_widgets = [] self._bank_option_widgets = [] self._option_fields = {} self._test_button = None self.existing = model is not None self.parent_account = parent_account self.bank_model = _TemporaryBankAccount() BaseEditor.__init__(self, store, model) action_area = self.main_dialog.action_area action_area.set_layout(Gtk.ButtonBoxStyle.END) action_area.pack_start(self._test_button, False, False, 0) action_area.set_child_secondary(self._test_button, True) self._test_button.show()
def __init__(self, store, model, visual_mode=False): self.proxy = None BaseEditor.__init__(self, store, model, visual_mode) order = self.model.order if order.status == PurchaseOrder.ORDER_CONFIRMED: self._set_not_editable() self.sold_lbl.hide() self.returned_lbl.hide() self.quantity_sold.hide() self.quantity_returned.hide() if model.parent_item: # We should not allow the user to edit the children self._set_not_editable() parent_expected = model.parent_item.expected_receival_date self.expected_receival_date.update(parent_expected) self.expected_receival_date.set_sensitive(False)
def __init__(self, store, param_detail): if not param_detail: raise ValueError("This editor can't be called without a model") # By default, if the user sets a value to None (e.g. selecting nothing # on a comboentry) we block it's update. Change this to False if the # param itself can accept None. self._block_none_value = True self.sensitive = True # TODO: After we migrate those parameters to set is_editable # to False we can probably remove this if if param_detail.key in [ 'DEMO_MODE', 'LOCAL_BRANCH', 'SYNCHRONIZED_MODE', 'USER_HASH' ]: self.sensitive = False self.detail = param_detail model = self._get_model(store, param_detail) BaseEditor.__init__(self, store, model) self._setup_widgets()
def __init__(self, store, model=None, previous_day=False, close_db=True, close_ecf=True): """ Create a new TillClosingEditor object. :param previous_day: If the till wasn't closed previously """ self._previous_day = previous_day self.till = Till.get_last(store, api.get_current_station(store)) if close_db: assert self.till self._close_db = close_db self._close_ecf = close_ecf self._blind_close = sysparam.get_bool('TILL_BLIND_CLOSING') BaseEditor.__init__(self, store, model) self._setup_widgets()
def __init__(self, store, model, account): self.parent_account = store.fetch(account) self.new = False BaseEditor.__init__(self, store, model) payment_button = Gtk.Button.new_with_label(_("Show Payment")) payment_button.connect("clicked", self._on_payment_button__clicked) box = self.main_dialog.action_area box.pack_start(payment_button, False, False, 0) box.set_child_secondary(payment_button, True) box.set_layout(Gtk.ButtonBoxStyle.END) # Setup the label, according to the type of transaction account_labels = Account.account_labels[account.account_type] self.is_incoming.set_label(account_labels[0]) self.is_outgoing.set_label(account_labels[1]) self.is_outgoing.set_active(self.model.source_account.id == account.id) payment_button.set_sensitive(self.model.payment is not None) payment_button.show()
def __init__(self, store, payments, show_till_info=True): """ Creates a new _PaymentConfirmSlave :param store: a store :param payments: a list of payments :param show_till_info: if we should show an info message explaining that this operation wont generate a till entry. """ self._show_till_info = show_till_info self._payments = payments self._proxy = None # We're about to pay a payment, fill in all paid_values # with the base value which is the initial value to be paid, # it'll be updated later on based on penalty, interest and discount # payment.paid_value will be updated *again* when we call # payment.pay with the calculated value for payment in self._payments: payment.paid_value = payment.value BaseEditor.__init__(self, store) self._setup_widgets()
def __init__(self, store, model, quantity, original_batches=None): """ :param store: the store for this editor :param model: the |storable| used to generate the batch quantities :param quantity: the quantity used to fill the first appended spin. Note that if :attr:`.validate_max_quantity` is set to ``True`` and this is different than 0, it will be used to validate the dialog as a maximum quantity (see the attr doc for more information). Passing 0 here means forcing no validation (so the user can type whatever he wants) :param original_batches: a dict mapping the batch to it's original quantity to be populated on entries. Very useful when calling this editor to edit the same model :param visual_mode: if we are working on visual mode """ if quantity < 0: raise ValueError("The quantity cannot be negative") # quantity = 0 means forcing no validation if quantity == 0: self._validate_max_quantity = False else: self._validate_max_quantity = self.validate_max_quantity self._quantity = quantity # A simple lock, used to avoid some problems (infinity recursion, # spin being updated wrong, etc) when appending a new dumb row self._append_dumb_row_lock = 0 # The last entry appended self._last_entry = None # This dicts store what is the spin given an entry, # or the entry given the spin self._spins = collections.OrderedDict() self._entries = collections.OrderedDict() BaseEditor.__init__(self, store, model=model, visual_mode=False) self._append_initial_rows(original_batches)
def __init__(self, store, model, attr_name='notes', title=u'', label_text=None, message_text=None, mandatory=False, visual_mode=False, ok_button_label=None, cancel_button_label=None, min_length=0): """ :param store: a store :param model: the model that's going to have it's notes edited :param attr_name: the name of the attribute that contains the text to be edited :param title: if not ``None``, will be used as the dialog's title :param label_text: the text that will be used as a description for the notes' text view. If ``None``, the default "Notes" will be used :param message_label: if not ``None``, it will be used to display a message at the top of the dialog :param mandatory: if we should set the notes' text view as mandatory, making the dialog impossible to confirm if the notes are empty :param visual_mode: if we are working on visual mode :param min_length: if we should consider a minimum note length """ self.title = title self.label_text = label_text self.message_text = message_text self.mandatory = mandatory self.attr_name = attr_name self.min_length = min_length # Keep this for a later rollback. self.original_notes = getattr(model, attr_name, u'') BaseEditor.__init__(self, store, model, visual_mode=visual_mode) self._setup_widgets() if ok_button_label is not None: self.main_dialog.ok_button.set_label(ok_button_label) if cancel_button_label is not None: self.main_dialog.cancel_button.set_label(cancel_button_label)