宜兴通达竭诚为您服务。

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

Python code server actions
  • 上传者: Administrator
  • 上传时间:2025年05月07日 08时56分39秒
摘要:
* Python code server actions ** *** Python code server actions are the most flexible kind of actions that helps users to meet their requirements thro ......
正文 相关文章 请喝咖啡

    Python code server actions

    Python code server actions are the most flexible kind of actions that helps users to meet their requirements through python code. It’s useful because of the capabilities to bring advanced logic to Odoo from the front end itself. Let’s have a look at the way in which the python code server actions are implemented;

    After enabling the developer mode go to Settings > Technical > Automation > Automated Actions. Then create a new action.

    For example, Let’s see how a warning is set on the record during creation.

     

    This is a basic example to show the python code server actions. The fields that are used here;

    Model: model upon which this action needs to be executed.

    Action to do: type of action to be performed

    Trigger: triggering conditions like on update, create, deletion, etc.

    Apply on: condition specified before executing the action

    Python Code: python code is explained here.

     

    After saving the action, it will be necessary to add an email while creating any contact. Otherwise, it will show UserError according to the python code server action.

    Automated actions on time conditions

    Automated actions can be triggered based on time conditions. Thus if an operation needs to be performed at a specific time, then the automated actions are able to perform it.

    Let’s see how this is implemented in Odoo;

    Once you enable the developer mode, then go to the menu Settings > Technical > Automation > Automated Actions. Then let’s create a new record on that.

     

    Model: Model on which the action needs to be performed.

    Action To do: Select the type of action.

    Trigger: Select the triggering type. Here it will be “Based on Time condition”

    Apply on: conditions executed before the action

    Email Template: email template to be used. It needs to be selected if the type is “send Email”

    Trigger Date: it decides when the action should be triggered.

    Delay after trigger date: it can have negative values so that the action will be triggered before the trigger date.

    Automated actions on event conditions

    Automated actions can be set to trigger the action based on a specific event. Let’s check if its working by using an example;

    Let's consider that the user can update the project status only if they have access rights to the project manager and project leader. Now let’s create a server action based on a python code to show user error. It checks if the logged-in user and the project manager are the same or not. If it fails, then it will raise an error message.

     

    Now let’s create another action for executing this action while on its update. It will be like this;

     

    Here, The fields are explained like;

    Model: The required model upon which the action will be performed.

    Trigger: Triggering condition of the action.

    Trigger fields: If any fields are mentioned, then the action will be based on the update on these fields.

    Before update domain: If any conditions are mentioned here they will be satisfied before the update of the record

    Apply on: If any conditions are specified on the field they will be satisfied before the action rule.

    Action to do: The type of action is specified here.

    After adding these requirements, when going to the project and trying to update the record, then, there will raise an error if the user is not the project manager for that particular project.

     

     

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

服务原则及地区范围

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

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

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

宜兴地区提供上门服务:

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