How to list all the current Plant Quantities in my vegetable garden Field?

Hello,

I currently pay for GrowVeg and like it but, it being a cloud service, I don’t know for how long it will exist and fear losing all my historical data at some point. I’d rather own my data.

So I decided to try to self-hosting farmOS and use it to manage my little 1ha family farm. We just have a very simple vegetable garden and will soon plant an orchard. Congratulations on the work thus far.

I’m still trying it and exploring its possibilities. I created all my organisational assets and input some seeding and transplanting. But I quickly ran into some blocking issues, mostly related to reporting:

  1. I’d like to have a report on my vegetable garden’s current situation. I have a Field. containing multiple Beds. I can see a list of Plants and their Quantities for a given Bed. But I’d like to be able to list all the Plants in that Field maybe grouped by Bed or something. How can I do this?

  2. I will always need the same reports with a particular Filter. I’d like to be able to save some filters and give them names so that I could easily recall them later. How can I do this?

Thank you in advance.

3 Likes

Hi @nununo - welcome to the forum! :slight_smile:

I wonder if you could post some screenshots from your current system to illustrate what you’d like to be able to do. That might help others provide suggestions here.

Just to be sure I understand, can you tell me which pages you’re looking at to get the information currently? There may be some options, or at the very least workaround, to make things easier.

If you can filter to your desired records with the existing Views (Records > Assets / Logs / Quantities), then one suggestion is to simply bookmark the page with your filters applied. Then you can easily get back to the same page with the same filters.

If you need filters that don’t exist, then it might warrant a new feature request. Feel free to drop ideas in this topic, or start a new dedicated one if it makes sense.

I should also mention, there is work happening on a “Crop Planning” module, which might help with some of the things you describe. It’s still in “alpha” stage right now, and although it’s functional, I would hesitate to recommend it until it’s a bit easier to use. But if you’d like to give it a try the module can be found here: GitHub - mstenta/farm_crop_plan: Crop plan type and related features for farmOS. (ALPHA 3.x IN DEVELOPMENT)

Highly recommend reading through this forum topic to understand what it does (and doesn’t do): farmOS Crop Plan module v3 alpha release

2 Likes

Hi Mike,

Thank you so much for your reply. I take the opportunity to thank you for all the work you’ve done. I’m very impressed with farmOS. I am an ERP developer (SAP ABAP) and really like how you make everything so versatile and flexible and yet at the same time so grounded in a solid data model.

I don’t really have a system right now. I started using GrowVeg but didn’t populate it fully because I didn’t feel comfortable with it being a cloud service. Also, I didn’t find that its diagrammatic approach is of much use. I currently use GrowVeg mostly to find out when and how to plant each species and because they have an amazing chat service where I can ask questions about agriculture.

I will try to explain my needs. I have two distinct needs: State and Log. The Log is pretty much covered already, as far as I am able to understand. The State is where I’m still struggling. I am trying to use this page:

Records > Assets > Plant

It is already great, except for two things:

  1. It doesn’t let me filter by Location. I would like to be able to list which Plants are in a particular bed like Bed 3, but also which Plants are in Field A, since my Beds are hierarchically grouped under Fields;
  2. It is missing the quantity. I would like to be able to know how many Onions I currently have in Field A, even if scattered across multiple Beds. Maybe this doesn’t make sense, conceptually. Maybe there is a better way to accomplish this.

While writing the above I had an idea. If I pre-create all the Harvest logs beforehand, maybe by listing all the pending Harvest logs I could get a good enough report of what Plants I currently have. Still, I think this would be missing the aggregated quantities, at least.

Bookmarking a particular filter is a great alternative to the named filters I proposed. Works fine for me. Thanks.

Well, as said above, I really wish the Records > Assets > Plant page would allow me to filter by Location, recursively. If you agree, I can go ahead and create a request for this feature in the repo. Earlier today I had a look at farmOS code in the hope that I could understand how to add the extra filter but I didn’t succeed. Unfortunately I have no knowledge of PHP or Drupal. I do intend to try again once I have a bit more time.

I ran into the “Crop planning” module and didn’t try it because it’s alpha. And also because I first wanted to understand what’s in the core to be sure I’d understand its added value. Thanks for the tip. Now I’ll definitely try.

