Add support for "Move on Open" (#1863)

* Add functionality to move a product when it is opened

* Update the API to support this (and some other new fields)

* Remove console, update move on open when either the default or the consume location change

* Fix conflict from fridge

* Ignore .DS_STORE from macOS

* Fix the migration conflict

* Fix the default location not appending properly

* Revert changes no longer needed

* Fix the checkbox disable logic, and call the function on page load

* Simplify the transfer to use the existing function (which also adds logs)

* Only move it if it's moving

* Code formatting / naming

* Clarify help text (it's not always about one unit, but about the corresponding amount opened)

* Handle splitted stock entries + optimized/unified product property checks

* Added UI feedback on auto moving

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
Rosemary Orchard
2022-04-18 17:25:08 +01:00
committed by GitHub
parent 0152f1c69d
commit 5e30e89737
10 changed files with 117 additions and 7 deletions

View File

@@ -146,6 +146,22 @@
$location->id == $product->default_consume_location_id) selected="selected" @endif value="{{ $location->id }}">{{ $location->name }}</option>
@endforeach
</select>
@if(GROCY_FEATURE_FLAG_STOCK_PRODUCT_OPENED_TRACKING)
<div class="custom-control custom-checkbox">
<input @if($mode=='edit'
&&
$product->move_on_open == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="move_on_open" name="move_on_open" value="1">
<label class="form-check-label custom-control-label"
for="move_on_open">{{ $__t('Move on open') }}&nbsp;<i class="fa-solid fa-question-circle text-muted"
data-toggle="tooltip"
data-trigger="hover click"
title="{{ $__t("When enabled, on marking this product as opened, the corresponding amount will be moved to the default consume location")
}}"></i>
</label>
</div>
@endif
</div>
@else
<input type="hidden"