Add new setting PURCHASEORDER_AUTO_COMPLETE (#6245)

* Add new setting PURCHASEORDER_AUTO_COMPLETE

- Controls whether purchase orders are automatically closed
- Default to True

* Tweak setting component
This commit is contained in:
Oliver 2024-01-16 00:51:03 +11:00 committed by GitHub
parent 3511450b3d
commit 576bef5d82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 5 deletions

View File

@ -1752,6 +1752,14 @@ class InvenTreeSetting(BaseInvenTreeSetting):
'default': False,
'validator': bool,
},
'PURCHASEORDER_AUTO_COMPLETE': {
'name': _('Auto Complete Purchase Orders'),
'description': _(
'Automatically mark purchase orders as complete when all line items are received'
),
'default': True,
'validator': bool,
},
# login / SSO
'LOGIN_ENABLE_PWD_FORGOT': {
'name': _('Enable password forgot'),

View File

@ -779,6 +779,9 @@ class PurchaseOrder(TotalPriceMixin, Order):
# Has this order been completed?
if len(self.pending_line_items()) == 0:
if common_models.InvenTreeSetting.get_setting(
'PURCHASEORDER_AUTO_COMPLETE', True
):
self.received_by = user
self.complete_order() # This will save the model

View File

@ -12,6 +12,7 @@
<tbody>
{% include "InvenTree/settings/setting.html" with key="PURCHASEORDER_REFERENCE_PATTERN" %}
{% include "InvenTree/settings/setting.html" with key="PURCHASEORDER_EDIT_COMPLETED_ORDERS" icon='fa-edit' %}
{% include "InvenTree/settings/setting.html" with key="PURCHASEORDER_AUTO_COMPLETE" icon='fa-check-circle' %}
</tbody>
</table>
{% endblock content %}

View File

@ -172,8 +172,8 @@ export function SettingItem({
return (
<Paper style={style}>
<Group position="apart" p="10">
<Stack spacing="2">
<Group position="apart" p="3">
<Stack spacing="2" p="4px">
<Text>{setting.name}</Text>
<Text size="xs">{setting.description}</Text>
</Stack>

View File

@ -238,7 +238,8 @@ export default function SystemSettings() {
<GlobalSettingList
keys={[
'PURCHASEORDER_REFERENCE_PATTERN',
'PURCHASEORDER_EDIT_COMPLETED_ORDERS'
'PURCHASEORDER_EDIT_COMPLETED_ORDERS',
'PURCHASEORDER_AUTO_COMPLETE'
]}
/>
)