Here is a question for the inventory function. I have a flock of layer chickens. I have this flock listed as an asset. However, we are conducting a breeding program, and I want to track certain individuals of this flock. I have started created individual assets of the individual chickens I want to track. Is there a way to tie their number (1) to the overall inventory of the flock asset? What I want is to be able to add or subtract (archive) individuals and the flock inventory automatically changes.
What we do is have separate assets for each chicken - which provides a convenient place to record data such as their sex, DOB, etc. - then use groups to model the flocks;
e.g.
@kyle You’ve got me thinking…
First, as @Symbioquine suggested, in farmOS 1.x Group assets are a good way to organize individuals. However, that is a different approach from “inventory” on the individual animal asset level (for tracking a head count of your flock). It’s sort of an either/or situation currently: you can either have individual animals in a group, and you can see the total inventory of that group (at the bottom of the page “Displaying X-Y of Z”)… OR you can have a single animal asset with an inventory head count that is incremented/decremented with logs. But there isn’t a built-in way to combine these numbers, aside from pulling out a calculator.
However, in farmOS 2.x we’ve expanded the ways in which inventory management works. And separately we’ve also made some big improvements to the way group membership affects other things, like member asset location for instance.
In 1.x Groups could have a location separate from their member assets, which was sort of weird and confusing, so the rule of thumb was basically “you can either track location of the group OR you can track the location of individual animals, but don’t try to do both”. Now, in 2.x, the logic is more cohesive: if an asset is a member of a group, and that group has a movement log, then the asset’s location reflects the location of the group (but if the member has a newer movement log, then it’s location can still be different from the group). This sounds unrelated to your question… but I’m leading up to it…
I could imagine doing something similar with group inventory logic: where we provide some mechanisms for recursively calculating the total inventory of all members within a group combined. @paul121 actually wrote a function for this in 1.x for a custom report we built for a farm, but it doesn’t get used anywhere in farmOS itself: farmOS/farm_livestock.module at 722339943b4ab30587eb0795249f0e1d2867f838 · farmOS/farmOS · GitHub - Something similar to this might form the basis for an “Aggregated Group Inventory” perhaps.
The other consideration with inventory in 2.x is that it can apply to ANY asset, and one asset can have multiple inventories. Inventories are tracked via Quantities, which can specify a “measure” and “unit” - so inventories are essentially grouped based on measure+unit pairs. This might make it a bit trickier to isolate out the “animal head count” inventory in a group from other inventories (if any). But perhaps it’s worth sketching up the code for this to see how it would look/behave. I think this would essentially be done in a new GroupInventory
class that overrides the AssetInventory
class, in the same way that GroupAssetLocation
overrides AssetLocation
(I just mention these specific pieces of code to point out that there may be a clear place to dive in on this.)
I created a feature request: Aggregated Group Inventory [#3238513] | Drupal.org