From 8186d4356f018bdd3a9926d1f564033690bf0344 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Wed, 16 Feb 2022 17:47:31 +0100 Subject: [PATCH] shopfloor: fix form mixin validators --- shopfloor/services/forms/form_mixin.py | 17 +++++++++++++++-- shopfloor/services/forms/picking_form.py | 16 +++++++--------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/shopfloor/services/forms/form_mixin.py b/shopfloor/services/forms/form_mixin.py index f0d1d4aaa79..44ddda84fdf 100644 --- a/shopfloor/services/forms/form_mixin.py +++ b/shopfloor/services/forms/form_mixin.py @@ -54,10 +54,23 @@ class ShopfloorFormMixinValidator(AbstractComponent): _usage = "form_mixin.validator" def get(self): - raise NotImplementedError() + return { + # TODO @simahawk: remove the need for this + # The black magic in base_rest + # is going to register the endpoint as `/int:id/get` (or `/update`) + # hence what is coming after as param is going to value `id` + # and `_id` as we expect in the method (to avoid using a built-in name). + # In theory we can replace this validator w/ proper restapi decorator. + "id": {"type": "integer", "rename": "_id"}, + "_id": {"type": "integer"}, + } def update(self): - raise NotImplementedError() + return { + # TODO @simahawk: remove the need for this + "id": {"type": "integer", "rename": "_id"}, + "_id": {"type": "integer"}, + } class ShopfloorFormMixinValidatorResponse(AbstractComponent): diff --git a/shopfloor/services/forms/picking_form.py b/shopfloor/services/forms/picking_form.py index daf51f23479..6390120c5f5 100644 --- a/shopfloor/services/forms/picking_form.py +++ b/shopfloor/services/forms/picking_form.py @@ -45,16 +45,14 @@ class ShopfloorPickingFormValidator(Component): _name = "shopfloor.form.stock.picking.validator" _usage = "form_edit_stock_picking.validator" - def get(self): - return { - "id": {"type": "integer", "rename": "_id"}, - "_id": {"type": "integer"}, - } - def update(self): - return { - "carrier_id": {"type": "integer", "required": True}, - } + schema = super().update() + schema.update( + { + "carrier_id": {"type": "integer", "required": True}, + } + ) + return schema class ShopfloorPickingFormValidatorResponse(Component):