优化工单

This commit is contained in:
jinling.yang
2024-11-13 17:59:47 +08:00
parent ff072a32bb
commit 33a1837274
7 changed files with 214 additions and 166 deletions

View File

@@ -259,7 +259,8 @@ class MrpProduction(models.Model):
# 退回调整
def technology_back_adjust(self):
domain = [('state', '=', 'confirmed')]
process_parameters = []
domain = [('state', '=', 'confirmed'), ('origin', '=', self.origin)]
if self.production_type == '自动化产线加工':
cloud_programming = self._cron_get_programming_state()
if cloud_programming['send_state'] == 'sending':
@@ -267,6 +268,15 @@ class MrpProduction(models.Model):
domain += [('programming_no', '=', self.programming_no)]
# 带排程的制造订单
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:
return {
'name': _('退回调整'),
@@ -284,20 +294,19 @@ class MrpProduction(models.Model):
process_parameters = []
account_moves = []
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:
if special.process_parameters_id and special.active is True:
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 special.active is False:
purchase = self.env['purchase.order'].search([('origin', '=', special.production_id.name)])
account = self.env['account.move'].search([('id', 'in', purchase.invoice_ids)])
if account.state != 'cancel':
if purchase.name not in account_moves:
account_moves.append(purchase.name)
purchase = self.env['purchase.order'].search([('origin', '=', special.production_id.name)])
account = self.env['account.move'].search([('id', 'in', purchase.invoice_ids)])
if account.state not in ['cancel', False]:
if purchase.name not in account_moves:
account_moves.append(purchase.name)
if account_moves:
raise UserError(_("请联系工厂生产经理对采购订单为%s生成的账单进行取消", ", ".join(account_moves)))
if process_parameters:
@@ -312,8 +321,8 @@ class MrpProduction(models.Model):
next_index = index + 1
next_design = technology_design[next_index]
next_design_routing_type = next_design.route_id.routing_type
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' % (design.route_id.name, design.panel))
# logging.info('下一个工序和加工面: %s-%s' % (next_design.route_id.name, next_design.panel))
if design.panel is not False:
if design.panel != next_design.panel:
if index == 0:
@@ -580,19 +589,13 @@ class MrpProduction(models.Model):
}]
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 ['表面工艺']:
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str(production, route))
else:
product_production_process = self.env['product.template'].search(
[('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(
self.env[
'mrp.workorder']._json_workorder_surface_process_str(
@@ -606,6 +609,27 @@ class MrpProduction(models.Model):
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str('', production, route_embryo))
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(
[('surface_technics_parameters_id', '!=', False), ('production_id', '=', production.id),
('is_subcontract', '=', True)])
@@ -651,8 +675,6 @@ class MrpProduction(models.Model):
self.env['stock.picking'].create_outcontract_picking(sorted_workorders, production)
else:
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):

View File

@@ -148,7 +148,7 @@ class ResMrpWorkOrder(models.Model):
def _compute_surface_technics_picking_ids(self):
for workorder in self:
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(
[('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'),
('production_id', '=', workorder.production_id.id)])
@@ -339,7 +339,7 @@ class ResMrpWorkOrder(models.Model):
@api.constrains('blocked_by_workorder_ids')
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']:
if not self._check_m2m_recursion('blocked_by_workorder_ids'):
raise ValidationError(_("您不能创建周期性的依赖关系."))
@@ -351,8 +351,9 @@ class ResMrpWorkOrder(models.Model):
for workorder in self.blocked_by_workorder_ids:
if workorder.state in ['done', 'cancel', 'rework']:
continue
workorder._plan_workorder(replan)
start_date = max(start_date, workorder.date_planned_finished)
if workorder.production_id.state not in ['technology_to_confirmed', 'confirmed']:
workorder._plan_workorder(replan)
start_date = max(start_date, workorder.date_planned_finished)
# Plan only suitable workorders
if self.state not in ['pending', 'waiting', 'ready']:
return
@@ -909,8 +910,34 @@ class ResMrpWorkOrder(models.Model):
@api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state',
'production_id.tool_state')
def _compute_state(self):
super()._compute_state()
# super()._compute_state()
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),
('processing_panel', '=', workorder.processing_panel),
('is_rework', '=', True), ('state', 'in', ['done', 'rework'])])
@@ -990,68 +1017,68 @@ class ResMrpWorkOrder(models.Model):
elif workorder.production_id.state == 'scrap':
if workorder.routing_type == '解除装夹' and unclamp_workorder.test_results == '报废':
workorder.state = 'waiting'
if workorder.routing_type == '装夹预调' and workorder.state in ['waiting', 'ready', 'pending']:
workorder_ids = workorder.production_id.workorder_ids
work_bo = True
for wo in workorder_ids.filtered(lambda a: a.routing_type == '装夹预调' and a.state == 'rework'):
if not workorder_ids.filtered(
lambda a: (a.routing_type == '装夹预调' and a.state not in ['rework', 'cancel']
and a.processing_panel == wo.processing_panel)):
work_bo = False
break
if (workorder.production_id.programming_state == '已编程' and work_bo
and not workorder_ids.filtered(lambda a: a.sequence == 0)):
# 当工单对应制造订单的功能刀具状态为 【无效刀】时,先对的第一个装夹预调工单状态设置为 【等待组件】
if workorder.production_id.tool_state in ['1', '2']:
if workorder.state in ['ready']:
workorder.state = 'waiting'
continue
elif workorder.state in ['waiting']:
continue
elif workorder.state == 'pending' and workorder == self.search(
[('production_id', '=', workorder.production_id.id),
('routing_type', '=', '装夹预调'),
('state', 'not in', ['rework', 'done', 'cancel'])],
limit=1,
order="sequence"):
workorder.state = 'waiting'
continue
elif workorder.production_id.tool_state in ['0']:
if workorder_ids.filtered(lambda a: a.state == 'rework'):
if not workorder_ids.filtered(
lambda a: (a.routing_type not in ['装夹预调'] and
a.state not in ['pending', 'done', 'rework', 'cancel'])):
# 查询工序最小的非完工、非返工的装夹预调工单
work_id = self.search(
[('production_id', '=', workorder.production_id.id),
('state', 'not in', ['rework', 'done', 'cancel'])],
limit=1,
order="sequence")
if work_id.routing_type == '装夹预调':
if workorder == work_id:
if workorder.production_id.reservation_state == 'assigned':
workorder.state = 'ready'
elif workorder.production_id.reservation_state != 'assigned':
workorder.state = 'waiting'
continue
elif (workorder.name == '装夹预调' and
workorder.state not in ['rework', 'done', 'cancel']):
if workorder.state != 'pending':
workorder.state = 'pending'
if workorder.production_id.tool_state in ['1', '2'] and workorder.state == 'ready':
workorder.state = 'waiting'
continue
if (workorder.production_id.tool_state in ['1', '2']
and not workorder.production_id.workorder_ids.filtered(lambda a: a.sequence == 0)
and workorder.production_id.programming_state == '编程中' and workorder.name == '装夹预调'):
if workorder.state == 'pending' and workorder == self.search(
[('production_id', '=', workorder.production_id.id),
('routing_type', '=', '装夹预调'),
('state', 'not in', ['rework', 'done', 'cancel'])],
limit=1,
order="sequence"):
workorder.state = 'waiting'
continue
# if workorder.routing_type == '装夹预调' and workorder.state in ['waiting', 'ready', 'pending']:
# workorder_ids = workorder.production_id.workorder_ids
# work_bo = True
# for wo in workorder_ids.filtered(lambda a: a.routing_type == '装夹预调' and a.state == 'rework'):
# if not workorder_ids.filtered(
# lambda a: (a.routing_type == '装夹预调' and a.state not in ['rework', 'cancel']
# and a.processing_panel == wo.processing_panel)):
# work_bo = False
# break
# if (workorder.production_id.programming_state == '已编程' and work_bo
# and not workorder_ids.filtered(lambda a: a.sequence == 0)):
# # 当工单对应制造订单的功能刀具状态为 【无效刀】时,先对的第一个装夹预调工单状态设置为 【等待组件】
# if workorder.production_id.tool_state in ['1', '2']:
# if workorder.state in ['ready']:
# workorder.state = 'waiting'
# continue
# elif workorder.state in ['waiting']:
# continue
# elif workorder.state == 'pending' and workorder == self.search(
# [('production_id', '=', workorder.production_id.id),
# ('routing_type', '=', '装夹预调'),
# ('state', 'not in', ['rework', 'done', 'cancel'])],
# limit=1,
# order="sequence"):
# workorder.state = 'waiting'
# continue
# elif workorder.production_id.tool_state in ['0']:
# if workorder_ids.filtered(lambda a: a.state == 'rework'):
# if not workorder_ids.filtered(
# lambda a: (a.routing_type not in ['装夹预调'] and
# a.state not in ['pending', 'done', 'rework', 'cancel'])):
# # 查询工序最小的非完工、非返工的装夹预调工单
# work_id = self.search(
# [('production_id', '=', workorder.production_id.id),
# ('state', 'not in', ['rework', 'done', 'cancel'])],
# limit=1,
# order="sequence")
# if work_id.routing_type == '装夹预调':
# if workorder == work_id:
# if workorder.production_id.reservation_state == 'assigned':
# workorder.state = 'ready'
# elif workorder.production_id.reservation_state != 'assigned':
# workorder.state = 'waiting'
# continue
# elif (workorder.name == '装夹预调' and
# workorder.state not in ['rework', 'done', 'cancel']):
# if workorder.state != 'pending':
# workorder.state = 'pending'
# if workorder.production_id.tool_state in ['1', '2'] and workorder.state == 'ready':
# workorder.state = 'waiting'
# continue
# if (workorder.production_id.tool_state in ['1', '2']
# and not workorder.production_id.workorder_ids.filtered(lambda a: a.sequence == 0)
# and workorder.production_id.programming_state == '编程中' and workorder.name == '装夹预调'):
# if workorder.state == 'pending' and workorder == self.search(
# [('production_id', '=', workorder.production_id.id),
# ('routing_type', '=', '装夹预调'),
# ('state', 'not in', ['rework', 'done', 'cancel'])],
# limit=1,
# order="sequence"):
# workorder.state = 'waiting'
# continue
# 重写工单开始按钮方法
def button_start(self):

