Expose, start to honor "units only" setting for products

This commit is contained in:
Lance Edgar 2023-01-07 11:52:37 -06:00
parent 8c201dced7
commit c6765fd9a9
3 changed files with 33 additions and 14 deletions

View file

@ -50,6 +50,15 @@
</b-checkbox>
</b-field>
<b-field message="If set, then &quot;case size&quot; etc. will not be shown.">
<b-checkbox name="rattail.products.units_only"
v-model="simpleSettings['rattail.products.units_only']"
native-value="true"
@input="settingsNeedSaved = true">
Products only come in units
</b-checkbox>
</b-field>
</div>
<h3 class="block is-size-3">Labels</h3>

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2020 Lance Edgar
# Copyright © 2010-2023 Lance Edgar
#
# This file is part of Rattail.
#
@ -41,7 +41,6 @@ class ImporterBatchView(BatchMasterView):
"""
model_class = model.ImporterBatch
default_handler_spec = 'rattail.batch.importer:ImporterBatchHandler'
model_title_plural = "Import / Export Batches"
route_prefix = 'batch.importer'
url_prefix = '/batches/importer'
template_prefix = '/batch/importer'

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar
# Copyright © 2010-2023 Lance Edgar
#
# This file is part of Rattail.
#
@ -1320,12 +1320,9 @@ class ProductView(MasterView):
def get_context_vendor_sources(self, product):
app = self.get_rattail_app()
route_prefix = self.get_route_prefix()
units_only = self.products_handler.units_only()
factory = self.get_grid_factory()
g = factory(
key='{}.vendor_sources'.format(route_prefix),
data=[],
columns=[
columns = [
'preferred',
'vendor',
'vendor_item_code',
@ -1333,7 +1330,16 @@ class ProductView(MasterView):
'case_cost',
'unit_cost',
'status',
],
]
if units_only:
columns.remove('case_size')
columns.remove('case_cost')
factory = self.get_grid_factory()
g = factory(
key='{}.vendor_sources'.format(route_prefix),
data=[],
columns=columns,
labels={
'preferred': "Pref.",
'vendor_item_code': "Order Code",
@ -1348,12 +1354,14 @@ class ProductView(MasterView):
'uuid': cost.uuid,
'preferred': "X" if cost.preference == 1 else None,
'vendor_item_code': cost.code,
'case_size': app.render_quantity(cost.case_size),
'case_cost': app.render_currency(cost.case_cost),
'unit_cost': app.render_currency(cost.unit_cost, scale=4),
'status': "discontinued" if cost.discontinued else "available",
}
if not units_only:
source['case_size'] = app.render_quantity(cost.case_size)
source['case_cost'] = app.render_currency(cost.case_cost)
text = six.text_type(cost.vendor)
if link_vendor:
url = self.request.route_url('vendors.view', uuid=cost.vendor.uuid)
@ -2145,6 +2153,9 @@ class ProductView(MasterView):
{'section': 'rattail',
'option': 'products.convert_type2_for_gpc_lookup',
'type': bool},
{'section': 'rattail',
'option': 'products.units_only',
'type': bool},
# labels
{'section': 'tailbone',