How to use the kiwi.python.Settable function in kiwi

To help you get started, we’ve selected a few kiwi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stoq / stoq / stoqlib / gui / dialogs / supplierdetails.py View on Github external
self.payments = []
        product_dict = {}
        for purchase_view in purchases:
            purchase = purchase_view.purchase
            self.payments.extend(purchase.group.payments)
            for purchase_item in purchase.get_items():
                qty = purchase_item.quantity
                cost = purchase_item.cost
                total_value = cost * qty
                unit = purchase_item.sellable.unit_description
                qty_str = '%s %s' % (qty, unit)
                product_codes = [item.code for item in product_dict.values()]
                sellable = purchase_item.sellable
                if not sellable.code in product_codes:
                    desc = sellable.description
                    obj = Settable(code=sellable.code, description=desc,
                                   _total_qty=qty, total_value=total_value,
                                   qty_str=qty_str, unit=unit, cost=cost)
                    product_dict[sellable] = obj
                else:
                    product_dict[sellable]._total_qty += qty
                    table = product_dict[sellable]
                    table.qty_str = '%s %s' % (table._total_qty, table.unit)
                    table.total_value = table._total_qty * table.cost
        self.products = list(product_dict.values())
github stoq / stoq / stoqlib / reporting / loanreceipt.py View on Github external
def get_namespace(self):
        store = self.loan.store
        order_identifier = str(self.loan.identifier)
        print_promissory_note = api.sysparam.get_bool('PRINT_PROMISSORY_NOTE_ON_LOAN')
        branch = api.get_current_branch(store)
        drawer_person = self.loan.branch.person
        drawee_person = self.loan.client.person
        emission_address = branch.person.get_main_address()
        emission_location = emission_address.city_location

        promissory_data = Settable(
            order_identifier=order_identifier,
            payment_number=None,
            drawee=drawee_person.name,
            drawer=branch.get_description(),
            drawee_document=self._get_person_document(drawee_person),
            drawer_document=self._get_person_document(drawer_person),
            drawee_address=self._get_person_address(drawee_person),
            drawer_address=self._get_person_address(drawer_person),
            due_date=self.loan.expire_date,
            value=self.loan.get_total_amount(),
            emission_city=emission_location.city,
            emission_date=datetime.date.today(),
        )

        return dict(
            subtitle=_("Loan number: %s") % order_identifier,
github stoq / stoq / stoqlib / gui / dialogs / productretention.py View on Github external
def _get_model(self, conn, product):
        return Settable(reason='',
                        available=currency(0),
                        product_description='',
                        cfop=None,
                        supplier=self.product.get_main_supplier_name(),
                        quantity=Decimal())
github stoq / stoq / stoqlib / gui / dialogs / csvexporterdialog.py View on Github external
def __init__(self, conn, klass, results=None):
        """A dialog to export data in CSV format.

        @param conn: a database connection
        @param klass:
        @param results:
        """
        if not results or isinstance(results, SelectResults):
            if not issubclass(klass, (ORMObject, Viewable)):
                raise TypeError("The klass argument should be a ORMObject or "
                                "Viewable class or subclass, got '%s' instead" %
                                klass.__class__.__name__)

        model = Settable(klass=klass, results=results)
        self.conn = conn
        BaseEditor.__init__(self, conn, model=model)
        self._setup_widgets()
github stoq / stoq / plugins / ecf / ecfui.py View on Github external
"""Returns a Settable with two attributes: document, a string with
        the client cpf or cnpj and document_type, being one of
        (FiscalSaleHistory.TYPE_CPF, FiscalSaleHistory.TYPE_CNPJ )
        """
        client_role = sale.get_client_role()
        if isinstance(client_role, Individual):
            document_type = FiscalSaleHistory.TYPE_CPF
            document = client_role.cpf
        elif isinstance(client_role, Company):
            document_type = FiscalSaleHistory.TYPE_CNPJ
            document = client_role.cnpj
        else:
            return

        if document:
            return Settable(document_type=document_type,
                            document=document)
github stoq / stoq / stoqlib / gui / dialogs / tilldailymovement.py View on Github external
salesperson=details[0],
                                        client=details[1],
                                        value=value)
                self.sales_list.append(sale, payment_data)

        # Lonely in payments
        self._show_lonely_payments(self.lonely_in_payments,
                                   self.inpayments_list)

        # Purchase data
        self.purchases_list.clear()
        for purchase, payments in self.purchases.items():
            self.purchases_list.append(None, purchase)
            for payment in payments:
                # TODO Add details refering to Bank, Agency later
                payment_data = Settable(identifier=payment.identifier,
                                        notes=payment.method.get_description())
                self.purchases_list.append(purchase, payment_data)

        # Lonely out payments
        self._show_lonely_payments(self.lonely_out_payments,
                                   self.outpayments_list)

        # Return sales
        self.return_sales_list.clear()
        for sale, payments in self.return_sales.items():
            self.return_sales_list.append(None, sale)
            for payment in payments:
                payment_data = Settable(identifier=payment.identifier,
                                        salesperson=payment.method.get_description(),
                                        client=payment.description,
                                        value=get_formatted_price(payment.value))
github stoq / kiwi / kiwi / ui / signal.py View on Github external
def _get_state(self, view):
        # Since self is shared between different views we cannot
        # store any state in there, instead store state inside
        # the view. We currently use one dictionary per object
        view_state = view.__dict__.setdefault('_SignalProxy_state_', {})

        state = view_state.get(self.object_name)
        if state is None:
            # The state we need:
            # - connected_signals, the signals we use
            # - obj: used to connect/disconnect/block/unblock
            # - view: for displaying nice error messages
            view_state[self.object_name] = state = Settable(
                obj=None,
                view=view,
                connected_signals=[])
        return state
github stoq / stoq / stoqlib / gui / editors / invoiceeditor.py View on Github external
def _create_field_list(self):
        items = ObjectList([Column('category', sorted=True),
                            Column('description', width=200),
                            Column('len', data_type=int, visible=False)])
        items.enable_dnd()
        items.set_size_request(200, -1)
        descriptions = {}
        invoice_fields = get_invoice_fields()
        for invoice_field in sorted(invoice_fields,
                                    key=operator.attrgetter('name')):
            items.append(
                Settable(description=invoice_field.get_description(),
                         name=invoice_field.name,
                         len=invoice_field.length,
                         category=invoice_field.category))
            descriptions[invoice_field.name] = invoice_field.description
        self._field_descriptions = descriptions
        self.left_vbox.pack_end(items, True, True, 0)
        items.show()