1.工单状态新增‘返工’,2,在制造订单上点击返工选择加工面确认后,新增加工面的对应工单及新增重置cloud的编程单的状态3.优化返工向导

This commit is contained in:
jinling.yang
2024-07-09 17:36:47 +08:00
parent b383a6d229
commit 7533d23d3e
5 changed files with 100 additions and 74 deletions

View File

@@ -103,7 +103,8 @@ class MrpProduction(models.Model):
precision_rounding=production.product_uom_id.rounding) >= 0:
production.state = 'to_close'
elif any(
wo.test_results == '返工' and wo.state == 'done' for wo in production.workorder_ids):
(wo.test_results == '返工' and wo.state == 'done') or wo.state == 'rework' for wo in
production.workorder_ids):
production.state = 'rework'
elif any(wo_state in ('progress', 'done') for wo_state in production.workorder_ids.mapped('state')):
production.state = 'progress'
@@ -155,27 +156,25 @@ class MrpProduction(models.Model):
for production in self:
production.maintenance_count = len(production.request_ids)
# 制造订单报废:编程单更新
def updateCNC(self):
# 编程单更新
def update_programming_state(self):
try:
res = {'production_no': self.name, 'programming_no': self.programming_no,
'order_no': self.origin}
res = {'programming_no': self.programming_no}
logging.info('res=%s:' % res)
configsettings = self.env['res.config.settings'].get_values()
config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
url = '/api/intelligent_programming/update_intelligent_programmings'
url = '/api/intelligent_programming/reset_state_again'
config_url = configsettings['sf_url'] + url
res['token'] = configsettings['token']
ret = requests.post(config_url, json={}, data=res, headers=config_header)
ret = ret.json()
logging.info('updateCNC-ret:%s' % ret)
logging.info('update_programming_state-ret:%s' % ret)
if ret['status'] == 1:
self.write({'work_state': '已编程'})
else:
raise UserError(ret['message'])
except Exception as e:
logging.info('updateCNC error:%s' % e)
raise UserError("更新程单失败,请联系管理员")
logging.info('update_programming_state error:%s' % e)
raise UserError("更新程单状态失败,请联系管理员")
# cnc程序获取
def fetchCNC(self, production_names):
@@ -698,8 +697,9 @@ class MrpProduction(models.Model):
'res_model': 'sf.rework.wizard',
'target': 'new',
'context': {
'default_production_id': [(6, 0, [self.id])],
'default_product_id': self.product_id.id
'default_production_id': self.id,
'default_product_id': self.product_id.id,
'default_is_reprogramming': True
}
}

View File

