Esempio n. 1
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)
Esempio n. 2
0
 def fields(self):
     return collections.OrderedDict(
         expire_at=DateField(_('Expire at'), proxy=True),
         branch_id=PersonField(_('Branch'), proxy=True, person_type=Branch),
         profile_id=UserProfileField(_('User profile'), proxy=True),
         user_id=PersonField(_('User'), proxy=True, person_type=LoginUser),
         content=MultiLineField(_('Message'), proxy=True),
     )
Esempio n. 3
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),
     )
Esempio n. 4
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()]
Esempio n. 5
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),
     )
 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),
     )
Esempio n. 7
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),
        )
Esempio n. 8
0
class CostCenterEditor(BaseEditor):
    model_name = _('Cost Center')
    size = (300, -1)
    model_type = CostCenter

    fields = dict(
        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),
    )

    #
    # BaseEditor Hooks
    #

    def create_model(self, store):
        return CostCenter(store=store)
Esempio n. 9
0
    def fields(self):
        # Check if sellable's unit allow fraction to use decimal places
        unit = self._product.sellable.unit
        if unit and unit.allow_fraction:
            quantity_digits = 3
        else:
            quantity_digits = 0

        fields = collections.OrderedDict(
            quantity=NumericField(_('Quantity'),
                                  proxy=True,
                                  mandatory=True,
                                  digits=quantity_digits), )
        # When creating an inventory, a reason is necessary
        if self._stock_item:
            fields['reason'] = MultiLineField(_('Reason'),
                                              proxy=True,
                                              mandatory=True)
        else:
            # Inventories dont do anything with the cost yet. Maybe we should
            # fix that
            fields['cost'] = PriceField(_('Cost'), proxy=True, mandatory=True)
        return fields
Esempio n. 10
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)