Esempio n. 1
0
    def __init__(self, entry, store, initial_value=None,
                 parent=None, run_editor=None):
        country = api.sysparam.get_string('COUNTRY_SUGGESTED')
        self._company_l10n = api.get_l10n_field('company_document', country)
        self._person_l10n = api.get_l10n_field('person_document', country)

        super(ClientEntryGadget, self).__init__(
            entry, store, initial_value=initial_value,
            parent=parent, run_editor=run_editor)
Esempio n. 2
0
    def __init__(self, entry, store, initial_value=None,
                 parent=None, run_editor=None,
                 edit_button=None, info_button=None):
        country = api.sysparam.get_string('COUNTRY_SUGGESTED')
        self._company_l10n = api.get_l10n_field('company_document', country)
        self._person_l10n = api.get_l10n_field('person_document', country)

        super(PersonEntryGadget, self).__init__(
            entry, store, initial_value=initial_value,
            parent=parent, run_editor=run_editor,
            edit_button=edit_button, info_button=info_button)
Esempio n. 3
0
    def _setup_widgets(self):
        self.document_l10n = api.get_l10n_field('person_document')
        self.person_document.set_mask(self.document_l10n.entry_mask)
        self.person_document.set_width_chars(17)
        if self._document:
            self.person_document.update(self._document)

        self.document_label.set_text(self.document_l10n.label)
        # Just adding some labels
        label = _('What kind of %s are you adding?')
        role_editor = self.wizard.role_editor
        if role_editor == BranchEditor or role_editor == UserEditor:
            self.company_check.set_sensitive(False)
            self.individual_check.set_sensitive(False)
            if role_editor == UserEditor:
                self.individual_check.set_active(True)
            else:
                label = _('Adding a %s')
                self.company_check.set_active(True)

        role_name = self.wizard.get_role_name().lower()
        self.person_role_label.set_text(label % role_name)
        self.person_role_label.set_size('large')
        self.person_role_label.set_bold(True)

        self.register_validate_function(self.wizard.refresh_next)
Esempio n. 4
0
    def fields(self):
        # Only users with admin or purchase permission can modify transporters
        user = api.get_current_user(self.store)
        can_modify_transporter = any((
            user.profile.check_app_permission(u'admin'),
            user.profile.check_app_permission(u'purchase'),
        ))
        freight_types = [(v, k) for k, v in Delivery.freights.items()]
        states = [(v, v) for v in api.get_l10n_field('state').state_list]

        return collections.OrderedDict(
            recipient=PersonQueryField(_("Recipient"), proxy=True, mandatory=True,
                                       person_type=self.person_type),
            transporter_id=PersonField(_("Transporter"), proxy=True,
                                       person_type=Transporter,
                                       can_add=can_modify_transporter,
                                       can_edit=can_modify_transporter),
            address=AddressField(_("Address"), proxy=True, mandatory=True),
            freight_type=ChoiceField(_("Freight type"), proxy=True,
                                     values=freight_types),
            price=PriceField(_("Delivery cost"), proxy=True),
            estimated_fix_date=DateField(_("Estimated delivery date"), proxy=True),
            volumes_kind=TextField(_("Volumes kind"), proxy=True),
            volumes_quantity=IntegerField(_("Volumes quantity"), proxy=True),
            volumes_net_weight=NumericField(_("Volumes net weight"), proxy=True,
                                            digits=3),
            volumes_gross_weight=NumericField(_("Volumes gross weight"),
                                              proxy=True, digits=3),
            vehicle_license_plate=TextField(_("Vehicle license plate"), proxy=True),
            vehicle_state=ChoiceField(_("Vehicle state"), proxy=True, use_entry=True,
                                      values=states),
            vehicle_registration=TextField(_("Vehicle registration"), proxy=True),
        )
