Example #1
0
 def fields(self):
     return collections.OrderedDict(
         name=TextField(_('Name'), proxy=True, mandatory=True),
         code=TextField(_('Code'), proxy=True, mandatory=True),
         branch_id=PersonField(_('Branch'), proxy=True, person_type=Branch,
                               can_add=False, can_edit=False, mandatory=True),
     )
Example #2
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()]

        return collections.OrderedDict(
            client_str=TextField(_("Client"), 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),
            is_received_check=BoolField(_("Was received by client?")),
            receive_date=DateField(_("Receive date"),
                                   mandatory=True,
                                   proxy=True),
            empty=EmptyField(),
        )
Example #3
0
class InventoryItemAdjustmentEditor(BaseEditor):
    title = _(u"Product Adjustment")
    hide_footer = False
    size = (500, 300)
    model_type = InventoryItem

    fields = dict(
        description=TextField(_("Product"), proxy=True, editable=False),
        recorded_quantity=TextField(_("Previous quantity"),
                                    proxy=True,
                                    editable=False),
        counted_quantity=TextField(_("Counted quantity"),
                                   proxy=True,
                                   editable=False),
        difference=TextField(_("Difference"), proxy=True, editable=False),
        actual_quantity=NumericField(_("Actual quantity"),
                                     proxy=True,
                                     mandatory=True),
        cfop_data=CfopField(_("C.F.O.P"), proxy=True),
        reason=MultiLineField(_("Reason"), proxy=True, mandatory=True),
    )

    def __init__(self, store, model, invoice_number):
        BaseEditor.__init__(self, store, model)
        self._invoice_number = invoice_number

    #
    #  BaseEditor
    #

    def setup_proxies(self):
        self.actual_quantity.update(self.model.counted_quantity)

    def on_confirm(self):
        self.model.adjust(self._invoice_number)
Example #4
0
class CfopEditor(BaseEditor):
    model_name = _('C.F.O.P.')
    model_type = CfopData

    fields = dict(
        code=TextField(_('C.F.O.P.'), input_mask=_("0.000"), mandatory=True,
                       proxy=True),
        description=TextField(_('Description'), mandatory=True, proxy=True),
    )

    def __init__(self, store, model=None, visual_mode=False):
        BaseEditor.__init__(self, store, model, visual_mode)
        self.set_description(self.model.code)

    #
    # BaseEditor Hooks
    #

    def create_model(self, store):
        return CfopData(code=u"", description=u"",
                        store=store)

    #
    # Kiwi handlers
    #

    def on_code__validate(self, widget, value):
        if not validate_cfop(value):
            return ValidationError(_(u"'%s' is not a valid C.F.O.P. code.")
                                   % value)
Example #5
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'),
        ))

        return collections.OrderedDict(
            client_str=TextField(_("Client"),
                                 proxy=True,
                                 editable=False,
                                 colspan=2),
            transporter_id=PersonField(_("Transporter"),
                                       proxy=True,
                                       person_type=Transporter,
                                       colspan=2,
                                       can_add=can_modify_transporter,
                                       can_edit=can_modify_transporter),
            address=AddressField(_("Address"),
                                 proxy=True,
                                 mandatory=True,
                                 colspan=2),
            was_delivered_check=BoolField(_("Was sent to deliver?")),
            deliver_date=DateField(_("Delivery date"),
                                   mandatory=True,
                                   proxy=True),
            tracking_code=TextField(_("Tracking code"), proxy=True),
            was_received_check=BoolField(_("Was received by client?")),
            receive_date=DateField(_("Receive date"),
                                   mandatory=True,
                                   proxy=True),
            empty=EmptyField(),
        )
Example #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),
        )
Example #7
0
 def fields(self):
     return collections.OrderedDict(
         description=TextField(_('Description'), mandatory=True,
                               proxy=True),
         contact_info=TextField(_('Contact Info'),
                                mandatory=True,
                                proxy=True),
     )
Example #8
0
 def fields(self):
     return collections.OrderedDict(
         code=TextField(_('Code'), proxy=True),
         description=TextField(_('Description'), proxy=True),
         barcode=TextField(_('Barcode'), proxy=True),
         price=PriceField(_('Price'), proxy=True),
         quantity=NumericField(_('Quantity'), proxy=True),
         skip=NumericField(_('Labels to skip'), proxy=True),
     )
Example #9
0
 def fields(self):
     return collections.OrderedDict(
         code=TextField(_('C.F.O.P.'),
                        input_mask="0.000",
                        mandatory=True,
                        proxy=True),
         description=TextField(_('Description'), mandatory=True,
                               proxy=True),
     )
