Example #1
0
    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)
Example #2
0
 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)
Example #3
0
    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))
Example #4
0
    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)
Example #5
0
    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)
Example #6
0
    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)
Example #7
0
    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)
Example #8
0
    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))
Example #9
0
    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)
Example #10
0
    def __init__(self,
                 store,
                 model=None,
                 role_type=None,
                 person=None,
                 visual_mode=False,
                 parent=None,
                 document=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
        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)
Example #11
0
    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()
Example #12
0
    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))
Example #13
0
 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()
Example #14
0
 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()
Example #15
0
    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)
Example #16
0
    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)
Example #17
0
 def __init__(self, store, model=None):
     BaseEditor.__init__(self, store, model)
     self.enable_normal_window()
     self.text.set_sensitive(False)
     self.preview_button = self.add_button(stock=gtk.STOCK_PRINT_PREVIEW)
     self.preview_button.connect('clicked',
                                 self._on_preview_button__clicked)
Example #18
0
 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())
Example #19
0
    def confirm(self):
        if len(self.notes.read()) < self.min_length:
            warning(
                _("The note must have at least %s characters.") %
                self.min_length)
            return

        BaseEditor.confirm(self)
Example #20
0
    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):
        # 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()
Example #22
0
    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)
Example #23
0
    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)
Example #24
0
 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)
Example #25
0
    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)
Example #26
0
    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()
Example #27
0
    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)
Example #28
0
    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)
Example #29
0
    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)
Example #30
0
    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()
Example #31
0
    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))
Example #32
0
    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)
Example #33
0
    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()
Example #34
0
    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, 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)
Example #36
0
 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()
Example #37
0
    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))
Example #38
0
 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
Example #39
0
    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()
Example #40
0
 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
Example #41
0
    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, 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()
Example #43
0
    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()
Example #44
0
    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()
Example #45
0
    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()
Example #46
0
    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)
Example #47
0
 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()
Example #48
0
    def __init__(self, store, model):
        self.icms_slave = None
        self.ipi_slave = None
        BaseEditor.__init__(self, store, model)

        sale = self.model.sale
        if sale.status == Sale.STATUS_CONFIRMED:
            self._set_not_editable()

        # not used with sale quote items
        self.sale_quantity_lbl.hide()
        self.return_quantity_lbl.hide()
        self.sale_quantity.hide()
        self.return_quantity.hide()
Example #49
0
    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'))
Example #50
0
    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'))
Example #51
0
 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()
Example #52
0
    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)
Example #53
0
    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()
Example #54
0
    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()
Example #55
0
    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()
Example #56
0
    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()