fix: set material types when creating new log w/ material quantity

This commit is contained in:
Lance Edgar 2026-03-22 14:24:20 -05:00
parent d9ed0de775
commit 066fcb857f
3 changed files with 15 additions and 8 deletions

View file

@ -138,6 +138,11 @@ class WuttaFarmMenuHandler(base.MenuHandler):
"route": "land_types", "route": "land_types",
"perm": "land_types.list", "perm": "land_types.list",
}, },
{
"title": "Material Types",
"route": "material_types",
"perm": "material_types.list",
},
{ {
"title": "Plant Types", "title": "Plant Types",
"route": "plant_types", "route": "plant_types",
@ -218,11 +223,6 @@ class WuttaFarmMenuHandler(base.MenuHandler):
"route": "log_types", "route": "log_types",
"perm": "log_types.list", "perm": "log_types.list",
}, },
{
"title": "Material Types",
"route": "material_types",
"perm": "material_types.list",
},
{ {
"title": "Measures", "title": "Measures",
"route": "measures", "route": "measures",

View file

@ -847,12 +847,18 @@
} }
const measureMap = {} const measureMap = {}
for (let m of this.measures) { for (const m of this.measures) {
measureMap[m.drupal_id] = m.name measureMap[m.drupal_id] = m.name
} }
const quantityTypeMap = {}
for (const qt of this.quantityTypes) {
quantityTypeMap[qt.drupal_id] = qt.name
}
return { return {
measureMap, measureMap,
quantityTypeMap,
quantityType: this.defaultQuantityType, quantityType: this.defaultQuantityType,
editShowDialog: false, editShowDialog: false,
editNew: true, editNew: true,
@ -893,8 +899,7 @@
this.newQuantity.quantity_type = { this.newQuantity.quantity_type = {
drupal_id: this.quantityType, drupal_id: this.quantityType,
## TODO: add support for other quantity types name: this.quantityTypeMap[this.quantityType],
name: "Standard",
} }
this.newQuantity.measure = null this.newQuantity.measure = null

View file

@ -408,6 +408,8 @@ class LogMasterView(WuttaFarmMasterView):
value_denominator=denom, value_denominator=denom,
units=units, units=units,
) )
if qty.quantity_type_id == "material":
self.set_material_types(qty, new_qty["material_types"])
# nb. must ensure "typed" quantity record persists! # nb. must ensure "typed" quantity record persists!
session.add(qty) session.add(qty)
# but must add "generic" quantity record to log # but must add "generic" quantity record to log