Accept Merge Request #1699: (feature/part_number -> develop)
Merge Request: 表面工艺采购单确认订单进行限制 Created By: @廖丹龙 Reviewed By: @胡尧 Approved By: @胡尧 Accepted By: @廖丹龙 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1699
This commit is contained in:
@@ -1035,49 +1035,6 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
'production_id.tool_state', 'production_id.schedule_state', 'sequence',
|
'production_id.tool_state', 'production_id.schedule_state', 'sequence',
|
||||||
'production_id.programming_state')
|
'production_id.programming_state')
|
||||||
def _compute_state(self):
|
def _compute_state(self):
|
||||||
# super()._compute_state()
|
|
||||||
# for workorder in self:
|
|
||||||
# if workorder.sequence != 1:
|
|
||||||
# previous_workorder = self.env['mrp.workorder'].search(
|
|
||||||
# [('production_id', '=', workorder.production_id.id),
|
|
||||||
# ('sequence', '=', workorder.sequence - 1)])
|
|
||||||
# if workorder.state == 'pending':
|
|
||||||
# if all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
|
|
||||||
# if workorder.production_id.reservation_state == 'assigned' and workorder.production_id.schedule_state == '已排':
|
|
||||||
# if ((workorder.sequence == 1 and not workorder.blocked_by_workorder_ids)
|
|
||||||
# or (workorder.blocked_by_workorder_ids.state in ('done', 'cancel')
|
|
||||||
# and workorder.blocked_by_workorder_ids.test_results not in ['报废', '返工'])
|
|
||||||
# or (previous_workorder.state in ('done', 'cancel')
|
|
||||||
# and not workorder.blocked_by_workorder_ids
|
|
||||||
# and previous_workorder.test_results not in ['报废', '返工'])
|
|
||||||
# ):
|
|
||||||
# workorder.state = 'ready'
|
|
||||||
# continue
|
|
||||||
# if workorder.production_id.schedule_state == '未排' and workorder.state in ('waiting', 'ready'):
|
|
||||||
# if workorder.sequence != 1:
|
|
||||||
# workorder.state = 'pending'
|
|
||||||
# continue
|
|
||||||
# if workorder.state not in ('waiting', 'ready'):
|
|
||||||
# continue
|
|
||||||
# if workorder.state in (
|
|
||||||
# 'waiting') and workorder.sequence == 1 and workorder.production_id.schedule_state == '已排':
|
|
||||||
# workorder.state = 'ready'
|
|
||||||
# continue
|
|
||||||
# if not all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
|
|
||||||
# workorder.state = 'pending'
|
|
||||||
# if workorder.state in ['waiting']:
|
|
||||||
# if previous_workorder.state == 'waiting':
|
|
||||||
# workorder.state = 'pending'
|
|
||||||
# if workorder.sequence == 1 and workorder.state == 'pending':
|
|
||||||
# workorder.state = 'waiting'
|
|
||||||
# continue
|
|
||||||
# if workorder.production_id.reservation_state not in ('waiting', 'confirmed', 'assigned'):
|
|
||||||
# continue
|
|
||||||
# if workorder.production_id.reservation_state == 'assigned' and workorder.state == 'waiting' and workorder.production_id.schedule_state == '已排':
|
|
||||||
# workorder.state = 'ready'
|
|
||||||
# elif workorder.production_id.reservation_state != 'assigned' and workorder.state == 'ready':
|
|
||||||
# workorder.state = 'waiting'
|
|
||||||
|
|
||||||
for workorder in self:
|
for workorder in self:
|
||||||
# 如果工单的工序没有进行排序则跳出循环
|
# 如果工单的工序没有进行排序则跳出循环
|
||||||
if workorder.production_id.workorder_ids.filtered(lambda wk: wk.sequence == 0):
|
if workorder.production_id.workorder_ids.filtered(lambda wk: wk.sequence == 0):
|
||||||
@@ -1119,7 +1076,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
if workorder.state != 'waiting':
|
if workorder.state != 'waiting':
|
||||||
workorder.state = 'waiting'
|
workorder.state = 'waiting'
|
||||||
continue
|
continue
|
||||||
if workorder.production_id.programming_state == '已编程':
|
if workorder.production_id.programming_state == '已编程' and workorder.technology_design_id.routing_tag != 'special':
|
||||||
workorder.state = 'ready'
|
workorder.state = 'ready'
|
||||||
elif workorder.state != 'waiting':
|
elif workorder.state != 'waiting':
|
||||||
workorder.state = 'waiting'
|
workorder.state = 'waiting'
|
||||||
@@ -1134,85 +1091,12 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
if workorder.is_subcontract is False:
|
if workorder.is_subcontract is False:
|
||||||
workorder.state = 'ready'
|
workorder.state = 'ready'
|
||||||
else:
|
else:
|
||||||
# production_programming = self.env['mrp.production'].search(
|
|
||||||
# [('origin', '=', self.production_id.origin)], order='name asc')
|
|
||||||
# production_no_remanufacture = production_programming.filtered(
|
|
||||||
# lambda a: a.is_remanufacture is False)
|
|
||||||
# production_list = [production.name for production in production_programming]
|
|
||||||
# purchase_orders = self.env['purchase.order'].search(
|
|
||||||
# [('origin', 'ilike', ','.join(production_list))])
|
|
||||||
# for line in purchase_orders.order_line:
|
|
||||||
# if (
|
|
||||||
# line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id
|
|
||||||
# and line.product_qty == len(production_no_remanufacture)):
|
|
||||||
# if all(pur_order.state == 'purchase' for pur_order in purchase_orders):
|
|
||||||
# workorder.state = 'ready'
|
|
||||||
# else:
|
|
||||||
# workorder.state = 'waiting'
|
|
||||||
purchase_orders_id = self._get_surface_technics_purchase_ids()
|
purchase_orders_id = self._get_surface_technics_purchase_ids()
|
||||||
if purchase_orders_id:
|
if purchase_orders_id:
|
||||||
workorder.state = 'ready' if purchase_orders_id.state == 'purchase' else 'waiting'
|
workorder.state = 'ready' if purchase_orders_id.state == 'purchase' else 'waiting'
|
||||||
else:
|
else:
|
||||||
workorder.state = 'waiting'
|
workorder.state = 'waiting'
|
||||||
|
|
||||||
# re_work = self.env['mrp.workorder'].search([('production_id', '=', workorder.production_id.id),
|
|
||||||
# ('processing_panel', '=', workorder.processing_panel),
|
|
||||||
# ('is_rework', '=', True), ('state', 'in', ['done', 'rework'])])
|
|
||||||
# cnc_workorder = self.env['mrp.workorder'].search(
|
|
||||||
# [('production_id', '=', workorder.production_id.id),
|
|
||||||
# ('processing_panel', '=', workorder.processing_panel),
|
|
||||||
# ('routing_type', '=', 'CNC加工'), ('state', 'in', ['done', 'rework']),
|
|
||||||
# ('test_results', '=', '返工')])
|
|
||||||
# cnc_workorder_pending = self.env['mrp.workorder'].search(
|
|
||||||
# [('production_id', '=', workorder.production_id.id),
|
|
||||||
# ('processing_panel', '=', workorder.processing_panel),
|
|
||||||
# ('routing_type', '=', 'CNC加工'), ('state', 'in', ['pending'])])
|
|
||||||
# unclamp_workorder = self.env['mrp.workorder'].search(
|
|
||||||
# [('production_id', '=', workorder.production_id.id),
|
|
||||||
# ('sequence', '=', workorder.sequence - 1),
|
|
||||||
# ('state', 'in', ['done'])])
|
|
||||||
# if workorder.state not in ['cancel', 'progress', 'rework']:
|
|
||||||
# if workorder.production_id.state == 'rework':
|
|
||||||
# if workorder.routing_type == '装夹预调':
|
|
||||||
# # # 有返工工单
|
|
||||||
# # if re_work:
|
|
||||||
# # 新工单
|
|
||||||
# if workorder.is_rework is False:
|
|
||||||
# if (workorder.production_id.programming_state == '已编程'
|
|
||||||
# and workorder.production_id.is_rework is False):
|
|
||||||
# if re_work or cnc_workorder:
|
|
||||||
# workorder.state = 'ready'
|
|
||||||
# else:
|
|
||||||
# if workorder.production_id.is_rework is True:
|
|
||||||
# if re_work or cnc_workorder:
|
|
||||||
# workorder.state = 'waiting'
|
|
||||||
#
|
|
||||||
# elif workorder.routing_type == 'CNC加工':
|
|
||||||
# pre_workorder = self.env['mrp.workorder'].search(
|
|
||||||
# [('production_id', '=', workorder.production_id.id),
|
|
||||||
# ('processing_panel', '=', workorder.processing_panel),
|
|
||||||
# ('routing_type', '=', '装夹预调'), ('state', '=', 'done')])
|
|
||||||
# if pre_workorder:
|
|
||||||
# if re_work:
|
|
||||||
# workorder.state = 'waiting'
|
|
||||||
# elif workorder.routing_type == '解除装夹':
|
|
||||||
# if cnc_workorder:
|
|
||||||
# if not cnc_workorder_pending or unclamp_workorder.test_results == '报废':
|
|
||||||
# workorder.state = 'waiting'
|
|
||||||
# # else:
|
|
||||||
# # if workorder.production_id.is_rework is True:
|
|
||||||
# # workorder.state = 'waiting'
|
|
||||||
# elif workorder.production_id.state == 'progress':
|
|
||||||
# if (workorder.routing_type == '装夹预调' and workorder.production_id.programming_state == '已编程'
|
|
||||||
# and workorder.is_rework is False and workorder.state not in ['done', 'rework', 'cancel']):
|
|
||||||
# if workorder.production_id.is_rework is False:
|
|
||||||
# if re_work or cnc_workorder or unclamp_workorder:
|
|
||||||
# workorder.state = 'ready'
|
|
||||||
# # if (re_work or cnc_workorder) and workorder.production_id.is_rework is False:
|
|
||||||
# # workorder.state = 'ready'
|
|
||||||
# elif workorder.production_id.state == 'scrap':
|
|
||||||
# if workorder.routing_type == '解除装夹' and unclamp_workorder.test_results == '报废':
|
|
||||||
# workorder.state = 'waiting'
|
|
||||||
|
|
||||||
# 重写工单开始按钮方法
|
# 重写工单开始按钮方法
|
||||||
def button_start(self):
|
def button_start(self):
|
||||||
|
|||||||
@@ -50,12 +50,6 @@ class PurchaseOrder(models.Model):
|
|||||||
for workorder in workorders:
|
for workorder in workorders:
|
||||||
if workorder.routing_type == '表面工艺' and workorder.is_subcontract is True:
|
if workorder.routing_type == '表面工艺' and workorder.is_subcontract is True:
|
||||||
move_out = workorder.move_subcontract_workorder_ids[1]
|
move_out = workorder.move_subcontract_workorder_ids[1]
|
||||||
# move_out = self.env['stock.move'].search(
|
|
||||||
# [('location_id', '=', self.env['stock.location'].search(
|
|
||||||
# [('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
|
|
||||||
# ('location_dest_id', '=', self.env['stock.location'].search(
|
|
||||||
# [('barcode', 'ilike', 'VL-SPOC')]).id),
|
|
||||||
# ('origin', '=', self.production_id.name), ('state', 'not in', ['cancel', 'done'])])
|
|
||||||
for mo in move_out:
|
for mo in move_out:
|
||||||
if mo.state != 'done':
|
if mo.state != 'done':
|
||||||
mo.write({'state': 'assigned', 'production_id': False})
|
mo.write({'state': 'assigned', 'production_id': False})
|
||||||
|
|||||||
@@ -395,6 +395,23 @@ class RePurchaseOrder(models.Model):
|
|||||||
production = self.env['mrp.production'].search([('name', '=', production_name)])
|
production = self.env['mrp.production'].search([('name', '=', production_name)])
|
||||||
for workorder in production.workorder_ids.filtered(
|
for workorder in production.workorder_ids.filtered(
|
||||||
lambda wd: wd.routing_type == '表面工艺' and wd.state == 'waiting' and line.product_id.server_product_process_parameters_id == wd.surface_technics_parameters_id):
|
lambda wd: wd.routing_type == '表面工艺' and wd.state == 'waiting' and line.product_id.server_product_process_parameters_id == wd.surface_technics_parameters_id):
|
||||||
|
work_ids = workorder.production_id.workorder_ids.filtered(
|
||||||
|
lambda wk: wk.state not in ['done', 'rework', 'cancel'])
|
||||||
|
min_sequence_wk = min(work_ids, key=lambda wk: wk.sequence)
|
||||||
|
artificial_offline = (
|
||||||
|
workorder.production_id.production_type == '人工线下加工' and workorder.production_id.schedule_state != '已排')
|
||||||
|
auto_production = (
|
||||||
|
workorder.production_id.production_type == '自动化产线加工' and workorder.production_id.schedule_state != '已编程')
|
||||||
|
if workorder.sequence == min_sequence_wk.sequence:
|
||||||
|
if artificial_offline or auto_production:
|
||||||
|
raise UserError('等待组件')
|
||||||
|
else:
|
||||||
|
sorted_work_ids = work_ids.sorted(key=lambda w: w.sequence)
|
||||||
|
previous_workorder = self.env['mrp.workorder'].search([('sequence', '<', workorder.sequence),
|
||||||
|
('production_id', '=', workorder.production_id.id),
|
||||||
|
('state', '=', 'done')], order='sequence desc', limit=1)
|
||||||
|
if not previous_workorder:
|
||||||
|
raise UserError('等待组件')
|
||||||
workorder.state = 'ready'
|
workorder.state = 'ready'
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@@ -427,6 +444,7 @@ class PurchaseOrderLine(models.Model):
|
|||||||
part_name = fields.Char('零件名称', related='product_id.part_name', readonly=True)
|
part_name = fields.Char('零件名称', related='product_id.part_name', readonly=True)
|
||||||
# part_number = fields.Char('零件图号',related='product_id.part_number', readonly=True)
|
# part_number = fields.Char('零件图号',related='product_id.part_number', readonly=True)
|
||||||
|
|
||||||
|
|
||||||
class ResPartnerToSale(models.Model):
|
class ResPartnerToSale(models.Model):
|
||||||
_inherit = 'res.partner'
|
_inherit = 'res.partner'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user