外协流程更改
This commit is contained in:
@@ -343,6 +343,11 @@ class RePurchaseOrder(models.Model):
|
||||
if order_line.product_id.id in product_list:
|
||||
purchase.purchase_type = 'outsourcing'
|
||||
break
|
||||
request_lines = self.order_line.mapped('purchase_request_lines')
|
||||
# 检查是否存在 is_subcontract 为 True 的行
|
||||
if any(line.is_subcontract for line in request_lines):
|
||||
purchase.purchase_type = 'consignment'
|
||||
|
||||
|
||||
delivery_warning = fields.Selection([('normal', '正常'), ('warning', '预警'), ('overdue', '已逾期')],
|
||||
string='交期状态', default='normal',
|
||||
@@ -379,15 +384,20 @@ class RePurchaseOrder(models.Model):
|
||||
def get_purchase_request(self, consecutive_process_parameters, production):
|
||||
result = []
|
||||
for pp in consecutive_process_parameters:
|
||||
server_template = self.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=', pp.surface_technics_parameters_id.id),
|
||||
('detailed_type', '=', 'service')])
|
||||
result.append({
|
||||
"product_id": pp.product_id.id,
|
||||
"name": production.name,
|
||||
"product_id": server_template.product_variant_id.id,
|
||||
"name": production.procurement_group_id.name,
|
||||
"date_required": fields.Datetime.now(),
|
||||
"product_uom_id":pp.product_id.uom_po_id.id,
|
||||
"product_uom_id":server_template.uom_id.id,
|
||||
"product_qty": 1,
|
||||
"request_id": False,
|
||||
"move_dest_ids": False,
|
||||
"orderpoint_id": False,
|
||||
'is_subcontract':True,
|
||||
'group_id':production.procurement_group_id.id,
|
||||
})
|
||||
return result
|
||||
|
||||
@@ -411,14 +421,14 @@ class RePurchaseOrder(models.Model):
|
||||
'manual_part_name': pp.part_name,
|
||||
}))
|
||||
# 获取服务商品最后一个供应商的采购员
|
||||
purchase_user_id = server_template.seller_ids[-1].partner_id.purchase_user_id
|
||||
purchase_user_id = server_template.seller_ids[-1].partner_id.purchase_user_id if server_template.seller_ids else False
|
||||
purchase_order = self.env['purchase.order'].sudo().create({
|
||||
'partner_id': server_template.seller_ids[0].partner_id.id,
|
||||
'partner_id': server_template.seller_ids[0].partner_id.id if server_template.seller_ids else False,
|
||||
'origin': production.name,
|
||||
'state': 'draft',
|
||||
'purchase_type': 'consignment',
|
||||
'order_line': server_product_process,
|
||||
'user_id': purchase_user_id.id
|
||||
'user_id': purchase_user_id.id if purchase_user_id else False,
|
||||
})
|
||||
purchase_order.order_line._compute_part_number()
|
||||
pp.purchase_id = [(6, 0, [purchase_order.id])]
|
||||
|
||||
Reference in New Issue
Block a user