Esempio n. 5
0
    def _setup_widgets(self):
        self.document_l10n = api.get_l10n_field('person_document')
        self.person_document.set_mask(self.document_l10n.entry_mask)
        self.person_document.set_width_chars(17)
        if self._document:
            self.person_document.update(self._document)

        self.document_label.set_text(self.document_l10n.label)
        # Just adding some labels
        label = _('What kind of %s are you adding?')
        role_editor = self.wizard.role_editor
        if role_editor == BranchEditor or role_editor == UserEditor:
            self.company_check.set_sensitive(False)
            self.individual_check.set_sensitive(False)
            if role_editor == UserEditor:
                self.individual_check.set_active(True)
            else:
                label = _('Adding a %s')
                self.company_check.set_active(True)

        role_name = self.wizard.get_role_name().lower()
        self.person_role_label.set_text(label % role_name)
        self.person_role_label.set_size('large')
        self.person_role_label.set_bold(True)

        self.register_validate_function(self.wizard.refresh_next)
Esempio n. 6
0
    def fields(self):
        # Only users with admin or purchase permission can modify transporters
        user = api.get_current_user(self.store)
        can_modify_transporter = any((
            user.profile.check_app_permission(u'admin'),
            user.profile.check_app_permission(u'purchase'),
        ))
        freight_types = [(v, k) for k, v in Delivery.freights.items()]
        states = [(v, v) for v in api.get_l10n_field('state').state_list]

        return collections.OrderedDict(
            recipient=PersonQueryField(_("Recipient"), proxy=True, mandatory=True,
                                       person_type=self.person_type),
            transporter_id=PersonField(_("Transporter"), proxy=True,
                                       person_type=Transporter,
                                       can_add=can_modify_transporter,
                                       can_edit=can_modify_transporter),
            address=AddressField(_("Address"), proxy=True, mandatory=True),
            freight_type=ChoiceField(_("Freight type"), proxy=True,
                                     values=freight_types),
            price=PriceField(_("Delivery cost"), proxy=True),
            estimated_fix_date=DateField(_("Estimated delivery date"), proxy=True),
            volumes_kind=TextField(_("Volumes kind"), proxy=True),
            volumes_quantity=IntegerField(_("Volumes quantity"), proxy=True),
            volumes_net_weight=NumericField(_("Volumes net weight"), proxy=True,
                                            digits=3),
            volumes_gross_weight=NumericField(_("Volumes gross weight"),
                                              proxy=True, digits=3),
            vehicle_license_plate=TextField(_("Vehicle license plate"), proxy=True),
            vehicle_state=ChoiceField(_("Vehicle state"), proxy=True, use_entry=True,
                                      values=states),
            vehicle_registration=TextField(_("Vehicle registration"), proxy=True),
        )
Esempio n. 7
0
    def __init__(self, entry, store, initial_value=None,
                 parent=None, run_editor=None,
                 edit_button=None, info_button=None, search_clause=None):
        country = api.sysparam.get_string('COUNTRY_SUGGESTED')
        self._person_l10n = api.get_l10n_field('person_document', country)

        super(IndividualEntryGadget, self).__init__(
            entry, store, initial_value=initial_value,
            parent=parent, run_editor=run_editor,
            edit_button=edit_button, info_button=info_button,
            search_clause=search_clause)
Esempio n. 8
0
    def on_individual_check__toggled(self, *args):
        """
        Change document labels based on check button

        Changes the document_label (proxy_widget) with the right document (CPF or CNPJ)
        that will be inserted on the person_document entry. Also changes the mask of
        person_document when is necessary
        """
        if self.individual_check.get_active():
            self.document_l10n = api.get_l10n_field('person_document')
            self.document_label.set_text(self.document_l10n.label + ':')
            # Change the entry size (in chars) to accomodate the cpf
            self.person_document.set_width_chars(17)
        else:
            self.document_l10n = api.get_l10n_field('company_document')
            self.document_label.set_text(self.document_l10n.label + ':')
            # Change the entry size (in chars) to accomodate the cnpj
            self.person_document.set_width_chars(21)

        self.person_document.set_mask(self.document_l10n.entry_mask)
