Livestock management workflow (birth / death / sale / ...)

Hey !

First, thanks to farmOS’ contributors for their work…

I’m evaluating farmOS for use in our sheep farm and so far am quite happy with what I see but I have two questions regarding birth and death/sale of animals. Maybe I’m trying to “fit” my current workflow into farmOS while there’s maybe a much better way/workflow I haven’t thought of, so I’d be really interested to read about other people manage their animals.

Birth: I’m still wondering what approach to use:

  • create a new asset/animal for the newborn lamb(s) and then create a birth log; cons: it’s quite involved so time-consuming and error prone
  • as above, but without creating a birth log; cons: loosing history
  • use the birth quick form ; that’s the simplest and quickest approach, however children (in my case, lambs) are assigned the same group(s) as their mother. So if the mother was - say - a member of “sheep” and “pregnant” groups, the lamb would be assigned those groups too which then requires manuall going through all newborn lambs and correct their group. I’ve looked at the birth quick form code, I could either comment the code that assigns the mother’s group(s) to the children, or hardcode a “lamb” group for any newborn (since we’re only a sheep farm, at least for now). But maybe I’m looking at the problem from the wrong angle, so any suggestions would be welcome.

Death/sale/…: this post suggests adding a log to animals and then archive them. That’s OK when updating just a few animals but isn’t very manageable otherwise: eg. if I’ve sold 10 lambs I have to select/search then once in the asset list, add a “sale” log, and then select/search the same lambs again to archive them - which is error-prone as I might forget to select one of the animals or select a wrong one (feature suggestion: when viewing logs, it’d be helpful to be able to create a “search view” with the assets/animals listed in the log; it would then be easy to perform further actions on the same animals directly from the search page).
How do you guys do that ? Maybe I’m missing something obvious - if not maybe a custom quick form would be the way to go.

Cheers !

1 Like

Hi @boris - welcome to the farmOS community! :slight_smile:

Great questions… I’ll see if I can provide some tips…

You hit the nail on the head with the “Birth Quick Form” - we made that specifically to make birth records a one-step process. You’re correct, though, that it automatically assigns the children to the mother’s group.

You can certainly alter the quick form code to disable that, but then you’ll need to maintain that override every time you update farmOS (which essentially involves replacing the whole codebase with the new version: Updating - farmOS.org).

Another option (without modifying code) would be to change the lambs’ groups after they are created, as you described, but an easier way to do this is to use the “bulk action”. For example: go to Assets > Animals, filter by date of birth, select all, and click the “Group” button at the bottom of the page. This allows you to change the group for multiple animals at once. That saves you having to go into each one to change the groups individually. But, of course, you’ll still end up with those animals being in the “pregnant” group at first. It’s a bit weird, but maybe it won’t affect anything, as long as you’re aware of it.

Ultimately, the best solution to this might be to add a checkbox to the birth quick form: “Assign these animals to the mother’s group”, which, if unchecked, would simply skip that step during the processing. It seems that you were able to figure out how to disable the code - maybe you’d be able to figure out how to add that checkbox? That would be a great contribution! If you’re interested, you could consider making a pull request to have that change included in farmOS core, so that you don’t need to worry about maintaining your overridden code base across updates.

Regarding death/sale: agreed farmOS would benefit from some better shortcuts and conventions around recording these things. One way that others have done this is with the CSV importer: Import - farmOS.org

There is a special column available that might do what you want:

Archive assets - If this is set to “Y”, then any assets referenced on the log will be archived. This can be used to archive assets at the same time as recording their harvest logs, for example. See “Boolean options” below for allowed values. If omitted, assets will not be archived. Note that this will archive assets even if the log is not marked “Done” during import.

So, if you are primarily recording “Sale” logs, and you want to archive at the same time, you could create a CSV template for importing sale logs, and fill in the “Archive assets” column with “Y” by default.

That’s just one potential way to do it… a dedicated quick form might also be worth investigating.

Hope that helps!

Hey Mike,

Thank you for your reply !

Yeah I know ; the change looked quite straightforward so making a patch and then applying it automatically after each update seemed OK. But I definitely agree that a proper contribution would be better.

That’s what I’ve done in my test scenarios, but sometimes I’d forget to select some animals and/or select the wrong ones. That’s why I think it would be really helpful to be able to “recall” the assets of a log into a “search view” where those bulk actions - eg. clicking the Group button - can be performed.

Indeed - a check box would do, or maybe better, a group dropdown list with the mother’s group(s) selected by default. I’m not so much of a PHP guy though and I’m quite busy with the farm (an understatement!) so I’m not sure I’ll be able to send a PR in the short term - but I’ll see what I can do (I’ll probably have to spend more time understanding the code/architecture than coding). [EDIT: PR sent ]

