mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 17:45:39 +00:00
Fixed stock entry Userfield edit handling (fixes #1969)
This commit is contained in:
parent
9b52168b94
commit
06968ac289
@ -13,6 +13,7 @@
|
||||
- Fixed that when the stock setting "Decimal places allowed for amounts" was set to `0`, unit conversion (if any) failed when adding the corresponding product to stock
|
||||
- Fixed that consuming a parent product which is not in stock itself (so essentially using any of the child products) may failed when unit conversions were involved (the current stock amount check was wrong in that case)
|
||||
- Fixed that the status button counters on the stock overview page ("X products are overdue" and so on) included products which have the option `Never show on stock overview` enabled
|
||||
- Fixed that adding Userfields to existing stock entries was not possible (only editing existing Userfield values, e.g. added during purchase or inventory, was possible)
|
||||
|
||||
### Shopping list
|
||||
|
||||
|
21
migrations/0196.sql
Normal file
21
migrations/0196.sql
Normal file
@ -0,0 +1,21 @@
|
||||
DROP TRIGGER userfield_values_special_handling_INS;
|
||||
CREATE TRIGGER userfield_values_special_handling_INS AFTER INSERT ON userfield_values
|
||||
BEGIN
|
||||
-- Entity stock:
|
||||
-- object_id is the transaction_id on insert -> replace it by the corresponding stock_id
|
||||
INSERT OR REPLACE INTO userfield_values
|
||||
(field_id, object_id, value)
|
||||
SELECT uv.field_id, sl.stock_id, uv.value
|
||||
FROM userfield_values uv
|
||||
JOIN stock_log sl
|
||||
ON uv.object_id = sl.transaction_id
|
||||
AND sl.transaction_type IN ('purchase', 'inventory-correction', 'stock-edit-new')
|
||||
WHERE uv.field_id IN (SELECT id FROM userfields WHERE entity = 'stock')
|
||||
AND uv.field_id = NEW.field_id
|
||||
AND uv.object_id = NEW.object_id;
|
||||
|
||||
DELETE FROM userfield_values
|
||||
WHERE field_id IN (SELECT id FROM userfields WHERE entity = 'stock')
|
||||
AND field_id = NEW.field_id
|
||||
AND object_id = NEW.object_id;
|
||||
END;
|
@ -44,6 +44,7 @@
|
||||
Grocy.Api.Put("stock/entry/" + Grocy.EditObjectRowId, jsonData,
|
||||
function(result)
|
||||
{
|
||||
Grocy.EditObjectId = result[0].transaction_id;
|
||||
Grocy.Components.UserfieldsForm.Save(function()
|
||||
{
|
||||
var successMessage = __t('Stock entry successfully updated') + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockBookingEntry(\'' + result.id + '\',\'' + Grocy.EditObjectRowId + '\')"><i class="fa-solid fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||
|
Loading…
x
Reference in New Issue
Block a user