1.修复销售订单确认按钮确认后不可见2.修复表面工艺工单完成3.下发编程单工件配送优化
This commit is contained in:
@@ -311,11 +311,9 @@ class MrpProduction(models.Model):
|
||||
production_programming = self.search(
|
||||
[('product_id.id', '=', production.product_id.id), ('origin', '=', production.origin)],
|
||||
limit=1, order='id asc')
|
||||
logging.info('production_programming1:%s' % production_programming.programming_no)
|
||||
if not production_programming.programming_no:
|
||||
production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id]))
|
||||
else:
|
||||
logging.info('production_programming2:%s' % production_programming.programming_no)
|
||||
production.write({'programming_no': production_programming.programming_no,
|
||||
'programming_state': '编程中'})
|
||||
# # 根据加工面板的面数及对应的工序模板生成工单
|
||||
|
||||
@@ -667,36 +667,6 @@ class ResMrpWorkOrder(models.Model):
|
||||
# 'domain': [('production_id', '=', self.id)],
|
||||
# 'target':'new'
|
||||
# }
|
||||
@api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state')
|
||||
def _compute_state(self):
|
||||
for workorder in self:
|
||||
if workorder.routing_type == '装夹预调':
|
||||
cnc_workorder = self.search(
|
||||
[('production_id', '=', workorder.production_id.id), ('routing_type', '=', 'CNC加工')],
|
||||
limit=1, order='id asc')
|
||||
if not cnc_workorder:
|
||||
workorder.state = 'waiting'
|
||||
else:
|
||||
for item in cnc_workorder.cnc_ids:
|
||||
functional_cutting_tool = self.env['sf.functional.cutting.tool.entity'].search(
|
||||
[('tool_name_id.name', '=', item.cutting_tool_name)])
|
||||
if not functional_cutting_tool:
|
||||
workorder.state = 'waiting'
|
||||
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 recreateManufacturingOrWorkerOrder(self):
|
||||
"""
|
||||
@@ -777,7 +747,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
cnc_workorder = self.search(
|
||||
[('production_id', '=', self.production_id.id), ('routing_type', '=', 'CNC加工')],
|
||||
limit=1, order='id asc')
|
||||
if not cnc_workorder:
|
||||
if not cnc_workorder.cnc_ids:
|
||||
raise UserError(_('该制造订单还未下发CNC程序,请稍后再试'))
|
||||
else:
|
||||
for item in cnc_workorder.cnc_ids:
|
||||
@@ -884,31 +854,38 @@ class ResMrpWorkOrder(models.Model):
|
||||
'''
|
||||
record.date_finished = datetime.now()
|
||||
if record.routing_type == '表面工艺':
|
||||
if record.picking_ids[0]:
|
||||
logging.info('record.picking_ids:%s' % record.picking_ids)
|
||||
logging.info('record.picking_out:%s' % record.picking_ids[0])
|
||||
if record.picking_ids:
|
||||
for pick_item in record.picking_ids:
|
||||
if pick_item.state not in ['done']:
|
||||
raise UserError(
|
||||
'请先完成该工单的工艺外协再进行操作')
|
||||
picking_out = record.env['stock.move.line'].search(
|
||||
[('picking_id', '=', record.picking_ids[0].id), ('workorder_id', '=', record.id)])
|
||||
[('picking_id', '=', record.picking_ids[0].id)])
|
||||
logging.info('picking_out:%s' % picking_out.picking_id.name)
|
||||
if picking_out:
|
||||
order_line_ids = []
|
||||
for item in picking_out.workorder_id:
|
||||
server_product = self.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=', item.surface_technics_parameters_id.id),
|
||||
('detailed_type', '=', 'service')])
|
||||
if server_product:
|
||||
order_line_ids.append((0, 0, {
|
||||
'product_id': server_product.product_variant_id.id,
|
||||
'product_qty': 1,
|
||||
'origin': record.production_id.name,
|
||||
'product_uom': server_product.uom_id.id
|
||||
}))
|
||||
else:
|
||||
raise UserError(
|
||||
'请先在产品中配置表面工艺为%s相关的外协服务产品' % item.surface_technics_parameters_id.name)
|
||||
if order_line_ids:
|
||||
logging.info('surface_technics_parameters_id:%s' % record.surface_technics_parameters_id.name)
|
||||
server_product = self.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=', record.surface_technics_parameters_id.id),
|
||||
('detailed_type', '=', 'service')])
|
||||
logging.info('server_product:%s' % server_product.name)
|
||||
if server_product:
|
||||
order_line_ids.append((0, 0, {
|
||||
'product_id': server_product.product_variant_id.id,
|
||||
'product_qty': 1,
|
||||
'product_uom': server_product.uom_id.id
|
||||
}))
|
||||
self.env['purchase.order'].create({
|
||||
'partner_id': server_product.seller_ids.partner_id.id,
|
||||
'origin': record.production_id.name,
|
||||
'state': 'draft',
|
||||
'order_line': order_line_ids,
|
||||
})
|
||||
else:
|
||||
raise UserError(
|
||||
'请先在产品中配置表面工艺为%s相关的外协服务产品' % item.surface_technics_parameters_id.name)
|
||||
tem_date_planned_finished = record.date_planned_finished
|
||||
logging.info('routing_type:%s' % record.routing_type)
|
||||
super().button_finish()
|
||||
|
||||
@@ -73,10 +73,7 @@ class Sf_Mrs_Connect(http.Controller):
|
||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
|
||||
[('production_id', 'in', cnc_program_ids)])
|
||||
if workpiece_delivery:
|
||||
for item in workpiece_delivery:
|
||||
item.is_cnc_program_down = True
|
||||
if item.workorder_id.state == 'waiting':
|
||||
item.workorder_id.state = 'ready'
|
||||
workpiece_delivery.write({'is_cnc_program_down': True})
|
||||
return json.JSONEncoder().encode(res)
|
||||
else:
|
||||
res = {'status': 0, 'message': '该制造订单暂未开始'}
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
<xpath expr="//form/header/button[@name='action_confirm'][2]" position="replace">
|
||||
<button name="action_confirm" data-hotkey="v"
|
||||
string="确认" type="object" context="{'validate_analytic': True}"
|
||||
attrs="{'invisible': ['|','&',('check_status', '!=', 'approved'),('state', 'in', ['draft','cancel']),'&','&',('check_status', '=', 'approved'),('state', 'in', ['sale','cancel']),('mrp_production_count', '>', 0)]}"/>
|
||||
attrs="{'invisible': ['|','&',('check_status', '!=', 'approved'),('state', 'in', ['draft','cancel']),'&','&',('check_status', '=', 'approved'),('state', 'in', ['sale','cancel']),('mrp_production_count', '!=', 0)]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//form/header/button[@name='action_cancel']" position="attributes">
|
||||
<attribute name="attrs">{'invisible': ['|','&',('state', 'in',
|
||||
|
||||
Reference in New Issue
Block a user