Example #1
0
    def _setup_widgets(self):
        devices = CardPaymentDevice.get_devices(self.method.store)
        self.card_device.prefill(api.for_combo(devices))

        providers = CreditProvider.get_card_providers(
            self.method.store)
        self.credit_provider.prefill(api.for_combo(providers))

        self._radio_group = None

        for ptype, name in CreditCardData.types.items():
            self._add_card_type(name, ptype)
Example #2
0
    def _setup_widgets(self):
        self.tax_constant.prefill(
            api.for_combo(self.store.find(SellableTaxConstant)))

        categories = set(self.store.find(SellableCategory,
                                         SellableCategory.id != self.model.id))
        # Remove all children recursively to avoid creating
        # a circular hierarchy
        categories -= self.model.get_children_recursively()

        self.category.prefill(
            api.for_combo(categories, attr='full_description'))
    def fields(self):
        device_values = api.for_combo(
            CardPaymentDevice.get_devices(self.store))
        provider_values = api.for_combo(
            CreditProvider.get_card_providers(self.store))

        return collections.OrderedDict(
            device=ChoiceField(_('Device'), proxy=True, mandatory=True,
                               values=device_values),
            provider=ChoiceField(_('Provider'), proxy=True, mandatory=True,
                                 values=provider_values),
            auth=TextField(_('Authorization'), proxy=True, mandatory=True)
        )
    def _setup_widgets(self):
        items = [(b.person.name, b)
                 for b in self.store.find(Branch)
                 if b is not self.branch]
        self.destination_branch.prefill(locale_sorted(
            items, key=operator.itemgetter(0)))
        self.source_branch.set_text(self.branch.person.name)

        employees = self.store.find(Employee)
        self.source_responsible.prefill(api.for_combo(employees))
        self.destination_responsible.prefill(api.for_combo(employees))

        self.transfer_order.source_branch = self.branch
        self.transfer_order.destination_branch = items[0][1]
    def _update_accounts(self):
        if len(self._payments) != 1:
            return

        payment = self._payments[0]
        create_transaction = payment.method.operation.create_transaction()
        for combo in [self.destination_account, self.source_account]:
            combo.set_sensitive(create_transaction)

        if not create_transaction:
            return

        destination_combo = self.get_account_destination_combo()
        for combo in [self.destination_account, self.source_account]:
            combo.prefill(api.for_combo(
                self.store.find(Account),
                attr='long_description'))

            if combo is destination_combo:
                combo.select(payment.method.destination_account)
            else:
                combo.select(
                    sysparam.get_object(self.store, 'IMBALANCE_ACCOUNT'))

        category_account = payment.category and payment.category.account
        if category_account:
            if payment.payment_type == payment.TYPE_IN:
                self.source_account.select(category_account)
            else:
                self.destination_account.select(category_account)
Example #6
0
    def _fill_clients_category_combo(self):
        categories = self.store.find(ClientCategory).order_by(ClientCategory.name)
        self.client_category.prefill(api.for_combo(categories, empty=''))

        if categories.is_empty():
            self.client_category.hide()
            self.client_category_lbl.hide()
Example #7
0
    def populate(self, gridgroup):
        from stoqlib.domain.product import GridGroup
        store = get_store_for_field(self)
        self.prefill(api.for_combo(store.find(GridGroup)), gridgroup)

        self.add_button.set_tooltip_text(_("Add a new grid group"))
        self.edit_button.set_tooltip_text(_("Edit the grid group"))
Example #8
0
    def _setup_widgets(self):
        # Hide total and subtotal
        self.table1.hide()
        self.hbox4.hide()
        # Hide invoice number details
        self.invoice_number_label.hide()
        self.invoice_number.hide()

        # Hide cost center combobox
        self.cost_center_lbl.hide()
        self.cost_center.hide()

        # Salesperson combo
        salespersons = self.store.find(SalesPerson)
        self.salesperson.prefill(api.for_person_combo(salespersons))
        if not sysparam(self.store).ACCEPT_CHANGE_SALESPERSON:
            self.salesperson.set_sensitive(False)
        else:
            self.salesperson.grab_focus()

        # CFOP combo
        if sysparam(self.store).ASK_SALES_CFOP:
            cfops = self.store.find(CfopData)
            self.cfop.prefill(api.for_combo(cfops))
        else:
            self.cfop_lbl.hide()
            self.cfop.hide()
            self.create_cfop.hide()

        self.transporter_lbl.hide()
        self.transporter.hide()
        self.create_transporter.hide()

        self._fill_clients_combo()
        self._fill_clients_category_combo()
