def __init__(self, store, model=None, role_type=None, person=None, visual_mode=False, parent=None, document=None, description=None): """ Creates a new BasePersonRoleEditor object :param store: a store :param model: :param none_type: None, ROLE_INDIVIDUAL or ROLE_COMPANY :param person: :param visual_mode: """ if not (model or role_type is not None): raise ValueError('A role_type attribute is required') self._description = description self._parent = parent self.individual_slave = None self.company_slave = None self._person_slave = None self.main_slave = None self.role_type = role_type self.person = person self.document = document BaseEditor.__init__(self, store, model, visual_mode=visual_mode) # FIXME: Implement and use IDescribable on the model self.set_description(self.model.person.name)
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, wizard, parent, store, order, payment_method, outstanding_value=currency(0)): BaseEditor.__init__(self, store, order.group) self._method = payment_method dsm = get_utility(IDomainSlaveMapper) slave_class = dsm.get_slave_class(self._method) assert slave_class self.store.savepoint('before_payment_creation') #FIXME: This is a workaround to make the slave_class to ignore the # payments created previously. class _InnerSlaveClass(slave_class): def get_created_adapted_payments(self): return [] self.slave = _InnerSlaveClass(wizard, parent, self.store, order, self._method, outstanding_value) #FIXME: We need to control how many payments could be created, since # we are ignoring the payments created previously. payments = order.group.get_valid_payments().find( Payment.method_id == self._method.id) max_installments = self._method.max_installments - payments.count() self.slave.installments_number.set_range(1, max_installments) self.attach_slave('place_holder', self.slave)
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, 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, 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): 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.active_check_box.set_property('sensitive', bool(model))
def __init__(self, store, model, visual_mode=False): self._user = None self._original_price = model.price self._original_quantity = model.quantity BaseEditor.__init__(self, store, model, visual_mode=visual_mode) self._calc = CalculatorPopup(self.price, CalculatorPopup.MODE_SUB)
def __init__(self, store, model, attr_name='notes', title=u'', label_text=None, message_text=None, mandatory=False, visual_mode=False): """ :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 """ assert model, (u"You must supply a valid model to this editor " "(%r)" % self) self.model_type = type(model) self.title = title self.label_text = label_text self.message_text = message_text self.mandatory = mandatory self.attr_name = attr_name # Keep this for a later rollback. self.original_notes = getattr(model, attr_name) BaseEditor.__init__(self, store, model, visual_mode=visual_mode) self._setup_widgets()
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, model): manager = get_plugin_manager() self.nfe_is_active = manager.is_active('nfe') self.proxy = None self.icms_slave = None self.ipi_slave = None BaseEditor.__init__(self, store, model)
def __init__(self, store, model): self.all_items = model.stock_decrease.get_items() BaseEditor.__init__(self, store, model) for widget in [self.order_lbl, self.sold_lbl, self.cost_lbl, self.expected_lbl, self.returned_lbl, self.total_lbl, self.quantity_sold, self.cost, self.quantity_returned, self.expected_receival_date, self.order]: widget.hide()
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, visual_mode=False): 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()
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, 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, 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=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, station=None): if station is not None and not isinstance(station, BranchStation): raise TypeError("station should be a BranchStation") self._device_manager = DeviceManager() self.printers_dict = get_supported_printers() 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
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=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, 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=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) if close_db: assert self.till self._close_db = close_db self._close_ecf = close_ecf BaseEditor.__init__(self, store, model) self._setup_widgets()
def __init__(self, store, model): if not model: 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 if model.field_name in ["DEMO_MODE", "LOCAL_BRANCH", "SYNCHRONIZED_MODE"]: self.sensitive = False self._parameter_details = sysparam.get_detail_by_name(model.field_name) BaseEditor.__init__(self, store, model) self._setup_widgets()
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, attr_name, title='', label_text=None, visual_mode=False): assert model, (u"You must supply a valid model to this editor " "(%r)" % self) self.model_type = type(model) self.title = title self.label_text = label_text self.attr_name = attr_name # Keep this for a later rollback. self.original_notes = getattr(model, attr_name) BaseEditor.__init__(self, store, model, visual_mode=visual_mode) 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): self._device_manager = DeviceManager() BaseEditor.__init__(self, store, model) self.progress_dialog = ProgressDialog() self.progress_dialog.connect("cancel", self._on_progress_dialog__cancel) self.progress_dialog.set_transient_for(self.main_dialog) if self.edit_mode: self.printer.set_sensitive(False) self.main_dialog.ok_button.grab_focus() else: self.edit_constants.hide() self.device_serial.hide() self.device_serial_label.hide() self.is_active.hide()
def __init__(self, store, model=None, sale_items=None): self.sale_items = sale_items self._deliver_items = [] if not model: for sale_item in sale_items: sale_item.deliver = True else: model.create_savepoint() # Store this information for later rollback. for sale_item in sale_items: self._deliver_items.append(sale_item.deliver) 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) if close_db: assert self.till self._close_db = close_db self._close_ecf = close_ecf BaseEditor.__init__(self, store, model) self._setup_widgets()
def __init__(self, store, model, attr_name, title='', label_text=None, visual_mode=False): assert model, (u"You must supply a valid model to this editor " "(%r)" % self) self.model_type = type(model) self.title = title self.label_text = label_text self.attr_name = attr_name # Keep this for a later rollback. self.original_notes = getattr(model, attr_name) BaseEditor.__init__(self, store, model, visual_mode=visual_mode) self._setup_widgets()
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, 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, account): self.parent_account = store.fetch(account) self.new = False BaseEditor.__init__(self, store, model) payment_button = gtk.Button(_("Show Payment")) payment_button.connect("clicked", self._on_payment_button__clicked) box = self.main_dialog.action_area box.pack_start(payment_button, False, False) box.set_child_secondary(payment_button, True) box.set_layout(gtk.BUTTONBOX_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, 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 sequence of :class:`batch item <.BatchItem>` with original items 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 = {} self._entries = {} BaseEditor.__init__(self, store, model=model, visual_mode=False) self._append_initial_rows(original_batches) self._update_view()
def __init__(self, store, model, attr_name='notes', title=u'', label_text=None, message_text=None, mandatory=False, visual_mode=False): """ :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 """ assert model, (u"You must supply a valid model to this editor " "(%r)" % self) self.model_type = type(model) self.title = title self.label_text = label_text self.message_text = message_text self.mandatory = mandatory self.attr_name = attr_name # Keep this for a later rollback. self.original_notes = getattr(model, attr_name) BaseEditor.__init__(self, store, model, visual_mode=visual_mode) self._setup_widgets()
def __init__(self, store, model, expanded_edition=False): """An editor for a loan item. If the expaned_edition is True, the editor will enable the sale_quantity and return_quantity fields to be edited and will lock the quantity and price fields. :param store: a store. :param model: a loan item. :param expanded_edition: whether or not we should enable sale_quantity and return_quantity fields to be edited. """ self._expanded_edition = expanded_edition self._branch = model.loan.branch default_store = api.get_default_store() orig_model = default_store.find(LoanItem, id=model.id).one() if orig_model: self._original_sale_qty = orig_model.sale_quantity self._original_return_qty = orig_model.return_quantity else: self._original_sale_qty = 0 self._original_return_qty = 0 BaseEditor.__init__(self, store, model)
def __init__(self, store, model=None, role_type=None, person=None, visual_mode=False, parent=None): """ Creates a new BasePersonRoleEditor object :param store: a store :param model: :param none_type: None, ROLE_INDIVIDUAL or ROLE_COMPANY :param person: :param visual_mode: """ if not (model or role_type is not None): raise ValueError('A role_type attribute is required') self._parent = parent self.individual_slave = None self.company_slave = None self._person_slave = None self.main_slave = None self.role_type = role_type self.person = person BaseEditor.__init__(self, store, model, visual_mode=visual_mode) # FIXME: Implement and use IDescribable on the model self.set_description(self.model.person.name)
def __init__(self, store, model=None, visual_mode=False): BaseEditor.__init__(self, store, model, visual_mode) self.set_description(self.model.name)
def __init__(self, store, payment): BaseEditor.__init__(self, store, payment) self._setup_widgets()
def __init__(self, store, model, branch): product = model.product self._is_batch = product and product.storable and product.storable.is_batch self._branch = branch BaseEditor.__init__(self, store, model) self._setup_widgets()
def __init__(self, store, client, model=None): self.client = store.fetch(client) assert self.client BaseEditor.__init__(self, store, model)
def __init__(self, store, model, visual_mode=False): self._original_quantity_decreased = model.quantity_decreased self.manager = None BaseEditor.__init__(self, store, model, visual_mode=visual_mode) self.price.set_icon_activatable(Gtk.EntryIconPosition.PRIMARY, activatable=True)
def __init__(self, store, model=None, visual_mode=False): from stoqlib.gui.slaves.sellableslave import CategoryPriceSlave is_new = not model self._sellable = None self._demo_mode = sysparam.get_bool('DEMO_MODE') self._requires_weighing_text = ( "<b>%s</b>" % api.escape(_("This unit type requires weighing"))) if self.ui_form_name: self.db_form = DatabaseForm(self.ui_form_name) else: self.db_form = None BaseEditor.__init__(self, store, model, visual_mode) self.enable_window_controls() if self._demo_mode: self._add_demo_warning() # Code suggestion. We need to do this before disabling sensitivity, # otherwise, the sellable will not be updated. if not self.code.read(): self._update_default_sellable_code() edit_code_product = sysparam.get_bool('EDIT_CODE_PRODUCT') self.code.set_sensitive(not edit_code_product and not self.visual_mode) self.description.grab_focus() self.table.set_focus_chain([ self.code, self.barcode, self.default_sale_cfop, self.description, self.cost_hbox, self.price_hbox, self.category_combo, self.tax_hbox, self.unit_combo, ]) self._print_labels_btn = self.add_button('print_labels', gtk.STOCK_PRINT) self._print_labels_btn.connect('clicked', self.on_print_labels_clicked, 'print_labels') label = self._print_labels_btn.get_children()[0] label = label.get_children()[0].get_children()[1] label.set_label(_(u'Print labels')) self.setup_widgets() if not is_new and not self.visual_mode: # Although a sellable can be both removed/closed, we show only one, # to avoid having *lots* of buttons. If it's closed, provide a way # to reopen it, else, show a delete button if it can be removed # or a close button if it can be closed if self._sellable.is_closed(): self._add_reopen_button() elif self._sellable.can_remove(): self._add_delete_button() elif self._sellable.can_close(): self._add_close_button() self.set_main_tab_label(self.model_name) price_slave = CategoryPriceSlave(self.store, self.model.sellable, self.visual_mode) self.add_extra_tab(_(u'Category Prices'), price_slave) self._setup_ui_forms() self._update_print_labels()
def __init__(self, store, model=None): model = create_main_branch(name=u"", store=store).person self.param = sysparam(store) BaseEditor.__init__(self, store, model, visual_mode=False) self._setup_widgets()
def __init__(self, store): self.categories = store.find(ClientCategory) self._last_cat = None BaseEditor.__init__(self, store, model=object()) self._setup_widgets()
def __init__(self, store, model=None, product=None): self._product = product BaseEditor.__init__(self, store=store, model=model)
def __init__(self, store, model, printer): self._printer = printer BaseEditor.__init__(self, store, model) self._setup_widgets()
def __init__(self, store, model): BaseEditor.__init__(self, store, model) self._setup_widgets()
def __init__(self, store, model): BaseEditor.__init__(self, store, model) self.main_dialog.set_ok_label(_('Undo Returned Sale')) self.main_dialog.set_cancel_label(_("Don't Undo")) # The user should fill the reason. self.main_dialog.ok_button.set_sensitive(False)
def __init__(self, store): BaseEditor.__init__(self, store) self.set_confirm_widget(self.reason) self.set_confirm_widget(self.cash_slave.value)
def __init__(self, store): BaseEditor.__init__(self, store, None)
def __init__(self, store, user, visual_mode=False): self.user = user self.old_password = self.user.pw_hash BaseEditor.__init__(self, store, visual_mode=visual_mode) self._setup_widgets()
def __init__(self, store): BaseEditor.__init__(self, store, model=None) self._setup_widgets() self._update_widgets()
def __init__(self, application_screen=None): # FIXME: BaseEditor expects a store, so we are passing one here, even # though it won't be used. We should be inheriting from BaseDialog. BaseEditor.__init__(self, api.get_default_store()) self.main_dialog.set_title(self.model_name) self.application_screen = application_screen
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, invoice_number): BaseEditor.__init__(self, store, model) self._invoice_number = invoice_number
def __init__(self, store): BaseEditor.__init__(self, store, model=object()) # FIXME: Maybe we should use the is_editable from the database in the # future? self._parameters = [d for d in sysparam.get_details() if d.is_editable] self._setup_widgets()