Product Category

Added in version 2.5.0.

Requires Pro Edition and Products plugin >= 2.1.5.

Manager

All operations on the ProductCategory resource are provided by its manager. To get access to it you have to call redmine.product_category where redmine is a configured redmine object. See the Configuration about how to configure redmine object.

Create methods

create

redminelib.managers.ResourceManager.create(**fields)

Creates new ProductCategory resource with given fields and saves it to the Products plugin.

Parameters:
  • name (string) – (required). Category name.

  • code (string) – (optional). Category code.

  • parent_id (int) – (optional). Category parent id.

Returns:

Resource object

>>> category = redmine.product_category.create(
...     name='Software',
...     code='S-001',
...     parent_id=13
... )
>>> category
<redminelib.resources.ProductCategory #123>

new

redminelib.managers.ResourceManager.new()

Creates new empty ProductCategory resource, but saves it to the Products plugin only when save() is called, also calls pre_create() and post_create() methods of the Resource object. Valid attributes are the same as for create() method above.

Returns:

Resource object

>>> category = redmine.product_category.new()
>>> category.name = 'Software'
>>> category.code = 'S-001'
>>> category.parent_id = 13
>>> category.save()
<redminelib.resources.ProductCategory #123>

Read methods

get

redminelib.managers.ResourceManager.get(resource_id, **params)

Returns single ProductCategory resource from the Products plugin by its id.

Parameters:

resource_id (int) – (required). Id of the product category.

Returns:

Resource object

>>> category = redmine.product_category.get(123)
>>> category
<redminelib.resources.ProductCategory #123>

all

redminelib.managers.ResourceManager.all(**params)

Returns all ProductCategory resources from the Products plugin.

Parameters:
  • limit (int) – (optional). How much resources to return.

  • offset (int) – (optional). Starting from what resource to return the other resources.

Returns:

ResourceSet object

>>> categories = redmine.product_category.all(limit=50)
>>> categories
<redminelib.resultsets.ResourceSet object with ProductCategory resources>

filter

Not supported by Products plugin

Update methods

update

redminelib.managers.ResourceManager.update(resource_id, **fields)

Updates values of given fields of a ProductCategory resource and saves them to the Products plugin.

Parameters:
  • resource_id (int) – (required). Category id.

  • name (string) – (optional). Category name.

  • code (string) – (optional). Category code.

  • parent_id (int) – (optional). Category parent id.

Returns:

True

>>> redmine.product_category.update(
...     123,
...     name='Software',
...     code='S-001',
...     parent_id=13
... )
True

save

redminelib.resources.ProductCategory.save(**attrs)

Saves the current state of a ProductCategory resource to the Products plugin. Attrs that can be changed are the same as for update() method above.

Returns:

Resource object

>>> category = redmine.product_category.get(123)
>>> category.name = 'Software'
>>> category.code = 'S-001'
>>> category.parent_id = 13
>>> category.save()
<redminelib.resources.ProductCategory #123>

Added in version 2.1.0: Alternative syntax was introduced.

>>> category = redmine.product_category.get(123).save(
...     name='Software',
...     code='S-001',
...     parent_id=13
... )
>>> category
<redminelib.resources.ProductCategory #123>

Delete methods

delete

redminelib.managers.ResourceManager.delete(resource_id)

Deletes single ProductCategory resource from the Products plugin by its id.

Parameters:

resource_id (int) – (required). Category id.

Returns:

True

>>> redmine.product_category.delete(123)
True
redminelib.resources.ProductCategory.delete()

Deletes current ProductCategory resource object from the Products plugin.

Returns:

True

>>> category = redmine.product_category.get(1)
>>> category.delete()
True

Export

Not supported by Products plugin