外协工艺合并采购单处理
This commit is contained in:
@@ -287,18 +287,15 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
# if technology_design.is_auto is False:
|
# if technology_design.is_auto is False:
|
||||||
# domain = [('origin', '=', order.production_id.name)]
|
# domain = [('origin', '=', order.production_id.name)]
|
||||||
# else:
|
# else:
|
||||||
domain = [('purchase_type', '=', 'consignment'), ('origin', '=', order.production_id.name),
|
domain = [('purchase_type', '=', 'consignment'), ('origin', 'like', '%' + self.production_id.name + '%'),
|
||||||
('state', '!=', 'cancel')]
|
('state', '!=', 'cancel')]
|
||||||
purchase = self.env['purchase.order'].search(domain)
|
purchase = self.env['purchase.order'].search(domain)
|
||||||
purchase_num = 0
|
purchase_num = 0
|
||||||
if not purchase:
|
if not purchase:
|
||||||
order.surface_technics_purchase_count = 0
|
order.surface_technics_purchase_count = 0
|
||||||
for po in purchase:
|
for po in purchase:
|
||||||
for line in po.order_line:
|
if all(line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id for line in po.order_line):
|
||||||
if line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id:
|
order.surface_technics_purchase_count = 1
|
||||||
if line.product_qty == 1:
|
|
||||||
purchase_num += 1
|
|
||||||
order.surface_technics_purchase_count = purchase_num
|
|
||||||
else:
|
else:
|
||||||
order.surface_technics_purchase_count = 0
|
order.surface_technics_purchase_count = 0
|
||||||
|
|
||||||
@@ -1062,13 +1059,20 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
purchase_orders_id = self._get_surface_technics_purchase_ids()
|
purchase_orders_id = self._get_surface_technics_purchase_ids()
|
||||||
if purchase_orders_id.state == 'purchase':
|
if purchase_orders_id.state == 'purchase':
|
||||||
workorder.state = 'ready'
|
workorder.state = 'ready'
|
||||||
|
move_out = workorder.move_subcontract_workorder_ids[1]
|
||||||
|
for mo in move_out:
|
||||||
|
if mo.state != 'done':
|
||||||
|
mo.write({'state': 'assigned', 'production_id': False})
|
||||||
|
if not mo.move_line_ids:
|
||||||
|
self.env['stock.move.line'].create(
|
||||||
|
mo.get_move_line(workorder.production_id, workorder))
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
workorder.state = 'waiting'
|
workorder.state = 'waiting'
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
workorder.state = 'ready'
|
workorder.state = 'ready'
|
||||||
continue
|
continue
|
||||||
# ================= 如果制造订单刀具状态为[无效刀、缺刀] 或者 制造订单状态为[返工]==========================
|
# ================= 如果制造订单刀具状态为[无效刀、缺刀] 或者 制造订单状态为[返工]==========================
|
||||||
if (workorder.production_id.tool_state in ['1', '2'] or workorder.production_id.state == 'rework'
|
if (workorder.production_id.tool_state in ['1', '2'] or workorder.production_id.state == 'rework'
|
||||||
or workorder.production_id.schedule_state != '已排'
|
or workorder.production_id.schedule_state != '已排'
|
||||||
@@ -1091,12 +1095,22 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
if workorder.is_subcontract is False:
|
if workorder.is_subcontract is False:
|
||||||
workorder.state = 'ready'
|
workorder.state = 'ready'
|
||||||
else:
|
else:
|
||||||
purchase_orders_id = self._get_surface_technics_purchase_ids()
|
if len(workorder.production_id.picking_ids.filtered(
|
||||||
if purchase_orders_id:
|
lambda w: w.state not in ['done',
|
||||||
workorder.state = 'ready' if purchase_orders_id.state == 'purchase' else 'waiting'
|
'cancel'])) == 0 and workorder.production_id.programming_state == '已编程':
|
||||||
else:
|
purchase_orders_id = self._get_surface_technics_purchase_ids()
|
||||||
workorder.state = 'waiting'
|
if purchase_orders_id:
|
||||||
|
if purchase_orders_id.state == 'purchase':
|
||||||
|
workorder.state = 'ready'
|
||||||
|
move_out = workorder.move_subcontract_workorder_ids[1]
|
||||||
|
for mo in move_out:
|
||||||
|
if mo.state != 'done':
|
||||||
|
mo.write({'state': 'assigned', 'production_id': False})
|
||||||
|
if not mo.move_line_ids:
|
||||||
|
self.env['stock.move.line'].create(
|
||||||
|
mo.get_move_line(workorder.production_id, workorder))
|
||||||
|
else:
|
||||||
|
workorder.state = 'waiting'
|
||||||
# 重写工单开始按钮方法
|
# 重写工单开始按钮方法
|
||||||
def button_start(self):
|
def button_start(self):
|
||||||
# 判断工单状态是否为等待组件
|
# 判断工单状态是否为等待组件
|
||||||
|
|||||||
@@ -44,18 +44,18 @@ class PurchaseOrder(models.Model):
|
|||||||
production_id = self.env['mrp.production'].search([('origin', 'in', origins)])
|
production_id = self.env['mrp.production'].search([('origin', 'in', origins)])
|
||||||
purchase.production_count = len(production_id)
|
purchase.production_count = len(production_id)
|
||||||
|
|
||||||
def button_confirm(self):
|
# def button_confirm(self):
|
||||||
super().button_confirm()
|
# super().button_confirm()
|
||||||
workorders = self.env['mrp.workorder'].search([('purchase_id', '=', self.id), ('state', '!=', 'cancel')])
|
# workorders = self.env['mrp.workorder'].search([('purchase_id', '=', self.id), ('state', '!=', 'cancel')])
|
||||||
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]
|
||||||
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})
|
||||||
if not mo.move_line_ids:
|
# if not mo.move_line_ids:
|
||||||
self.env['stock.move.line'].create(mo.get_move_line(workorder.production_id, workorder))
|
# self.env['stock.move.line'].create(mo.get_move_line(workorder.production_id, workorder))
|
||||||
return True
|
# return True
|
||||||
|
|
||||||
origin_sale_id = fields.Many2one('sale.order', string='销售订单号', store=True, compute='_compute_origin_sale_id')
|
origin_sale_id = fields.Many2one('sale.order', string='销售订单号', store=True, compute='_compute_origin_sale_id')
|
||||||
origin_sale_ids = fields.Many2many('sale.order', string='销售订单号(多个)', store=True,
|
origin_sale_ids = fields.Many2many('sale.order', string='销售订单号(多个)', store=True,
|
||||||
|
|||||||
Reference in New Issue
Block a user