1.修复材料型号同步报验证问题2.优化工单的工件派送3.计划里新增生产线的优化

This commit is contained in:
jinling.yang
2024-01-26 17:46:53 +08:00
parent 37161e2e20
commit cf2aaa38fe
7 changed files with 51 additions and 42 deletions

View File

@@ -131,7 +131,7 @@ class ResMrpWorkOrder(models.Model):
maximum_clamping_force = fields.Char(string="最大夹持力[n]")
production_line = fields.Char(string="生产线")
preset_program_information = fields.Char(string="预调程序信息")
workpiece_delivery_id = fields.One2many('sf.workpiece.delivery', 'workorder_id', '工件配送')
workpiece_delivery_ids = fields.One2many('sf.workpiece.delivery', 'workorder_id', '工件配送')
@api.onchange('is_ok')
def _onchange_inspection_user_id(self):
@@ -196,9 +196,24 @@ class ResMrpWorkOrder(models.Model):
work = workorder.production_id.workorder_ids
work.compensation_value_x = eval(self.material_center_point)[0]
work.compensation_value_y = eval(self.material_center_point)[1]
workorder.button_finish()
except:
raise UserError("参数计算有误")
# def button_workpiece_delivery(self):
# if self.routing_type == '装夹预调':
# if not self.workpiece_delivery_ids:
# raise UserError('请添加【工件配送】信息')
# else:
# for item in self.workpiece_delivery_ids:
# if not item.feeder_station_start:
# raise UserError('【工件配送】明细中请输入起点接驳站')
# if not item.workpiece_code:
# raise UserError('请对【同运工件】进行扫描')
# else:
# workpiece_code
# 拼接工单对象属性值
def json_workorder_str(self, k, production, route):
# 计算预计时长duration_expected
@@ -241,7 +256,9 @@ class ResMrpWorkOrder(models.Model):
'date_planned_finished': False,
'duration_expected': duration_expected,
'duration': 0,
'workpiece_delivery_ids': False if not route.routing_type == '装夹预调' else self.env[
'sf.workpiece.delivery'].create(
{'production_id': production.id})
}]
return workorders_values_str
@@ -731,7 +748,7 @@ class SfWorkOrderBarcodes(models.Model):
if workorder:
if workorder.routing_type == '装夹预调':
stock_move_line = self.env['stock.move.line'].search([('lot_name', '=', barcode)])
if stock_move_line:
if stock_move_line.product_id.categ_type == '夹具':
workorder.write({
'tray_serial_number': stock_move_line.lot_name,
'tray_product_id': stock_move_line.product_id.id,
@@ -740,26 +757,36 @@ class SfWorkOrderBarcodes(models.Model):
'tray_model_id': stock_move_line.product_id.fixture_model_id.id
})
workorder.button_start()
# elif stock_move_line.product_id.categ_type == '坯料':
# if stock_move_line.production_id.production_line_id.id == workorder.production_id.production_line_id.id
# workorder.
class WorkPieceDelivery(models.Model):
_name = "sf.workpiece.delivery"
_description = '工件配送'
workorder_id = fields.Many2one('mrp.workorder', string='工单',
domain=[('name', 'in', ('装夹', '解除装夹'))])
production_code = fields.Char(related='workorder_id.production_id.name', string='工件编码/任务编码', store=True)
plan_start_processing_time = fields.Datetime('计划开始加工时间')
workorder_id = fields.Many2one('mrp.workorder', string='工单', readonly=True)
production_id = fields.Many2one('mrp.production', string='制造订单', readonly=True)
production_line_id = fields.Many2one('sf.production.line', compute='_compute_production_line_id',
string='目标生产线', readonly=True,
store=True)
plan_start_processing_time = fields.Datetime('计划开始加工时间', readonly=True)
workpiece_code = fields.Char('同运工件编码')
feeder_station_start = fields.Char('起点接驳站')
feeder_station_destination = fields.Char('目的接驳站')
production_line_id = fields.Many2one('sf.production.line', string='目标生产线')
task_delivery_time = fields.Datetime('任务下发时间')
task_completion_time = fields.Datetime('任务完成时间')
delivery_time = fields.Char('配送时长', compute='_compute_delivery_time')
status = fields.Selection([('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态',
default='待下发')
@api.depends('production_id.production_line_id')
def _compute_production_line_id(self):
if self.production_id.production_line_id:
self.production_line_id = self.production_id.production_line_id.id
self.plan_start_processing_time = self.production_id.plan_start_processing_time
@api.depends('task_delivery_time', 'task_completion_time')
def _compute_delivery_time(self):
for obj in self: