当前位置:网站首页>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”)
边栏推荐
- Experimental support for decorators may change in future releases.Set the "experimentalDecorators" option in "tsconfig" or "jsconfig" to remove this warning
- [LeetCode] Find the sum of the numbers from the root node to the leaf node
- 【无标题】
- 递归 二分查找 冒泡排序 快速排序
- [论文阅读] Multimodal Unsupervised Image-to-Image Translation
- 使用 apxs 构建和安装 Apache 扩展共享对象模块
- shell指定参数名传参
- @PostConsturct注解作用及特点
- DHCP——动态主机配置协议
- Chip Information|Semiconductor revenue growth expected to slow to 7%, Bluetooth chip demand still growing steadily
猜你喜欢

为什么字符串一旦创建就不可以改变?

【论文笔记】基于深度学习的机器人抓取虚拟仿真实验教学系统

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

跳房子游戏

OSS-访问oss生成的url无法访问,直接下载问题

03|Process Control

Not, even the volume of the king to write code in the company are copying and pasting it reasonable?

Shader Graph learns various special effects cases

Unity vertex animation

C# 四舍五入 MidpointRounding.AwayFromZero
随机推荐
hint: Updates were rejected because the tip of your current branch is behind hint: its remote counte
-red and black-
Summary of basic operations of c language files
Interdepartmental Communication Skills
手把手教你编写性能测试用例
【kali-密码攻击】(5.1.2)密码在线破解:Medusa
初步认识对象
Minimum number of steps to get out of the maze 2
多线程之享元模式和final原理
开发IM即时通讯容易吗?需要什么技术
OpenSSF的开源软件风险评估工具:Scorecards
数据建模已死,真的吗?
即时通讯开发如何撸一个WebSocket服务器
宽带由20M换为100M
什么是持续测试?
微信小程序tab切换时保存checkbox状态
使用 apxs 构建和安装 Apache 扩展共享对象模块
[LeetCode] Find the sum of the numbers from the root node to the leaf node
基于SSM实现手机销售商城系统
Research on Ethernet PHY Chip LAN8720A Chip