This question has been flagged

I'm a bit of a newbie to OpenERP/Odoo, and am slowly trying to come up to speed with it (but it's a pretty steep learning curve it seems).

I've become disappointed by the free/OpenSource Test Management Packages available (TestLink seems the best of them), so would like to incorporate something into Odoo to perform this role.

I have five 'classes' related to this question, and they are within an addon module called 'testing', the classes are:

'testcaseparameter', 'testcaseparametertemplate', 'testcasestep', 'testcase', and 'testcasetemplate'

The testcase class contains a many2one field to a testcasetemplate, with that testcasetemplate having one2many fields for both testcasestep(s) and testcaseparametertemplate(s).  The testcase class also has a related field for the testcasestep(s) (linked via its testcasetemplate_id reference to the steps of the associated testcasetemplate), and a separate one2many field for testcaseparameter(s).

I have a form displaying the testcase and letting me choose the testcasetemplate, and when I save and redisplay everything is ok.  However I wish for the display of the testcasestep(s) to be updated after changing the testcasetemplate within the form.  I understand this requires an on_change method.

I currently have (in the testcase on_change):

    def on_change_template_id(self, cr, uid, ids, template_id, context=None):
        vals = {}
        if template_id:
            vals["template_id"] = (6, 0, template_id)
            step_ids = self.pool.get("testing.testcasestep").search(cr, uid, [('testcasetemplate_id','=',template_id)])
            vals["step_ids"] = (6, 0, step_ids)
        else:
            vals["step_ids"] = []
        return {"value": vals}

However it complains saying:

  File "/opt/odoo/openerp/fields.py", line 1381, in convert_to_cache
    raise ValueError("Wrong value for %s: %s" % (self, value))
ValueError: Wrong value for testing.testcase.step_ids: (6, 0, [1,2])

I also want to use the testcaseparametertemplate one2many (from the testcasetemplate) to generate a set of matching testcaseparameter(s) (using just the char field of 'name' from the testcaseparametertemplate(s)).  How would I do this?

Avatar
Discard
Best Answer

Hi..

Syntax written for assigning One2Many values is not correct..

It should be vals["step_ids"] = [(6, 0, step_ids)]    (i.e) list of tuples format

Avatar
Discard