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

View File

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

View File

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

View File

@@ -12,7 +12,7 @@ class ReworkWizard(models.TransientModel):
workorder_id = fields.Many2one('mrp.workorder', string='工单') workorder_id = fields.Many2one('mrp.workorder', string='工单')
product_id = fields.Many2one('product.product') product_id = fields.Many2one('product.product')
production_ids = fields.Many2many('mrp.production', string='制造订单号') production_id = fields.Many2one('mrp.production', string='制造订单号')
rework_reason = fields.Selection( rework_reason = fields.Selection(
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"), [("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"),
("operate computer", "操机"), ("operate computer", "操机"),
@@ -23,11 +23,32 @@ class ReworkWizard(models.TransientModel):
('CNC加工', 'CNC加工')], string="工序类型") ('CNC加工', 'CNC加工')], string="工序类型")
# 根据工单的加工面来显示 # 根据工单的加工面来显示
processing_panel_id = fields.Many2one('sf.processing.panel', string="加工面") processing_panel_id = fields.Many2one('sf.processing.panel', string="加工面")
is_reprogramming = fields.Boolean(string='申请重新编程', default=False)
def confirm(self): 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.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, 'rework_reason': self.rework_reason,
'detailed_reason': self.detailed_reason, 'detailed_reason': self.detailed_reason,
# 'processing_panel': self.workorder_id.processing_panel, # 'processing_panel': self.workorder_id.processing_panel,
@@ -50,4 +71,3 @@ class ReworkWizard(models.TransientModel):
panel_ids.append(panel.id) panel_ids.append(panel.id)
domain = {'processing_panel_id': [('id', 'in', panel_ids)]} domain = {'processing_panel_id': [('id', 'in', panel_ids)]}
return {'domain': domain} return {'domain': domain}

View File

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