Example #9
0
    def _setup_widgets(self):
        self._calc = CalculatorPopup(self.price,
                                     CalculatorPopup.MODE_SUB)

        self.sale.set_text(unicode(self.model.sale.identifier))
        self.description.set_text(self.model.sellable.get_description())
        self.original_price.update(self.model.base_price)
        for widget in [self.quantity, self.price]:
            widget.set_adjustment(gtk.Adjustment(lower=1, upper=MAX_INT,
                                                 step_incr=1, page_incr=10))
        self.reserved.set_adjustment(gtk.Adjustment(lower=0,
                                                    upper=self.quantity_model.quantity,
                                                    step_incr=1, page_incr=10))
        first_page = self.tabs.get_nth_page(0)
        self.tabs.set_tab_label_text(first_page, _(u'Basic'))

        if not self.nfe_is_active:
            self.cfop_label.hide()
            self.cfop.hide()

        if not self._can_reserve():
            self.reserved.hide()
            self.reserved_lbl.hide()

        # We populate this even if it's hidden because we need a default value
        # selected to add to the sale item
        cfop_items = CfopData.get_for_sale(self.store)
        self.cfop.prefill(api.for_combo(cfop_items))

        self._setup_taxes()
        self._update_total()
Example #10
0
    def create_filters(self):
        self.set_text_field_columns(['salesperson_name', 'identifier_str'])

        items = api.for_combo(self.store.find(SalesPerson), empty=_("Anyone"))
        self._salesperson_filter = ComboSearchFilter(_("Sold by:"), items)
        self.add_filter(self._salesperson_filter, SearchFilterPosition.TOP,
                        callback=self._get_salesperson_query)
Example #11
0
    def _setup_widgets(self):
        # Salesperson combo
        salespersons = SalesPerson.get_active_salespersons(self.store)
        self.salesperson.prefill(salespersons)

        change_salesperson = sysparam.get_int('ACCEPT_CHANGE_SALESPERSON')
        if change_salesperson == ChangeSalespersonPolicy.ALLOW:
            self.salesperson.grab_focus()
        elif change_salesperson == ChangeSalespersonPolicy.DISALLOW:
            self.salesperson.set_sensitive(False)
        elif change_salesperson == ChangeSalespersonPolicy.FORCE_CHOOSE:
            self.model.salesperson = None
            self.salesperson.grab_focus()
        else:
            raise AssertionError

        # CFOP combo
        if sysparam.get_bool('ASK_SALES_CFOP'):
            cfops = CfopData.get_for_sale(self.store)
            self.cfop.prefill(api.for_combo(cfops))
        else:
            self.cfop_lbl.hide()
            self.cfop.hide()
            self.create_cfop.hide()

        self._fill_clients_category_combo()
        self._setup_clients_widget()

        self._client_credit_set_visible(bool(self.client.read()))
Example #12
0
    def _setup_widgets(self):
        self.total.set_bold(True)
        idents = sorted(p.identifier for p in self.purchases)
        identifier = ', '.join(str(i) for i in idents)
        self.identifier.set_text(identifier)

        # TODO: Testar isso quando compras > 1
        if len(self.purchases) == 1 and self.purchases[0].is_paid():
            # This widgets would make the value of the installments change.
            for widget in (self.ipi, self.discount_value, self.icms_total,
                           self.icms_st_total, self.secure_value, self.expense_value):
                widget.set_sensitive(False)

        # Only allow to edit the cfop if there is only one receiving for this invoice
        self.cfop.set_sensitive(bool(not self.visual_mode and self._receiving_order))

        self._setup_transporter_entry()
        self._setup_freight_combo()

        cfops = CfopData.get_for_receival(self.store)
        self.cfop.prefill(api.for_combo(cfops))
        self.table.set_focus_chain([self.invoice_hbox,
                                    self.invoice_key,
                                    self.cfop,
                                    self.transporter,
                                    self.freight_combo,
                                    self.notes_box,
                                    self.freight,
                                    self.ipi,
                                    self.icms_total,
                                    self.icms_st_total,
                                    self.discount_value,
                                    self.secure_value,
                                    self.expense_value])
