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

View file

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

View file

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