Example #10
0
 def fields(self):
     return collections.OrderedDict(
         identifier=TextField(_("Sale #"), proxy=True, editable=False),
         open_date=DateTextField(_("Open date"), proxy=True, editable=False),
         status_str=TextField(_("Status"), proxy=True, editable=False),
         salesperson_id=PersonField(_("Salesperson"), proxy=True,
                                    can_add=False, can_edit=False,
                                    person_type=SalesPerson),
         client=PersonQueryField(_("Client"), proxy=True,
                                 person_type=Client),
     )
Example #11
0
 def fields(self):
     return collections.OrderedDict(
         description=TextField(_("Product"), proxy=True, editable=False),
         recorded_quantity=TextField(_("Previous quantity"), proxy=True,
                                     editable=False),
         counted_quantity=TextField(_("Counted quantity"), proxy=True,
                                    editable=False),
         difference=TextField(_("Difference"), proxy=True, editable=False),
         actual_quantity=NumericField(_("Actual quantity"), proxy=True,
                                      mandatory=True),
         cfop_data=CfopField(_("C.F.O.P"), proxy=True),
         reason=MultiLineField(_("Reason"), proxy=True, mandatory=True),
     )
Example #12
0
class ClientCategoryEditor(BaseEditor):
    model_name = _('Client Category')
    model_type = ClientCategory
    confirm_widgets = ['name', 'max_discount']

    fields = dict(
        name=TextField(_('Name'), proxy=True),
        max_discount=PercentageField(_('Max Discount'), proxy=True),
    )

    def create_model(self, store):
        return ClientCategory(name=u'', store=store)

    def setup_proxies(self):
        self.name.grab_focus()

    #
    # Kiwi Callbacks
    #

    def on_name__validate(self, widget, new_name):
        if not new_name:
            return ValidationError(
                _("The client category should have a name."))
        if self.model.check_unique_value_exists(ClientCategory.name, new_name):
            return ValidationError(
                _("The client category '%s' already exists.") % new_name)
Example #13
0
class WorkOrderCategoryEditor(BaseEditor):
    """An editor for |workordercategory| objects"""

    model_name = _('Work order category')
    model_type = WorkOrderCategory
    confirm_widgets = ['name']

    fields = dict(
        name=TextField(_('Name'), proxy=True),
        color=ColorField(_('Color'), proxy=True),
    )

    #
    # BaseEditor
    #

    def create_model(self, store):
        used_colors = set([woc.color for woc in store.find(WorkOrderCategory)])
        color = get_random_color(ignore=used_colors)
        return WorkOrderCategory(store=store, name=u'', color=color)

    def setup_proxies(self):
        self.name.grab_focus()

    #
    # Kiwi Callbacks
    #

    def on_name__validate(self, widget, name):
        if not name:
            return ValidationError(
                _("The work order category should have a name."))
        if self.model.check_unique_value_exists(WorkOrderCategory.name, name):
            return ValidationError(
                _("The work order category '%s' already exists.") % name)
Example #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()]

        return collections.OrderedDict(
            client=PersonQueryField(_("Client"),
                                    proxy=True,
                                    mandatory=True,
                                    person_type=Client),
            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),
        )
Example #15
0
class EmployeeRoleEditor(BaseEditor):
    model_type = EmployeeRole
    model_name = _('Employee Role')
    confirm_widgets = ['name']

    fields = dict(name=TextField(_('Name'), proxy=True, mandatory=True), )

    def __init__(self, store, model=None, visual_mode=False):
        BaseEditor.__init__(self, store, model, visual_mode=visual_mode)
        self.set_description(self.model.name)

    #
    # BaseEditorSlave Hooks
    #

    def create_model(self, store):
        return EmployeeRole(store=store, name=u'')

    def on_cancel(self):
        # XXX This will prevent problems in case that you can't
        # update the store.
        if not self.edit_mode:
            self.model_type.delete(self.model.id, store=self.store)

    #
    # Kiwi handlers
    #

    def on_name__validate(self, widget, value):
        if self.model.has_other_role(value):
            return ValidationError('This role already exists!')
Example #16
0
 def fields(self):
     return collections.OrderedDict(
         branch_id=PersonField(_('Branch'),
                               proxy=True,
                               person_type=Branch,
                               can_add=False,
                               can_edit=False,
                               mandatory=True),
         method=PaymentMethodField(_('Method'),
                                   payment_type=self.payment_type,
                                   proxy=True,
                                   mandatory=True,
                                   separate=True),
         account=ChoiceField(self.account_label),
         description=TextField(_('Description'), proxy=True,
                               mandatory=True),
         person=PersonQueryField(person_type=self.person_type, proxy=True),
         value=PriceField(_('Value'), proxy=True, mandatory=True),
         due_date=DateField(_('Due date'), proxy=True, mandatory=True),
         category=PaymentCategoryField(_('Category'),
                                       category_type=self.category_type,
                                       proxy=True),
         repeat=ChoiceField(_('Repeat')),
         end_date=DateField(_('End date')),
         attachment=AttachmentField(_('Attachment')))
