OBGM-551 Unable to Place PO#4129
OBGM-551 Unable to Place PO#4129awalkowiak merged 2 commits intofeature/upgrade-to-grails-3.3.10from
Conversation
| boolean canApproveOrder(Order order, User userInstance) { | ||
| if (isApprovalRequired(order)) { | ||
| List<RoleType> defaultRoleTypes = grailsApplication.config.openboxes.purchasing.approval.defaultRoleTypes | ||
| .collect { RoleType."$it" } |
There was a problem hiding this comment.
Can you first try to define it as defaultRoleTypes: [org.pih.warehouse.core.RoleType.ROLE_APPROVER] instead of "ROLE_APPROVER" in the application.yml? If that will work this should be the change. Otherwise, if that won't work, then I think we should discuss it in the tech huddle. The change to string in the applicaiton.yml was a quick temporary hotfix.
There was a problem hiding this comment.
Also, if that does not work I recommend we change the enum lookup from
RoleType."$it"
to
RoleType.valueOf(it)
There was a problem hiding this comment.
Actually an even better way to do this would be to use the approach suggested here https://grails.org/blog/2016-08-31.html
Either inject the value into the class
@Value('${openboxes.purchasing.approval.defaultRoleTypes:[RoleType.ROLE_APPROVER]}')
List<RoleType> defaultRoleTypes
or pull the property from the config object
List<RoleType> defaultRoleTypes = grailsApplication.config.getProperty("openboxes.purchasing.approval.defaultRoleTypes", List, [RoleType.ROLE_APPROVER])
Unfortunately neither of these approaches seem to coerce the object into the proper type List.
So let's just use the collect { return RoleType.valueOf(it) } approach.
| boolean canApproveOrder(Order order, User userInstance) { | ||
| if (isApprovalRequired(order)) { | ||
| List<RoleType> defaultRoleTypes = grailsApplication.config.openboxes.purchasing.approval.defaultRoleTypes | ||
| .collect { RoleType."$it" } |
There was a problem hiding this comment.
Also, if that does not work I recommend we change the enum lookup from
RoleType."$it"
to
RoleType.valueOf(it)
Roles passed from the application.yaml weren't properly compared with the values from
getEffectiveRoles(user)(it always returnedfalse, so we didn't have appropriate privileges to perform actions).