Esempio n. 9
0
    def on_individual_check__toggled(self, *args):
        """
        Change document labels based on check button

        Changes the document_label (proxy_widget) with the right document (CPF or CNPJ)
        that will be inserted on the person_document entry. Also changes the mask of
        person_document when is necessary
        """
        if self.individual_check.get_active():
            self.document_l10n = api.get_l10n_field('person_document')
            self.document_label.set_text(self.document_l10n.label + ':')
            # Change the entry size (in chars) to accomodate the cpf
            self.person_document.set_width_chars(17)
        else:
            self.document_l10n = api.get_l10n_field('company_document')
            self.document_label.set_text(self.document_l10n.label + ':')
            # Change the entry size (in chars) to accomodate the cnpj
            self.person_document.set_width_chars(21)

        self.person_document.set_mask(self.document_l10n.entry_mask)
Esempio n. 10
0
def test_api():
    store = api.get_default_store()

    assert store is get_default_store()
    assert api.get_current_user(store) is get_current_user(store)
    assert api.db_settings is db_settings
    assert api.user_settings is get_settings()
    assert isinstance(api.device_manager, DeviceManager)
    with pytest.raises(NotImplementedError):
        assert isinstance(api.config, IStoqConfig)
    assert api.is_developer_mode() is is_developer_mode()
    assert api.get_l10n_field('CPF') is get_l10n_field('CPF')
Esempio n. 11
0
    def fields(self):
        # Only users with admin or purchase permission can modify transporters
        user = api.get_current_user(self.store)
        can_modify_transporter = any((
            user.profile.check_app_permission(u'admin'),
            user.profile.check_app_permission(u'purchase'),
        ))
        freight_types = [(v, k) for k, v in Delivery.freights.items()]
        states = [(v, v) for v in api.get_l10n_field('state').state_list]

        return collections.OrderedDict(
            recipient_str=TextField(_("Recipient"), proxy=True,
                                    editable=False),
            transporter_id=PersonField(_("Transporter"),
                                       proxy=True,
                                       person_type=Transporter,
                                       can_add=can_modify_transporter,
                                       can_edit=can_modify_transporter),
            address=AddressField(_("Address"), proxy=True, mandatory=True),
            is_sent_check=BoolField(_("Was sent to deliver?")),
            send_date=DateField(_("Send date"), mandatory=True, proxy=True),
            tracking_code=TextField(_("Tracking code"), proxy=True),
            freight_type=ChoiceField(_("Freight type"),
                                     proxy=True,
                                     values=freight_types),
            volumes_kind=TextField(_("Volumes kind"), proxy=True),
            volumes_quantity=IntegerField(_("Volumes quantity"), proxy=True),
            volumes_net_weight=NumericField(_("Volumes net weight"),
                                            proxy=True,
                                            digits=3),
            volumes_gross_weight=NumericField(_("Volumes gross weight"),
                                              proxy=True,
                                              digits=3),
            vehicle_license_plate=TextField(_("Vehicle license plate"),
                                            proxy=True),
            vehicle_state=ChoiceField(_("Vehicle state"),
                                      proxy=True,
                                      use_entry=True,
                                      values=states),
            vehicle_registration=TextField(_("Vehicle registration"),
                                           proxy=True),
            is_received_check=BoolField(_("Was received by recipient?")),
            receive_date=DateField(_("Receive date"),
                                   mandatory=True,
                                   proxy=True),
            empty=EmptyField(),
        )