I see. I’m comfortable using the importer but I’m not sure my vet can do that without messing it up, although she’s learning quickly. In passing, while testing/importing our animals some days ago I’ve noticed that farmOS would import records that are properly formatted and return errors for those that aren’t - but without telling the user which records weren’t OK. When dealing with a larger sets of assets it’s a trial-and-error process - ie. backup the DB, import records, try to find out which and why records weren’t processed properly, restore the DB and repeat until the import is successful ; a suggestion would be to “wrap” the import as a transaction, ie. import everything if all records are OK, but don’t import anything if there are errors.

But back to the death/sale/… scenario: the quick form is likely the best way to solve this use-case. When I have a bit more time I’ll try to understand how the birth quick form works and try to make a new form for death/sale/…; if it works well - and if I’m not too ashamed of my PHP coding skills :slight_smile: - I’ll send a PR.

Thank you again, and keep up the good work !

Cheers !

1 Like

Quick follow up for anyone interested (replying to myself, not sure it’s OK to do that - if not I’ll add an edit next time - sorry).

  • Birth: I’ve added a checkbox/group selection to the birth quick form (PR sent); issue solved :slight_smile:

  • Death/sale/…: a dedicated quick form initially looked like the best solution but in the end keeping the date of archiving dissociated from the date of death/sale actually makes much more sense for me:

    • we first move animals to dedicated groups - eg. “sold” or “dead”; that way the date on which an animal was sold/died is recorded (that’d be the “group membership” log’s date); groups also make it far easier to search/find those animals later on.
    • we then archive the animal(s) a few days later once they’re officialy declared sold/dead in the national livestock register. With that approach we thus have an exact register of both “unofficial” and “official” assets in the farm - which is a great way to keep up with the bureaucratic nightmare we have to deal with.
  • “Re-selecting” the assets of a previous log for further action seems like a pretty common task so I’m wondering how other fellow farmOS users do - maybe I’m overlooking something ? For instance I could create a “sales” log (eg. from the farm_ledger module), then be able to re-select the same animals from the log’s “view”, and from the resulting search view click the “Group” button to move the assets to a specific group (eg. for later archival). Right now I don’t see how to do that, other than manually selecting each animal, or using temporary/transient groups.
    (note: I tried to add a “search from assets” button to a log’s view but didn’t have enough time to understand Drupal’s internals ; also, given what I’ve read on the upcoming farmOS 2.x release, such change/feature would probably have to be redone for Drupal 9, so I’m leaving this aside for now.)

In a few weeks I’ll try to post the workflow we’ve settled on (still a moving target now) along with any issue/shortcomings - if any - that we’ve encountered and how we dealt with them. Hopefully it’ll be of interest for other fellow livestock farmers who are considering using farmOS !

1 Like

Great work @boris !! :smiley:

I’ve merged your pull request: Add optional group membership selection to quick birth form #424 · farmOS/farmOS@2b64bc8 · GitHub

we then archive the animal(s) a few days later once they’re officialy declared sold/dead in the national livestock register. With that approach we thus have an exact register of both “unofficial” and “official” assets in the farm - which is a great way to keep up with the bureaucratic nightmare we have to deal with.

Oh that is a super interesting way to approach it! Hadn’t thought of those considerations…

“Re-selecting” the assets of a previous log for further action seems like a pretty common task

This is also an interesting idea! Currently the “Assets” of a log are just displayed as a simple list of links to the asset records… but I could also see replacing that with a “View” (table of assets with the “bulk operations” checkboxes and buttons).

This is something we could consider adding in farmOS 2.x! I’m actually working on the inverse of that right now (lists of logs on asset pages). So let me give this some thought… it might be worth opening up a dedicated feature request for it, in either case. We use drupal.org for farmOS core issue management, if you’d like to get that ball rolling! https://www.drupal.org/project/issues/farm

while testing/importing our animals some days ago I’ve noticed that farmOS would import records that are properly formatted and return errors for those that aren’t - but without telling the user which records weren’t OK

Ugh yea… I’ve never been satisfied with the validation in farmOS 1.x CSV importers. We are somewhat limited to what we can get from the Feeds module in that regard, which isn’t specifically designed for CSV imports in this way (but is the best option available in Drupal 7). We are currently investigating using Drupal 9’s Migrate API to build the CSV importers in farmOS 2.x, and the validation is much more robust in that. So I’m optimistic that this will be a big improvement in 2.x…

1 Like