优化工单
This commit is contained in:
@@ -259,7 +259,8 @@ class MrpProduction(models.Model):
|
|||||||
|
|
||||||
# 退回调整
|
# 退回调整
|
||||||
def technology_back_adjust(self):
|
def technology_back_adjust(self):
|
||||||
domain = [('state', '=', 'confirmed')]
|
process_parameters = []
|
||||||
|
domain = [('state', '=', 'confirmed'), ('origin', '=', self.origin)]
|
||||||
if self.production_type == '自动化产线加工':
|
if self.production_type == '自动化产线加工':
|
||||||
cloud_programming = self._cron_get_programming_state()
|
cloud_programming = self._cron_get_programming_state()
|
||||||
if cloud_programming['send_state'] == 'sending':
|
if cloud_programming['send_state'] == 'sending':
|
||||||
@@ -267,6 +268,15 @@ class MrpProduction(models.Model):
|
|||||||
domain += [('programming_no', '=', self.programming_no)]
|
domain += [('programming_no', '=', self.programming_no)]
|
||||||
# 带排程的制造订单
|
# 带排程的制造订单
|
||||||
production_confirmed = self.env['mrp.production'].search(domain)
|
production_confirmed = self.env['mrp.production'].search(domain)
|
||||||
|
for special in production_confirmed.technology_design_ids:
|
||||||
|
if special.process_parameters_id:
|
||||||
|
product_production_process = self.env['product.template'].search(
|
||||||
|
[('server_product_process_parameters_id', '=', special.process_parameters_id.id)])
|
||||||
|
if not product_production_process:
|
||||||
|
if special.process_parameters_id not in process_parameters:
|
||||||
|
process_parameters.append(special.process_parameters_id.display_name)
|
||||||
|
if process_parameters:
|
||||||
|
raise UserError(_("【工艺设计】-【参数】为%s的在【产品】中不存在,请先创建", ", ".join(process_parameters)))
|
||||||
if production_confirmed:
|
if production_confirmed:
|
||||||
return {
|
return {
|
||||||
'name': _('退回调整'),
|
'name': _('退回调整'),
|
||||||
@@ -284,18 +294,17 @@ class MrpProduction(models.Model):
|
|||||||
process_parameters = []
|
process_parameters = []
|
||||||
account_moves = []
|
account_moves = []
|
||||||
special_design = self.technology_design_ids.filtered(
|
special_design = self.technology_design_ids.filtered(
|
||||||
lambda a: a.routing_tag == 'special' and a.active in [True, False] and special.is_auto is False)
|
lambda a: a.routing_tag == 'special' and a.is_auto is False)
|
||||||
for special in special_design:
|
for special in special_design:
|
||||||
if special.process_parameters_id and special.active is True:
|
if special.process_parameters_id:
|
||||||
product_production_process = self.env['product.template'].search(
|
product_production_process = self.env['product.template'].search(
|
||||||
[('server_product_process_parameters_id', '=', special.process_parameters_id.id)])
|
[('server_product_process_parameters_id', '=', special.process_parameters_id.id)])
|
||||||
if not product_production_process:
|
if not product_production_process:
|
||||||
if special.process_parameters_id not in process_parameters:
|
if special.process_parameters_id not in process_parameters:
|
||||||
process_parameters.append(special.process_parameters_id.display_name)
|
process_parameters.append(special.process_parameters_id.display_name)
|
||||||
if special.active is False:
|
|
||||||
purchase = self.env['purchase.order'].search([('origin', '=', special.production_id.name)])
|
purchase = self.env['purchase.order'].search([('origin', '=', special.production_id.name)])
|
||||||
account = self.env['account.move'].search([('id', 'in', purchase.invoice_ids)])
|
account = self.env['account.move'].search([('id', 'in', purchase.invoice_ids)])
|
||||||
if account.state != 'cancel':
|
if account.state not in ['cancel', False]:
|
||||||
if purchase.name not in account_moves:
|
if purchase.name not in account_moves:
|
||||||
account_moves.append(purchase.name)
|
account_moves.append(purchase.name)
|
||||||
if account_moves:
|
if account_moves:
|
||||||
@@ -312,8 +321,8 @@ class MrpProduction(models.Model):
|
|||||||
next_index = index + 1
|
next_index = index + 1
|
||||||
next_design = technology_design[next_index]
|
next_design = technology_design[next_index]
|
||||||
next_design_routing_type = next_design.route_id.routing_type
|
next_design_routing_type = next_design.route_id.routing_type
|
||||||
logging.info('当前工序和加工面: %s-%s' % (design.route_id.name, design.panel))
|
# logging.info('当前工序和加工面: %s-%s' % (design.route_id.name, design.panel))
|
||||||
logging.info('下一个工序和加工面: %s-%s' % (next_design.route_id.name, next_design.panel))
|
# logging.info('下一个工序和加工面: %s-%s' % (next_design.route_id.name, next_design.panel))
|
||||||
if design.panel is not False:
|
if design.panel is not False:
|
||||||
if design.panel != next_design.panel:
|
if design.panel != next_design.panel:
|
||||||
if index == 0:
|
if index == 0:
|
||||||
@@ -580,19 +589,13 @@ class MrpProduction(models.Model):
|
|||||||
}]
|
}]
|
||||||
if production.product_id.categ_id.type == '成品':
|
if production.product_id.categ_id.type == '成品':
|
||||||
# # 根据工序设计生成工单
|
# # 根据工序设计生成工单
|
||||||
for route in item.technology_design_ids:
|
for route in production.technology_design_ids:
|
||||||
if route.route_id.routing_type not in ['表面工艺']:
|
if route.route_id.routing_type not in ['表面工艺']:
|
||||||
workorders_values.append(
|
workorders_values.append(
|
||||||
self.env['mrp.workorder'].json_workorder_str(production, route))
|
self.env['mrp.workorder'].json_workorder_str(production, route))
|
||||||
else:
|
else:
|
||||||
product_production_process = self.env['product.template'].search(
|
product_production_process = self.env['product.template'].search(
|
||||||
[('server_product_process_parameters_id', '=', route.process_parameters_id.id)])
|
[('server_product_process_parameters_id', '=', route.process_parameters_id.id)])
|
||||||
# if product_production_process:
|
|
||||||
# route_production_process = self.env[
|
|
||||||
# 'mrp.routing.workcenter'].search(
|
|
||||||
# [('surface_technics_id', '=', p.id),
|
|
||||||
# ('id', 'in', route_workcenter_arr)])
|
|
||||||
# if route_production_process:
|
|
||||||
workorders_values.append(
|
workorders_values.append(
|
||||||
self.env[
|
self.env[
|
||||||
'mrp.workorder']._json_workorder_surface_process_str(
|
'mrp.workorder']._json_workorder_surface_process_str(
|
||||||
@@ -606,6 +609,27 @@ class MrpProduction(models.Model):
|
|||||||
workorders_values.append(
|
workorders_values.append(
|
||||||
self.env['mrp.workorder'].json_workorder_str('', production, route_embryo))
|
self.env['mrp.workorder'].json_workorder_str('', production, route_embryo))
|
||||||
production.workorder_ids = workorders_values
|
production.workorder_ids = workorders_values
|
||||||
|
production.get_subcontract_pick()
|
||||||
|
for workorder in production.workorder_ids:
|
||||||
|
workorder.duration_expected = workorder._get_duration_expected()
|
||||||
|
|
||||||
|
# 生成采购单
|
||||||
|
def get_subcontract_purchase(self):
|
||||||
|
for production in self:
|
||||||
|
for special in production.technology_design_ids:
|
||||||
|
if special.process_parameters_id.gain_way == '外协':
|
||||||
|
product_id_to_production_names = {}
|
||||||
|
grouped_product_ids = {k: list(g) for k, g in
|
||||||
|
groupby(special.production_id, key=lambda x: x.product_id.id)}
|
||||||
|
for product_id, production in grouped_product_ids.items():
|
||||||
|
product_id_to_production_names[product_id] = [p.name for p in production]
|
||||||
|
self.env['purchase.order'].get_purchase_order(special.process_parameters_id,
|
||||||
|
special.production_id,
|
||||||
|
product_id_to_production_names)
|
||||||
|
|
||||||
|
# 外协出入库单处理
|
||||||
|
def get_subcontract_pick(self):
|
||||||
|
for production in self:
|
||||||
process_parameter_workorder = self.env['mrp.workorder'].search(
|
process_parameter_workorder = self.env['mrp.workorder'].search(
|
||||||
[('surface_technics_parameters_id', '!=', False), ('production_id', '=', production.id),
|
[('surface_technics_parameters_id', '!=', False), ('production_id', '=', production.id),
|
||||||
('is_subcontract', '=', True)])
|
('is_subcontract', '=', True)])
|
||||||
@@ -651,8 +675,6 @@ class MrpProduction(models.Model):
|
|||||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders, production)
|
self.env['stock.picking'].create_outcontract_picking(sorted_workorders, production)
|
||||||
else:
|
else:
|
||||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production)
|
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production)
|
||||||
for workorder in production.workorder_ids:
|
|
||||||
workorder.duration_expected = workorder._get_duration_expected()
|
|
||||||
|
|
||||||
# 工单排序
|
# 工单排序
|
||||||
def _reset_work_order_sequence1(self, k):
|
def _reset_work_order_sequence1(self, k):
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
def _compute_surface_technics_picking_ids(self):
|
def _compute_surface_technics_picking_ids(self):
|
||||||
for workorder in self:
|
for workorder in self:
|
||||||
if workorder.routing_type == '表面工艺':
|
if workorder.routing_type == '表面工艺':
|
||||||
domain = [('origin', '=', workorder.production_id.name)]
|
domain = [('origin', '=', workorder.production_id.name), ('state', 'not in', ['cancel'])]
|
||||||
previous_workorder = self.env['mrp.workorder'].search(
|
previous_workorder = self.env['mrp.workorder'].search(
|
||||||
[('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'),
|
[('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'),
|
||||||
('production_id', '=', workorder.production_id.id)])
|
('production_id', '=', workorder.production_id.id)])
|
||||||
@@ -339,7 +339,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
|
|
||||||
@api.constrains('blocked_by_workorder_ids')
|
@api.constrains('blocked_by_workorder_ids')
|
||||||
def _check_no_cyclic_dependencies(self):
|
def _check_no_cyclic_dependencies(self):
|
||||||
if self.production_id.state not in ['rework', 'technology_to_confirmed', 'pending_cam'] and self.state not in [
|
if self.production_id.state not in ['rework', 'technology_to_confirmed', 'confirmed'] and self.state not in [
|
||||||
'rework']:
|
'rework']:
|
||||||
if not self._check_m2m_recursion('blocked_by_workorder_ids'):
|
if not self._check_m2m_recursion('blocked_by_workorder_ids'):
|
||||||
raise ValidationError(_("您不能创建周期性的依赖关系."))
|
raise ValidationError(_("您不能创建周期性的依赖关系."))
|
||||||
@@ -351,6 +351,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
for workorder in self.blocked_by_workorder_ids:
|
for workorder in self.blocked_by_workorder_ids:
|
||||||
if workorder.state in ['done', 'cancel', 'rework']:
|
if workorder.state in ['done', 'cancel', 'rework']:
|
||||||
continue
|
continue
|
||||||
|
if workorder.production_id.state not in ['technology_to_confirmed', 'confirmed']:
|
||||||
workorder._plan_workorder(replan)
|
workorder._plan_workorder(replan)
|
||||||
start_date = max(start_date, workorder.date_planned_finished)
|
start_date = max(start_date, workorder.date_planned_finished)
|
||||||
# Plan only suitable workorders
|
# Plan only suitable workorders
|
||||||
@@ -909,8 +910,34 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
@api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state',
|
@api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state',
|
||||||
'production_id.tool_state')
|
'production_id.tool_state')
|
||||||
def _compute_state(self):
|
def _compute_state(self):
|
||||||
super()._compute_state()
|
# super()._compute_state()
|
||||||
for workorder in self:
|
for workorder in self:
|
||||||
|
logging.info(workorder.name)
|
||||||
|
logging.info(workorder.state)
|
||||||
|
logging.info(workorder.sequence)
|
||||||
|
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'
|
||||||
|
if workorder.state in ['waiting']:
|
||||||
|
previous_workorder = self.env['mrp.workorder'].search(
|
||||||
|
[('production_id', '=', workorder.production_id.id),
|
||||||
|
('sequence', '=', workorder.sequence - 1)])
|
||||||
|
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':
|
||||||
|
workorder.state = 'ready'
|
||||||
|
elif workorder.production_id.reservation_state != 'assigned' and workorder.state == 'ready':
|
||||||
|
workorder.state = 'waiting'
|
||||||
re_work = self.env['mrp.workorder'].search([('production_id', '=', workorder.production_id.id),
|
re_work = self.env['mrp.workorder'].search([('production_id', '=', workorder.production_id.id),
|
||||||
('processing_panel', '=', workorder.processing_panel),
|
('processing_panel', '=', workorder.processing_panel),
|
||||||
('is_rework', '=', True), ('state', 'in', ['done', 'rework'])])
|
('is_rework', '=', True), ('state', 'in', ['done', 'rework'])])
|
||||||
@@ -990,68 +1017,68 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
elif workorder.production_id.state == 'scrap':
|
elif workorder.production_id.state == 'scrap':
|
||||||
if workorder.routing_type == '解除装夹' and unclamp_workorder.test_results == '报废':
|
if workorder.routing_type == '解除装夹' and unclamp_workorder.test_results == '报废':
|
||||||
workorder.state = 'waiting'
|
workorder.state = 'waiting'
|
||||||
if workorder.routing_type == '装夹预调' and workorder.state in ['waiting', 'ready', 'pending']:
|
# if workorder.routing_type == '装夹预调' and workorder.state in ['waiting', 'ready', 'pending']:
|
||||||
workorder_ids = workorder.production_id.workorder_ids
|
# workorder_ids = workorder.production_id.workorder_ids
|
||||||
work_bo = True
|
# work_bo = True
|
||||||
for wo in workorder_ids.filtered(lambda a: a.routing_type == '装夹预调' and a.state == 'rework'):
|
# for wo in workorder_ids.filtered(lambda a: a.routing_type == '装夹预调' and a.state == 'rework'):
|
||||||
if not workorder_ids.filtered(
|
# if not workorder_ids.filtered(
|
||||||
lambda a: (a.routing_type == '装夹预调' and a.state not in ['rework', 'cancel']
|
# lambda a: (a.routing_type == '装夹预调' and a.state not in ['rework', 'cancel']
|
||||||
and a.processing_panel == wo.processing_panel)):
|
# and a.processing_panel == wo.processing_panel)):
|
||||||
work_bo = False
|
# work_bo = False
|
||||||
break
|
# break
|
||||||
if (workorder.production_id.programming_state == '已编程' and work_bo
|
# if (workorder.production_id.programming_state == '已编程' and work_bo
|
||||||
and not workorder_ids.filtered(lambda a: a.sequence == 0)):
|
# and not workorder_ids.filtered(lambda a: a.sequence == 0)):
|
||||||
# 当工单对应制造订单的功能刀具状态为 【无效刀】时,先对的第一个装夹预调工单状态设置为 【等待组件】
|
# # 当工单对应制造订单的功能刀具状态为 【无效刀】时,先对的第一个装夹预调工单状态设置为 【等待组件】
|
||||||
if workorder.production_id.tool_state in ['1', '2']:
|
# if workorder.production_id.tool_state in ['1', '2']:
|
||||||
if workorder.state in ['ready']:
|
# if workorder.state in ['ready']:
|
||||||
workorder.state = 'waiting'
|
# workorder.state = 'waiting'
|
||||||
continue
|
# continue
|
||||||
elif workorder.state in ['waiting']:
|
# elif workorder.state in ['waiting']:
|
||||||
continue
|
# continue
|
||||||
elif workorder.state == 'pending' and workorder == self.search(
|
# elif workorder.state == 'pending' and workorder == self.search(
|
||||||
[('production_id', '=', workorder.production_id.id),
|
# [('production_id', '=', workorder.production_id.id),
|
||||||
('routing_type', '=', '装夹预调'),
|
# ('routing_type', '=', '装夹预调'),
|
||||||
('state', 'not in', ['rework', 'done', 'cancel'])],
|
# ('state', 'not in', ['rework', 'done', 'cancel'])],
|
||||||
limit=1,
|
# limit=1,
|
||||||
order="sequence"):
|
# order="sequence"):
|
||||||
workorder.state = 'waiting'
|
# workorder.state = 'waiting'
|
||||||
continue
|
# continue
|
||||||
elif workorder.production_id.tool_state in ['0']:
|
# elif workorder.production_id.tool_state in ['0']:
|
||||||
if workorder_ids.filtered(lambda a: a.state == 'rework'):
|
# if workorder_ids.filtered(lambda a: a.state == 'rework'):
|
||||||
if not workorder_ids.filtered(
|
# if not workorder_ids.filtered(
|
||||||
lambda a: (a.routing_type not in ['装夹预调'] and
|
# lambda a: (a.routing_type not in ['装夹预调'] and
|
||||||
a.state not in ['pending', 'done', 'rework', 'cancel'])):
|
# a.state not in ['pending', 'done', 'rework', 'cancel'])):
|
||||||
# 查询工序最小的非完工、非返工的装夹预调工单
|
# # 查询工序最小的非完工、非返工的装夹预调工单
|
||||||
work_id = self.search(
|
# work_id = self.search(
|
||||||
[('production_id', '=', workorder.production_id.id),
|
# [('production_id', '=', workorder.production_id.id),
|
||||||
('state', 'not in', ['rework', 'done', 'cancel'])],
|
# ('state', 'not in', ['rework', 'done', 'cancel'])],
|
||||||
limit=1,
|
# limit=1,
|
||||||
order="sequence")
|
# order="sequence")
|
||||||
if work_id.routing_type == '装夹预调':
|
# if work_id.routing_type == '装夹预调':
|
||||||
if workorder == work_id:
|
# if workorder == work_id:
|
||||||
if workorder.production_id.reservation_state == 'assigned':
|
# if workorder.production_id.reservation_state == 'assigned':
|
||||||
workorder.state = 'ready'
|
# workorder.state = 'ready'
|
||||||
elif workorder.production_id.reservation_state != 'assigned':
|
# elif workorder.production_id.reservation_state != 'assigned':
|
||||||
workorder.state = 'waiting'
|
# workorder.state = 'waiting'
|
||||||
continue
|
# continue
|
||||||
elif (workorder.name == '装夹预调' and
|
# elif (workorder.name == '装夹预调' and
|
||||||
workorder.state not in ['rework', 'done', 'cancel']):
|
# workorder.state not in ['rework', 'done', 'cancel']):
|
||||||
if workorder.state != 'pending':
|
# if workorder.state != 'pending':
|
||||||
workorder.state = 'pending'
|
# workorder.state = 'pending'
|
||||||
if workorder.production_id.tool_state in ['1', '2'] and workorder.state == 'ready':
|
# if workorder.production_id.tool_state in ['1', '2'] and workorder.state == 'ready':
|
||||||
workorder.state = 'waiting'
|
# workorder.state = 'waiting'
|
||||||
continue
|
# continue
|
||||||
if (workorder.production_id.tool_state in ['1', '2']
|
# if (workorder.production_id.tool_state in ['1', '2']
|
||||||
and not workorder.production_id.workorder_ids.filtered(lambda a: a.sequence == 0)
|
# and not workorder.production_id.workorder_ids.filtered(lambda a: a.sequence == 0)
|
||||||
and workorder.production_id.programming_state == '编程中' and workorder.name == '装夹预调'):
|
# and workorder.production_id.programming_state == '编程中' and workorder.name == '装夹预调'):
|
||||||
if workorder.state == 'pending' and workorder == self.search(
|
# if workorder.state == 'pending' and workorder == self.search(
|
||||||
[('production_id', '=', workorder.production_id.id),
|
# [('production_id', '=', workorder.production_id.id),
|
||||||
('routing_type', '=', '装夹预调'),
|
# ('routing_type', '=', '装夹预调'),
|
||||||
('state', 'not in', ['rework', 'done', 'cancel'])],
|
# ('state', 'not in', ['rework', 'done', 'cancel'])],
|
||||||
limit=1,
|
# limit=1,
|
||||||
order="sequence"):
|
# order="sequence"):
|
||||||
workorder.state = 'waiting'
|
# workorder.state = 'waiting'
|
||||||
continue
|
# continue
|
||||||
|
|
||||||
# 重写工单开始按钮方法
|
# 重写工单开始按钮方法
|
||||||
def button_start(self):
|
def button_start(self):
|
||||||
|
|||||||
@@ -683,7 +683,8 @@ class StockPicking(models.Model):
|
|||||||
raise UserError(
|
raise UserError(
|
||||||
_('该入库单对应的单号为%s的出库单还未完成,不能进行验证操作!' % move_out.picking_id.name))
|
_('该入库单对应的单号为%s的出库单还未完成,不能进行验证操作!' % move_out.picking_id.name))
|
||||||
res = super().button_validate()
|
res = super().button_validate()
|
||||||
if res is True:
|
if res is True and self.picking_type_id:
|
||||||
|
|
||||||
if self.id == move_out.picking_id.id:
|
if self.id == move_out.picking_id.id:
|
||||||
# if move_out.move_line_ids.workorder_id.state == 'progress':
|
# if move_out.move_line_ids.workorder_id.state == 'progress':
|
||||||
move_in = self.env['stock.move'].search(
|
move_in = self.env['stock.move'].search(
|
||||||
@@ -701,10 +702,8 @@ class StockPicking(models.Model):
|
|||||||
|
|
||||||
# 创建 外协出库入单
|
# 创建 外协出库入单
|
||||||
def create_outcontract_picking(self, sorted_workorders_arr, item):
|
def create_outcontract_picking(self, sorted_workorders_arr, item):
|
||||||
m = 0
|
|
||||||
for sorted_workorders in sorted_workorders_arr:
|
for sorted_workorders in sorted_workorders_arr:
|
||||||
# pick_ids = []
|
# pick_ids = []
|
||||||
if m == 0:
|
|
||||||
outcontract_stock_move = self.env['stock.move'].search(
|
outcontract_stock_move = self.env['stock.move'].search(
|
||||||
[('workorder_id', '=', sorted_workorders.id), ('production_id', '=', item.id)])
|
[('workorder_id', '=', sorted_workorders.id), ('production_id', '=', item.id)])
|
||||||
if not outcontract_stock_move:
|
if not outcontract_stock_move:
|
||||||
@@ -735,7 +734,6 @@ class StockPicking(models.Model):
|
|||||||
moves_in.write(
|
moves_in.write(
|
||||||
{'picking_id': picking_in.id, 'state': 'waiting', 'workorder_id': sorted_workorders.id})
|
{'picking_id': picking_in.id, 'state': 'waiting', 'workorder_id': sorted_workorders.id})
|
||||||
moves_in._assign_picking_post_process(new=new_picking)
|
moves_in._assign_picking_post_process(new=new_picking)
|
||||||
m += 1
|
|
||||||
# sorted_workorders.write({'picking_ids': [(6, 0, pick_ids)]})
|
# sorted_workorders.write({'picking_ids': [(6, 0, pick_ids)]})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -171,6 +171,9 @@ access_sf_technology_design_group_production_engineer,sf_technology_design_group
|
|||||||
access_sf_production_technology_wizard_group_plan_dispatch,sf_production_technology_wizard_group_plan_dispatch,model_sf_production_technology_wizard,sf_base.group_plan_dispatch,1,1,1,0
|
access_sf_production_technology_wizard_group_plan_dispatch,sf_production_technology_wizard_group_plan_dispatch,model_sf_production_technology_wizard,sf_base.group_plan_dispatch,1,1,1,0
|
||||||
access_sf_production_technology_wizard_group_sf_mrp_manager,sf_production_technology_wizard_group_sf_mrp_manager,model_sf_production_technology_wizard,sf_base.group_sf_mrp_manager,1,1,1,0
|
access_sf_production_technology_wizard_group_sf_mrp_manager,sf_production_technology_wizard_group_sf_mrp_manager,model_sf_production_technology_wizard,sf_base.group_sf_mrp_manager,1,1,1,0
|
||||||
access_sf_production_technology_wizard_group_production_engineer,sf_production_technology_wizard_group_production_engineer,model_sf_production_technology_wizard,sf_base.group_production_engineer,1,1,1,0
|
access_sf_production_technology_wizard_group_production_engineer,sf_production_technology_wizard_group_production_engineer,model_sf_production_technology_wizard,sf_base.group_production_engineer,1,1,1,0
|
||||||
|
access_sf_production_technology_re_adjust_wizard_group_plan_dispatch,sf_production_technology_re_adjust_wizard_group_plan_dispatch,model_sf_production_technology_re_adjust_wizard,sf_base.group_plan_dispatch,1,1,1,0
|
||||||
|
access_sf_production_technology_re_adjust_wizard_group_sf_mrp_manager,sf_production_technology_re_adjust_wizard_group_sf_mrp_manager,model_sf_production_technology_re_adjust_wizard,sf_base.group_sf_mrp_manager,1,1,1,0
|
||||||
|
access_sf_production_technology_re_adjust_wizard_group_production_engineer,sf_production_technology_re_adjust_wizard_group_production_engineer,model_sf_production_technology_re_adjust_wizard,sf_base.group_production_engineer,1,1,1,0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
|
@@ -1,10 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Part of YiZuo. See LICENSE file for full copyright and licensing details.
|
|
||||||
import logging
|
import logging
|
||||||
from odoo.exceptions import UserError, ValidationError
|
from itertools import groupby
|
||||||
from collections import defaultdict, namedtuple
|
|
||||||
from odoo.addons.stock.models.stock_rule import ProcurementException
|
|
||||||
from datetime import datetime
|
|
||||||
from odoo import models, api, fields, _
|
from odoo import models, api, fields, _
|
||||||
|
|
||||||
|
|
||||||
@@ -18,58 +14,54 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
|||||||
|
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
if self.is_technology_re_adjust is True:
|
if self.is_technology_re_adjust is True:
|
||||||
domain = [('origin', '=', self.origin),('state', '=', 'confirmed')]
|
domain = [('origin', '=', self.origin), ('state', '=', 'confirmed')]
|
||||||
else:
|
else:
|
||||||
domain = [('id', '=', self.production_id.id)]
|
domain = [('id', '=', self.production_id.id)]
|
||||||
productions = self.env['mrp.production'].search(domain)
|
productions = self.env['mrp.production'].search(domain)
|
||||||
for item in productions:
|
|
||||||
special_design = item.technology_design_ids.filtered(
|
|
||||||
lambda a: a.routing_tag == 'special' and a.is_auto is False and a.active in [True, False])
|
|
||||||
workorders_values = []
|
workorders_values = []
|
||||||
for item in special_design:
|
for item in productions:
|
||||||
if item.active is False:
|
special_design = self.env['sf.technology.design'].sudo().search(
|
||||||
|
[('routing_tag', '=', 'special'), ('production_id', '=', item.id),
|
||||||
|
('is_auto', '=', False), ('active', 'in', [True, False])])
|
||||||
|
for special in special_design:
|
||||||
|
if special.active is False:
|
||||||
# 工单采购单外协出入库单皆需取消
|
# 工单采购单外协出入库单皆需取消
|
||||||
domain = [('production_id', '=', item.id)]
|
domain = [('production_id', '=', special.production_id.id)]
|
||||||
if item.process_parameters_id:
|
if special.process_parameters_id:
|
||||||
domain += [('surface_technics_parameters_id', '=', item.process_parameters_id)]
|
domain += [('surface_technics_parameters_id', '=', special.process_parameters_id.id)]
|
||||||
else:
|
else:
|
||||||
domain += [('name', '=', item.route_id.name)]
|
domain += [('name', '=', special.route_id.name)]
|
||||||
workorder = self.env['mrp.workorder'].search(domain)
|
workorder = self.env['mrp.workorder'].search(domain)
|
||||||
if workorder:
|
if workorder.state != 'cancel':
|
||||||
workorder.write({'state': 'cancel'})
|
workorder.write({'state': 'cancel'})
|
||||||
workorder.picking_ids.write({'state': 'cancel'})
|
workorder.picking_ids.write({'state': 'cancel'})
|
||||||
|
# workorder.picking_ids.
|
||||||
purchase_order = self.env['purchase.order'].search(
|
purchase_order = self.env['purchase.order'].search(
|
||||||
[('origin', '=', workorder.production_id.origin)])
|
[('origin', '=', workorder.production_id.origin)])
|
||||||
for line in purchase.order_line:
|
for line in purchase_order.order_line:
|
||||||
if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id:
|
if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id:
|
||||||
purchase_order.write({'state': 'cancel'})
|
purchase_order.write({'state': 'cancel'})
|
||||||
|
|
||||||
else:
|
else:
|
||||||
workorder = self.env['mrp.workorder'].search([('name', '=', item.route_id.name)])
|
workorder = self.env['mrp.workorder'].search([('name', '=', special.route_id.display_name)])
|
||||||
if not workorder:
|
if not workorder:
|
||||||
if item.route_id.routing_type == '表面工艺':
|
if special.route_id.routing_type == '表面工艺':
|
||||||
product_production_process = self.env['product.template'].search(
|
product_production_process = self.env['product.template'].search(
|
||||||
[('server_product_process_parameters_id', '=', item.process_parameters_id.id)])
|
[('server_product_process_parameters_id', '=', special.process_parameters_id.id)])
|
||||||
workorders_values.append(
|
workorders_values.append(
|
||||||
self.env[
|
self.env[
|
||||||
'mrp.workorder']._json_workorder_surface_process_str(self, item,
|
'mrp.workorder']._json_workorder_surface_process_str(special.production_id, special,
|
||||||
product_production_process.seller_ids[
|
product_production_process.seller_ids[
|
||||||
0].partner_id.id))
|
0].partner_id.id))
|
||||||
if item.process_parameters_id.gain_way == '外协':
|
if special.process_parameters_id.gain_way == '外协':
|
||||||
product_id_to_production_names = {}
|
special.production_id.get_subcontract_purchase()
|
||||||
# grouped_product_ids = {k: list(g) for k, g in
|
|
||||||
# groupby(self, key=lambda x: x.product_id.id)}
|
|
||||||
|
|
||||||
product_id_to_production_names[self.product_id] = [production.name for production in self]
|
|
||||||
self.env['purchase.order'].get_purchase_order(item.process_parameters_id,
|
|
||||||
self,
|
|
||||||
product_id_to_production_names)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
workorders_values.append(
|
workorders_values.append(
|
||||||
self.env['mrp.workorder'].json_workorder_str(self, item))
|
self.env['mrp.workorder'].json_workorder_str(special.production_id, special))
|
||||||
|
|
||||||
if workorders_values:
|
if workorders_values:
|
||||||
self.write({'workorder_ids': workorders_values})
|
productions.write({'workorder_ids': workorders_values})
|
||||||
self._reset_work_order_sequence()
|
productions.get_subcontract_pick()
|
||||||
|
productions._reset_work_order_sequence()
|
||||||
|
for item in productions:
|
||||||
|
workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
||||||
|
key=lambda a: a.sequence)
|
||||||
|
workorder[0].state = 'waiting'
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Part of YiZuo. See LICENSE file for full copyright and licensing details.
|
# Part of YiZuo. See LICENSE file for full copyright and licensing details.
|
||||||
import logging
|
import logging
|
||||||
from odoo.exceptions import UserError, ValidationError
|
from itertools import groupby
|
||||||
from collections import defaultdict, namedtuple
|
|
||||||
from odoo.addons.stock.models.stock_rule import ProcurementException
|
|
||||||
from datetime import datetime
|
|
||||||
from odoo import models, api, fields, _
|
from odoo import models, api, fields, _
|
||||||
|
|
||||||
|
|
||||||
@@ -22,4 +19,13 @@ class ProductionTechnologyWizard(models.TransientModel):
|
|||||||
else:
|
else:
|
||||||
domain = [('id', '=', self.production_id.id)]
|
domain = [('id', '=', self.production_id.id)]
|
||||||
productions = self.env['mrp.production'].search(domain)
|
productions = self.env['mrp.production'].search(domain)
|
||||||
productions._create_workorder(self.production_id)
|
for production in productions:
|
||||||
|
special = production.technology_design_ids.filtered(
|
||||||
|
lambda td: td.is_auto is False and td.process_parameters_id is not False)
|
||||||
|
if special:
|
||||||
|
production.get_subcontract_purchase()
|
||||||
|
productions._create_workorder(False)
|
||||||
|
for item in productions:
|
||||||
|
workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
||||||
|
key=lambda a: a.sequence)
|
||||||
|
workorder[0].state = 'waiting'
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ class RePurchaseOrder(models.Model):
|
|||||||
}))
|
}))
|
||||||
if server_product_process:
|
if server_product_process:
|
||||||
self.env['purchase.order'].sudo().create({
|
self.env['purchase.order'].sudo().create({
|
||||||
'partner_id': server_template.seller_ids.partner_id.id,
|
'partner_id': server_template.seller_ids[0].partner_id.id,
|
||||||
'origin': ','.join(production_process),
|
'origin': ','.join(production_process),
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
'purchase_type': 'consignment',
|
'purchase_type': 'consignment',
|
||||||
|
|||||||
Reference in New Issue
Block a user