Honor case vs. unit restrictions for new custorder

and expose them in config view
This commit is contained in:
Lance Edgar 2022-03-29 18:19:14 -05:00
parent 4e25e87bfb
commit 1bb41b21af
3 changed files with 43 additions and 15 deletions

View file

@ -52,12 +52,21 @@
<h3 class="block is-size-3">Product Handling</h3>
<div class="block" style="padding-left: 2rem;">
<b-field message="If set, user can enter details of an arbitrary new &quot;pending&quot; product.">
<b-checkbox name="rattail.custorders.allow_unknown_product"
v-model="simpleSettings['rattail.custorders.allow_unknown_product']"
<b-field>
<b-checkbox name="rattail.custorders.allow_case_orders"
v-model="simpleSettings['rattail.custorders.allow_case_orders']"
native-value="true"
@input="settingsNeedSaved = true">
Allow creating orders for "unknown" products
Allow "case" orders
</b-checkbox>
</b-field>
<b-field>
<b-checkbox name="rattail.custorders.allow_unit_orders"
v-model="simpleSettings['rattail.custorders.allow_unit_orders']"
native-value="true"
@input="settingsNeedSaved = true">
Allow "unit" orders
</b-checkbox>
</b-field>
@ -70,6 +79,15 @@
</b-checkbox>
</b-field>
<b-field message="If set, user can enter details of an arbitrary new &quot;pending&quot; product.">
<b-checkbox name="rattail.custorders.allow_unknown_product"
v-model="simpleSettings['rattail.custorders.allow_unknown_product']"
native-value="true"
@input="settingsNeedSaved = true">
Allow creating orders for "unknown" products
</b-checkbox>
</b-field>
</div>
</%def>

View file

@ -790,9 +790,8 @@
<b-field grouped>
<b-field label="Quantity" horizontal>
<b-input v-model="productQuantity"
type="number" step="0.01">
</b-input>
<numeric-input v-model="productQuantity">
</numeric-input>
</b-field>
<b-select v-model="productUOM">
@ -1040,13 +1039,8 @@
template: '#customer-order-creator-template',
data() {
## TODO: these should come from handler
let defaultUnitChoices = [
{key: '${enum.UNIT_OF_MEASURE_EACH}', value: "Each"},
{key: '${enum.UNIT_OF_MEASURE_POUND}', value: "Pound"},
{key: '${enum.UNIT_OF_MEASURE_CASE}', value: "Case"},
]
let defaultUOM = '${enum.UNIT_OF_MEASURE_CASE}'
let defaultUnitChoices = ${json.dumps(default_uom_choices)|n}
let defaultUOM = ${json.dumps(default_uom)|n}
return {
batchAction: null,
@ -1329,6 +1323,9 @@
return true
}
}
if (!this.productUOM) {
return true
}
return false
},

View file

@ -347,8 +347,15 @@ class CustomerOrderView(MasterView):
'product_key_label': self.rattail_config.product_key_title(),
'allow_unknown_product': self.batch_handler.allow_unknown_product(),
'department_options': self.get_department_options(),
'default_uom_choices': self.batch_handler.uom_choices_for_product(None),
'default_uom': None,
})
if self.batch_handler.allow_case_orders():
context['default_uom'] = self.enum.UNIT_OF_MEASURE_CASE
elif self.batch_handler.allow_unit_orders():
context['default_uom'] = self.enum.UNIT_OF_MEASURE_EACH
return self.render_to_response(template, context)
def get_department_options(self):
@ -944,11 +951,17 @@ class CustomerOrderView(MasterView):
# product handling
{'section': 'rattail.custorders',
'option': 'allow_unknown_product',
'option': 'allow_case_orders',
'type': bool},
{'section': 'rattail.custorders',
'option': 'allow_unit_orders',
'type': bool},
{'section': 'rattail.custorders',
'option': 'product_price_may_be_questionable',
'type': bool},
{'section': 'rattail.custorders',
'option': 'allow_unknown_product',
'type': bool},
]
@classmethod