Looking forward to read your reply.

Again, thank you so much for all the work.

Regards,
Nuno

2 Likes

@nununo Welcome to the forum and farmOS! From your response to Mike, it feels like you’ve really dug into the existing UI and data-model more thoroughly than the average new farmOS user… nice job!

This would be a great feature! We’ve talked about this before, but I can’t find the tracking issue for it.

If you want to open the feature request, it should probably be a Drupal.org issue under the farmOS project: https://www.drupal.org/project/farm

Also a great feature we should have. We were just talking about this on the most recent monthly call. I don’t see the issue for this one either, but to recap what we found during the call:

The simple version of what you’re talking about would be showing the inventory quantity at the asset level. (Then however you filter the assets, you can see all the inventory quantities on that view - at a per-asset level.)

As Mike linked during the call, inventory field would need to be added to the asset/log views similar to how the group field is added by the group module;

https://github.com/farmOS/farmOS/blob/f01dd2524911c16fe492d45df50651a7a80cd39c/modules/asset/group/farm_group.module#L63

The views field is already defined, just not added to the (any?) views right now;

https://github.com/farmOS/farmOS/blob/3.x/modules/core/inventory/farm_inventory.views.inc

The more complex version would be figuring out how to “roll up” the quantities for separate plantings. That might start to fall into the realm of a custom report… (especially if Onions is actually many different distinct plant types).

2 Likes

Thank you @Symbioquine for your thorough reply!

I just posted a Feature Request for allowing to filter by Location. It’s here. I hope I got it right.

As for the quantities, I’m glad you’ve already considered it. After reading your explanation I do see that there is some complexity to it and that there are several different ways to implement it. I’ll carry on populating farmOS with my little reality and try to start using it to better understand what I really need.

What exactly do you mean by “custom report”? The only reports I find in farmOS are the more technical ones under the Administration menu.

Also, I will try to participate in the next monthly call.

2 Likes

We also have a development call weekly on Thursdays at 9 AM Pacific (Los Angeles) Time.

2 Likes

I’ll respond in more detail to this limitation (and feature request) in a moment, but wanted to note: even though you can’t filter by location directly in Records > Assets > Plant, it is possible to see all the assets currently in a specific location by going directly to that location’s Asset record and clicking the “Assets” tab. This will show the same list of assets as the main list, but filtered to only include ones that are currently in that location. So that’s one way to do it. But it doesn’t currently provide an option to see assets that are in child locations, so you would need to go to each Bed to see what’s in it.

It is worth noting: if you are including geometries, then you can pretty quickly see what (and how many) plant assets are located in each field and bed by looking at the map on Records > Assets > Plant. They will be “clustered” with an icon showing how many are in the area, and when you zoom in the clusters split up to be more granular. Clicking on the icon will show you a list of links to individual assets.

Thanks for opening that! We actually have two existing feature requests, which are related:

The goal of this one is the same as yours, I think, although your description is probably better. I might close yours as a duplicate, and copy the description over to the existing one.

I’m pretty sure I started exploring this in a branch on my fork a while back, and got an initial proof of concept working, but never got around to finishing it and opening a pull request. So I think that’s the next step. I’ll try to dig it up…

However, I did not look into the “optionally show assets in child locations” part. That’s going to add complexity, but I agree it would be useful.

This one would extend what I suggested above (going directly to a location asset to see assets within it) to add the ability to see assets in child locations as well.

farmOS itself doesn’t have any built-in reports. It just has a placeholder “Reports” module (not enabled by default) that other custom modules can depend on. All it does is add a “Reports” item to the main menu, so modules can provide their own reports as sub-items. This gets into the realm of custom Drupal development, but the possibilities are vast within that.

2 Likes

I think this is the branch I started experimenting with:

It needs to be rebased and cleaned up a bit… looks like there are some irrelevant commits included as well.

1 Like

Hi Mike,

Hum… I just tried that and I can’t seem to find an “Assets” tab in the Location’s Asset record of one of my beds:

And yet, as you can see from the screenshot below, if I go to Records > Assets > Plant, the list shows several Plants under that Location:

