Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Set Default Stock Entry Label when Creating Products #2445

Open
cvergaray opened this issue Jan 16, 2024 · 6 comments
Open

Comments

@cvergaray
Copy link

In my workflow, I always want to print a Label Per Unit when purchasing. I see that when creating a product I can set the default when purchasing to print a label per unit, but I would like to have a configurable default for that setting so that the default when creating a product is to print a Label Per Unit. That way, I reduce the chance of accidentally forgetting to set it when creating the product. This is also helpful when using a 3rd party UI for creating a product that don't have that option when creating a product.

@berrnd
Copy link
Member

berrnd commented Jan 16, 2024

The following simple custom JS snippet (for data/custom_js.html) would give you that right now:

<script>
if (Grocy.View == "productform" && Grocy.EditMode == "create")
{
	$("#default_stock_label_type").val(2);
}
</script>

@cvergaray
Copy link
Author

Thank you! That does look like a quick and easy way to get that implemented. Though, I expect that would only apply when using the web interface, and not when using the API, correct? I use a mix of both the web UI and some 3rd party tools via API, so Ideally I'd like to be able to set it so that when using the API it uses my custom default value when nothing is provided.

@berrnd
Copy link
Member

berrnd commented Jan 16, 2024

Though, I expect that would only apply when using the web interface, and not when using the API, correct?

Sure, it's JS, running client side in your Browser only when using the web frontend.

@berrnd
Copy link
Member

berrnd commented Jan 16, 2024

I use a mix of both the web UI and some 3rd party tools via API, so Ideally I'd like to be able to set it so that when using the API it uses my custom default value when nothing is provided.

Well, the current other "Presets for new products" are also not implement in that way currently. The 3rd party tool in question would need to consider those presets on a "new product screen" exactly in the same way the web frontend does that.

"when nothing is provided" also doesn't fit for mandatory fields. Of course the API endpoint could handle that just fine, but a mandatory field (like the product's "Default location") is naturally also a mandatory field in any third party tool/app, required to be filled out there...

@cvergaray
Copy link
Author

The "when nothing is provided" was, in my mind, only applicable in cases of optional attributes, like Default Stock Label Type. With a default applied when the API doesn't receive an optional attribute, those attributes could still be used (in a limited capacity) with 3rd party tools right out of the gate, without waiting for those tools to catch up to the current feature set. Of course, that would only make sense for an optional attribute with a reasonable default that could be applied to every product, which may only be Default Stock Label Type.

So, that makes sense. It appears I misunderstood how those presets for new products worked. I thought that they not only populated the required attributes but also filled in the optional attributes when not provided to the API. In which case, it seems this would be a non-trivial request because it doesn't really mesh with the current design, especially because that would make the system record data that was not provided.

@berrnd
Copy link
Member

berrnd commented Jan 16, 2024

Yes, using any of those "product presets" outside of prefilling the fields on /product/new would be technically something totally different than how it works today.

 

optional attributes, like Default Stock Label Type

Technically this field was never optional and simply falls back to a fixed default No label when omitted (code ref). What's a reasonable default exactly most of the time depends also on personal preference at the very end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants