Send Mail From Any Button From OpenERP
OpenERP enables user to send and receive emails when an action is done from OpenERP. We can configure emails to be send when a sale is confirmed or invoice is paid etc. But to implements these type of functionality, we need to change the functions that is being called from these button actions.
We need to call the send_mail function in these button actions to send mail. OpenERP enables to send mail using “Automated Actions” but we cannot configure it when a button action is done for example when a report is printed from a button action. This requires change in code.
We have developed a module in such a way that the user will be able to configure to which button action mail is to be send. User requires some technical knowledge about OpenERP like button name, button type etc. Module adds a new menu in location “Settings > Button Mail Configuration > Button Mail Configuration” where user will be able to configure the button actions. A screenshot is shown below:
Field details that are used to configure is given below:
-
Name : Name of the configuration. Main purpose of this field is for identification of configuration.
-
Model : Model for which the mail is to be send. The button action should belong to the model defined in this field.
-
Method : The name of the button for which the mail is to be send. Name of the button can be found out by enabling the debug mode of OpenERP.
-
Button Type : If the button is of type Object or Workflow. Object buttons will call a python function when clicked and the workflow button will send a workflow signal to trigger a workflow process. If there is attribute in button definition as <button….. type=”object”…/> then it is a object button. If there is no type attribute in button definition, its a workflow button. An screenshot showing the workflow button and object button in fields_view_get window from debug mode is shown below:
-
Send Mail After : If the mail is to send after function execution. After workflow trigger incase of workflow buttons.
-
Send Mail Before : If the mail is to send before function execution. Before workflow trigger incase of workflow buttons.
-
Email Template : Email template to be used for sending mail. Template can be defined from the menu “Settings > Technical > Email > Templates“. Here you can define the the mail sender and recipient addresses, mail body etc.
-
Resource ID Field : Expression to fetch the resource id to use for sending the emails. Argument like ids, context and all the arguments that are passed to the function being called can be fetched from a dictionary “arguments”. For example argument.get(‘ids’, []) or argument.get(‘context’, {}).get(‘active_ids’, []). This option will be available for button actions of type “Object”. A screenshot of configuration to send mails on confirming a quotation is given below:
This configuration will send mail after triggering the purchase_confirm workflow signal.
Model : Model for which the mail is to be send. The button action should belong to the model defined in this field.
Method : The name of the button for which the mail is to be send. Name of the button can be found out by enabling the debug mode of OpenERP.
Button Type : If the button is of type Object or Workflow. Object buttons will call a python function when clicked and the workflow button will send a workflow signal to trigger a workflow process. If there is attribute in button definition as <button….. type=”object”…/> then it is a object button. If there is no type attribute in button definition, its a workflow button. An screenshot showing the workflow button and object button in fields_view_get window from debug mode is shown below:
Model : Model for which the mail is to be send. The button action should belong to the model defined in this field.
Method : The name of the button for which the mail is to be send. Name of the button can be found out by enabling the debug mode of OpenERP.
Button Type : If the button is of type Object or Workflow. Object buttons will call a python function when clicked and the workflow button will send a workflow signal to trigger a workflow process. If there is attribute in button definition as <button….. type=”object”…/> then it is a object button. If there is no type attribute in button definition, its a workflow button. An screenshot showing the workflow button and object button in fields_view_get window from debug mode is shown below:
Comments
Leave a Reply