adding custom fields to project
Hi,
I'm trying to add custom fields to an existing project. This seems not to work, while updating existing custom fields in a project works fine. The documentation's example https://python-redmine.com/resources/project.html#save isn't saying if the custom_fields exist in the example and get updated or if they're added to the project. So I'm not sure if it's a bug or not.
You can reproduce it by creating a custom field via the GUI, e.g. a simple true/false one, and a project that has no custom fields enabled in its settings (here "templates")
Then run
blub = redmine.project.get('templates', include = ['trackers', 'issue_categories', 'enabled_modules' ])
and
dir(blub.custom_fields)
will show "redminelib.exceptions.ResourceAttrError: Resource doesn't have the requested attribute" correctly.
Then proceed as in the manual:
blub.custom_fields = [{'id': 71, 'value': 0 }]
dir(blub.custom_fields) # now populated
blub.save()
Now open the project in the UI and there's still no custom field enabled.
Activating the custom field via the UI and doing the above again will show no error when running
dir(blub.custom_fields)
after retrieving the project and I can happily toggle the custom field's value on and off as expected.
Hi @laaber
This is an expected behaviour from Redmine and its API. You won't be able to work with custom fields unless they're enabled for the needed resource i.e. project, issue etc.
Closing this due to inactivity.