Hello,
I am done and it seems to be working allright. Took me some time since channels were not working properly on my installed version and had to find out some bit more. In order to reach the intended behavior, I am calling from my view the function named submit_long_process and this in turn calls the long-process function which writes to the channel.
Thanks a lot Axel. I appreciate again your guidance.
Javier.
@api.one
def submit_long_process(self):
from openerp.exceptions import ValidationError
import datetime
from dateutil.parser import parse
from openerp import fields
id_value='(None, '+str(self.id)+',)'
my_dict={
'name': 'Cron job para enviar mensajes de correo---ok',
'function': 'long_process',
'args': id_value,
'model': 'hr.payslip.run',
'doall': False
}
self.env['ir.cron'].create(my_dict)
self.env.cr.commit()
return True
@api.multi
def long_process(self, id):
k_obj=self.env['mail.message']
values={'body': u'Starting long process.......',
'model': 'mail.channel', 'attachment_ids': [], 'res_id': 4,
'email_from': u'test <test@empresa.com>', 'parent_id': False,
'subtype_id': 1, 'author_id': 6, 'message_type': u'comment',
'partner_ids': [], 'subject': False}
my_id=k_obj._get_message_id(values)
new_rec = k_obj.create({'body': u'Starting long process.......',
'model': 'mail.channel',
'res_id': 4,
'email_from': u'test <test@empresa.com>',
'parent_id': False,
'subtype_id': 1,
'author_id': 6,
'message_type': u'comment',
'record_name': 'canal1',
'reply_to': 'Administrator <admin@example.com>',
'message_type': 'comment',
'email_from': 'Administrator <admin@example.com>',
'message_id': my_id})
{{---------------RUNNING LONG PROCESS-------}}}
return True