Example #13
0
    def _setup_widgets(self):
        self.total.set_bold(True)

        purchase = self.model.purchase
        if not purchase:
            for widget in (self.purchase_number_label,
                           self.purchase_supplier_label,
                           self.identifier, self.supplier_label):
                widget.hide()
        elif purchase and purchase.is_paid():
            for widget in (self.ipi, self.discount_value, self.icms_total,
                           self.secure_value, self.expense_value):
                widget.set_sensitive(False)

        self._setup_transporter_entry()
        self._setup_freight_combo()

        cfops = self.store.find(CfopData)
        self.cfop.prefill(api.for_combo(cfops))
        self.table.set_focus_chain([self.invoice_hbox,
                                    self.cfop,
                                    self.transporter,
                                    self.freight_combo,
                                    self.notes_box,
                                    self.freight,
                                    self.ipi,
                                    self.icms_total,
                                    self.discount_value,
                                    self.secure_value,
                                    self.expense_value])
Example #14
0
    def _setup_widgets(self):
        self.total.set_bold(True)
        idents = sorted(p.identifier for p in self.purchases)
        identifier = ', '.join(str(i) for i in idents)
        self.identifier.set_text(identifier)

        # TODO: Testar isso quando compras > 1
        if len(self.purchases) == 1 and self.purchases[0].is_paid():
            # This widgets would make the value of the installments change.
            for widget in (self.ipi, self.discount_value, self.icms_total,
                           self.secure_value, self.expense_value):
                widget.set_sensitive(False)

        self._setup_transporter_entry()
        self._setup_freight_combo()

        cfops = self.store.find(CfopData)
        self.cfop.prefill(api.for_combo(cfops))
        self.table.set_focus_chain([self.invoice_hbox,
                                    self.cfop,
                                    self.transporter,
                                    self.freight_combo,
                                    self.notes_box,
                                    self.freight,
                                    self.ipi,
                                    self.icms_total,
                                    self.discount_value,
                                    self.secure_value,
                                    self.expense_value])
Example #15
0
 def create_filters(self):
     self.search.set_query(self._query)
     self.set_text_field_columns(["description", "code", "barcode", "category_description", "manufacturer"])
     branches = Branch.get_active_branches(self.store)
     self.branch_filter = ComboSearchFilter(_("Show by:"), api.for_combo(branches, empty=_("All branches")))
     self.branch_filter.select(api.get_current_branch(self.store))
     self.add_filter(self.branch_filter, position=SearchFilterPosition.TOP)
Example #16
0
 def setup_proxies(self):
     categories = self.store.find(ClientCategory)
     self.category_combo.prefill(api.for_combo(categories, empty=""))
     table = self.model_type
     items = [(value, constant) for constant, value in table.statuses.items()]
     self.statuses_combo.prefill(items)
     self.proxy = self.add_proxy(self.model, ClientStatusSlave.proxy_widgets)
Example #17
0
 def testForComboAll(self):
     client = self.create_client()
     client.credit_limit = 99
     clients = self.store.find(Client, credit_limit=99,
                               )
     items = api.for_combo(clients)
     self.assertEquals(items, [('Client', client)])
Example #18
0
    def _setup_widgets(self):
        self._calc = CalculatorPopup(self.price, CalculatorPopup.MODE_SUB)

        self.sale.set_text(unicode(self.model.sale.identifier))
        self.description.set_text(self.model.sellable.get_description())
        self.original_price.update(self.model.base_price)

        self.price.set_adjustment(gtk.Adjustment(lower=0, upper=MAX_INT,
                                                 step_incr=1, page_incr=10))
        unit = self.model.sellable.unit
        digits = QUANTITY_PRECISION if unit and unit.allow_fraction else 0
        for widget in [self.quantity, self.reserved]:
            widget.set_digits(digits)
            widget.set_adjustment(gtk.Adjustment(lower=0, upper=MAX_INT,
                                                 step_incr=1, page_incr=10))

        manager = get_plugin_manager()
        self.nfe_is_active = manager.is_active('nfe')

        if not self.nfe_is_active:
            self.cfop_label.hide()
            self.cfop.hide()

        if not self._can_reserve():
            self.reserved.hide()
            self.reserved_lbl.hide()

        # We populate this even if it's hidden because we need a default value
        # selected to add to the sale item
        cfop_items = CfopData.get_for_sale(self.store)
        self.cfop.prefill(api.for_combo(cfop_items))

        self._update_total()
        self.reserved.get_adjustment().set_upper(self.quantity_model.quantity)