Can this be a bug or did I misunderstood what you said? Because, now that you said it, having an Assets tab in there makes a lot of sense. And I did notice that when I look at the Asset page of a Location which has sub-locations, there I see a Locations tab, so I guess this would be something similar.

Yes, there should be a “Assets” tab on all location assets.

If that’s missing, it does sound a bit like a bug…

You could try going directly to that tab by taking the url of your “Cama 1” bed and adding “/assets” to the end. It should end up looking something like this:

https://example.farm/asset/${assetId}/assets

When I try to access that url I get an Access Denied error.
I just confirmed that my user has Admin role. I actually just added all the roles to it and I still get that error:

Any suggestions as to why this may be happening and how to solve it?

Actually, strangely, I never see my own user on the People page. This is what I see when I click People on the sidebar:

And this is what I see when I go to Administration > People:

Is there a reason why my user isn’t listed under People? Could it be related to the Access Denied error?

1 Like

The people page linked from the sidebar explicitly filters out the site admin user (i.e. the user with id=1).

However, if your user is indeed the site admin, I believe it should never get an access denied error since it should implicitly have all permissions.

Hmmm, no :sweat_smile:. Hopefully @mstenta has ideas where to look next…

2 Likes

Hmm that is interesting…

This is true, and part of the reasoning here is to encourage you to create a lower-level user for your day-to-day usage, and reserve user 1 (super admin) for administrative purposes, as a security best practice. Think of user 1 like the root user in a Linux system.

Well… you would think so… :sweat_smile:

In some case, (including this one) it’s just easier for us to return 403 than 404 (or other code), based on where the logic for showing/hiding the page is.

In this case, it’s in an access callback that checks to see if there are any assets in a particular location, so we can only return an access result (which then gets translated by Drupal into a `403).

Here is where the logic is: farmOS/modules/core/ui/views/src/Access/FarmLocationAssetViewsAccessCheck.php at 496240f263ce8ab8ae0f89d7dbe0e9aabe0154ce · farmOS/farmOS · GitHub

It’s pretty simple: if the asset has is_location set to true then it shows the tab.

@nununo Is it possible that your “location” asset isn’t actually set as is_location? It would be by default if it was a Land, Water, or Structure asset. But it’s possible to override that default on individual assets, if you unchecked that box. Or if it’s a different asset type, then you need to set it to true.

2 Likes

Looking at your screenshot closer… I see that “Cama 1” has “Is location: Yes”, so that must not be the issue.

Hmm…

2 Likes

Please let me know if I can I help any further, to try to figure this out!

This is a bug! I just replicated it myself. I will investigate a fix and open a pull request…

Thanks for raising this to my attention @nununo!

2 Likes

@nununo If you want a quick fix while you wait for the PR and an official release (and you’re comfortable editing the code yourself), you basically just need to remove " || !is_int($asset_id)" from this line:

… so it is only “if (empty($asset_id)) {”.

1 Like

I tried and failed :slight_smile:

I searched for a file named FarmLocationAssetViewsAccessCheck.php in my Docker persistent folder and couldn’t find it. I then searched for it inside the container and did find it. I used sed to make the change since to other editor seemed to be available but to no avail: even after changing the file nothing changed in the app, even after I restarted the container.

But please don’t waste your time on help me hack it :slight_smile: While this functionality is very important to me, it is not urgent. I am not on a rush so I’ll wait for the release.

I just wish I knew more about Drupal to be able to participate more and help improve farmOS.

Thanks again!

2 Likes

@nununo Yea editing code (especially inside the Docker container) isn’t the easiest thing! :sweat_smile:

The good news is, we just approved and merged my fix: Fix missing Assets tab on locations by mstenta · Pull Request #951 · farmOS/farmOS · GitHub

This means that you could consider switching to the farmos/farmos:3.x Docker image to get the fix soon (once our automated build process finishes building it).

Or you could wait for farmOS 3.4.5 to be released, which will hopefully happen soon! I have two more PRs that I want to get reviewed/merged for that, so it’s just a matter of time.

If you’re not in a rush then I would recommend waiting for that. Using farmos/farmos:3.x works fine, but has some considerations for how you keep it updated, so it’s better to use tagged releases and upgrade each intentionally IMO.

Subscribe to this forum or to our Mastodon for the release announcements!

1 Like