@@ -47,7 +47,7 @@ class ResMrpWorkOrder(models.Model):
('切割', '切割'), ('表面工艺', '表面工艺')
], string="工序类型")
results = fields.Char('结果')
state = fields.Selection(selection_add=[('to be detected', "待检测")])
state = fields.Selection(selection_add=[('to be detected', "待检测"), ('rework', '返工')])
manual_quotation = fields.Boolean('人工编程', default=False, readonly=True)
@@ -820,26 +820,26 @@ class ResMrpWorkOrder(models.Model):
# @api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state')
# def _compute_state(self):
# super(ResMrpWorkOrder, self)._compute_state()
# for item in self:
# print(item.name)
# print(item.state)
# print(item.is_remanufacture)
# scrap_workorder = self.env['mrp.workorder'].search(
# [('production_id', '=', item.production_id.id), ('routing_type', '=', 'CNC加工'),
# ('state', '=', 'done'), ('test_results', 'in', ['返工', '报废'])])
# print(scrap_workorder)
# # if item.routing_type == 'CNC加工' and item.state in ['done'] and item.test_results in ['返工', '报废']:
# if item.routing_type == '解除装夹':
# if scrap_workorder and item.state not in ['cancel']:
# item.state = 'cancel'
# elif item.routing_type == '表面工艺':
# if scrap_workorder:
# stock_move = self.env['stock.move'].search(
# [('origin', '=', item.production_id.name)])
# stock_move.write({'state': 'cancel'})
# item.picking_ids.write({'state': 'cancel'})
# item.state = 'cancel'
# for workorder in self:
# if any(
# (wo.test_results == '返工' and wo.state == 'done') or wo.state == 'rework' for wo in
# production.workorder_ids):
# production.state = 'rework'
# if workorder.state == 'pending':
# if all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
# workorder.state = 'ready' if workorder.production_id.reservation_state == 'assigned' else 'waiting'
# continue
# if workorder.state not in ('waiting', 'ready'):
# continue
# if not all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
# workorder.state = 'pending'
# continue
# if workorder.production_id.reservation_state not in ('waiting', 'confirmed', 'assigned'):
# continue
# if workorder.production_id.reservation_state == 'assigned' and workorder.state == 'waiting':
# workorder.state = 'ready'
# elif workorder.production_id.reservation_state != 'assigned' and workorder.state == 'ready':
# workorder.state = 'waiting'
# 重写工单开始按钮方法
def button_start(self):
@@ -1175,6 +1175,7 @@ class CNCprocessing(models.Model):
def _json_cnc_processing(self, panel, ret):
cnc_processing = []
if ret is not False:
for item in ret['programming_list']:
if item['processing_panel'] == panel and item['ftp_path'].find('.dmi') == -1:
cnc_processing.append((0, 0, {
@@ -1648,6 +1649,7 @@ class CMMprogram(models.Model):
def _json_cmm_program(self, panel, ret):
cmm_program = []
if ret is not False:
for item in ret['programming_list']:
if item['processing_panel'] == panel and item['ftp_path'].find('.dmi') != -1:
cmm_program.append((0, 0, {

View File

@@ -11,7 +11,7 @@
<field name="name" decoration-success="is_subcontract" decoration-bf="is_subcontract"/>
</field>
<field name="name" position="before">
<field name="sequence" optional="hide"/>
<field name="sequence" />
<field name='user_permissions' invisible="1"/>
</field>
<field name="name" position="after">

View File

@@ -12,7 +12,7 @@ class ReworkWizard(models.TransientModel):
workorder_id = fields.Many2one('mrp.workorder', string='工单')
product_id = fields.Many2one('product.product')
production_ids = fields.Many2many('mrp.production', string='制造订单号')
production_id = fields.Many2one('mrp.production', string='制造订单号')
rework_reason = fields.Selection(
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"),
("operate computer", "操机"),
@@ -23,11 +23,32 @@ class ReworkWizard(models.TransientModel):
('CNC加工', 'CNC加工')], string="工序类型")
# 根据工单的加工面来显示
processing_panel_id = fields.Many2one('sf.processing.panel', string="加工面")
is_reprogramming = fields.Boolean(string='申请重新编程', default=False)
def confirm(self):
if len(self.production_ids) == 1:
if self.is_reprogramming is True:
if self.production_id.workorder_ids:
panel_workorder = self.production_id.workorder_ids.filtered(
lambda ap: ap.processing_panel == self.processing_panel_id.name)
if panel_workorder:
panel_workorder.write({'state': 'rework'})
product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
[('product_model_type_id', '=', self.production_id.product_id.product_model_type_id.id)],
order='sequence asc'
)
workorders_values = []
for route in product_routing_workcenter:
if route.is_repeat is True:
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str(self.processing_panel_id.name,
self.production_id, route, False))
if workorders_values:
self.production_id.write({'workorder_ids': workorders_values, 'programming_state': '编程中'})
self.production_id._reset_work_order_sequence()
self.production_id.update_programming_state()
else:
self.workorder_id.is_rework = True
self.production_ids.write({'detection_result_ids': [(0, 0, {
self.production_id.write({'detection_result_ids': [(0, 0, {
'rework_reason': self.rework_reason,
'detailed_reason': self.detailed_reason,
# 'processing_panel': self.workorder_id.processing_panel,
@@ -50,4 +71,3 @@ class ReworkWizard(models.TransientModel):
panel_ids.append(panel.id)
domain = {'processing_panel_id': [('id', 'in', panel_ids)]}
return {'domain': domain}

View File

@@ -6,13 +6,17 @@
<field name="arch" type="xml">
<form>
<sheet>
<field name="production_ids" invisible="True"/>
<field name="production_id" invisible="True"/>
<field name="workorder_id" invisible="True"/>
<field name="product_id" invisible="True"/>
<group>
<field name="processing_panel_id" options="{'no_create': True}" />
<field name="rework_reason" required="1"/>
<field name="detailed_reason" required="1"/>
<field name="processing_panel_id" options="{'no_create': True}"/>
<field name="is_reprogramming"
attrs='{"invisible": [("is_reprogramming","=",False)],"readonly": [("is_reprogramming","=",True)]}'/>
<field name="rework_reason"
attrs='{"invisible": [("is_reprogramming","=",True)],"required": [("is_reprogramming","=",False)]}'/>
<field name="detailed_reason"
attrs='{"invisible": [("is_reprogramming","=",True)],"required": [("is_reprogramming","=",False)]}'/>
</group>
<footer>
<button string="确认" name="confirm" type="object" class="oe_highlight" confirm="是否确认返工"/>