Example #19
0
 def test_for_combo_empty(self):
     client = self.create_client()
     client.credit_limit = 99
     results = self.store.find(Client, credit_limit=99)
     items = api.for_combo(results,
                           empty=u'All')
     self.assertEqual(items, [('All', None), ('Client', client)])
Example #20
0
 def testForComboAttr(self):
     individual = self.create_individual()
     individual.father_name = u'Daddy'
     individual.mother_name = u'Mommy'
     results = self.store.find(Individual, father_name=u'Daddy')
     items = api.for_combo(results, attr=u'mother_name')
     self.assertEquals(items, [('Mommy', individual)])
Example #21
0
 def create_filters(self):
     # Category
     categories = self.store.find(SellableCategory)
     items = api.for_combo(categories, attr='full_description')
     items.insert(0, (_('Any'), None))
     category_filter = ComboSearchFilter(_('Category'), items)
     self.add_filter(category_filter, columns=[Sellable.category])
 def setup_entry(self, entry):
     entry.set_mode(ENTRY_MODE_DATA)
     entry.set_exact_completion()
     completion = entry.get_completion()
     completion.set_minimum_key_length = 1
     items = self.model.get_available_batches(
         api.get_current_branch(self.store))
     entry.prefill(api.for_combo(items))
Example #23
0
 def _setup_widgets(self):
     """Populate device widgets and set some properties"""
     # Let the user edit provider_id when creating a new one
     self.provider_id.set_property('sensitive', not self.edit_mode)
     self.provider_id.set_property('editable', not self.edit_mode)
     devices = CardPaymentDevice.get_devices(self.store)
     self.default_device.prefill(api.for_combo(devices,
                                               empty=_(u"No device")))
Example #24
0
 def create_filters(self):
     self.search.set_query(self._query)
     self.set_text_field_columns(['description'])
     branches = Branch.get_active_branches(self.store)
     self.branch_filter = ComboSearchFilter(
         _('Show by:'), api.for_combo(branches, empty=_("All branches")))
     self.branch_filter.select(api.get_current_branch(self.store))
     self.add_filter(self.branch_filter, position=SearchFilterPosition.TOP)
Example #25
0
 def fields(self):
     user = api.for_combo(self.store.find(Employee), empty='')
     return collections.OrderedDict(
         responsible=ChoiceField(_("Responsible"), mandatory=True,
                                 use_entry=True, proxy=True,
                                 values=user),
         notes=TextField(_('Notes'), proxy=True),
     )
Example #26
0
 def _setup_widgets(self):
     self._widgets = {}
     group = GridGroup.get_active_groups(self.store)
     self.attribute_group_combo.prefill(api.for_combo(group,
                                                      attr='description',
                                                      empty=_("Select a group")))
     self.attribute_group_combo.connect('changed',
                                        self._on_attribute_group_combo_selection__changed)
Example #27
0
    def setup_sellable_combos(self):
        self._fill_categories()
        self.edit_category.set_sensitive(False)

        cfops = self.store.find(CfopData)
        self.default_sale_cfop.prefill(api.for_combo(cfops, empty=''))

        self.setup_unit_combo()
Example #28
0
    def populate(self, cfop):
        from stoqlib.domain.fiscal import CfopData
        store = get_store_for_field(self)
        cfops = store.find(CfopData)
        self.prefill(api.for_combo(cfops), cfop)

        self.add_button.set_tooltip_text(_("Add a new C.F.O.P"))
        self.edit_button.set_tooltip_text(_("View C.F.O.P details"))
Example #29
0
 def _fill_person_combo(self):
     if self.model.person:
         self.person_combo.prefill([(self.model.person.name, self.model.person)])
         self.person_combo.set_sensitive(False)
     else:
         # Get only persons of person_type by joining with the table
         query = self.person_type.person_id == Person.id
         persons = self.store.find(Person, query)
         self.person_combo.prefill(api.for_combo(persons, attr="name"))
