diff --git a/tailbone/templates/batch/view.mako b/tailbone/templates/batch/view.mako index b39ea376..d0a1ca21 100644 --- a/tailbone/templates/batch/view.mako +++ b/tailbone/templates/batch/view.mako @@ -211,6 +211,12 @@ diff --git a/tailbone/templates/forms/deform_buefy.mako b/tailbone/templates/forms/deform_buefy.mako index 7bd20139..514d520d 100644 --- a/tailbone/templates/forms/deform_buefy.mako +++ b/tailbone/templates/forms/deform_buefy.mako @@ -1,6 +1,7 @@ ## -*- coding: utf-8; -*- + % endif <%def name="func_show_mode()"> diff --git a/tailbone/templates/receiving/create.mako b/tailbone/templates/receiving/create.mako index a8055188..1763b50f 100644 --- a/tailbone/templates/receiving/create.mako +++ b/tailbone/templates/receiving/create.mako @@ -3,6 +3,7 @@ <%def name="extra_javascript()"> ${parent.extra_javascript()} + % if not use_buefy: ${self.func_show_batch_type()} + % endif <%def name="func_show_batch_type()"> diff --git a/tailbone/views/purchases/core.py b/tailbone/views/purchases/core.py index fbb77bc9..2c31e904 100644 --- a/tailbone/views/purchases/core.py +++ b/tailbone/views/purchases/core.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2018 Lance Edgar +# Copyright © 2010-2021 Lance Edgar # # This file is part of Rattail. # @@ -48,8 +48,12 @@ class PurchaseView(MasterView): model_row_class = model.PurchaseItem row_model_title = 'Purchase Item' + labels = { + 'id': "ID", + } + grid_columns = [ - 'store', + 'id', 'vendor', 'department', 'buyer', @@ -62,6 +66,7 @@ class PurchaseView(MasterView): ] form_fields = [ + 'id', 'store', 'vendor', 'department', @@ -162,6 +167,9 @@ class PurchaseView(MasterView): default_active=True, default_verb='contains') g.sorters['buyer'] = g.make_sorter(model.Person.display_name) + # id + g.set_renderer('id', self.render_id_str) + # date_ordered g.filters['date_ordered'].default_active = True g.filters['date_ordered'].default_verb = 'equal' @@ -182,6 +190,9 @@ class PurchaseView(MasterView): g.set_type('po_total', 'currency') g.set_type('invoice_total', 'currency') g.set_label('invoice_number', "Invoice No.") + + g.set_link('id') + g.set_link('vendor') g.set_link('date_ordered') g.set_link('po_total') g.set_link('date_received') @@ -190,6 +201,8 @@ class PurchaseView(MasterView): def configure_form(self, f): super(PurchaseView, self).configure_form(f) + f.set_renderer('id', self.render_id_str) + f.set_renderer('store', self.render_store) f.set_renderer('vendor', self.render_vendor) f.set_renderer('department', self.render_department) @@ -220,14 +233,6 @@ class PurchaseView(MasterView): url = self.request.route_url('stores.view', uuid=store.uuid) return tags.link_to(text, url) - def render_vendor(self, purchase, field): - vendor = purchase.vendor - if not vendor: - return "" - text = "({}) {}".format(vendor.id, vendor.name) - url = self.request.route_url('vendors.view', uuid=vendor.uuid) - return tags.link_to(text, url) - def render_department(self, purchase, field): department = purchase.department if not department: @@ -316,6 +321,17 @@ class PurchaseView(MasterView): def configure_row_form(self, f): super(PurchaseView, self).configure_row_form(f) + # quantity fields + f.set_type('case_quantity', 'quantity') + f.set_type('cases_ordered', 'quantity') + f.set_type('units_ordered', 'quantity') + f.set_type('cases_received', 'quantity') + f.set_type('units_received', 'quantity') + f.set_type('cases_damaged', 'quantity') + f.set_type('units_damaged', 'quantity') + f.set_type('cases_expired', 'quantity') + f.set_type('units_expired', 'quantity') + # currency fields f.set_type('po_unit_cost', 'currency') f.set_type('po_total', 'currency') diff --git a/tailbone/views/purchases/credits.py b/tailbone/views/purchases/credits.py index dafe5d5e..79530fe2 100644 --- a/tailbone/views/purchases/credits.py +++ b/tailbone/views/purchases/credits.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2019 Lance Edgar +# Copyright © 2010-2021 Lance Edgar # # This file is part of Rattail. # @@ -180,11 +180,19 @@ class PurchaseCreditView(MasterView): @classmethod def defaults(cls, config): + cls._purchase_credit_defaults(config) + cls._defaults(config) + + @classmethod + def _purchase_credit_defaults(cls, config): route_prefix = cls.get_route_prefix() url_prefix = cls.get_url_prefix() permission_prefix = cls.get_permission_prefix() model_title_plural = cls.get_model_title_plural() + # fix perm group name + config.add_tailbone_permission_group(permission_prefix, model_title_plural, overwrite=False) + # change status config.add_tailbone_permission(permission_prefix, '{}.change_status'.format(permission_prefix), "Change status for {}".format(model_title_plural)) @@ -192,8 +200,6 @@ class PurchaseCreditView(MasterView): config.add_view(cls, attr='change_status', route_name='{}.change_status'.format(route_prefix), permission='{}.change_status'.format(permission_prefix)) - cls._defaults(config) - def includeme(config): PurchaseCreditView.defaults(config) diff --git a/tailbone/views/purchasing/batch.py b/tailbone/views/purchasing/batch.py index d83beb6f..ebfcf8ce 100644 --- a/tailbone/views/purchasing/batch.py +++ b/tailbone/views/purchasing/batch.py @@ -281,9 +281,9 @@ class PurchasingBatchView(BatchMasterView): if self.creating: f.replace('vendor', 'vendor_uuid') f.set_label('vendor_uuid', "Vendor") - widget_type = self.rattail_config.get('tailbone', 'default_widget.vendor', - default='autocomplete') - if widget_type == 'autocomplete': + use_autocomplete = self.rattail_config.getbool( + 'rattail', 'vendor.use_autocomplete', default=True) + if use_autocomplete: vendor_display = "" if self.request.method == 'POST': if self.request.POST.get('vendor_uuid'): @@ -293,14 +293,12 @@ class PurchasingBatchView(BatchMasterView): vendors_url = self.request.route_url('vendors.autocomplete') f.set_widget('vendor_uuid', forms.widgets.JQueryAutocompleteWidget( field_display=vendor_display, service_url=vendors_url)) - elif widget_type == 'dropdown': + else: vendors = self.Session.query(model.Vendor)\ .order_by(model.Vendor.id) vendor_values = [(vendor.uuid, "({}) {}".format(vendor.id, vendor.name)) for vendor in vendors] f.set_widget('vendor_uuid', dfwidget.SelectWidget(values=vendor_values)) - else: - raise NotImplementedError("Unsupported vendor widget type: {}".format(widget_type)) elif self.editing: f.set_readonly('vendor') diff --git a/tailbone/views/purchasing/ordering.py b/tailbone/views/purchasing/ordering.py index ef37b3b3..2a7a9b11 100644 --- a/tailbone/views/purchasing/ordering.py +++ b/tailbone/views/purchasing/ordering.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2020 Lance Edgar +# Copyright © 2010-2021 Lance Edgar # # This file is part of Rattail. # @@ -155,9 +155,11 @@ class OrderingBatchView(PurchasingBatchView): def configure_form(self, f): super(OrderingBatchView, self).configure_form(f) + batch = f.model_instance # purchase - f.remove_field('purchase') + if self.creating or not batch.executed or not batch.purchase: + f.remove_field('purchase') def get_batch_kwargs(self, batch, mobile=False): kwargs = super(OrderingBatchView, self).get_batch_kwargs(batch, mobile=mobile) @@ -468,6 +470,11 @@ class OrderingBatchView(PurchasingBatchView): return self.file_response(path) + def get_execute_success_url(self, batch, result, **kwargs): + if isinstance(result, model.Purchase): + return self.request.route_url('purchases.view', uuid=result.uuid) + return super(OrderingBatchView, self).get_execute_success_url(batch, result, **kwargs) + @classmethod def _ordering_defaults(cls, config): route_prefix = cls.get_route_prefix()