Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Only one crop (out of four entered) shows when I go from Home to Plantings to Crops.
I have only entered one planting. Could that be why the others won't display? Could a button be added to display all crops?
I have entered 2 crops as root entries, with 2 crops as subordinate crops with variety names.
They do all show up when I open the hierarchy screen.
Comments
Comment #2
m.stentaHmm ok... I see what's happening. It's a result of this recent feature: #2477409: Inactive assets
During that development, I added a filter to the Crops list to only include "active" assets in the total counts of plantings in each crop. Otherwise, you might see something like "Cherry tomatoes (200)" instead of "Cherry tomatoes (5)" (assuming you have 5 cherry tomato plantings that are active, and another 195 from previous years). Unfortunately, a side effect of that query filter is that it only shows crops with active plantings.
Adding this to the roadmap for beta6... I'll try to come up with a better solution.
Comment #3
m.stentaRenaming this issue and moving it to the Farm Asset module because it affects more than just the Crops view. It also affects Animal Groups, Animal Types, and any other taxonomy term Views that join in farm assets that reference them.
I've almost got a solution worked out for this... but I'll post that in a separate comment.
Comment #4
m.stentaOk, so I figured out a pretty good way to fix this without having to change the end result of the Views that are affected.
Basically, the problem was that I was using a filter to remove any plantings that were not active. But that meant that if a crop didn't have any active plantings it wouldn't be displayed.
I examined the query being generated by the View (annotated below):
The part that was causing the issue was in the WHERE clause:
AND (field_farm_crop_taxonomy_term_data.active <> '0')
The BETTER way to achieve the same goal, without losing crops from the list is to add an additional condition to the 4th JOIN (where the farm_asset) table is joined in. The extra condition could be used to check for the "active" property on the assets, and only include active assets in the join. Like this:
Getting that extra "
AND field_farm_crop_taxonomy_term_data.active = 1
" in there is harder than it seems, however... I ended up having to create a new Views relationship handler that extends views_handler_relationship_entity_reverse. Inside that handler, I was able to use Views' "#join_extra" property to add the necessary condition.All taxonomy term / farm asset reverse reference relationships are overridden with the new handler. The handler includes a checkbox option that let's you turn it on/off - in case you want to build a View that includes counts of inactive assets for example.
This will be included in beta6 which I'm rolling out shortly: #2548397: [META] FarmOS 7.x-1.0-beta6
Comment #6
m.stentaI am in the process of updating all the various Views (in other modules). But the bug itself is fixed.
Comment #7
m.stentaMoving old issues to the canonical farmOS project for easier searching. Apologies for email spam if anyone is following these. :-)