Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

How to send messages about progress from an executing model method

By
Javier
on 3/14/16, 9:05 PM 317 views

Hi,

I have a python method which execution lasts some time and would like to inform the user about process progres. I wonder if there is a way to do it from inside the method or somehow else? Can anybody provide guidance on it?

Thanks in advance for your reply.

0

Axel Mendoza

--Axel Mendoza--
10318
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 3/15/16, 5:54 AM

You could publish messages in a chat channel for that and open the chat channel for the user. I planned to do that in a module but i dont do it yet. If you do that please share your results

It seems to me that I will have to submit the process as a cron job besides using chat. Since I haven't done anything neither with crons nor with chat, I will have to find out about them and as soon as I have worked on this solution will be back here to comment it. Thanks a lot for your response.

Javier
on 3/15/16, 10:57 AM
0
Javier
On 3/15/16, 10:56 AM

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

 

happy to help, thanks for sharing it

Axel Mendoza
on 3/17/16, 4:18 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/14/16, 9:05 PM
Seen: 317 times
Last updated: 3/17/16, 2:38 AM