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

Don't send automatic e-mail when confirming quotation?

By
Yenthe
on 5/4/15, 11:27 AM 1,231 views

Hi guys,

When you have portal activated you'll get an automatic e-mail saying something along these lines:

 Quotation confirmed
    • Customer: Yenthe
    • Untaxed Amount: 1.

The problem is that I do not want this message to be e-mailed. Any message should be e-mailed to the customer when the portal is active, except this one.
The message is made by the function format_message in mail/mail_thread.py:

 def format_message(message_description, tracked_values):
            message = ''
            if message_description:
                message = '<span>%s</span>' % message_description
            for name, change in tracked_values.items():
                message += '<div> &nbsp; &nbsp; &bull; <b>%s</b>: ' % change.get('col_info')
                if change.get('old_value'):
                    message += '%s &rarr; ' % change.get('old_value')
                message += '%s</div>' % change.get('new_value')
            return message
        if not tracked_fields:
            return True

This function posts the message to the view (in the chatter) but the problem is that somewhere else an action is triggered to send this message as an e-mail to the user.

So, my question, how can I / what is the best way to prevent this message to be send by email but allow anything else to be e-mailed to the customers?

Thanks,
Yenthe

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 10/14/15, 11:52 PM

You could read more about that here:

https://www.odoo.com/es_ES/forum/help-1/question/adding-messages-subtypes-for-product-changes-v7-91170#answer-91171

In your case you could disable that tracking of the needed fields just defining the field name in the _track dict with a lambda function that returns False like:

_track = {
    'field': {
'sale.mt_quotation.anything': lambda self, cr, uid, obj, ctx=None: False,
}
}

it will have the same results like you have with the change, the difference is that you need to define all the field tracked in your model in the _track dict

Axel Mendoza
on 10/14/15, 11:54 PM

I am facing the same issue, I want to mute only email for this subtype message "Quotation Confirmed". Trying your method now.

Ehtesham
on 10/28/15, 5:37 PM

Thanks, I just tried and it works as expected however I don't want to include all fields in my child model. I just want 'sale.mt_order_confirmed' to be set false. So in my child model instead of this _track = { 'state': { 'sale.mt_order_confirmed': lambda self, cr, uid, obj, ctx=None: False, 'sale.mt_order_sent': lambda self, cr, uid, obj, ctx=None: obj.state in ['sent'] }, } I want something like this _track['state']['sale.mt_order_confirmed'] = lambda self, cr, uid, obj, ctx=None: False Excuse my syntax I am new to Python, I just want to change the targeted field's specific state. just to be future proof.

Ehtesham
on 10/28/15, 6:05 PM

Then you are ready to vote the answer :). The other scenario that you describe require the extension of the message_track method in your model extension to support that behavior

Axel Mendoza
on 10/28/15, 6:09 PM
0

Yenthe

--Yenthe--
6721
| 7 7 8
Turnhout, Belgium
--Yenthe--

My Odoo blog: http://www.odoo.yenthevg.com/

My Twitter: https://twitter.com/Yenthe666

Yenthe
On 5/14/15, 10:32 AM

Hi guys,

Found the solution myself. In the module mail is a Python file named mail_thread. In mail_thread.py is a function def message_track(self, cr, uid, ids, tracked_fields, initial_values, context=None): and inside this function you will find the following code:

 for subtype in subtypes:
                subtype_rec = self.pool.get('ir.model.data').xmlid_to_object(cr, uid, subtype, context=context)
                if not (subtype_rec and subtype_rec.exists()):
                    _logger.debug('subtype %s not found' % subtype)
                    continue
                message = format_message(subtype_rec.description if subtype_rec.description else subtype_rec.name, tracked_values)
                self.message_post(cr, uid, browse_record.id, body=message, subtype=subtype, context=context)
                posted = True
            if not posted:
                message = format_message('', tracked_values)
                self.message_post(cr, uid, browse_record.id, body=message, context=context)

When you change the message variable in the first if condition there will be no more automatic messages e-mailed, not even when the portal is activated.Result:

 for subtype in subtypes:
                subtype_rec = self.pool.get('ir.model.data').xmlid_to_object(cr, uid, subtype, context=context)
                if not (subtype_rec and subtype_rec.exists()):
                    _logger.debug('subtype %s not found' % subtype)
                    continue
                message = format_message('', tracked_values)
                self.message_post(cr, uid, browse_record.id, body=message, context=context)
                posted = True
            if not posted:
                message = format_message('', tracked_values)
                self.message_post(cr, uid, browse_record.id, body=message, context=context)

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

2 follower(s)

Stats

Asked: 5/4/15, 11:27 AM
Seen: 1231 times
Last updated: 10/14/15, 11:52 PM