Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Email aliasing in odoo

140 views

Published on

Email aliasing is a default feature in Odoo which allows the user to fetch contents to ERP records directly from incoming emails. The feature is a type of automation. Since we can configure the E-mails to fetch contents directly; it reduces the human effort and simplifies the business process

Published in: Business
  • Be the first to comment

  • Be the first to like this

Email aliasing in odoo

  1. 1. www.cybrosys.com Email Aliasing in Odoo
  2. 2. INTRODUCTION • Email aliasing is a default feature in Odoo which allows the user to fetch contents to ERP records directly from incoming emails. The feature is a type of automation. Since we can configure the E-mails to fetch contents directly; it reduces the human effort and simplifies the business process.
  3. 3.  To do so we have to follow the following steps. 1. Configure default alias name and alias domain 2. Create a record in model ‘Aliases’ 3. Change ‘message_new’ global function according to your need 4. Configure incoming mail with an Action
  4. 4.  Configure default alias name and alias domain  The first step is to configure the default alias name and domain. We can fetch the alias domain from ir.config_parameter. To perform these two tasks, we have to add following fields. alias_prefix = fields.Char('Default Alias Name) alias_domain = fields.Char('Alias Domain', default=lambda self: self.env["ir.config_parameter"].get_param("mail.catchall.domain"))
  5. 5.  For eg:- Suppose we need to fetch emails from the mail id ‘leave_request@cybrosys.in’. So here Alias name is ‘leave_request’ and alias domain is ‘cybrosys.in’. We have to set default alias domain in general settings. For that, go to Settings -> General Settings And provide alias domain in the field.
  6. 6.  Create a record in model ‘Aliases’  The second step is to create a record in ‘Aliases’ model. For that, we have to add an XML file as follow. <record id="mail_alias_leave" model="mail.alias"> <field name="alias_name">leave</field> <field name="alias_model_id" ref="model_hr_holidays"/> <field name="alias_user_id" ref="base.user_root"/> <field name="alias_contact">employees</field> </record>
  7. 7.  Here we have to 'refer' the model in the field ‘alias_model_id’. This is the model which we need to create the record from our incoming mail. Then we can see this record from user interface too.  Go to Settings-> Technical -> Email-> Aliases  Change ‘message_new’ global function according to the need
  8. 8.  The next step is to modify the global function ‘message_new’ according to the need. Here we can add parameters which we need to create a record into the dictionary ‘custom_values’. When we update the ‘custom_values’ dictionary, our record will be created according to that information. def message_new(self, msg_dict, custom_values=None): if custom_values is None: custom_values = {} email_address = email_split(msg_dict.get('email_from', False))[0] user = self.env['res.users'].search([ '|', ('email', 'ilike', email_address)) ], limit=1) msg_subject = msg_dict.get('subject', '') msg_body = msg_dict.get('body', '') custom_values.update({ 'name': msg_subject.strip(), 'user_id': user.id, }) return super(HrLeaveAlias, self).message_new(msg_dict, custom_values)
  9. 9.  Here we can find the incoming mail id by using ‘email_split’. For that, we need to import this library from odoo.tools. Eg:- from odoo.tools import email_split  Also we can fetch email subject and body from ‘msg’ parameter. Eg:- msg_subject = msg_dict.get('subject', '') msg_body = msg_dict.get('body', '')  In custom values, we can update any values into the corresponding field.
  10. 10.  Configure incoming mail with an Action  The final step is to configure the incoming emails with an action.
  11. 11.  Form the label ‘Actions to Perform on Incoming Mails’, we can create actions on 1. Record 2. Server Action  If we select a record it will automatically create record while clicking on the button ‘Fetch New’. If we select a server action then it will run while clicking on the button ‘Fetch New’.
  12. 12. Refer this link for more: https://www.cybrosys.com/blog/email-aliasing-in-odoo
  13. 13. Thank You ! Cybrosys Technologies Pvt. Ltd. Neospace, Kinfra Techno Park, Kakkancherry, Calicut University P.O. Calicut Kerala, India - 673635. Cybrosys Ltd 15, ST Antonys Road, Forest Gate, London England, E79QA. Cybrosys Technologies Pvt. Ltd. 1st Floor, Thapasya Building, Infopark, Kakkanad, Kochi, Kerala, India-682030.

×