1.制造订单添加报废状态,

2.返工操作制造订单添加过滤条件:状态为报废
3.cnc工单完成检测结果添加报废
This commit is contained in:
jinling.yang
2024-08-08 15:40:29 +08:00
parent ce8b0127b8
commit 745658eff2
6 changed files with 20 additions and 16 deletions

View File

@@ -77,9 +77,10 @@ class MrpProduction(models.Model):
('pending_cam', '待加工'), ('pending_cam', '待加工'),
('progress', '加工中'), ('progress', '加工中'),
('rework', '返工'), ('rework', '返工'),
('scrap', '报废'),
('to_close', 'To Close'), ('to_close', 'To Close'),
('done', 'Done'), ('done', 'Done'),
('cancel', '报废')], string='State', ('cancel', '已取消')], string='State',
compute='_compute_state', copy=False, index=True, readonly=True, compute='_compute_state', copy=False, index=True, readonly=True,
store=True, tracking=True, store=True, tracking=True,
help=" * Draft: The MO is not confirmed yet.\n" help=" * Draft: The MO is not confirmed yet.\n"
@@ -166,7 +167,7 @@ class MrpProduction(models.Model):
production.state = 'pending_cam' production.state = 'pending_cam'
if production.state == 'progress': if production.state == 'progress':
if all(wo_state not in ('progress', 'done', 'rework') for wo_state in if all(wo_state not in ('progress', 'done', 'rework', 'scrap') for wo_state in
production.workorder_ids.mapped('state')): production.workorder_ids.mapped('state')):
production.state = 'pending_cam' production.state = 'pending_cam'
if production.is_rework is True: if production.is_rework is True:
@@ -184,9 +185,11 @@ class MrpProduction(models.Model):
for wo in for wo in
production.workorder_ids): production.workorder_ids):
production.state = 'rework' production.state = 'rework'
if any(wo.test_results == '报废' and wo.state == 'done' for wo in production.workorder_ids):
production.state = 'scrap'
# 如果制造订单的功能刀具为【无效刀】则制造订单状态改为返工 # 如果制造订单的功能刀具为【无效刀】则制造订单状态改为返工
# if production.tool_state == '2': if production.tool_state == '2':
# production.state = 'rework' production.state = 'rework'
def action_check(self): def action_check(self):
""" """
@@ -866,7 +869,7 @@ class MrpProduction(models.Model):
if download_state is False: if download_state is False:
raise UserError('编程单号为%s的CNC程序文件从FTP拉取失败' % (self.programming_no)) raise UserError('编程单号为%s的CNC程序文件从FTP拉取失败' % (self.programming_no))
productions = self.env['mrp.production'].search( productions = self.env['mrp.production'].search(
[('programming_no', '=', self.programming_no), ('state', 'not in', ('cancel', 'done'))]) [('programming_no', '=', self.programming_no), ('state', 'not in', ('cancel', 'done', 'scrap'))])
if productions: if productions:
for production in productions: for production in productions:
panel_workorder = production.workorder_ids.filtered(lambda panel_workorder = production.workorder_ids.filtered(lambda

View File

@@ -1144,7 +1144,8 @@ class ResMrpWorkOrder(models.Model):
'detailed_reason': record.detailed_reason, 'detailed_reason': record.detailed_reason,
'processing_panel': record.processing_panel, 'processing_panel': record.processing_panel,
'routing_type': record.routing_type, 'routing_type': record.routing_type,
'handle_result': '待处理' if record.test_results == '返工' or record.is_rework is True else '', 'handle_result': '待处理' if record.test_results in ['返工',
'报废'] or record.is_rework is True else '',
'test_results': record.test_results, 'test_results': record.test_results,
'test_report': record.detection_report})], 'test_report': record.detection_report})],
'is_scrap': True if record.test_results == '报废' else False}) 'is_scrap': True if record.test_results == '报废' else False})

View File

@@ -9,8 +9,8 @@ from odoo.exceptions import ValidationError, UserError
from odoo.modules import get_resource_path from odoo.modules import get_resource_path
from OCC.Extend.DataExchange import read_step_file # from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.DataExchange import write_stl_file # from OCC.Extend.DataExchange import write_stl_file
class ResProductMo(models.Model): class ResProductMo(models.Model):

View File

@@ -122,15 +122,15 @@
groups="sf_base.group_sf_mrp_user"/> groups="sf_base.group_sf_mrp_user"/>
</xpath> </xpath>
<xpath expr="(//header//button[@name='button_scrap'])" position="replace"> <xpath expr="(//header//button[@name='button_scrap'])" position="replace">
<button name="button_scrap" invisible="0"/> <button name="button_scrap" invisible="1"/>
<button name="do_update_program" string="更新程序" type="object" groups="sf_base.group_sf_mrp_user" <button name="do_update_program" string="更新程序" type="object" groups="sf_base.group_sf_mrp_user"
confirm="是否确认更新程序" confirm="是否确认更新程序"
attrs="{'invisible': ['|',('state', '!=', 'rework'),('programming_state', '!=', '已编程未下发')]}"/> attrs="{'invisible': ['|',('state', '!=', 'rework'),('programming_state', '!=', '已编程未下发')]}"/>
<button name="button_rework" string="返工" type="object" groups="sf_base.group_sf_mrp_user" <button name="button_rework" string="返工" type="object" groups="sf_base.group_sf_mrp_user"
attrs="{'invisible': ['|',('state', '!=', 'rework') ,('programming_state', '!=', '已编程')]}"/> attrs="{'invisible': ['|',('state', '!=', 'rework') ,('programming_state', '!=', '已编程')]}"/>
<!-- <button name="%(sf_manufacturing.action_sf_production_wizard)d" string="报废" type="action"--> <button name="%(sf_manufacturing.action_sf_production_wizard)d" string="报废" type="action"
<!-- groups="sf_base.group_sf_mrp_user"--> groups="sf_base.group_sf_mrp_user"
<!-- attrs="{'invisible': [('is_scrap', '=', False)]}"/>--> attrs="{'invisible': [('is_scrap', '=', False)]}"/>
</xpath> </xpath>
<xpath expr="(//header//button[@name='button_mark_done'])[3]" position="replace"> <xpath expr="(//header//button[@name='button_mark_done'])[3]" position="replace">
<button name="button_mark_done" attrs="{'invisible': [ <button name="button_mark_done" attrs="{'invisible': [

View File

@@ -8,8 +8,8 @@ from datetime import datetime
import requests import requests
from odoo import http from odoo import http
from odoo.http import request from odoo.http import request
from OCC.Extend.DataExchange import read_step_file # from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.DataExchange import write_stl_file # from OCC.Extend.DataExchange import write_stl_file
from odoo import models, fields, api from odoo import models, fields, api
from odoo.modules import get_resource_path from odoo.modules import get_resource_path
from odoo.exceptions import ValidationError, UserError from odoo.exceptions import ValidationError, UserError

View File

@@ -6,8 +6,8 @@ import os
from datetime import datetime from datetime import datetime
from stl import mesh from stl import mesh
# from OCC.Core.GProp import GProp_GProps # from OCC.Core.GProp import GProp_GProps
from OCC.Extend.DataExchange import read_step_file # from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.DataExchange import write_stl_file # from OCC.Extend.DataExchange import write_stl_file
from odoo.addons.sf_base.commons.common import Common from odoo.addons.sf_base.commons.common import Common
from odoo import models, fields, api from odoo import models, fields, api
from odoo.modules import get_resource_path from odoo.modules import get_resource_path