Example #17
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(),
        )
Example #18
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 #19
0
 def fields(self):
     return collections.OrderedDict(
         name=TextField(_('Name'), proxy=True),
         color=ColorField(_('Color'), proxy=True),
         category_type=ChoiceField(_('Type'),
                                   data_type=int,
                                   values=self._category_type_values,
                                   proxy=True),
     )
Example #20
0
 def fields(self):
     return collections.OrderedDict(
         name=TextField(_('Name'), mandatory=True, proxy=True),
         budget=PriceField(_('Budget'), mandatory=True, proxy=True),
         description=MultiLineField(_('Description'),
                                    mandatory=True,
                                    proxy=True),
         is_active=BoolField(_('Active'), proxy=True),
     )
Example #21
0
 def fields(self):
     return collections.OrderedDict(
         group=GridGroupField(_('Attribute group'),
                              proxy=True,
                              mandatory=True),
         description=TextField(_('Attribute name'),
                               proxy=True,
                               mandatory=True),
         is_active=BoolField(_('Is active'), proxy=True),
     )
Example #22
0
    def fields(self):
        # Check if sellable's unit allow fraction to use decimal places
        unit = self.model.product.sellable.unit
        if unit and unit.allow_fraction:
            quantity_digits = 3
        else:
            quantity_digits = 0

        return collections.OrderedDict(
            description=TextField(_("Product"), proxy=True, editable=False),
            recorded_quantity=TextField(_("Previous quantity"), proxy=True,
                                        editable=False),
            counted_quantity=TextField(_("Counted quantity"), proxy=True,
                                       editable=False),
            difference=TextField(_("Difference"), proxy=True, editable=False),
            actual_quantity=NumericField(_("Actual quantity"), proxy=True,
                                         mandatory=True, digits=quantity_digits),
            cfop_data=CfopField(_("C.F.O.P"), proxy=True),
            reason=MultiLineField(_("Reason"), proxy=True, mandatory=True),
        )
Example #23
0
class CreditEditor(BaseEditor):
    model_type = Payment
    model_name = _('Credit Transaction')

    confirm_widgets = ['description', 'value']

    fields = dict(
        description=TextField(_('Description'), proxy=True, mandatory=True),
        value=PriceField(_('Value'), proxy=True, mandatory=True),
    )

    def __init__(self, store, client, model=None):
        self.client = client
        BaseEditor.__init__(self, store, model)

    def create_model(self, store):
        group = PaymentGroup()
        method = PaymentMethod.get_by_name(store, u'credit')
        branch = api.get_current_branch(store)
        # Set status to PENDING now, to avoid calling set_pending on
        # on_confirm for payments that shoud not have its status changed.
        return Payment(open_date=localtoday(),
                       branch=branch,
                       status=Payment.STATUS_PENDING,
                       description=u'',
                       value=currency(0),
                       base_value=currency(0),
                       due_date=None,
                       method=method,
                       group=group,
                       till=None,
                       category=None,
                       payment_type=Payment.TYPE_OUT,
                       bill_received=False)

    def setup_proxies(self):
        self.add_proxy(self.model, CreditEditor.proxy_widgets)

    def validate_confirm(self):
        return bool(self.model.description and self.model.value)

    def on_confirm(self):
        if self.model.value < 0:
            self.model.payment_type = Payment.TYPE_IN
            self.model.value = abs(self.model.value)
        self.model.base_value = self.model.value
        self.model.due_date = localtoday()
        self.model.group.payer = self.client.person
        self.model.pay()

    def on_value__validate(self, widget, newvalue):
        if newvalue is None or newvalue == 0:
            return ValidationError(_('Value must be different from zero.'))
