当前位置:网站首页>odoo公用变量或数组的使用
odoo公用变量或数组的使用
2022-08-10 00:56:00 【姜振建 15954039008】
对于项目中用到的公用变量或数组,应该单独放在一个py文件中,方便在其他PY文件中调用。
使用时用import导入即可。
1、在ODOO中创建一个基本模块,命名为:base_tools,结构:
在文件夹下创建g_assets_public.py文件,内容:
"""
资产管理模块
数组元组字典定义
"""
# 设备状态
EQUIPMENT_STATE = [('scrap', '报废'), ('in-use', '在用'), ('maintain', '维修'), ('replacement', '备件')]
# 设备类型
EQUIPMENT_TYPE = [('general', '通用设备'), ('non-standard', '非标准设备')]
# 资产分类
ASSET_CLASSIFY = [('current', '流动资产'), ('non-current', '非流动资产')]
# 行业类型
INDUSTRY_TYPE = [('materials', '材料'), ('engineering', '工程'), ('equipment', '设备'), ('services', '服务')]
# 客户级别
CUSTOMER_LEVEL = [('key', '关键'), ('main', '主要'), ('common', '普通')]
创建g_project_public.py文件,内容:
"""
项目管理模块
数组元组字典定义
"""
# 项目状态
PROJECT_STATE = [
("draft", "草稿"),
("start_on", "进行中"),
("deliver_on", "交付中"),
("deliver_wait", "待交付"),
("shelved", "搁置"),
("wait", "待商务确认"),
("cancel", "已取消"),
]
# 任务状态
TASK_STATE = [
('finished', '已完成'),
('to-be-completed', '待完成'),
('postponed', '已延期'),
]
创建g_project_public.py文件,内容:
import datetime
import random
2、具体使用:
创建一个应用模块,命名为:assets_use,在model文件夹下创建一个assets_public.py文件,内容:
# -*- coding: utf-8 -*-
```bash
from dtcloud import models, fields, api
# 导入选择字段值
from g_tools.g_assts_public import EQUIPMENT_STATE
from g_tools.g_assts_public import EQUIPMENT_TYPE
from g_tools import g_project_public
equipment_state = fields.Selection(EQUIPMENT_STATE, default=‘in-use’, string=‘设备状态’, required=True)
project_state = fields.Selection(string=“项目状态”, selection=g_project_public.PROJECT_STATE, default=“draft”)
边栏推荐
- In the 2022 gold, nine, silver and ten work tide, how can I successfully change jobs and get a high salary?
- 浏览器中location详解
- DHCP——动态主机配置协议
- R语言使用glm函数构建logistic回归模型,使用forestmodel包的forest_model函数可视化逻辑回归模型对应的森林图
- 微信小程序tab切换时保存checkbox状态
- Prometeus 2.31.0 新特性
- sql实战积累
- 不是吧,连公司里的卷王写代码都复制粘贴,这合理?
- XSS高级 svg 复现一个循环问题以及两个循环问题
- Web性能测试模型小结
猜你喜欢

GB28181 sip和RTSP(Real-Time Streaming Protocol)实时流控制协议

鲜花线上销售管理系统的设计与实现

Unity顶点动画

20220809-PotPlayer如何设置默认字体色-设置默认字体色的方法

Pagoda measurement - building LightPicture open source map bed system
![[LeetCode] Find the sum of the numbers from the root node to the leaf node](/img/1c/6c627e17a60f424601226504f4ff36.png)
[LeetCode] Find the sum of the numbers from the root node to the leaf node

Visual low-code system practice based on design draft identification

C# 四舍五入 MidpointRounding.AwayFromZero

墨西哥大众VW Mexico常见的几种label

type-C 边充电边听歌(OTG) PD芯片方案,LDR6028 PD充电加OTG方案
随机推荐
墨西哥大众VW Mexico常见的几种label
RedHat红帽RHEL7安装与使用,VMware Workstation16 Pro虚拟机的安装与使用
宽带由20M换为100M
【论文笔记】基于深度学习的机器人抓取虚拟仿真实验教学系统
C# 四舍五入 MidpointRounding.AwayFromZero
跨部门沟通的技巧
UI遍历的初步尝试
Web性能测试模型小结
使用 GoogleTest 框架对 C 代码进行单元测试
UI遍历的初步尝试
Character Statistics Histogram
罗彻斯特大学 | 现在是什么序列?蛋白质序列的贝叶斯优化的预训练集成
不是吧,连公司里的卷王写代码都复制粘贴,这合理?
[论文阅读] Multimodal Unsupervised Image-to-Image Translation
shell指定参数名传参
-Pickling peanuts-
使用 apxs 构建和安装 Apache 扩展共享对象模块
22.括号生成
微信小程序tab切换时保存checkbox状态
y92.第六章 微服务、服务网格及Envoy实战 -- Envoy基础(三)