Example #30
0
    def setup_proxies(self):
        if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
            current = api.get_current_branch(self.store)
            branches = [(current.get_description(), current)]
        else:
            branches = api.for_combo(Branch.get_active_branches(self.store))

        self.branch.prefill(branches)
        self.add_proxy(self.model, self.proxy_widgets)
Example #31
0
 def _fill_categories_combo(self):
     categories = self.store.find(WorkOrderCategory)
     self.category.color_attribute = 'color'
     self.category.prefill(
         api.for_combo(categories, empty=_(u"No category")))
Example #32
0
 def _setup_role_entry_completition(self):
     roles = self.store.find(EmployeeRole)
     self.role.prefill(api.for_combo(roles, attr="name",
                                     empty=_("No Role")))
 def _populate_accounts(self):
     accounts = self.store.find(Account)
     self.account.prefill(api.for_combo(accounts, attr='long_description'))
Example #34
0
 def _fill_categories(self):
     categories = self.store.find(SellableCategory)
     self.category_combo.prefill(
         api.for_combo(categories, attr='full_description'))
Example #35
0
 def _fill_categories(self):
     categories = self.store.find(SellableCategory)
     self.category_combo.set_sensitive(
         any(categories) and not self.visual_mode)
     self.category_combo.prefill(
         api.for_combo(categories, attr='full_description'))
Example #36
0
 def _setup_entry_completion(self):
     roles = self.store.find(EmployeeRole)
     self.role.prefill(api.for_combo(roles))
Example #37
0
 def _fill_clients_category_combo(self):
     categories = self.store.find(ClientCategory)
     self.client_category.prefill(api.for_combo(categories, empty=''))
Example #38
0
 def populate(self, profile):
     from stoqlib.domain.profile import UserProfile
     store = get_store_for_field(self)
     self.prefill(api.for_combo(store.find(UserProfile)), profile)
Example #39
0
 def _fill_cfop_combo(self):
     cfops = self.store.find(CfopData)
     self.cfop.prefill(api.for_combo(cfops))
Example #40
0
 def _fill_cfop_combo(self):
     marker('Filling CFOPs')
     cfops = CfopData.get_for_sale(self.store)
     self.cfop.prefill(api.for_combo(cfops))
     marker('Filled CFOPs')
Example #41
0
 def _setup_transporter_entry(self):
     transporters = Transporter.get_active_transporters(self.store)
     self.transporter.prefill(api.for_combo(transporters))
Example #42
0
 def _fill_salesperson_combo(self):
     salespersons = SalesPerson.get_active_salespersons(self.store)
     self.salesperson_combo.prefill(api.for_combo(salespersons))
Example #43
0
 def _setup_widgets(self):
     group = GridGroup.get_active_groups(self.store)
     self.attribute_group.prefill(
         api.for_combo(group, attr='description',
                       empty=_("Select a group")))
Example #44
0
 def _setup_profile_entry_completion(self):
     if self.model.profile is None:
         self.model.profile = UserProfile.get_default(store=self.store)
     profiles = self.store.find(UserProfile).order_by(UserProfile.name)
     self.profile.prefill(api.for_combo(profiles, attr="name"))
Example #45
0
 def _fill_cfop_combo(self):
     cfops = CfopData.get_for_sale(self.store)
     self.cfop.prefill(api.for_combo(cfops))
Example #46
0
 def _setup_widgets(self):
     accounts = self.store.find(Account)
     self.account.prefill(api.for_combo(accounts, attr='long_description'))
     self.account.select(self.model.destination_account)
Example #47
0
 def setup_unit_combo(self):
     units = self.store.find(SellableUnit)
     self.unit_combo.prefill(api.for_combo(units, empty=_('No units')))
Example #48
0
 def _fill_options(self, widget, attr):
     options = attr.options.find(is_active=True)
     widget.prefill(
         api.for_combo(options, empty=_("Select an option"), sorted=False))
Example #49
0
 def _fill_branch_combo(self):
     branches = Branch.get_active_branches(self.store)
     self.branch_combo.prefill(api.for_combo(branches))
Example #50
0
 def _fill_manufacturers(self):
     options = self.store.find(ProductManufacturer)
     self.manufacturer.prefill(api.for_combo(options, empty=''))
Example #51
0
 def _fill_cfop_combo(self):
     marker('Filling CFOPs')
     cfops = self.store.find(CfopData)
     self.cfop.prefill(api.for_combo(cfops))
     marker('Filled CFOPs')