def create(request, values):
    """Creates a new Test Run object and stores it in the database.

    :param dict values: a mapping containing these data to create a test run.

        * plan: (int) **Required** ID of test plan
        * build: (int)/(str) **Required** ID of Build
        * manager: (int) **Required** ID of run manager
        * summary: (str) **Required**
        * product: (int) **Required** ID of product
        * product_version: (int) **Required** ID of product version
        * default_tester: (int) optional ID of run default tester
        * plan_text_version: (int) optional
        * estimated_time: (str) optional, could be in format ``2h30m30s``, which is recommended or ``HH:MM:SS``.
        * notes: (str) optional
        * status: (int) optional 0:RUNNING 1:STOPPED  (default 0)
        * case: list or (str) optional list of case ids to add to the run
        * tag: list or (str) optional list of tag to add to the run

    :return: a mapping representing newly created :class:`TestRun`.
    :rtype: dict

    .. versionchanged:: 4.5
       Argument ``errata_id`` is removed.

    Example::

        values = {
            'build': 2,
            'manager': 1,
            'plan': 1,
            'product': 1,
            'product_version': 2,
            'summary': 'Testing XML-RPC for TCMS',
        }
        TestRun.create(values)
    """
    from datetime import datetime

    from tcms.core import forms
    from tcms.testruns.forms import XMLRPCNewRunForm

    if not values.get("product"):
        raise ValueError("Value of product is required")
    # TODO: XMLRPC only accept HH:MM:SS rather than DdHhMm

    if values.get("estimated_time"):
        values["estimated_time"] = pre_process_estimated_time(values.get("estimated_time"))

    if values.get("case"):
        values["case"] = pre_process_ids(value=values["case"])

    form = XMLRPCNewRunForm(values)
    form.populate(product_id=values["product"])

    if form.is_valid():
        tr = TestRun.objects.create(
            product_version=form.cleaned_data["product_version"],
            plan_text_version=form.cleaned_data["plan_text_version"],
            stop_date=form.cleaned_data["status"] and datetime.now() or None,
            summary=form.cleaned_data["summary"],
            notes=form.cleaned_data["notes"],
            estimated_time=form.cleaned_data["estimated_time"],
            plan=form.cleaned_data["plan"],
            build=form.cleaned_data["build"],
            manager=form.cleaned_data["manager"],
            default_tester=form.cleaned_data["default_tester"],
        )

        if form.cleaned_data["case"]:
            for c in form.cleaned_data["case"]:
                tr.add_case_run(case=c)
                del c

        if form.cleaned_data["tag"]:
            tags = form.cleaned_data["tag"]
            tags = [c.strip() for c in tags.split(",") if c]

            for tag in tags:
                t, c = TestTag.objects.get_or_create(name=tag)
                tr.add_tag(tag=t)
                del tag, t, c
    else:
        raise ValueError(forms.errors_to_list(form))

    return tr.serialize()