Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/优化工件配送
This commit is contained in:
@@ -32,7 +32,9 @@ class MrpProduction(models.Model):
|
||||
('draft', 'Draft'),
|
||||
('confirmed', 'Confirmed'),
|
||||
('progress', '待排程'),
|
||||
('pending_cam', '待装夹'),
|
||||
('pending_processing', '待加工'),
|
||||
('pending_era_cam', '待解除装夹'),
|
||||
('completed', '已完工'),
|
||||
('to_close', 'To Close'),
|
||||
('done', 'Done'),
|
||||
@@ -54,15 +56,29 @@ class MrpProduction(models.Model):
|
||||
glb_file = fields.Binary("glb模型文件")
|
||||
production_line_id = fields.Many2one('sf.production.line', string='生产线')
|
||||
plan_start_processing_time = fields.Datetime('计划开始加工时间')
|
||||
production_line_state = fields.Selection(
|
||||
[('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')],
|
||||
string='上/下产线', default='待上产线')
|
||||
production_line_state = fields.Selection([('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')],
|
||||
string='上/下产线', default='待上产线')
|
||||
# 工序状态
|
||||
# Todo 研究下用法
|
||||
process_state = fields.Selection([
|
||||
('待装夹', '待装夹'),
|
||||
('待检测', '待检测'),
|
||||
('待加工', '待加工'),
|
||||
('待解除装夹', '待解除装夹'),
|
||||
('已完工', '已完工'),
|
||||
], string='工序状态', related='workorder_ids.process_state', store=True)
|
||||
|
||||
# 零件图号
|
||||
part_number = fields.Char('零件图号')
|
||||
|
||||
# 上传零件图纸
|
||||
part_drawing = fields.Binary('零件图纸')
|
||||
|
||||
manual_quotation = fields.Boolean('人工编程', default=False, readonly=True)
|
||||
|
||||
@api.depends(
|
||||
'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state',
|
||||
'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state')
|
||||
'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state', 'process_state')
|
||||
def _compute_state(self):
|
||||
for production in self:
|
||||
if not production.state or not production.product_uom_id:
|
||||
@@ -94,11 +110,15 @@ class MrpProduction(models.Model):
|
||||
production.state = 'progress'
|
||||
|
||||
# 新添加的状态逻辑
|
||||
if production.state == 'progress' and production.schedule_state == '已排':
|
||||
if production.state == 'progress' and production.schedule_state == '已排' and production.process_state == '待装夹':
|
||||
# production.state = 'pending_processing'
|
||||
production.state = 'pending_cam'
|
||||
if production.state == 'progress' and production.schedule_state == '已排' and production.process_state == '待加工':
|
||||
# if production.state == 'pending_cam' and production.process_state == '待加工':
|
||||
production.state = 'pending_processing'
|
||||
# elif production.state == 'progress' and production.schedule_state == '已完成':
|
||||
# production.state = 'completed'
|
||||
elif production.state == 'pending_processing' and production.work_order_state == '已完成':
|
||||
elif production.state == 'progress' and production.process_state == '待解除装夹':
|
||||
production.state = 'pending_era_cam'
|
||||
elif production.state == 'progress' and production.process_state == '已完工':
|
||||
production.state = 'completed'
|
||||
elif production.state == 'progress' and production.work_order_state == '已完成':
|
||||
production.state = 'completed'
|
||||
|
||||
@@ -123,6 +123,23 @@ class ResMrpWorkOrder(models.Model):
|
||||
# 获取数据状态
|
||||
data_state = fields.Boolean(string='获取数据状态', default=False)
|
||||
|
||||
# 坯料长宽高
|
||||
material_length = fields.Float(string='长')
|
||||
material_width = fields.Float(string='宽')
|
||||
material_height = fields.Float(string='高')
|
||||
# 零件图号
|
||||
part_number = fields.Char(string='零件图号')
|
||||
# 工序状态
|
||||
process_state = fields.Selection([
|
||||
('待装夹', '待装夹'),
|
||||
('待检测', '待检测'),
|
||||
('待加工', '待加工'),
|
||||
('待解除装夹', '待解除装夹'),
|
||||
('已完工', '已完工'),
|
||||
], string='工序状态', default='待装夹')
|
||||
# 加工图纸
|
||||
processing_drawing = fields.Binary(string='加工图纸', related='production_id.part_drawing')
|
||||
|
||||
@api.depends('production_id')
|
||||
def _compute_save_name(self):
|
||||
"""
|
||||
@@ -390,7 +407,10 @@ 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]
|
||||
work.process_state = '待加工'
|
||||
self.sudo().production_id.state = 'pending_processing'
|
||||
workorder.button_finish()
|
||||
|
||||
except Exception as e:
|
||||
# 重新抛出捕获到的异常信息
|
||||
raise UserError(str(e))
|
||||
@@ -696,6 +716,11 @@ class ResMrpWorkOrder(models.Model):
|
||||
'materiel_width': self.move_raw_ids[0].product_id.width,
|
||||
'materiel_height': self.move_raw_ids[0].product_id.height
|
||||
})
|
||||
self.write({
|
||||
'material_length': self.move_raw_ids[0].product_id.length,
|
||||
'material_width': self.move_raw_ids[0].product_id.width,
|
||||
'material_height': self.move_raw_ids[0].product_id.height
|
||||
})
|
||||
|
||||
self.ensure_one()
|
||||
if any(not time.date_end for time in self.time_ids.filtered(lambda t: t.user_id.id == self.env.user.id)):
|
||||
@@ -782,6 +807,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
workorder.rfid_code = None
|
||||
for move_raw_id in self.production_id.move_raw_ids:
|
||||
move_raw_id.quantity_done = move_raw_id.product_uom_qty
|
||||
self.process_state = '已完工'
|
||||
self.production_id.button_mark_done1()
|
||||
# self.production_id.state = 'done'
|
||||
|
||||
@@ -1006,6 +1032,7 @@ class SfWorkOrderBarcodes(models.Model):
|
||||
for item in workorder_rfid:
|
||||
item.write({'rfid_code': barcode})
|
||||
logging.info("Rfid绑定成功!!!")
|
||||
self.process_state = '待检测'
|
||||
else:
|
||||
raise UserError('该托盘信息不存在!!!')
|
||||
# stock_move_line = self.env['stock.move.line'].search([('lot_name', '=', barcode)])
|
||||
|
||||
@@ -269,6 +269,13 @@ class ProductionLot(models.Model):
|
||||
rfid = fields.Char('Rfid', readonly=True)
|
||||
product_specification = fields.Char('规格', compute='_compute_product_specification', store=True)
|
||||
|
||||
def search_lot_put_rfid(self):
|
||||
# 使用SQL将所有刀柄Rfid不满十位的值在前方补零
|
||||
self.env.cr.execute(
|
||||
'''UPDATE stock_lot SET rfid = LPAD(rfid, 10, '0') WHERE rfid IS NOT NULL AND LENGTH(rfid) < 10'''
|
||||
)
|
||||
self.env.cr.commit()
|
||||
|
||||
@api.depends('product_id')
|
||||
def _compute_product_specification(self):
|
||||
for stock in self:
|
||||
|
||||
Reference in New Issue
Block a user