Maintenance Log (v2)

Hi all
I’ve started to:

  1. Input all our pieces of equipment, using “Equipment assets” records; then
  2. Created “Purchase logs” for each of these equipments, with
    a) a “Price quantity”, and related invoice nb etc; and then
    b) Linking the equipment asset I had created in the previous step, using the “Asset” section (though not sure if should have rather used “Equipment used” section instead, or both?? A bit confusing!)
  3. Created maintenance logs, with:
    a) a “Price quantity” - but then contrary to a “Purchase” log, I cannot input the invoice nb and service provider name (at least not in a dedicated section, only in the generic “Notes”)
    b) Linking the equipment asset (with same uncertainty reg using the “Asset” vs “Equipment used” section or both??)

Is that all correct? Any recommendation?

As mentioned many time in this forum, the fway forms are designed makes it very flexible, which is good, but also quite combursome and confusing…
I guess that you foresee a dedicated quick-form (similar to the “Planting quick-form”), at some point in the future be, right?

Last point/questions: I wish I knew how to code so at least I could contribute, but I don’t :-/
Drupal is PHP if understand, right? (so I assume a very steep learning curve…)
I taught myself Excel VBA, and a friend told me that moving to Python shouldn’t be too much of a leap, correct? I saw in some posts from @mstenta that it neabled some stuff. However, would that be useful considering that we’re hosted on Farmier (as I also don’t know how to manage servers… :-/)???
Thanks for the guidance/clarifications!

1 Like

I agree. It’s not always easy to figure out a best practice.
As a main rule, I think as long as you can find back the info in the ways you find natural, you should’nt be very wrong.

I trust things will get clearer the more I use it.
Sometimes I think it would be easier to start with v1 and it’s appropriate modules/quickforms and v1 fieldkit.

It’s alwas a middle cround between using enough details entering a log, and searching for the info later. The more granular you get, the harder it is to maintain the same granularity for every similar log.

Maybe if we had list of possible quickforms and their wanted content it would be easier to make them?

1 Like

@brunocacao Yup that sounds about right! Similar to how I do things too.

Linking the equipment asset I had created in the previous step, using the “Asset” section (though not sure if should have rather used “Equipment used” section instead, or both?? A bit confusing!)

The “Asset” field is intended to reference assets that “were acted upon” - where as the “Equipment used” field is intended to reference equipment assets that “did the action”.

So for example, if you have an equipment asset named Tractor, and you use it to seed a field, your Seeding log would reference “Tractor” in the “Equipment used” and it would reference the Plant and/or Land asset in the “Asset” field.

On the flip side, when you perform maintenance on the tractor, your Maintenance log would reference the Tractor in the “Asset” field, because it is being acted upon. If you used another piece of equipment to perform the maintenance, you could reference that in the “Equipment used” field.

Hope that clarifies!

a “Price quantity” - but then contrary to a “Purchase” log, I cannot input the invoice nb and service provider name (at least not in a dedicated section, only in the generic “Notes”)

Sounds like adding some additional fields for these things would be useful on Maintenance logs!

I guess that you foresee a dedicated quick-form (similar to the “Planting quick-form”), at some point in the future be, right?

Yes quick forms are one way to help a) make data entry faster, and b) standardize it so that records are consistent. Field Modules (for Field Kit) are another future option I’m excited for!

Maybe if we had list of possible quickforms and their wanted content it would be easier to make them?

@pat Yea it would be great to start organizing a list of that kind! Hopefully as more quick forms get developed people can use them as reference points to develop their own, speeding up the process of creating them!

I’d also love to see other options develop, that don’t require installing additional modules in farmOS. SurveyStack.io provides a survey builder UI that can connect to a farmOS instance. Their v2 integration is still in development, but it would be awesome to see that gain more traction in the future! (cc @gbathree)

I assumed that a quantity should belong to an asset, because an asset with a quantity zero is IMHO not an assett. Hence I added a quantity field to an asset. However I couldn’t modify the quantity of that asset with a log. It seems that I always need an log to create a quantity. Is there an easier way to create an asset together with a quantity?

@Farmy It probably depends on what you’re representing?

I assumed that a quantity should belong to an asset, because an asset with a quantity zero is IMHO not an assett.

Are you referring to “inventory” of the asset? Or some other kind of measurement associated with the asset?

Generally speaking, Logs are what give all (most) meaning to assets, because they situate them in a specific time and place. Certain things might make sense as “static” properties of an asset… but most things will change over time, and therefore they should be tracked via logs. This creates a rich history of those changes to look back on.

