Merge branch 'develop' into feature/commercially_launched

This commit is contained in:
胡尧
2025-03-10 16:31:35 +08:00
14 changed files with 146 additions and 62 deletions

View File

@@ -365,7 +365,7 @@ class MrpProduction(models.Model):
and production.schedule_state == '已排' and production.is_rework is False):
production.state = 'pending_cam'
if any((wo.test_results == '返工' and wo.state == 'done' and
(production.programming_state in ['已编程'] or wo.individuation_page_PTD is True))
(production.programming_state in ['已编程'] or(wo.individuation_page_list and 'PTD' in wo.individuation_page_list)))
or (wo.is_rework is True and wo.state == 'done' and production.programming_state in ['编程中', '已编程'])
for wo in production.workorder_ids) or production.is_rework is True:
production.state = 'rework'
@@ -684,7 +684,6 @@ class MrpProduction(models.Model):
logging.info('change_programming_state error:%s' % e)
raise UserError("修改编程单状态失败,请联系管理员")
# cnc程序获取
def fetchCNC(self, production_names):
cnc = self.env['mrp.production'].search([('id', '=', self.id)])
@@ -714,9 +713,9 @@ class MrpProduction(models.Model):
[('id', '=', cnc.product_id.materials_type_id.id)]).materials_no,
'machining_processing_panel': cnc.product_id.model_processing_panel,
'machining_precision': '',
'embryo_long': cnc.product_id.bom_ids.bom_line_ids.product_id.length,
'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height,
'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width,
'embryo_long': cnc.product_id.bom_ids[0].bom_line_ids.product_id.length,
'embryo_height': cnc.product_id.bom_ids[0].bom_line_ids.product_id.height,
'embryo_width': cnc.product_id.bom_ids[0].bom_line_ids.product_id.width,
'order_no': cnc.origin,
'model_order_no': cnc.product_id.default_code,
'user': cnc.env.user.name,
@@ -1300,12 +1299,14 @@ class MrpProduction(models.Model):
'target': 'new',
'context': {
'default_production_id': self.id,
'default_is_clamping': True if self.workorder_ids.filtered(lambda wk: wk.routing_type == '装夹预调') else False,
'default_is_clamping': True if self.workorder_ids.filtered(
lambda wk: wk.routing_type == '装夹预调') else False,
'default_workorder_ids': workorder_ids.ids if workorder_ids.ids != [] else self.workorder_ids.ids,
'default_hidden_workorder_ids': ','.join(map(str, work_id_list)) if work_id_list != [] else '',
'default_reprogramming_num': cloud_programming.get('reprogramming_num') if cloud_programming else '',
'default_programming_state': cloud_programming.get('programming_state') if cloud_programming else '',
'default_is_reprogramming': True if cloud_programming and (cloud_programming.get('programming_state') in ['已下发']) else False
'default_is_reprogramming': True if cloud_programming and (
cloud_programming.get('programming_state') in ['已下发']) else False
}
}
@@ -1339,7 +1340,8 @@ class MrpProduction(models.Model):
for rework_item in rework_workorder:
pending_workorder = production.workorder_ids.filtered(
lambda m1: m1.state in [
'pending'] and m1.processing_panel == rework_item.processing_panel and m1.routing_type in ['CNC加工', '人工线下加工'])
'pending'] and m1.processing_panel == rework_item.processing_panel and m1.routing_type in [
'CNC加工', '人工线下加工'])
if not pending_workorder.cnc_ids:
production.get_new_program(rework_item.processing_panel)
# production.write({'state': 'progress', 'programming_state': '已编程', 'is_rework': False})
@@ -1382,8 +1384,9 @@ class MrpProduction(models.Model):
if productions:
for production in productions:
panel_workorder = production.workorder_ids.filtered(lambda
pw: pw.processing_panel == processing_panel and pw.routing_type in ['CNC加工', '人工线下加工'] and pw.state not in (
'rework', 'done'))
pw: pw.processing_panel == processing_panel and pw.routing_type in [
'CNC加工', '人工线下加工'] and pw.state not in (
'rework', 'done'))
if panel_workorder:
if panel_workorder.cmm_ids:
panel_workorder.cmm_ids.sudo().unlink()
@@ -1408,8 +1411,9 @@ class MrpProduction(models.Model):
'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
logging.info('len(cnc_worksheet):%s' % len(panel_workorder.cnc_worksheet))
pre_workorder = production.workorder_ids.filtered(lambda
ap: ap.routing_type in ['装夹预调', '人工线下加工'] and ap.processing_panel == processing_panel and ap.state not in (
'rework', 'done'))
ap: ap.routing_type in ['装夹预调',
'人工线下加工'] and ap.processing_panel == processing_panel and ap.state not in (
'rework', 'done'))
if pre_workorder:
pre_workorder.write(
{'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})

View File

@@ -1442,7 +1442,8 @@ class ResMrpWorkOrder(models.Model):
record.production_id.process_state = '待加工'
# 生成工件配送单
record.workpiece_delivery_ids = record._json_workpiece_delivery_list()
if record.routing_type == 'CNC加工' or record.individuation_page_PTD is True:
if (record.routing_type == 'CNC加工' or
(record.individuation_page_list and 'PTD' in record.individuation_page_list)):
if record.routing_type == 'CNC加工':
record.process_state = '待解除装夹'
# record.write({'process_state': '待加工'})
@@ -1675,31 +1676,31 @@ class ResMrpWorkOrder(models.Model):
move_subcontract_workorder_ids = fields.One2many('stock.move', 'subcontract_workorder_id', string='组件')
# ==============================配置化页签--个性化记录===================================
routing_workcenter_id = fields.Many2one('mrp.routing.workcenter', compute='_compute_routing_workcenter_id',
store=True)
individuation_page_ids = fields.Many2many('sf.work.individuation.page', string='个性化记录', store=True,
compute='_compute_individuation_page_ids')
individuation_page_PTD = fields.Boolean('个性化记录(是否显示后置三元检测[PTD]页签)', default=False)
routing_work_center_id = fields.Many2one('mrp.routing.workcenter', compute='_compute_routing_work_center_id',
store=True, string='工序作业')
individuation_page_ids = fields.Many2many('sf.work.individuation.page', string='个性化记录',
related='routing_work_center_id.individuation_page_ids')
individuation_page_list = fields.Char('个性化记录', default='', compute='_compute_individuation_page_ids', store=True)
@api.depends('name')
def _compute_routing_workcenter_id(self):
def _compute_routing_work_center_id(self):
for mw in self:
routing_workcenter_id = self.env['mrp.routing.workcenter'].sudo().search(
[('name', '=', mw.name), ('routing_type', '=', mw.routing_type)])
if routing_workcenter_id:
mw.routing_workcenter_id = routing_workcenter_id.id
if not mw.routing_work_center_id and mw.name:
routing_work_center_id = self.env['mrp.routing.workcenter'].sudo().search(
[('name', 'in', mw.name.split('-')), ('routing_type', '=', mw.routing_type)])
if routing_work_center_id:
mw.routing_work_center_id = routing_work_center_id.id
@api.depends('routing_workcenter_id.individuation_page_ids')
@api.depends('individuation_page_ids')
def _compute_individuation_page_ids(self):
for mw in self:
if mw.routing_workcenter_id:
mw.individuation_page_ids = mw.routing_workcenter_id.individuation_page_ids.ids
# 初始化页签配置
mw.individuation_page_PTD = False
# 根据工单对应的【作业_个性化记录】配置页签
if any(item.code == 'PTD' for item in mw.routing_workcenter_id.individuation_page_ids):
mw.individuation_page_PTD = True
mw.individuation_page_list = '[]'
if mw.routing_work_center_id:
if mw.individuation_page_ids:
# 根据工单对应的【作业_个性化记录】配置页签
individuation_page_list = [item.code for item in mw.individuation_page_ids]
if individuation_page_list:
mw.individuation_page_list = list(set(individuation_page_list))
# =============================================================================================
is_inspect = fields.Boolean('需送检', compute='_compute_is_inspect', store=True, default=False)
@@ -2009,7 +2010,7 @@ class WorkPieceDelivery(models.Model):
feeder_station_destination_id = fields.Many2one('sf.agv.site', '目的接驳站')
task_delivery_time = fields.Datetime('任务下发时间')
task_completion_time = fields.Datetime('任务完成时间')
def _get_agv_route_type_selection(self):
return self.env['sf.agv.task.route'].fields_get(['route_type'])['route_type']['selection']
type = fields.Selection(selection=_get_agv_route_type_selection, string='类型')