Example #1
0
    def __init__(self, attributes=None, label='', store=None, **kwargs):
        from fvl.cimarron.skin import VBox, HBox, Button, Label, Entry

        super(Editor, self).__init__(**kwargs)
        if attributes is None:
            attributes = []

        # main containers
        # self.vbox = VBox(parent=self)
        self.vbox = VBox()
        self._outerWidget = self.vbox._outerWidget

        hbox = HBox(parent=self.vbox)
        self.labels = VBox(parent=hbox)
        self.entries = VBox(parent=hbox)
        self.store = store

        self.label = label
        for attr in attributes:
            Label(parent=self.labels, text=attr)
            # FIX: make if more flexible
            Entry(parent=self.entries, attribute=attr)

        # save/discard buttons
        hbox = HBox(parent=self.vbox, expand=False)
        save = Button(parent=hbox, label='Save', onAction=self.save)
        self.mainWidget = save
        discard = Button(parent=hbox, label='Discard', onAction=self.discard)
    def __init__(self, **kw):
        super(StockAdjustmentWindow, self).__init__(**kw)
        self.window.title = "Stock Adjustment"
        self.trans = Transaction()

        v = VBox(parent=self.window)

        columns = (Column(name="Code", attribute="product.code",
                          readOnly=True),
                   Column(name="Name", attribute="product.name",
                          readOnly=True))

        self.searcher = Search(parent=v,
                               columns=columns,
                               cls=Stock,
                               searcher=self.trans,
                               onAction=self.listValues)

        columns = (Column(name="Code", attribute="product.code",
                          readOnly=True),
                   Column(name="Name", attribute="product.name",
                          readOnly=True),
                   Column(name="Level", attribute="level"))
        self.stockEditor = Grid(parent=v, columns=columns)
        actionContainer = HBox(parent=v, expand=False)
        save = Button(parent=actionContainer, label="Save", onAction=self.save)
        discard = Button(parent=actionContainer,
                         label="Discard",
                         onAction=self.discard)
Example #3
0
    def buildUI(self):
        self.window.title = 'Generacion de Recibo'

        v1 = VBox(parent=self.window, expand=True, fill=True)
        h0 = HBox(parent=v1, expand=False, fill=True)
        v0left = VBox(parent=h0, expand=False, fill=True)
        v0right = VBox(parent=h0, expand=False, fill=True)
        v2 = VBox(parent=v1)
        actionContainer = HBox(parent=v1, expand=False, fill=True)

        Label(parent=v0left, text='Cuenta Contable:')
        columns= (Column(name='Cod', attribute='code'),
                  Column(name='Nombre', attribute='name',
                         operator=Qualifier.like),)
        self.category = SearchEntry(parent=v0right, columns=columns,
                                    searcher=self.trans, cls=MovementAccount)

        Label(parent=v0left, text='Cliente:')
        columns = (Column(name='Nombre', attribute='person.name',
                          operator=Qualifier.like),
                   Column(name='Apellido', attribute='person.surname',
                          operator=Qualifier.like),)
        self.otherParty = SearchEntry(parent=v0right, cls=Client,
                                      searcher=self.trans,
                                      columns=columns)


        Label(parent=v0left, text='Numero:')
        self.docNumber = Entry(parent=v0right)

        Label(parent=v0left, text='Fecha:')
        self.actualDate = Entry(parent=v0right,emptyValue=now())
        self.actualDate.commitValue(self.actualDate.value)

        Label(parent=v0left, text='Monto:')
        self.amount = Entry(parent=v0right)
        
        Label(parent=v2, text='Concepto:', expand=False, fill=False)
        self.concept = MultiLine(parent=v2)
        
        save = Button(parent=actionContainer, label='Guardar',
                      onAction=self.save)

        discard = Button(parent=actionContainer, label='Descartar',
                         onAction=self.discard)
Example #4
0
    def __init__(self, columns=None, cls=None, searcher=None, **kwargs):
        """
        @param columns: A list of Columns. Only the C{read} attribute
            needs to be set.

        @param searcher: an object that knows the values() for the right type of
            objects. Typically a Store.

        @param cls: The class that we'll want to look for with C{searcher}.
        """
        from fvl.cimarron.skin import HBox

        super(Search, self).__init__(**kwargs)
        self.entries = []
        self.h = HBox(parent=self, expand=False)
        self.columns = columns
        self.value = None
        self.searcher = searcher
        self.cls = cls
Example #5
0
    def __init__(self, columns=None, cls=None, searcher=None, **kwargs):
        """
        @param columns: A list of Columns. Only the C{read} attribute
            needs to be set.

        @param searcher: an object that knows the values() for the right type of
            objects. Typically a Store.

        @param cls: The class that we'll want to look for with C{searcher}.
        """
        from fvl.cimarron.skin import HBox

        super(Search, self).__init__(**kwargs)
        self.entries = []
        self.h = HBox(parent=self, expand=False)
        self.columns = columns
        self.value = None
        self.searcher = searcher
        self.cls = cls
Example #6
0
    def buildUI(self):
        self.window.title = 'Caja chica - Carga'
        v = VBox(parent=self.window)

        f0 = Frame(parent=v, label='Cuenta')
        h0 = HBox(parent=f0)
        right0 = VBox(parent=h0)
        columns = (Column(name='Nombre',
                          attribute='name',
                          operator=Qualifier.like), )
        self.account = SearchEntry(parent=right0,
                                   columns=columns,
                                   searcher=self.trans,
                                   cls=CustomerAccount)

        f1 = Frame(parent=v, label='Operacion')
        h1 = HBox(parent=f1)
        left1 = VBox(parent=h1)
        right1 = VBox(parent=h1)

        # Label(parent=left1, text='Fecha')
        # fecha = Entry(parent=right1)

        Label(parent=left1, text='Categoria')
        columns = (
            Column(name='Cod', attribute='code'),
            Column(name='Nombre', attribute='name', operator=Qualifier.like),
        )
        self.category = SearchEntry(parent=right1,
                                    columns=columns,
                                    searcher=self.trans,
                                    cls=MovementAccount)

        f2 = Frame(parent=v, label='Comprobante')
        h2 = HBox(parent=f2)
        left2 = VBox(parent=h2)
        right2 = VBox(parent=h2)

        Label(parent=left2, text='Tipo')
        columns = (Column(name='Nombre',
                          attribute='name',
                          operator=Qualifier.like), )
        self.docType = SearchEntry(parent=right2,
                                   columns=columns,
                                   searcher=DocumentType,
                                   onAction=self.setThirdLabel)

        Label(parent=left2, text='Numero')
        self.docNumber = Entry(parent=right2)

        Label(parent=left2, text='Fecha')
        self.docDate = Entry(parent=right2, emptyValue=now())
        self.docDate.commitValue(self.docDate.value)

        self.thirdLabel = Label(parent=left2)
        columns = (Column(name='Apellido',
                          attribute='person.surname',
                          operator=Qualifier.like), )
        self.otherParty = SearchEntry(parent=right2,
                                      columns=columns,
                                      searcher=self.trans)
        self.otherParty.disable()

        # f3 = Frame(parent=v, label='Montos')
        h3 = HBox(parent=v)

        # Label(parent=h3, text='Ingreso')
        # self.moneyIn = Entry(parent=h3)

        # Label(parent=h3, text='Egreso')
        # self.moneyOut = Entry(parent=h3)

        Label(parent=h3, text='Monto')
        self.amount = Entry(parent=h3)

        Label(parent=h3, text='Descripcion')
        self.description = Entry(parent=h3)

        h4 = HBox(parent=v)
        Button(parent=h4, label='Guardar', onAction=self.save)
        Button(parent=h4, label='Descartar')
Example #7
0
class Search(ColumnAwareXmlMixin, Controller):
    """
    Abstract class for searching. Consist of a widget
    with one Entry for each Column.

    The method C{search()} must be
    implemented in the subclass, which sould take one parameter
    for each column and return the list of objects found to that
    search criteria.

    This class already handles the case when the amount of objets
    found is greater that one. In that case, it presents a window
    where the user can select from a list.

    When one object is found or selected, it calls the action.
    """
    def attributesToConnect(cls):
        """
        See L{XmlMixin.attributesToConnect
        <fvl.cimarron.skins.common.XmlMixin.attributesToConnect>}
        """
        attrs = super (Search, cls).attributesToConnect()
        return attrs+['searcher']
    attributesToConnect = classmethod(attributesToConnect)

    def __init__(self, columns=None, cls=None, searcher=None, **kwargs):
        """
        @param columns: A list of Columns. Only the C{read} attribute
            needs to be set.

        @param searcher: an object that knows the values() for the right type of
            objects. Typically a Store.

        @param cls: The class that we'll want to look for with C{searcher}.
        """
        from fvl.cimarron.skin import HBox

        super(Search, self).__init__(**kwargs)
        self.entries = []
        self.h = HBox(parent=self, expand=False)
        self.columns = columns
        self.value = None
        self.searcher = searcher
        self.cls = cls

    def _set_columns(self, columns):
        logger.debug (`columns`)
        if columns is not None:
            from fvl.cimarron.skin import Label, Button
            for column in columns:
                # build label and entry
                Label(text=column.name+":", parent=self.h)
                entryConstr = column.entry
                entry = entryConstr(parent=self.h, onAction=self.search)
                entry.delegates.append (self)
                # if columns are added at creation it willset the first entry
                # as the _concreteWidget, else it will be the button
                if '_concreteWidget' not in self.__dict__:
                    self._concreteWidget = entry
                self.entries.append(entry)

            # search button
            b = Button(parent=self.h, label='Search!', onAction=self.search)
            if '_concreteWidget' not in self.__dict__:
                self._concreteWidget = b

            # the widget that fires the action.
            self.mainWidget = b
            logger.debug('here')
        self.__columns = columns
    def _get_columns(self):
        return self.__columns
    columns = property(_get_columns, _set_columns)

    def doSearch(self, *ignore):
        """
        Performs the abstract search. The result ends up in aSearch.value as a
        list and returns the length of the list.
        """
        self.window.disable()
        try:
            qual = None
            for i in xrange(len(self.columns)):
                e = self.entries[i]
                if e.value != '' and e.value is not None:
                    value = e.value
                    c = self.columns[i]
                    logger.debug ('%s op %r' % (c.attribute, c.operator))
                    # this wil be gone when operator `startswith´
                    # gets into trunk.
                    if c.operator == Qualifier.like:
                        value += '*'
                    if qual is None:
                        qual = c.operator(getattr(Qualifier(),
                                                  c.attribute), value)
                    else:
                        qual = qual & c.operator(getattr(Qualifier(),
                                                         c.attribute), value)

            logger.debug ('searching %r, %r', self.cls, qual)
            if qual is None:
                qual = nullQualifier
            self.value = self.searcher.search(self.cls, qual)
        finally:
            self.window.enable()
        return len(self.value)
    def search (self, *ignore):
        """
        Performs the search and fires the action thereupon.
        """
        ans = self.doSearch()
        self.onAction()
        return ans


    def enable(self):
        self.h.enable()

    def disable(self):
        self.h.disable()
Example #8
0
class Search(ColumnAwareXmlMixin, Controller):
    """
    Abstract class for searching. Consist of a widget
    with one Entry for each Column.

    The method C{search()} must be
    implemented in the subclass, which sould take one parameter
    for each column and return the list of objects found to that
    search criteria.

    This class already handles the case when the amount of objets
    found is greater that one. In that case, it presents a window
    where the user can select from a list.

    When one object is found or selected, it calls the action.
    """
    def attributesToConnect(cls):
        """
        See L{XmlMixin.attributesToConnect
        <fvl.cimarron.skins.common.XmlMixin.attributesToConnect>}
        """
        attrs = super (Search, cls).attributesToConnect()
        return attrs+['searcher']
    attributesToConnect = classmethod(attributesToConnect)
    
    def __init__(self, columns=None, cls=None, searcher=None, **kwargs):
        """
        @param columns: A list of Columns. Only the C{read} attribute
            needs to be set.

        @param searcher: an object that knows the values() for the right type of
            objects. Typically a Store.

        @param cls: The class that we'll want to look for with C{searcher}.
        """
        from fvl.cimarron.skin import HBox

        super(Search, self).__init__(**kwargs)
        self.entries = []
        self.h = HBox(parent=self, expand=False)
        self.columns = columns
        self.value = None
        self.searcher = searcher
        self.cls = cls

    def _set_columns(self, columns):
        logger.debug (`columns`)
        if columns is not None:
            from fvl.cimarron.skin import Label, Button
            for column in columns:
                # build label and entry
                Label(text=column.name+":", parent=self.h)
                entryConstr = column.entry
                entry = entryConstr(parent=self.h, onAction=self.search)
                entry.delegates.append (self)
                # if columns are added at creation it willset the first entry
                # as the _concreteWidget, else it will be the button
                if '_concreteWidget' not in self.__dict__:
                    self._concreteWidget = entry
                self.entries.append(entry)

            # search button
            b = Button(parent=self.h, label='Search!', onAction=self.search)
            if '_concreteWidget' not in self.__dict__:
                self._concreteWidget = b
            
            # the widget that fires the action.
            self.mainWidget = b
            logger.debug('here')
        self.__columns = columns
    def _get_columns(self):
        return self.__columns
    columns = property(_get_columns, _set_columns)

    def doSearch(self, *ignore):
        """
        Performs the abstract search. The result ends up in aSearch.value as a
        list and returns the length of the list.
        """
        self.window.disable()
        try:
            qual = None
            for i in xrange(len(self.columns)):
                e = self.entries[i]
                if e.value != '' and e.value is not None:
                    value = e.value
                    c = self.columns[i]
                    logger.debug ('%s op %r' % (c.attribute, c.operator))
                    if c.operator == Qualifier.like:
                        value += '*'
                    if qual is None:
                        qual = c.operator(getattr(Qualifier(),
                                                  c.attribute), value)
                    else:
                        qual = qual & c.operator(getattr(Qualifier(),
                                                         c.attribute), value)

            logger.debug ('searching %r, %r', self.searcher, qual)
            if qual is None:
                qual = nullQualifier
            self.value = self.searcher.search(self.cls, qual)
        finally:
            self.window.enable()
        return len(self.value)
    def search (self, *ignore):
        """
        Performs the search and fires the action thereupon.
        """
        ans = self.doSearch()
        self.onAction()
        return ans


    def enable(self):
        self.h.enable()

    def disable(self):
        self.h.disable()