Inventory is one of those things. You start with an asset (eg: “Flock of chickens”), and then you assign it an initial inventory with a log (eg: “Purchased 100 chickens”). Additional logs can increment/decrement/reset that inventory (eg: “2 chickens killed by fox”, “Butchered 10 chickens”, “Purchased an additional 25 chickens”, etc). So over time you can look back and understand how your inventory changed over time.

Animal weight is similar. You can use Observation logs to record weight measurements over time so you can calculate things like daily weight gain etc.

It may seem extraneous to require two records to start (and asset + a log), but this is a core part of the farmOS data model, and is what allows for so much flexibility. If the “time to enter data” is a concern, then the solution is to create helper UIs for making that bit easier. For example, a “quick form” that creates all the records from a single form (eg: the Planting quick form will create a Plant asset + Seeding/Transplanting/Harvest logs).

Hope that helps to clarify the thinking! Curious what specific cases you are thinking through… :slight_smile:

@mstenta Thank you for the explanation.
I’ve been thinking about the following case: The asset “field” should have the quantity “free square meters”, which is the whole field size at the beginning. After seeding in the first week I would decrement the “free square meters” by e.g. 10% of the initial space, then after seeding in the next week I would reduce by another 15%. After harvesting I would increase the “free square meters” again. At the end I would like to see on the dashboard how much “free square meters” this field has.

1 Like

Ah very cool idea @Farmy!

You might be able to achieve something like that with the existing inventory management features (with the exception of the dashboard summary, but that could probably be done as a follow-up), although it would be a lot of manual data management at first. A fully automated system could probably use the same approach but do some of that stuff for you.

Something like this:

First, create a Land asset to represent the field.
Then, create an Observation log with a quantity:

  • Measure: Area
  • Value: [total square meters, eg 100]
  • Units: m2
  • Label: total free space
  • Inventory adjustment type: Reset
  • Inventory asset: [reference the Land asset created in step 1).

Go to the Land asset and you should see the inventory summarized.

Next, create a Seeding log, with a quantity:

  • Measure: Area
  • Value: [how much area was seeded, eg: 10]
  • Units: m2
  • Label: (leave blank)
  • Inventory adjustment type: Decrement
  • Inventory asset: [reference the Land asset created in step 1).

Then go back to the Land asset and the inventory should be 90 m2.

It’s a bit rough… but demonstrates a way to do something like that right now with the existing inventory system.

If I were to design a more full-featured “free space” management system, I might build a more dedicated thing, perhaps with a computed field on the asset that look at all the geometries of currently planted crops. That assume, of course, that you are recording exact geometries for each.

Just some food for thought… :slight_smile:

1 Like

That works @mstenta .

Instead of checking the inventory of every single land asset and calculating all changes manually, I would love to add the field “current inventory” to the page /assets/land. I wanted to add this field to the View “Farm Asset”, but couldn’t find it. Is it possible at all to add “current inventoy” to the page /assets/land?

2 Likes

Ah yea, I believe we actually had this in farmOS v1, but it hasn’t been replicated in v2 yet.

farmOS v2 does already adds a “computed field” for inventory on assets (so you can get a summary of the current inventory levels for the asset).

I think we just need to “describe” this field to Views in order for it to “magically appear” in the Views UI so you can add it as a column. Here’s an example of how we’re doing that for the location computed field: farmOS/farm_location.views.inc at 2.x · farmOS/farmOS · GitHub

1 Like

@mstenta I did what you proposed and created the file farm_inventory_views.inc. The field “Current inventory” appeared then in the Views UI. After pressing the “Apply” button the following error occured: “The handler for this item is broken or missing. The following details are available: Enabling the appropriate module may solve this issue. Otherwise, check to see if there is a module update available.”
I guess there is more to do than just adding the inc file. As I’m not a professional Drupal programmer I need some more help…

1 Like

Oh yes - I forgot another piece. In the [module].views.inc function, it references a specific plugin ID:

That is a reference to this PHP class/file: farmOS/AssetLocation.php at 2.x · farmOS/farmOS · GitHub

As you can see, it’s just an empty class, and the @ViewsField("asset_location") annotation is what defines the “ID”.

So this is probably what the function will look like:

/**
 * Implements hook_views_data_alter().
 */
function farm_inventory_views_data_alter(array &$data) {

  // Add computed field to assets.
  if (isset($data['asset'])) {

    // Computed location.
    $data['asset']['location'] = [
      'title' => t('Current inventory'),
      'field' => [
        'id' => 'asset_inventory',
        'field_name' => 'inventory',
      ],
    ];
  }
}

