宜兴通达竭诚为您服务。

通达科技 - 宜兴电脑维护及IT服务外包服务商

Create server actions
  • 上传者: Administrator
  • 上传时间:2025年05月03日 07时27分50秒
摘要:
* Create server actions ** *** Server actions are actions that work on the base models. These actions are executed automatically. Let’s check the way ......
正文 相关文章 请喝咖啡

    Create server actions

    Server actions are actions that work on the base models. These actions are executed automatically. Let’s check the way how it is created;

    After enabling the developer mode, check out the menu Settings > Technical > Actions > Server Actions.

     

    Let’s check the server action types;

    1. Update the record

    2. Create a new record

    3. Execute Python Code

    4. Execute several actions

    5. Send Email

    6. Add Followers

    7. Create the next activity

    8. Send an SMS text Message

     

    Once you click on the ‘Create’ button, this form view will appear. Here the ‘Action name’ needs to be filled, and also select any model upon which this server action needs to be acted. The next mandatory field is the ‘Action to do,’ which determines the action type.

    XML code for creating a server action. It is placed in the data file of the module.

    <record id="action_set_salesperson" model="ir.actions.server" >

             <field name="name" >Set Sales Person </field >

             <field name="model_id" ref="base.model_res_partner"/ >

             <field name="state" >code </field >

          </record >

    In this record, as with every record, it has a unique id and also a name used to name the server action. Another field is the ‘model_id’ used to mention the model to which this action is linked. Next is the ‘state’ field that is used for specifying the type of server action.

    Let’s go through the type of actions;

    Update the record

    This type of server action is created in order to update something in the specified model.

    For example, If we need to set anyone as the salesperson for the records of contact, then the server action will be like this;

     

    Here, the page ‘Data to Write’ refers to the fields and their corresponding actions to be done on the model. The field ‘Evaluation Type’ contains three modes like ‘Value, ‘Reference,’ and ‘Python Code.’ If it’s Value, then it will be specified as a literal value. If it is ‘Reference,’ then the existing value will be available to select and set its field. Otherwise, if it is the ‘Python Code,’ then a python expression is required.

    Once the details are filled up then, the button ‘Create Contextual Action’ can be clicked. As a result, you will get a new menu in the contextual action in the view as given below.

     

    If the option is clicked, the salesperson field will get assigned the value for the server action. Hence the record can be updated.

    In the code, the update can be used as;

    <field name="state" >object_write </field >

    Create a new Record

    Here, the server action created a new record in the specified model. Its server action will be like this;

     

    After creating this action, the model ‘Contact’ will have a contextual action to create a record based on the values set in the action. Its target model is also specified here.

    The code will be like this;

    Execute Python Code

    This type of server action is used to execute python code.

    This is done in the code as follows;

            <field name="state" >code </field >

     

    Execute several actions

    This is a type of server action that performs multiple actions at a time. Thus here, we can choose the actions that need to be executed simultaneously.

     

    After creating this record, a contextual action will be created, and the listed child actions will be executed simultaneously when the action is selected. This type of action is declared in the XML as;

     <field name="state" >multi </field >

    Send Email

    This is used to send emails to our partner from a specified model. Once this type of action is selected, then a field will be displayed to select the email template.

     

    Here is another option to select the mode of sending the template. Either it can be sent as an ‘Email’ or ‘ Post as Message’ or ‘post as Note. Its declaration in the code is;

     <field name="state" >email </field >

    Add Followers

    This is used to add followers to the specified model.

     

    After creating this server action, a similar contextual action will be created, and the selected followers will be added to the corresponding model.

    In the XML, this type if defined as followers;

    <field name="state" >followers </field >

    Create Next Activity

    These types of actions are used to schedule the next activities based on a model.

     

    This will create a contextual action to schedule the action that is mentioned in the record for server action.

    In the XML code, it is defined as;

    <field name="state" >next_activity </field >

    Send SMS Text Message

    This type of server action is used to send text messages in bulk.

    The field ‘state’ is declared as ‘SMS’ here;

    <field name="state" >sms </field >

     

    Once the action type is selected, a field for selecting the template and the field to set the mode of sending the text message will appear. Thus once the contextual action is created, then the text message will be sent based on the model.

    本文章从网上收集,如有侵权请联系tderp@tderp.com删除
  • 微信扫一扫,一分也是爱:
  • 微信

服务原则及地区范围

宜兴通达网络科技有限公司,地处中国宜兴环科园内,是一家高新技术企业。公司在企业网络维护和企业信息化建设与咨询方面,有10多年经验。

我公司愿与客户一道,力求彻底解决客户问题!
我们不是在给企业提供“头痛医头、脚痛医脚”的暂时解决方案,而是在部署根本性安全与稳定服务!!
我们愿携手客户,建立企业IT规划;杜绝随意安装系统、软件等操作;力求共同维护有序、安全、稳定的网络办公环境!!!
IT服务,服务是根本,客户是上帝;我们提供快速响应、快速上门、快速排查,提供优质高效的服务!!!!

通达科技提供全国范围内的服务,服务形式包括远程协助、电话咨询、电子邮件咨询、传真咨询、问答平台的问题解决等。

宜兴地区提供上门服务:

  • 市区服务:宜城街道、城北街道(屺亭街道)、新街街道、新庄街道、环科园、渚桥开发区
  • 市郊服务:张渚镇、西渚镇、太华镇、徐舍镇、官林镇、杨巷镇、新建镇、和桥镇、高塍镇、万石镇、周铁镇、芳桥镇、丁蜀镇、湖父镇。
  • 联系电话:189-21-343434
  • 在线沟通: