Thanks for the pointer, Keyur.
In the interest of completion, I'll include exactly what I did so that there's a definitely working example in this answer.
(I'm modeling the requirement to perform a test on some equipment. The test_module.test model is the results of the test. When one of these objects is created, I want to create a Task that will track actually doing it.)
First, I added the logic to create a Task when my Test is created:
#this is in class test_module_test...
def test_pending(self, cr, uid, ids):
project_task = self.pool.get('project.task')
for test in self.browse(cr, uid, ids, context=None):
#create the task for this new test
print "Creating task for Test"
task_id = project_task.create(cr, uid, {
'name': test.task_name(),
'user_id': test.task_uid(),
'description': test.task_description(),
test.column_for_test_id_in_task: test.id,
}, context=None)
self.write(cr,uid, ids, {'state':'pending', 'created_on': time.strftime('%Y-%m-%d')})
return True
Then, in my modules.py file, I added the following class:
This class inherits from project.task, overriding the case_close method to signal my Test that it has been submitted.
class test_module_test_task(osv.osv):
_name='project.task'
_inherit='project.task'
_columns = {
'test_id': fields.many2one('eggrule.se_environmental_test', "SE Env. Test", ondelete='restrict'),
}
def case_close(self, cr, uid, ids, context=None):
#if the super method succeeds...
if super(test_module_test_task, self).case_close(cr, uid, ids, context=context):
print "About to signal task workflows, if there are any"
wf_service = netsvc.LocalService("workflow")
#for each object that we were passed...
for task in self.browse(cr, uid, ids):
#if there is an environmental test...
if task.test_id:
#signal it...
wf_service.trg_validate(uid, 'test_module.test', task.test_id.id, "test_submitted", cr)
return True
#else, the super method failed... (can't happen)
return False
Voila!