View File

@@ -683,7 +683,8 @@ class StockPicking(models.Model):
raise UserError(
_('该入库单对应的单号为%s的出库单还未完成,不能进行验证操作!' % move_out.picking_id.name))
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 move_out.move_line_ids.workorder_id.state == 'progress':
move_in = self.env['stock.move'].search(
@@ -701,42 +702,39 @@ class StockPicking(models.Model):
# 创建 外协出库入单
def create_outcontract_picking(self, sorted_workorders_arr, item):
m = 0
for sorted_workorders in sorted_workorders_arr:
# pick_ids = []
if m == 0:
outcontract_stock_move = self.env['stock.move'].search(
[('workorder_id', '=', sorted_workorders.id), ('production_id', '=', item.id)])
if not outcontract_stock_move:
new_picking = True
location_id = self.env['stock.location'].search(
[('barcode', 'ilike', 'VL-SPOC')]).id,
location_dest_id = self.env['stock.location'].search(
[('barcode', 'ilike', 'WH-PREPRODUCTION')]).id,
outcontract_picking_type_in = self.env.ref(
'sf_manufacturing.outcontract_picking_in').id,
outcontract_picking_type_out = self.env.ref(
'sf_manufacturing.outcontract_picking_out').id,
moves_out = self.env['stock.move'].sudo().create(
self.env['stock.move']._get_stock_move_values_Res(item, location_dest_id, location_id,
outcontract_picking_type_out))
picking_out = self.create(
moves_out._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCOUT/'))
# pick_ids.append(picking_out.id)
moves_out.write(
{'picking_id': picking_out.id, 'state': 'waiting', 'workorder_id': sorted_workorders.id})
moves_out._assign_picking_post_process(new=new_picking)
moves_in = self.env['stock.move'].sudo().create(
self.env['stock.move']._get_stock_move_values_Res(item, location_id, location_dest_id,
outcontract_picking_type_in))
picking_in = self.create(
moves_in._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCIN/'))
# pick_ids.append(picking_in.id)
moves_in.write(
{'picking_id': picking_in.id, 'state': 'waiting', 'workorder_id': sorted_workorders.id})
moves_in._assign_picking_post_process(new=new_picking)
m += 1
# sorted_workorders.write({'picking_ids': [(6, 0, pick_ids)]})
outcontract_stock_move = self.env['stock.move'].search(
[('workorder_id', '=', sorted_workorders.id), ('production_id', '=', item.id)])
if not outcontract_stock_move:
new_picking = True
location_id = self.env['stock.location'].search(
[('barcode', 'ilike', 'VL-SPOC')]).id,
location_dest_id = self.env['stock.location'].search(
[('barcode', 'ilike', 'WH-PREPRODUCTION')]).id,
outcontract_picking_type_in = self.env.ref(
'sf_manufacturing.outcontract_picking_in').id,
outcontract_picking_type_out = self.env.ref(
'sf_manufacturing.outcontract_picking_out').id,
moves_out = self.env['stock.move'].sudo().create(
self.env['stock.move']._get_stock_move_values_Res(item, location_dest_id, location_id,
outcontract_picking_type_out))
picking_out = self.create(
moves_out._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCOUT/'))
# pick_ids.append(picking_out.id)
moves_out.write(
{'picking_id': picking_out.id, 'state': 'waiting', 'workorder_id': sorted_workorders.id})
moves_out._assign_picking_post_process(new=new_picking)
moves_in = self.env['stock.move'].sudo().create(
self.env['stock.move']._get_stock_move_values_Res(item, location_id, location_dest_id,
outcontract_picking_type_in))
picking_in = self.create(
moves_in._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCIN/'))
# pick_ids.append(picking_in.id)
moves_in.write(
{'picking_id': picking_in.id, 'state': 'waiting', 'workorder_id': sorted_workorders.id})
moves_in._assign_picking_post_process(new=new_picking)
# sorted_workorders.write({'picking_ids': [(6, 0, pick_ids)]})
class ReStockMove(models.Model):

View File

@@ -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_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_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 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
171
172
173
174
175
176
177
178
179

View File

@@ -1,10 +1,6 @@
# -*- coding: utf-8 -*-
# Part of YiZuo. See LICENSE file for full copyright and licensing details.
import logging
from odoo.exceptions import UserError, ValidationError
from collections import defaultdict, namedtuple
from odoo.addons.stock.models.stock_rule import ProcurementException
from datetime import datetime
from itertools import groupby
from odoo import models, api, fields, _
@@ -18,58 +14,54 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
def confirm(self):
if self.is_technology_re_adjust is True:
domain = [('origin', '=', self.origin),('state', '=', 'confirmed')]
domain = [('origin', '=', self.origin), ('state', '=', 'confirmed')]
else:
domain = [('id', '=', self.production_id.id)]
productions = self.env['mrp.production'].search(domain)
workorders_values = []
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 = []
for item in special_design:
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)]
if item.process_parameters_id:
domain += [('surface_technics_parameters_id', '=', item.process_parameters_id)]
domain = [('production_id', '=', special.production_id.id)]
if special.process_parameters_id:
domain += [('surface_technics_parameters_id', '=', special.process_parameters_id.id)]
else:
domain += [('name', '=', item.route_id.name)]
domain += [('name', '=', special.route_id.name)]
workorder = self.env['mrp.workorder'].search(domain)
if workorder:
if workorder.state != 'cancel':
workorder.write({'state': 'cancel'})
workorder.picking_ids.write({'state': 'cancel'})
# workorder.picking_ids.
purchase_order = self.env['purchase.order'].search(
[('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:
purchase_order.write({'state': 'cancel'})
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 item.route_id.routing_type == '表面工艺':
if special.route_id.routing_type == '表面工艺':
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(
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[
0].partner_id.id))
if item.process_parameters_id.gain_way == '外协':
product_id_to_production_names = {}
# 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)
if special.process_parameters_id.gain_way == '外协':
special.production_id.get_subcontract_purchase()
else:
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str(self, item))
if workorders_values:
self.write({'workorder_ids': workorders_values})
self._reset_work_order_sequence()
self.env['mrp.workorder'].json_workorder_str(special.production_id, special))
if workorders_values:
productions.write({'workorder_ids': workorders_values})
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'

View File

@@ -1,10 +1,7 @@
# -*- coding: utf-8 -*-
# Part of YiZuo. See LICENSE file for full copyright and licensing details.
import logging
from odoo.exceptions import UserError, ValidationError
from collections import defaultdict, namedtuple
from odoo.addons.stock.models.stock_rule import ProcurementException
from datetime import datetime
from itertools import groupby
from odoo import models, api, fields, _
@@ -22,4 +19,13 @@ class ProductionTechnologyWizard(models.TransientModel):
else:
domain = [('id', '=', self.production_id.id)]
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'

View File

@@ -271,7 +271,7 @@ class RePurchaseOrder(models.Model):
}))
if server_product_process:
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),
'state': 'draft',
'purchase_type': 'consignment',