Esempio n. 12
0
    def setup_proxies(self):
        CityLocationMixin.setup_proxies(self)

        if self.db_form:
            self._update_forms()
        self.proxy = self.add_proxy(self.model, AddressSlave.proxy_widgets)

        # Not using self._statel10n and self._city_l10n here because we need
        # to get the label name based on SUGGESTED_COUNTRY and not on the
        # country on model.
        for field, label in [('state', self.state_lbl),
                             ('city', self.city_lbl)]:
            l10n_field = api.get_l10n_field(self.store, field)
            label.set_text(l10n_field.label + ':')

        # Enable if we already have a number or if we are adding a new address.
        self.streetnumber_check.set_active(
            bool(self.model.streetnumber) or not self.edit_mode)
        self._update_streetnumber()
Esempio n. 13
0
    def setup_proxies(self):
        CityLocationMixin.setup_proxies(self)

        if self.db_form:
            self._update_forms()
        self.proxy = self.add_proxy(self.model,
                                    AddressSlave.proxy_widgets)

        # Not using self._statel10n and self._city_l10n here because we need
        # to get the label name based on SUGGESTED_COUNTRY and not on the
        # country on model.
        for field, label in [
                ('state', self.state_lbl),
                ('city', self.city_lbl)]:
            l10n_field = api.get_l10n_field(self.store, field)
            label.set_text(l10n_field.label + ':')

        # Enable if we already have a number or if we are adding a new address.
        self.streetnumber_check.set_active(bool(self.model.streetnumber)
                                           or not self.edit_mode)
        self._update_streetnumber()
Esempio n. 14
0
    def fields(self):
        # Only users with admin or purchase permission can modify transporters
        user = api.get_current_user(self.store)
        can_modify_transporter = any((
            user.profile.check_app_permission(u'admin'),
            user.profile.check_app_permission(u'purchase'),
        ))
        freight_types = [(v, k) for k, v in Delivery.freights.items()]
        states = [(v, v) for v in api.get_l10n_field('state').state_list]

        return collections.OrderedDict(
            recipient_str=TextField(_("Recipient"), proxy=True, editable=False),
            transporter_id=PersonField(_("Transporter"), proxy=True,
                                       person_type=Transporter,
                                       can_add=can_modify_transporter,
                                       can_edit=can_modify_transporter),
            address=AddressField(_("Address"), proxy=True, mandatory=True),
            is_sent_check=BoolField(_("Was sent to deliver?")),
            send_date=DateField(_("Send date"), mandatory=True, proxy=True),
            tracking_code=TextField(_("Tracking code"), proxy=True),

            freight_type=ChoiceField(_("Freight type"), proxy=True,
                                     values=freight_types),
            volumes_kind=TextField(_("Volumes kind"), proxy=True),
            volumes_quantity=IntegerField(_("Volumes quantity"), proxy=True),
            volumes_net_weight=NumericField(_("Volumes net weight"), proxy=True,
                                            digits=3),
            volumes_gross_weight=NumericField(_("Volumes gross weight"),
                                              proxy=True, digits=3),
            vehicle_license_plate=TextField(_("Vehicle license plate"), proxy=True),
            vehicle_state=ChoiceField(_("Vehicle state"), proxy=True, use_entry=True,
                                      values=states),
            vehicle_registration=TextField(_("Vehicle registration"), proxy=True),
            is_received_check=BoolField(_("Was received by recipient?")),
            receive_date=DateField(_("Receive date"), mandatory=True, proxy=True),
            empty=EmptyField(),
        )
Esempio n. 15
0
 def __init__(self, store, birth_date=None, **kwargs):
     self._birth_date = birth_date
     self.company_doc_l10n = api.get_l10n_field('company_document')
     self.person_doc_l10n = api.get_l10n_field('person_document')
     SearchEditor.__init__(self, store, **kwargs)
Esempio n. 16
0
 def _setup_widgets(self):
     self.name.grab_focus()
     self.document_l10n = api.get_l10n_field(self.store, 'company_document')
     self.cnpj_lbl.set_label(self.document_l10n.label)
     self.cnpj.set_mask(self.document_l10n.entry_mask)
