Allowing Material Quantities link to multiple Material Taxonomy Terms

So I’m using the Material Quantity type pretty extensively and the Material Taxonomy list. I’ve hit a snag, which is currently you may only link a single Material Taxonomy term to a Material Quantity log. In my cases, I’m using this field primarily as a reference for the types of materials included in this quantity. So I could add a herbicide named ‘greg’s horrible herbicide’, and enter:

  • Quantity
    • value: 10
    • relationships
      • material
        • herbicide
        • greg’s horrible herbicide

Another example: I’m adding mixes of products - a mix of fertilizers “hog manure”, “cow manure”, “chicken manure”.

  • Quantity
    • value: 10
    • relationships
      • material
        • hog manure
        • cow manure
        • chicken manure

I know that if I were doing inventory tracking, this conceptually wouldn’t make sense because I don’t know of the ‘value: 10’ which parts apply to which manure type. But I don’t care and I don’t even know, what I care about is knowing the component parts of whatever I applied (I might not even have a value! Sometimes I just use the quantity to reference material taxonomy terms).

Workarounds like making 3 different quantities and adding the value: 10 to one of them are wonky and furthermore provide inaccurate information (I didn’t add value: 10 for just the hog manure and nothing of the rest… it was a mix…). I also don’t want to use comma separate values, because you end up with a mess in your material taxonomy terms which I really want to effectively use.

So… would allowing material to reference multiple taxonomy_term--material cause issues / break anything in your modules / code? (remember, currently it allows only 1 reference).

I hope this is a small change, but I wanted to ask and see if anyone felt this could break something.

Thanks for the feedback!

2 Likes

Makes sense to me. I think the main question will be whether or not this is a “breaking change”. I don’t think it would be, but I’ll have to take a closer look…

It’s funny because you’re essentially asking for something we had in farmOS v1… which was too limited/ambiguous (couldn’t track granular quantity of each ingredient in a mix) and was the motivation for moving the material type reference to the quantity.

But when we did that, we just assumed that single term references were the only requirement. But what your describing does make sense… as a slightly less granular way of recording things… similar to v1, but still on the quantity.

1 Like

I think specifying down to 1 could also be a very reasonable convention, in a certain management system also.

2 Likes

Discussed in the FarmOS call 4/27/2023… turns out there is a breaking change because relationships.materials in the API goes from being a single object to an array :\ bummer that’s a breaking change.

So we’ll add a request for FarmOS 3.x, and we’ll add a module to change it in SurveyStack managed instances and other farmers using these tools.

3 Likes

Added a link to this from our 3.x tracking issue, so we don’t forget: [META] farmOS 3.x Breaking Changes [#3347412] | Drupal.org

I think next steps we discussed were:

  1. Open a dedicated farmOS | Drupal.org issue for making this change, with a patch or merge request, and mark the status as “Postponed” - so it’s ready to merge when the 3.x branch is opened.
  2. Enable altering of bundle fields (needs an issue of it’s own).
  3. Create a contrib “shim” module that alters the core material reference field definition to set 'multiple' => TRUE - for instances that want to enable this before 3.x.
1 Like
  1. Open a dedicated farmOS | Drupal.org issue for making this change, with a patch or merge request, and mark the status as “Postponed” - so it’s ready to merge when the 3.x branch is opened.

I created this issue, with a merge request: https://www.drupal.org/project/farm/issues/3357679

And linked it to our meta 3.x issue here: https://www.drupal.org/project/farm/issues/3347412

Created an issue for this as well: https://www.drupal.org/project/farm/issues/3357686

1 Like