And this is what the plugin class would look like:

<?php

namespace Drupal\farm_location\Plugin\views\field;

use Drupal\views\Plugin\views\field\EntityField;

/**
 * A field that displays asset inventory.
 *
 * @ingroup views_field_handlers
 *
 * @ViewsField("asset_inventory")
 */
class AssetInventory extends EntityField {

}
1 Like

Phantastic! It works now. Thank you @mstenta .

1 Like

I’m still struggling with the logs:

  1. After creating an asset I wanted to add a quantity with a log (clicked “add activity log” in the asset view). In the log form I clicked “Add new quantity”. Then I had the choice for “Inventory adjustment”:
    a. N/A - the quantity was created as expected, but not added to the inventory
    b. other options - the quantity was created and added to the inventory as expected, but I had to select one more time the asset itself, from where I started the logging. Why was it programmed that way?

  2. After doing step 1.b I wanted to modify the quantity of the same asset with a log (clicked “add activity log” in the asset view). In the log form - quantity section, the button “Add existing quantity” appeared, but by pressing it nothing happened. What did go wrong?
    grafik

the quantity was created and added to the inventory as expected, but I had to select one more time the asset itself, from where I started the logging. Why was it programmed that way?

It is possible for a log to adjust the quantity of multiple assets, and the inventory adjustment may have nothing to do with the “Asset” field on the log itself.

Imagine this simple example: “Spread manure on Field A and decrement the compost pile inventory”

  • Input log
  • References “Field A” in the log’s “Assets” field (indicating that the input was applied to that asset).
  • w/ Quantity:
    • Inventory asset: “Compost pile”
    • Inventory adjustment type: “Decrement”

This is working as designed, but perhaps the workflow isn’t intuitive, as indicated by:

After creating an asset I wanted to add a quantity with a log (clicked “add activity log” in the asset view).

The “add log” link will automatically reference the asset you came from in the “Assets” field of the log, because the general assumption is that you’re recording something that happened to that asset. But it doesn’t touch the inventory assets at all.

I think the best next step in this regard would be to create some inventory management quick forms, which can serve as the “canonical” place to go to adjust inventories - with a simple set of input questions and it automatically creates the necessary logs/quantities/references when submitted.

After doing step 1.b … In the log form - quantity section, the button “Add existing quantity” appeared, but by pressing it nothing happened.

Hmm that’s odd, and may be a bug.

farmOS uses the “Inline Entity Form” module for the “Add quantity” button, which provides generic functionality for creating/linking other entities (eg: quantities) to the entity that you’re working with (eg: the log). Technically, it also allows you to link existing entities, but the farmOS data model assumes that quantities are never shared across multiple logs… so the fact that it is (almost) allowing you to do that isn’t desireable.

Are you able to reproduce this consistently?

Thank you @mstenta for the explanation.

And yes, I’m able to reproduce the bug consistently.

1 Like

And yes, I’m able to reproduce the bug consistently.

Hmm could you provide steps to reproduce from a fresh farmOS installation? I’m not able to make this happen when I try it. Have you changed any configuration in your instance?

You can create a “demo” farmOS instance here: https://farmos-demo.rootedsolutions.io/

I can’t reproduce it with https://farmos-demo.rootedsolutions.io/, because I can’t “Manage form display” of log types there. What I basically did is to change the “Quantity” field configuration of the log type from


to

If I add a log with the changed field configuration, then the button “Add new quantity” works, but the button “Add existing quantity” doesn’t.
grafik

1 Like

Ah ok - so that’s a customization that would actually go against the intended farmOS data model. You shouldn’t reference existing quantities from multiple logs.

It’s not a bug because it’s a change that you made to the lower-level Drupal configuration.

1 Like

@mstenta unfortunately, I still don’t get it resp. can’t reproduce it. Here is another example:

After I set the log status to done, the inventories of the two seed assets were incremented and the activity log listed under “Seeds box logs”. Under " Assets in Seeds box" I expected to see the two seed assets, but instead I see there the asset “Seeds box” itself:

What do I have to change to see the seed assets in the “Seeds box”?

@Farmy not sure I completely follow… but here is how “movements and location” work for reference: Location | farmOS

So that log you created is essentially moving “Seeds box” to itself (which probably shouldn’t be possible… maybe we need some logic to prevent that in farmOS). If you wanted to move your seed assets to “Seeds” box then those should be referenced in the “Assets” field on the log. Thus, if you wanted to use one log to BOTH move AND increment inventory, you need to reference those assets in BOTH the “Assets” field on the log AND the “Inventory assets” field on the quantities.

1 Like