初次提交,智能工厂基础数据
This commit is contained in:
3
sf_base/models/__init__.py
Normal file
3
sf_base/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
from. import sf_base
|
||||
from. import sf_common
|
||||
237
sf_base/models/sf_base.py
Normal file
237
sf_base/models/sf_base.py
Normal file
@@ -0,0 +1,237 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import logging
|
||||
|
||||
from odoo import fields, models, api
|
||||
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class MachineBrandTags(models.Model):
|
||||
_name = 'mrs.machine.brand.tags'
|
||||
_description = '标签'
|
||||
|
||||
name = fields.Char('名称', size=50)
|
||||
color = fields.Integer('颜色', default=0)
|
||||
|
||||
|
||||
class MachineControlSystem(models.Model):
|
||||
_name = 'mrs.machine_tool.type.control_system'
|
||||
_description = '控制系统'
|
||||
|
||||
name = fields.Char('名称', size=50)
|
||||
# type_id = fields.Many2one('mrs.machine_tool.type')
|
||||
|
||||
|
||||
# 品牌标签
|
||||
class MachineBrand(models.Model):
|
||||
_name = 'mrs.machine.brand'
|
||||
_description = '品牌'
|
||||
|
||||
name = fields.Char('名称')
|
||||
tag_ids = fields.Many2many('mrs.machine.brand.tags', 'rel_machine_brand_tags', string='类别')
|
||||
image_brand = fields.Image("品牌图片")
|
||||
active = fields.Boolean('有效', default=True)
|
||||
|
||||
code = fields.Char('编码')
|
||||
|
||||
|
||||
# 机床
|
||||
class MachineTool(models.Model):
|
||||
_name = 'mrs.machine_tool'
|
||||
_description = '机床'
|
||||
|
||||
code = fields.Char('编码')
|
||||
name = fields.Char('名称')
|
||||
knife_type = fields.Selection(
|
||||
[("BT40", "BT40"), ("BT30", "BT30")],
|
||||
default="", string="刀把类型")
|
||||
number_of_knife_library = fields.Integer('刀库数量')
|
||||
rotate_speed = fields.Integer('转速')
|
||||
number_of_axles = fields.Selection(
|
||||
[("3轴", "3轴"), ("4轴", "4轴"), ("5轴", "5轴")],
|
||||
default="", string="轴数")
|
||||
# 加工进程
|
||||
x_axis = fields.Integer('X轴')
|
||||
y_axis = fields.Integer('Y轴')
|
||||
z_axis = fields.Integer('Z轴')
|
||||
b_axis = fields.Integer('B轴')
|
||||
c_axis = fields.Integer('C轴')
|
||||
remark = fields.Text('备注')
|
||||
precision = fields.Float('加工精度')
|
||||
control_system_id = fields.Many2one('mrs.machine_tool.type.control_system',
|
||||
string="控制系统")
|
||||
# 多个机床型号对应一个机床
|
||||
type_id = fields.Many2one('mrs.machine_tool.type', '型号',
|
||||
compute='_compute_type_id')
|
||||
brand_id = fields.Many2one('mrs.machine.brand', string='品牌')
|
||||
status = fields.Selection(
|
||||
[("正常", "正常"), ("故障", "故障"), ("不可用", "不可用")],
|
||||
default="", string="状态")
|
||||
|
||||
# 一个机床对应一個加工工厂,一个加工工厂对应多个机床
|
||||
factory_id = fields.Many2one('res.partner', string='所属工厂',
|
||||
domain="[('is_factory', '=', True)]")
|
||||
# 一个机床对应一个供应商,一个供应商对应多个机床
|
||||
supplier_id = fields.Many2one('res.partner', string='制造商',
|
||||
domain="[('is_vendor', '=', True)]")
|
||||
registration_date = fields.Date('注册日期')
|
||||
|
||||
active = fields.Boolean('有效', default=True)
|
||||
|
||||
# @api.depends('type_id')
|
||||
# def _compute_type_id(self):
|
||||
# to_reset = self.filtered(lambda e: e.type_id != e.type_id.id)
|
||||
# to_reset.type_id = False
|
||||
|
||||
# 编码规则:加工工厂编码-品牌编码-注册年月-00001
|
||||
# def get_machine_tool_code(self):
|
||||
# partner = self.env['res.partner'].sudo().search(
|
||||
# [('is_factory', '=', True)],
|
||||
# limit=1,
|
||||
# order="id desc")
|
||||
# brand = self.env['mrs.machine.brand'].sudo().search(
|
||||
# [('tag_ids', '=', '机床')],
|
||||
# limit=1,
|
||||
# order="id desc")
|
||||
# if not brand:
|
||||
# num = item.brand_id.code + "%04d" % 1
|
||||
# item.code = num
|
||||
# else:
|
||||
# print('--------')
|
||||
# print(type)
|
||||
# m = int(type.code[-4:]) + 1
|
||||
# num = item.brand_id.code + "%04d" % m
|
||||
# item.code = num
|
||||
|
||||
# 选择机床型号时,该型号的基本信息带出并赋给机床对应的信息里
|
||||
|
||||
# @api.onchange('type_id')
|
||||
# def get_type_info(self):
|
||||
# for item in self:
|
||||
# item.knife_type = item.type_id.knife_type
|
||||
# item.number_of_knife_library = item.type_id.number_of_knife_library
|
||||
# item.number_of_axles = item.type_id.number_of_axles
|
||||
# item.rotate_speed = item.type_id.rotate_speed
|
||||
# item.precision = item.type_id.precision
|
||||
# item.control_system_id = item.type_id.control_system_id
|
||||
# item.x_axis = item.type_id.x_axis
|
||||
# item.y_axis = item.type_id.y_axis
|
||||
# item.z_axis = item.type_id.z_axis
|
||||
# item.b_axis = item.type_id.b_axis
|
||||
# item.c_axis = item.type_id.c_axis
|
||||
|
||||
|
||||
class MachineToolType(models.Model):
|
||||
_name = 'mrs.machine_tool.type'
|
||||
_description = '机床型号'
|
||||
# _order = 'priority desc, code, name, id'
|
||||
|
||||
name = fields.Char('名称')
|
||||
brand_id = fields.Many2one('mrs.machine.brand', string='品牌')
|
||||
knife_type = fields.Selection(
|
||||
[("BT40", "BT40"), ("BT30", "BT30")],
|
||||
default="", string="刀把类型")
|
||||
number_of_knife_library = fields.Integer('刀库数量')
|
||||
rotate_speed = fields.Integer('转速')
|
||||
# 多个型号对应一个机床
|
||||
machine_tool_id = fields.Many2one('mrs.machine_tool', '机床')
|
||||
number_of_axles = fields.Selection(
|
||||
[("3轴", "3轴"), ("4轴", "4轴"), ("5轴", "5轴")],
|
||||
default="", string="轴数")
|
||||
# 加工进程
|
||||
x_axis = fields.Integer('X轴')
|
||||
y_axis = fields.Integer('Y轴')
|
||||
z_axis = fields.Integer('Z轴')
|
||||
b_axis = fields.Integer('B轴')
|
||||
c_axis = fields.Integer('C轴')
|
||||
remark = fields.Text('备注')
|
||||
precision = fields.Float('加工精度')
|
||||
control_system_id = fields.Many2one('mrs.machine_tool.type.control_system',
|
||||
string="控制系统")
|
||||
active = fields.Boolean('有效', default=True)
|
||||
code = fields.Char('编码')
|
||||
|
||||
# @api.onchange('brand_id')
|
||||
# def get_machine_tool_type_code(self):
|
||||
# for item in self:
|
||||
# if not item.brand_id:
|
||||
# return False
|
||||
# type = self.env['mrs.machine_tool.type'].sudo().search(
|
||||
# [('brand_id', '=', item.brand_id.id)],
|
||||
# limit=1,
|
||||
# order="id desc"
|
||||
# )
|
||||
# print(item.brand_id.id)
|
||||
# if not type:
|
||||
# num = item.brand_id.code + "%04d" % 1
|
||||
# item.code = num
|
||||
# print(item.code)
|
||||
# else:
|
||||
# print('----------')
|
||||
# m = int(type.code[-4:]) + 1
|
||||
# num = item.brand_id.code + "%04d" % m
|
||||
# item.code = num
|
||||
# print(item.code)
|
||||
|
||||
|
||||
# 刀具
|
||||
class CuttingTool(models.Model):
|
||||
_name = 'mrs.cutting_tool.category'
|
||||
_description = '刀具类别'
|
||||
|
||||
# def get_cutting_tool_category_code(self):
|
||||
# code = self.env['mrs.cutting_tool.category'].sudo().search(
|
||||
# [('code', '!=', False)], limit=1,
|
||||
# order="id desc")
|
||||
# if not code:
|
||||
# num = "%03d" % 1
|
||||
# else:
|
||||
# m = int(code.code) + 1
|
||||
# num = "%03d" % m
|
||||
# return num
|
||||
|
||||
code = fields.Char('编码')
|
||||
name = fields.Char('名称')
|
||||
# type_ids = fields.One2many('mrs.cutting_tool.type', 'category_id', string='刀具型号')
|
||||
remark = fields.Text('备注')
|
||||
active = fields.Boolean('有效', default=True)
|
||||
|
||||
|
||||
class CuttingToolType(models.Model):
|
||||
_name = 'mrs.cutting_tool.type'
|
||||
_description = '刀具型号'
|
||||
|
||||
code = fields.Char('编码')
|
||||
name = fields.Char('名称')
|
||||
diameter = fields.Integer('直径')
|
||||
long_blade = fields.Integer('避空长/刃长')
|
||||
cone_angle_pitch = fields.Integer('锥角/节距')
|
||||
shank_diameter = fields.Integer('柄径')
|
||||
taper_shank_length = fields.Integer('锥柄长')
|
||||
tool_length = fields.Integer('刀具总长')
|
||||
blade_number = fields.Integer('刃数')
|
||||
category_id = fields.Many2one('mrs.cutting_tool.category', string='刀具类别')
|
||||
brand_id = fields.Many2one('mrs.machine.brand', string='品牌')
|
||||
remark = fields.Text('备注')
|
||||
active = fields.Boolean('有效', default=True)
|
||||
|
||||
# @api.onchange('brand_id', 'category_id')
|
||||
# def get_cutting_tool_type_code(self):
|
||||
# for item in self:
|
||||
# if not item.brand_id:
|
||||
# return False
|
||||
# if not item.category_id:
|
||||
# return False
|
||||
# type = self.env['mrs.cutting_tool.type'].sudo().search(
|
||||
# [('brand_id', '=', item.brand_id.id), ('brand_id', '=', item.category_id.id)],
|
||||
# limit=1,
|
||||
# order="id desc"
|
||||
# )
|
||||
# if not type:
|
||||
# num = item.brand_id.code + item.category_id.code + "%03d" % 1
|
||||
# item.code = num
|
||||
# else:
|
||||
# m = int(type.code[-4:]) + 1
|
||||
# num = item.brand_id.code + item.category_id.code + "%03d" % m
|
||||
# item.code = num
|
||||
54
sf_base/models/sf_common.py
Normal file
54
sf_base/models/sf_common.py
Normal file
@@ -0,0 +1,54 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import logging
|
||||
from odoo import fields, models, api
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# 材料
|
||||
class MrsProductionMaterials(models.Model):
|
||||
_name = 'mrs.production.materials'
|
||||
_description = '材料'
|
||||
remark = fields.Text("备注")
|
||||
name = fields.Char('名称')
|
||||
partner_ids = fields.Many2many('res.partner', 'materials_ids', '加工工厂')
|
||||
materials_model_ids = fields.One2many('mrs.materials.model', 'materials_id', '材料型号')
|
||||
materials_no = fields.Char("编码")
|
||||
|
||||
|
||||
# 材料型号
|
||||
class MrsMaterialModel(models.Model):
|
||||
_name = 'mrs.materials.model'
|
||||
_description = '材料型号'
|
||||
remark = fields.Text("备注")
|
||||
name = fields.Char('型号名')
|
||||
need_h = fields.Boolean("需要热处理", default="false")
|
||||
mf_materia_post = fields.Char("热处理后硬度")
|
||||
density = fields.Float("密度(kg/m³)")
|
||||
materials_id = fields.Many2one('mrs.production.materials', "材料名")
|
||||
materials_num = fields.Char("编码号")
|
||||
material_no = fields.Char("编码")
|
||||
|
||||
|
||||
# 工艺 编码,名称,备注
|
||||
class MrsProductionProcess(models.Model):
|
||||
_name = 'mrs.production.process'
|
||||
_description = '表面工艺'
|
||||
name = fields.Char('表面工艺')
|
||||
remark = fields.Text("备注")
|
||||
processing_technology_ids = fields.Many2many('mrs.processing.technology', 'mrs_associated_processes',
|
||||
index=True)
|
||||
partner_process_ids = fields.Many2many('res.partner', 'process_ids', '加工工厂')
|
||||
process_encode = fields.Char("编码")
|
||||
|
||||
|
||||
class MrsProcessingTechnology(models.Model):
|
||||
_name = 'mrs.processing.technology'
|
||||
_description = '加工工艺'
|
||||
remark = fields.Text("备注")
|
||||
sequence = fields.Integer('Sequence', index=True)
|
||||
name = fields.Char('加工工艺', index=True)
|
||||
remark = fields.Text('备注', index=True)
|
||||
process_encode = fields.Char("编码")
|
||||
production_process_ids = fields.Many2many('mrs.production.process', 'mrs_associated_processes',
|
||||
index=True)
|
||||
Reference in New Issue
Block a user