From e711ff0ab3070097dc10285adecc63606b5571e5 Mon Sep 17 00:00:00 2001
From: yuxianghui <1608204036@qq.com>
Date: Fri, 7 Jul 2023 17:36:42 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E4=BA=A7=E7=BA=BF?=
=?UTF-8?q?=E8=AE=BE=E5=A4=87=E8=B5=84=E6=BA=90=E8=AE=BE=E7=BD=AE=EF=BC=8C?=
=?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A0=B9=E6=8D=AE=E9=80=89=E5=8F=96=E7=9A=84?=
=?UTF-8?q?=E5=B7=A5=E4=BD=9C=E4=B8=AD=E5=BF=83=E8=87=AA=E5=8A=A8=E5=B8=A6?=
=?UTF-8?q?=E5=87=BA=E8=AE=BE=E5=A4=87=E7=9A=84=E6=95=B0=E6=8D=AE=EF=BC=8C?=
=?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A0=B9=E6=8D=AE=E9=80=89=E6=8B=A9=E7=9A=84?=
=?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=97=A5=E5=8E=86=E8=87=AA=E5=8A=A8=E5=B8=A6?=
=?UTF-8?q?=E5=87=BA=E7=8F=AD=E6=AC=A1=E7=9A=84=E6=95=B0=E6=8D=AE=EF=BC=8C?=
=?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=90=9C=E7=B4=A2=E8=A7=86=E5=9B=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_maintenance/__manifest__.py | 1 +
sf_plan_management/__manifest__.py | 2 +-
sf_plan_management/models/base.py | 74 ++++++++++++---------
sf_plan_management/views/paln_base_view.xml | 63 ++++++++++++------
4 files changed, 87 insertions(+), 53 deletions(-)
diff --git a/sf_maintenance/__manifest__.py b/sf_maintenance/__manifest__.py
index 529c62fc..6e644ebc 100644
--- a/sf_maintenance/__manifest__.py
+++ b/sf_maintenance/__manifest__.py
@@ -12,6 +12,7 @@
'data': [
'security/group_security.xml',
'security/ir.model.access.csv',
+ 'views/production_line_base.py',
'views/maintenance_views.xml',
'views/maintenance_logs_views.xml',
'views/equipment_maintenance_standards_views.xml',
diff --git a/sf_plan_management/__manifest__.py b/sf_plan_management/__manifest__.py
index 5f82e7b4..44be0987 100644
--- a/sf_plan_management/__manifest__.py
+++ b/sf_plan_management/__manifest__.py
@@ -10,7 +10,7 @@
""",
'category': 'sf',
'website': 'https://www.sf.jikimo.com',
- 'depends': [],
+ 'depends': ['sf_maintenance'],
'data': [
'security/ir.model.access.csv',
# 'security/ir.model.access.csv',
diff --git a/sf_plan_management/models/base.py b/sf_plan_management/models/base.py
index 0bda7291..1a8d1e27 100644
--- a/sf_plan_management/models/base.py
+++ b/sf_plan_management/models/base.py
@@ -1,43 +1,55 @@
-from odoo import models, fields
+from odoo import models, fields, api
+from odoo.exceptions import UserError
class ProcedureEquipmentResourceSetting(models.Model):
_name = 'sf.procedure.equipment.resource.setting'
_description = '产线设备资源设置'
- def _get_code(self):
- """
- 自动生成编码
- :return:
- """
- fixture_material = self.env['sf.procedure.equipment.resource.setting'].sudo().search(
- [('code', '!=', '')],
- limit=1,
- order="id desc")
- if not fixture_material:
- num = "%03d" % 1
- else:
- m = int(fixture_material.code) + 1
- num = "%03d" % m
- return num
-
- code = fields.Char(string='序号', readonly=True, default=_get_code)
- work_center_name = fields.Char(string='工作中心名称')
- equipment_code = fields.Char(string='机台号')
- # todo 绑定设备
- # equipment_name = fields.Many2one('', string='设备名称')
- brand = fields.Char(string='品牌')
- model = fields.Char(string='型号')
- working_procedure = fields.Char(string='工序')
- production_capacity = fields.Char(string='产能', required=True)
+ production_line_id = fields.Many2one('sf.production.line', string='生产线', required=True)
+ work_center_name_id = fields.Many2one('mrp.workcenter', string='工作中心名称')
+ equipment_code = fields.Char(string='机台号(原设备编码)', readonly=True, compute='_onchange_equipment_name_id')
+ equipment_name_id = fields.Many2one('maintenance.equipment',
+ string='设备名称',
+ readonly=True,
+ compute='_onchange_work_center_name_id')
+ brand = fields.Char(string='品牌', readonly=True, compute='_onchange_equipment_name_id')
+ model = fields.Char(string='型号', readonly=True, compute='_onchange_equipment_name_id')
+ # todo 传入工序数据
+ working_procedure = fields.Char(string='工序', readonly=True)
+ production_capacity = fields.Float(string='产能', required=True, digits=(4, 1))
working_calendar_id = fields.Many2one('sf.work.log.setting', string='工作日历')
- working_shift = fields.Char(string='班次')
- create_time = fields.Datetime(string='新增时间', default=lambda self: fields.Datetime.now())
- status = fields.Selection([('0', '正常'), ('1', '故障停机'), ('2', '计划停机')], string='设备状态', default='0')
+ working_shift = fields.Char(string='班次', readonly=True, compute='_onchange_working_calendar_id')
+ create_time = fields.Datetime(string='新增时间', default=lambda self: fields.Datetime.now(), readonly=True)
+ status = fields.Selection([('正常', '正常'), ('1', '故障停机'), ('2', '计划停机')],
+ string='设备状态',
+ readonly=True,
+ compute='_onchange_equipment_name_id')
participate_in_scheduling = fields.Boolean(string='参与排程', default=True)
-
-
+ @api.onchange('production_capacity')
+ def _onchange_production_capacity(self):
+ for record in self:
+ if record.production_capacity < 0:
+ raise UserError("输入的产能值不正确,请重新输入!")
+
+ @api.depends('work_center_name_id')
+ def _onchange_work_center_name_id(self):
+ for record in self:
+ record.equipment_name_id = record.work_center_name_id.equipment_ids
+
+ @api.onchange('equipment_name_id')
+ def _onchange_equipment_name_id(self):
+ for record in self:
+ record.equipment_code = record.equipment_name_id.code,
+ record.brand = record.equipment_name_id.brand_id.name,
+ record.model = record.equipment_name_id.type_id.name,
+ record.status = record.equipment_name_id.state
+
+ @api.depends('working_calendar_id')
+ def _onchange_working_calendar_id(self):
+ for record in self:
+ record.working_shift = record.working_calendar_id.working_shift
diff --git a/sf_plan_management/views/paln_base_view.xml b/sf_plan_management/views/paln_base_view.xml
index b029a6e0..645aa45d 100644
--- a/sf_plan_management/views/paln_base_view.xml
+++ b/sf_plan_management/views/paln_base_view.xml
@@ -106,18 +106,19 @@
sf.procedure.equipment.resource.setting
-
-
+
-
+
+
+
@@ -128,32 +129,40 @@
@@ -165,8 +174,20 @@
sf.procedure.equipment.resource.setting
+
+
+
+
+
+
+
+
+
+
+
+
-
+