Esempio n. 17
0
 def __init__(self):
     self.method = self.SAME_NAME
     self.same_phone = True
     self.same_street = True
     self._street_prefixes = api.get_l10n_field('common_street_prefixes')
Esempio n. 18
0
 def setup_proxies(self):
     self.document_l10n = api.get_l10n_field('company_document')
     self.cnpj_lbl.set_label(self.document_l10n.label + ':')
     self.cnpj.set_mask(self.document_l10n.entry_mask)
     self.proxy = self.add_proxy(self.model,
                                 CompanyDocumentsSlave.proxy_widgets)
Esempio n. 19
0
 def setup_proxies(self):
     self.document_l10n = api.get_l10n_field('person_document')
     self.cpf_lbl.set_label(self.document_l10n.label + ':')
     self.cpf.set_mask(self.document_l10n.entry_mask)
     self.proxy = self.add_proxy(self.model,
                                 _IndividualDocuments.proxy_widgets)
Esempio n. 20
0
 def setup_proxies(self):
     self.document_l10n = api.get_l10n_field(self.store, 'person_document')
     self.cpf_lbl.set_label(self.document_l10n.label + ':')
     self.cpf.set_mask(self.document_l10n.entry_mask)
     self.proxy = self.add_proxy(self.model,
                                 _IndividualDocuments.proxy_widgets)
Esempio n. 21
0
 def __init__(self, store, **kwargs):
     self.company_doc_l10n = api.get_l10n_field('company_document')
     SearchEditor.__init__(self, store, **kwargs)
Esempio n. 22
0
 def _setup_widgets(self):
     self.name.grab_focus()
     self.document_l10n = api.get_l10n_field(self.store, 'company_document')
     self.cnpj_lbl.set_label(self.document_l10n.label)
     self.cnpj.set_mask(self.document_l10n.entry_mask)
Esempio n. 23
0
 def setup_proxies(self):
     self.document_l10n = api.get_l10n_field(self.store, 'company_document')
     self.cnpj_lbl.set_label(self.document_l10n.label + ':')
     self.cnpj.set_mask(self.document_l10n.entry_mask)
     self.proxy = self.add_proxy(self.model,
                                 CompanyDocumentsSlave.proxy_widgets)
Esempio n. 24
0
 def __init__(self, store, **kwargs):
     self.company_doc_l10n = api.get_l10n_field("company_document")
     SearchEditor.__init__(self, store, **kwargs)
Esempio n. 25
0
 def __init__(self):
     self.method = self.SAME_NAME
     self.same_phone = True
     self.same_street = True
     self._street_prefixes = api.get_l10n_field('common_street_prefixes')
Esempio n. 26
0
 def _setup_widgets(self):
     self.document_l10n = api.get_l10n_field('person_document')
     self.cpf_lbl.set_label(self.document_l10n.label + ':')
     self.cpf.set_mask(self.document_l10n.entry_mask)
Esempio n. 27
0
 def __init__(self, store, birth_date=None, **kwargs):
     self._birth_date = birth_date
     self.company_doc_l10n = api.get_l10n_field('company_document')
     self.person_doc_l10n = api.get_l10n_field('person_document')
     SearchEditor.__init__(self, store, **kwargs)
Esempio n. 28
0
 def __init__(self, store, **kwargs):
     self.company_doc_l10n = api.get_l10n_field(store, 'company_document')
     self.person_doc_l10n = api.get_l10n_field(store, 'person_document')
     SearchEditor.__init__(self, store, **kwargs)
Esempio n. 29
0
 def _cache_l10n_fields(self):
     self._city_l10n = api.get_l10n_field('city',
                                          self.model.country)
     self._state_l10n = api.get_l10n_field('state',
                                           self.model.country)
Esempio n. 30
0
 def _setup_widgets(self):
     self.document_l10n = api.get_l10n_field('person_document')
     self.cpf_lbl.set_label(self.document_l10n.label + ':')
     self.cpf.set_mask(self.document_l10n.entry_mask)