Merge branch 'feature/NC程序和功能刀具校验' into feature/NC程序和功能刀具校验_1
# Conflicts: # sf_manufacturing/models/mrp_workorder.py
This commit is contained in:
@@ -27,6 +27,43 @@ class MrpProduction(models.Model):
|
||||
string='工单状态', default='未排')
|
||||
|
||||
detection_result_ids = fields.One2many('sf.detection.result', 'production_id', '检测报告')
|
||||
tool_state = fields.Selection([('0', '正常'), ('1', '缺刀'), ('2', '无效刀')], string='功能刀具状态', default='0',
|
||||
store=True, compute='_compute_tool_state')
|
||||
tool_state_remark = fields.Text(string='功能刀具状态备注(缺刀)', readonly=True)
|
||||
tool_state_remark2 = fields.Text(string='功能刀具状态备注(无效刀)', readonly=True)
|
||||
|
||||
@api.depends('workorder_ids.tool_state')
|
||||
def _compute_tool_state(self):
|
||||
for item in self:
|
||||
if item:
|
||||
workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ('rework', '返工'))
|
||||
if workorder_ids.filtered(lambda a: a.tool_state == '2'):
|
||||
item.tool_state = '2'
|
||||
elif workorder_ids.filtered(lambda a: a.tool_state == '1'):
|
||||
tool_state_remark = ''
|
||||
data = {}
|
||||
# 获取所有缺刀工单加工面对应缺的刀
|
||||
for work in workorder_ids.filtered(lambda a: a.tool_state == '1'):
|
||||
if work.processing_panel not in list(data.keys()):
|
||||
data.update({work.processing_panel: []})
|
||||
for cnc in work.cnc_ids.filtered(lambda a: a.tool_state == '1'):
|
||||
if cnc.cutting_tool_name not in data[work.processing_panel]:
|
||||
data[work.processing_panel].append(cnc.cutting_tool_name)
|
||||
# 按格式生成缺刀提示信息
|
||||
for key in data:
|
||||
if data.get(key) and not data.get(key):
|
||||
if tool_state_remark != '':
|
||||
tool_state_remark = f'{tool_state_remark}\n{key}缺刀:{data.get(key)}'
|
||||
else:
|
||||
tool_state_remark = f'{key}缺刀:{data.get(key)}'
|
||||
item.tool_state = '1'
|
||||
item.tool_state_remark = tool_state_remark
|
||||
item.tool_state_remark2 = ''
|
||||
else:
|
||||
item.tool_state = '0'
|
||||
item.tool_state_remark = ''
|
||||
item.tool_state_remark2 = ''
|
||||
|
||||
# state = fields.Selection(selection_add=[
|
||||
# ('pending_scheduling', '待排程'),
|
||||
# ('pending_processing', '待加工'),
|
||||
|
||||
@@ -13,7 +13,7 @@ from dateutil.relativedelta import relativedelta
|
||||
# import subprocess
|
||||
from odoo import api, fields, models, SUPERUSER_ID, _
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.exceptions import UserError,ValidationError
|
||||
from odoo.addons.sf_mrs_connect.models.ftp_operate import FtpController
|
||||
|
||||
|
||||
@@ -170,6 +170,21 @@ class ResMrpWorkOrder(models.Model):
|
||||
# 加工图纸
|
||||
processing_drawing = fields.Binary(string='加工图纸')
|
||||
|
||||
# 功能刀具状态
|
||||
tool_state = fields.Selection([('0', '正常'), ('1', '缺刀'), ('2', '无效刀')], string='功能刀具状态', default='0',
|
||||
store=True, compute='_compute_tool_state')
|
||||
|
||||
@api.depends('cnc_ids.tool_state')
|
||||
def _compute_tool_state(self):
|
||||
for item in self:
|
||||
if item:
|
||||
if item.cnc_ids.filtered(lambda a: a.tool_state == '2'):
|
||||
item.tool_state = '2'
|
||||
elif item.cnc_ids.filtered(lambda a: a.tool_state == '1'):
|
||||
item.tool_state = '1'
|
||||
else:
|
||||
item.tool_state = '0'
|
||||
|
||||
@api.depends('production_id')
|
||||
def _compute_save_name(self):
|
||||
"""
|
||||
@@ -999,6 +1014,8 @@ class ResMrpWorkOrder(models.Model):
|
||||
rfid_code = workorder.rfid_code
|
||||
workorder.write({'rfid_code_old': rfid_code,
|
||||
'rfid_code': False})
|
||||
if workorder.rfid_code:
|
||||
raise ValidationError(f'【{workorder.name}】工单解绑失败,请重新点击完成按钮!!!')
|
||||
# workorder.rfid_code_old = rfid_code
|
||||
# workorder.rfid_code = False
|
||||
logging.info('workorder.rfid_code:%s' % workorder.rfid_code)
|
||||
@@ -1095,6 +1112,8 @@ class CNCprocessing(models.Model):
|
||||
program_path = fields.Char('程序文件路径')
|
||||
program_create_date = fields.Datetime('程序创建日期')
|
||||
|
||||
tool_state = fields.Selection([('0', '正常'), ('1', '缺刀'), ('2', '无效刀')], string='刀具状态', default='0')
|
||||
|
||||
# mrs下发编程单创建CNC加工
|
||||
def cnc_processing_create(self, cnc_workorder, ret, program_path, program_path_tmp):
|
||||
cnc_processing = None
|
||||
|
||||
@@ -99,6 +99,9 @@
|
||||
<!-- <field name="production_line_state" readonly="1"/>-->
|
||||
<field name="part_number" string="成品的零件图号"/>
|
||||
<field name="part_drawing"/>
|
||||
<field name="tool_state"/>
|
||||
<field name="tool_state_remark" string="备注" attrs="{'invisible': [('tool_state', '!=', '1')]}"/>
|
||||
<field name="tool_state_remark2" string="备注" attrs="{'invisible': [('tool_state', '!=', '2')]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//header//button[@name='action_cancel']" position="replace">
|
||||
<button name="action_cancel" type="object" string="取消" data-hotkey="z"
|
||||
@@ -421,7 +424,9 @@
|
||||
<xpath expr="//header//button[@name='action_cancel']" position="replace">
|
||||
<button name="action_cancel" type="object" string="取消" groups="sf_base.group_sf_mrp_user"/>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//field[@name='state']" position="after">
|
||||
<field name="tool_state" invisible="1"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
</field>
|
||||
<field name="state" position="after">
|
||||
<field name="work_state" optional="hide"/>
|
||||
<field name="tool_state" invisible="1"/>
|
||||
<field name="product_tmpl_name" invisible="1"/>
|
||||
</field>
|
||||
<field name="duration" position="replace">
|
||||
@@ -124,6 +125,7 @@
|
||||
</button>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='state']" position="before">
|
||||
<field name='tool_state' invisible="1"/>
|
||||
<field name='user_permissions' invisible="1"/>
|
||||
<field name='name' invisible="1"/>
|
||||
<field name='is_rework' invisible="1"/>
|
||||
@@ -513,6 +515,7 @@
|
||||
<field name="sequence_number"/>
|
||||
<field name="program_name"/>
|
||||
<field name="cutting_tool_name"/>
|
||||
<field name="tool_state"/>
|
||||
<field name="cutting_tool_no"/>
|
||||
<field name="processing_type"/>
|
||||
<field name="margin_x_y"/>
|
||||
|
||||
Reference in New Issue
Block a user