Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/销售权限
# Conflicts: # sf_manufacturing/models/product_template.py
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
from odoo import api, fields, models, SUPERUSER_ID, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class SfEquipmentSaintenanceStandards(models.Model):
|
||||
_name = 'equipment.maintenance.standards'
|
||||
_description = '设备维保标准'
|
||||
@@ -18,6 +19,7 @@ class SfEquipmentSaintenanceStandards(models.Model):
|
||||
m = int(partner.code[-4:]) + 1
|
||||
num = "%04d" % m
|
||||
return num
|
||||
|
||||
code = fields.Char(string='编码')
|
||||
remark = fields.Char('备注')
|
||||
maintenance_type = fields.Selection([('保养', '保养'), ("检修", "检修")], string='类型', default='保养')
|
||||
@@ -69,6 +71,7 @@ class SfEquipmentSaintenanceStandards(models.Model):
|
||||
# work.sequence = current_sequence
|
||||
# current_sequence += 1
|
||||
|
||||
|
||||
class SfSaintenanceStandards(models.Model):
|
||||
_name = 'maintenance.standards'
|
||||
_description = '维保项目'
|
||||
@@ -92,7 +95,3 @@ class MaintenanceStandardImage(models.Model):
|
||||
|
||||
image = fields.Binary(string='维保图片')
|
||||
standard_id = fields.Many2one('maintenance.standards', string='Standard')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ class SfMaintenanceEquipmentCategory(models.Model):
|
||||
_inherit = 'maintenance.equipment.category'
|
||||
_description = '设备类别'
|
||||
|
||||
equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'), ('检测设备', '检测设备')], string='类型', default='机床')
|
||||
equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'),
|
||||
('检测设备', '检测设备')], string='类型', default='机床')
|
||||
|
||||
|
||||
class SfMaintenanceEquipment(models.Model):
|
||||
@@ -62,9 +63,10 @@ class SfMaintenanceEquipment(models.Model):
|
||||
else:
|
||||
record.equipment_maintenance_standards_ids = False
|
||||
|
||||
MTcode = fields.Char("编码", default=get_no)
|
||||
MTcode = fields.Char("机台编码", default=get_no)
|
||||
created_user = fields.Many2one('res.users', string='创建人', default=lambda self: self.env.user)
|
||||
equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'), ('检测设备', '检测设备')], compute='_compute_category_id')
|
||||
equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'), ('检测设备', '检测设备')]
|
||||
, compute='_compute_category_id')
|
||||
|
||||
@api.depends('category_id')
|
||||
def _compute_category_id(self):
|
||||
@@ -72,8 +74,8 @@ class SfMaintenanceEquipment(models.Model):
|
||||
if record:
|
||||
record.equipment_type = record.category_id.equipment_type
|
||||
|
||||
code = fields.Char('机台号')
|
||||
name = fields.Char('名称')
|
||||
code = fields.Char('行业编码')
|
||||
name = fields.Char('机台号')
|
||||
knife_type = fields.Selection(
|
||||
[("BT40", "BT40"), ("BT30", "BT30"), ("BT50", "BT50")],
|
||||
default="", string="刀把类型")
|
||||
@@ -152,6 +154,18 @@ class SfMaintenanceEquipment(models.Model):
|
||||
result.append((parameter.id, name))
|
||||
return result
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
# 在创建设备之前执行一些自定义逻辑
|
||||
|
||||
equipment = super(SfMaintenanceEquipment, self).create(vals)
|
||||
equipment.name = equipment.MTcode + '#' + equipment.category_id.name
|
||||
|
||||
# 在创建设备之后执行一些自定义逻辑
|
||||
# ...
|
||||
|
||||
return equipment
|
||||
|
||||
# @api.constrains('rotate_speed')
|
||||
# def _check_rotate_speed(self):
|
||||
# if self.rotate_speed <= 0:
|
||||
@@ -278,7 +292,8 @@ class SfMaintenanceEquipment(models.Model):
|
||||
detect_y_axis = fields.Char('检测Y轴')
|
||||
detect_z_axis = fields.Char('检测Z轴')
|
||||
detect_precision = fields.Char('测量精度')
|
||||
detect_measurement_mode = fields.Selection([('光栅尺', '光栅尺'), ('容栅', '容栅'), ('磁栅', '磁栅'), ('激光干涉仪', '激光干涉仪')], string='测量方式')
|
||||
detect_measurement_mode = fields.Selection([('光栅尺', '光栅尺'), ('容栅', '容栅'), ('磁栅', '磁栅'),
|
||||
('激光干涉仪', '激光干涉仪')], string='测量方式')
|
||||
detect_resolution = fields.Char('分辨率')
|
||||
detect_load_weight_max = fields.Char('最大负载重量')
|
||||
detect_weight = fields.Char('本体总重量')
|
||||
@@ -304,13 +319,15 @@ class SfMaintenanceEquipment(models.Model):
|
||||
robot_load_weight_max = fields.Char('最大负载重量')
|
||||
robot_weight = fields.Char('本体总重量')
|
||||
robot_repeatable_positioning_accuracy = fields.Char('重复定位精度')
|
||||
robot_axis_num = fields.Selection([('2轴', '2轴'), ('3轴', '3轴'), ('4轴', '4轴'), ('5轴', '5轴'), ('6轴', '6轴'), ('7轴', '7轴'), ('8轴', '8轴')], string='轴数')
|
||||
robot_axis_num = fields.Selection([('2轴', '2轴'), ('3轴', '3轴'), ('4轴', '4轴'), ('5轴', '5轴'), ('6轴', '6轴'),
|
||||
('7轴', '7轴'), ('8轴', '8轴')], string='轴数')
|
||||
axis_ids = fields.One2many('sf.robot.axis.num', 'equipment_id', string='动作范围')
|
||||
robot_track_dimensions_L = fields.Char('轨道尺寸(长)')
|
||||
robot_track_dimensions_W = fields.Char('轨道尺寸(宽)')
|
||||
robot_track_dimensions_H = fields.Char('轨道尺寸(高)')
|
||||
robot_drive_mode = fields.Char('驱动方式')
|
||||
robot_installation_method = fields.Selection([('置地式', '置地式'), ('壁挂式', '壁挂式'), ('倒挂式', '倒挂式')], string='安装方式')
|
||||
robot_installation_method = fields.Selection([('置地式', '置地式'), ('壁挂式', '壁挂式'), ('倒挂式', '倒挂式')],
|
||||
string='安装方式')
|
||||
robot_operating_temperature = fields.Char('机器人环境温度')
|
||||
robot_operating_humidity = fields.Char('机器人环境湿度')
|
||||
|
||||
@@ -347,7 +364,7 @@ class SfMaintenanceEquipment(models.Model):
|
||||
images_ids_names = []
|
||||
for a in self.env['maintenance.equipment.image'].search([('id', 'in', item.image_id.ids)]):
|
||||
images_ids_names.append(a.name)
|
||||
if item.machine_tool_picture != False:
|
||||
if item.machine_tool_picture:
|
||||
image = base64.b64encode(item.machine_tool_picture).decode('utf-8')
|
||||
else:
|
||||
image = False
|
||||
@@ -433,7 +450,8 @@ class SfMaintenanceEquipment(models.Model):
|
||||
if next_maintenance_todo and last_maintenance_done:
|
||||
next_date = next_maintenance_todo.request_date
|
||||
date_gap = next_maintenance_todo.request_date - last_maintenance_done.close_date
|
||||
# If the gap between the last_maintenance_done and the next_maintenance_todo one is bigger than 2 times the period and next request is in the future
|
||||
# If the gap between the last_maintenance_done and the next_maintenance_todo one is bigger than
|
||||
# 2 times the period and next request is in the future
|
||||
# We use 2 times the period to avoid creation too closed request from a manually one created
|
||||
if date_gap > timedelta(0) and date_gap > timedelta(
|
||||
days=equipment.period) * 2 and next_maintenance_todo.request_date > date_now:
|
||||
@@ -445,7 +463,8 @@ class SfMaintenanceEquipment(models.Model):
|
||||
elif next_maintenance_todo:
|
||||
next_date = next_maintenance_todo.request_date
|
||||
date_gap = next_maintenance_todo.request_date - date_now
|
||||
# If next maintenance to do is in the future, and in more than 2 times the period, we insert an new request
|
||||
# If next maintenance to do is in the future, and in more than 2 times the period, we insert
|
||||
# an new request
|
||||
# We use 2 times the period to avoid creation too closed request from a manually one created
|
||||
if date_gap > timedelta(0) and date_gap > timedelta(days=equipment.period) * 2:
|
||||
next_date = date_now + timedelta(days=equipment.period)
|
||||
@@ -475,7 +494,8 @@ class SfMaintenanceEquipment(models.Model):
|
||||
if next_maintenance_todo and last_maintenance_done:
|
||||
next_date = next_maintenance_todo.request_date
|
||||
date_gap = next_maintenance_todo.request_date - last_maintenance_done.close_date
|
||||
# If the gap between the last_maintenance_done and the next_maintenance_todo one is bigger than 2 times the period and next request is in the future
|
||||
# If the gap between the last_maintenance_done and the next_maintenance_todo one is bigger than 2
|
||||
# times the period and next request is in the future
|
||||
# We use 2 times the period to avoid creation too closed request from a manually one created
|
||||
if date_gap > timedelta(0) and date_gap > timedelta(
|
||||
days=equipment.overhaul_period) * 2 and next_maintenance_todo.request_date > date_now:
|
||||
@@ -487,7 +507,8 @@ class SfMaintenanceEquipment(models.Model):
|
||||
elif next_maintenance_todo:
|
||||
next_date = next_maintenance_todo.request_date
|
||||
date_gap = next_maintenance_todo.request_date - date_now
|
||||
# If next maintenance to do is in the future, and in more than 2 times the period, we insert an new request
|
||||
# If next maintenance to do is in the future, and in more than 2 times the period, we insert
|
||||
# an new request
|
||||
# We use 2 times the period to avoid creation too closed request from a manually one created
|
||||
if date_gap > timedelta(0) and date_gap > timedelta(days=equipment.overhaul_period) * 2:
|
||||
next_date = date_now + timedelta(days=equipment.overhaul_period)
|
||||
@@ -577,7 +598,8 @@ class SfMaintenanceEquipment(models.Model):
|
||||
if not next_requests:
|
||||
equipment._create_new_request1(equipment.overhaul_date)
|
||||
|
||||
image_id = fields.Many2many('maintenance.equipment.image', 'equipment_id', string='加工能力', domain="[('type', '=', '加工能力')]")
|
||||
image_id = fields.Many2many('maintenance.equipment.image', 'equipment_id', string='加工能力',
|
||||
domain="[('type', '=', '加工能力')]")
|
||||
|
||||
|
||||
class SfRobotAxisNum(models.Model):
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*-coding:utf-8-*-
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class SfMaintenanceLogs(models.Model):
|
||||
_name = 'sf.maintenance.logs'
|
||||
_description = '设备故障日志'
|
||||
@@ -11,16 +12,17 @@ class SfMaintenanceLogs(models.Model):
|
||||
brand = fields.Many2one('sf.machine.brand', related='maintenance_equipment_id.brand_id', string='品牌')
|
||||
maintenance_equipment_id = fields.Many2one('maintenance.equipment', string='设备')
|
||||
code_location = fields.Char(string='编码位置')
|
||||
fault_type = fields.Selection([('电气类', '电气类'), ('机械类', '机械类'), ('程序类', '程序类'), ('系统类', '系统类')], string='故障类型')
|
||||
fault_type = fields.Selection(
|
||||
[('电气类', '电气类'), ('机械类', '机械类'), ('程序类', '程序类'), ('系统类', '系统类')], string='故障类型')
|
||||
fault_code = fields.Char(string='故障代码')
|
||||
fault_alarm_info = fields.Char(string='故障报警信息')
|
||||
alarm_level = fields.Selection([('一级', '一级(严重)'), ('二级', '二级(中等)'), ('三级', '三级(轻微)')], string='报警级别')
|
||||
alarm_level = fields.Selection([('一级', '一级(严重)'), ('二级', '二级(中等)'), ('三级', '三级(轻微)')],
|
||||
string='报警级别')
|
||||
alarm_time = fields.Datetime(string='报警时间')
|
||||
alarm_way = fields.Selection([('文本提示报警', '文本提示报警'), ('声光报警', '声光报警'), ('图文报警', '图文报警')], string='报警方式')
|
||||
alarm_way = fields.Selection([('文本提示报警', '文本提示报警'), ('声光报警', '声光报警'), ('图文报警', '图文报警')],
|
||||
string='报警方式')
|
||||
fault_process = fields.Text(string='故障处理方法')
|
||||
operator = fields.Many2one('res.users', string='处理人')
|
||||
recovery_time = fields.Datetime(string='复原时间')
|
||||
fault_duration = fields.Float(string='故障时长')
|
||||
note = fields.Text(string='备注')
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class SfMaintenanceEquipmentCategory(models.Model):
|
||||
sf_maintenance_type = fields.Selection([('保养', '保养'), ('检修', '检修')], string='维保类别', default='保养')
|
||||
|
||||
equipment_maintenance_id = fields.Many2one('equipment.maintenance.standards', string='设备维保标准',
|
||||
domain="[('maintenance_type','=',sf_maintenance_type)]")
|
||||
domain="[('maintenance_type','=',sf_maintenance_type)]")
|
||||
|
||||
@api.onchange('sf_maintenance_type')
|
||||
def _compute_equipment_maintenance_request_id(self):
|
||||
@@ -38,8 +38,3 @@ class SfMaintenanceEquipmentCategory(models.Model):
|
||||
|
||||
def confirm_maintenance_done(self):
|
||||
self.write({'stage_id': 3})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -52,11 +52,13 @@
|
||||
<button type="object" class="oe_highlight" name='enroll_machine_tool' string="机床注册"
|
||||
attrs="{'invisible': [('equipment_type', '!=', '机床'), ('brand_id','!=',False),('type_id','!=',False),('control_system_id','!=',False)]}"/>
|
||||
</div>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='category_id']" position="before">
|
||||
<field name="MTcode"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='category_id']" position="after">
|
||||
<field name="state_zc"/>
|
||||
<field name="code"/>
|
||||
|
||||
<field name="code" readonly="1"/>
|
||||
<field name="equipment_type" invisible="1"/>
|
||||
<field name="brand_id" force_save="1"/>
|
||||
<field name="type_id" attrs="{'required': [('equipment_type', '=', '机床')]}"
|
||||
|
||||
Reference in New Issue
Block a user