Example #24
0
class CreditCheckHistoryEditor(BaseEditor):
    model_type = CreditCheckHistory
    model_name = _("Client Credit Check History")
    size = (400, -1)

    fields = dict(
        client=PersonField(_('Client'), proxy=True, person_type=Client,
                           mandatory=True),
        identifier=TextField(_('Identifier'), proxy=True, mandatory=True),
        status=ChoiceField('Status', mandatory=True),
        check_date=DateField(_('Date'), proxy=True),
        user=ChoiceField(_('User')),
        notes=MultiLineField(_('Notes'), proxy=True),
    )

    def __init__(self, store, model, client, visual_mode=None):
        self._client = client
        self.fields['status'].values = self.get_status_options()

        BaseEditor.__init__(self, store, model, visual_mode)

        if visual_mode or client:
            self.client_add_button.hide()
            self.client_edit_button.hide()

        if self.model.client:
            self.set_description(_('client credit check history for %s') %
                                 self.model.client.person.name)
            self.client.set_sensitive(False)
        else:
            self.set_description(_('client credit check history'))

    def create_model(self, store):
        return CreditCheckHistory(check_date=localtoday().date(),
                                  identifier=u'',
                                  status=CreditCheckHistory.STATUS_NOT_INCLUDED,
                                  client=self._client,
                                  notes=u'',
                                  user=api.get_current_user(self.store),
                                  store=store)

    def setup_proxies(self):
        self._fill_user_field()

    def _fill_user_field(self):
        self.user.prefill([(self.model.user.person.name,
                            self.model.user)])
        self.user.set_sensitive(False)

    @classmethod
    def get_status_options(cls):
        return [(value, key) for key, value in CreditCheckHistory.statuses.items()]
Example #25
0
class ContactInfoEditor(BaseEditor):
    model_name = _('Contact Info')
    model_type = ContactInfo

    confirm_widgets = ['description', 'contact_info']

    fields = dict(
        description=TextField(_('Description'), mandatory=True, proxy=True),
        contact_info=TextField(_('Contact Info'), mandatory=True, proxy=True),
    )

    def __init__(self, store, model=None, person=None):
        self.person = person
        BaseEditor.__init__(self, store, model)
        self.set_description(self.model.description)

    #
    # BaseEditor Hooks
    #

    def create_model(self, store):
        return ContactInfo(person=self.person, store=store)
Example #26
0
class PrintLabelEditor(BaseEditor):
    """ This editor is used to gather information to print labels for a
    purchase item
    """
    model_type = object
    title = _(u'Print labels')

    fields = dict(
        code=TextField(_('Code'), proxy=True),
        description=TextField(_('Description'), proxy=True),
        barcode=TextField(_('Barcode'), proxy=True),
        price=PriceField(_('Price'), proxy=True),
        quantity=NumericField(_('Quantity'), proxy=True),
        skip=NumericField(_('Labels to skip'), proxy=True),
    )

    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()

    def _setup_widgets(self):
        for i in [self.code, self.description, self.barcode, self.price]:
            i.set_sensitive(False)
        if self.max_quantity:
            self.quantity.update(self.max_quantity)

    #
    # BaseEditor Hooks
    #

    def create_model(self, store):
        sellable = self.sellable
        return Settable(barcode=sellable.barcode, code=sellable.code,
                        description=sellable.description, price=sellable.price,
                        quantity=Decimal('1'), skip=Decimal('0'))
 def fields(self):
     return collections.OrderedDict(
         client_id=PersonField(_('Client'),
                               proxy=True,
                               person_type=Client,
                               mandatory=True),
         identifier=TextField(_('Identifier'), proxy=True, mandatory=True),
         status=ChoiceField('Status',
                            values=self.get_status_options(),
                            mandatory=True),
         check_date=DateField(_('Date'), proxy=True),
         user=ChoiceField(_('User')),
         notes=MultiLineField(_('Notes'), proxy=True),
     )
Example #28
0
class WorkOrderPackageItemEditor(BaseEditor):
    """A simple editor for |workorderpackageitem|

    Most useful to edit the item's notes
    """

    size = (400, 200)
    model_name = _(u"Work order")
    model_type = WorkOrderPackageItem

    fields = dict(
        package=TextField(_('Package'), editable=False),
        order=TextField(_('Description'), editable=False),
        notes=MultiLineField(_('Notes'), proxy=True),
    )

    #
    #  BaseEditor
    #

    def setup_proxies(self):
        self.package.set_text(self.model.package.identifier)
        self.order.set_text(self.model.order.equipment)
Example #29
0
    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))
Example #30
0
class SellableTaxConstantEditor(BaseEditor):
    model_type = SellableTaxConstant
    model_name = _('Taxes and Tax rates')

    fields = dict(
        description=TextField(_('Name'), proxy=True, mandatory=True),
        tax_value=PercentageField(_('Value'), proxy=True, mandatory=True),
    )

    #
    # BaseEditor
    #

    def create_model(self, store):
        return SellableTaxConstant(tax_type=int(TaxType.CUSTOM),
                                   tax_value=None,
                                   description=u'',
                                   store=store)