创建制造订单后生成询价单
This commit is contained in:
@@ -18,6 +18,7 @@ class StatusChange(models.Model):
|
||||
server_product_none = []
|
||||
for order in self.order_line:
|
||||
for item in order.product_template_id.model_process_parameters_ids:
|
||||
if item.gain_way == '外协':
|
||||
server_product = self.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=', item.id),
|
||||
('detailed_type', '=', 'service')])
|
||||
@@ -25,25 +26,6 @@ class StatusChange(models.Model):
|
||||
server_product_none.append(item.name)
|
||||
if server_product_none:
|
||||
raise UserError(_("请先至产品中创建表面工艺参数为%s的服务产品", ", ".join(server_product_none)))
|
||||
|
||||
# if not server_product_none:
|
||||
# for st_item in order.product_template_id.model_process_parameters_ids:
|
||||
# server_product = self.env['product.template'].search(
|
||||
# [('server_product_process_parameters_id', '=', st_item.surface_technics_parameters_id.id),
|
||||
# ('detailed_type', '=', 'service')])
|
||||
# if server_product:
|
||||
# order_line_ids.append((0, 0, {
|
||||
# 'product_id': server_product.product_variant_id.id,
|
||||
# 'product_qty': 1,
|
||||
# 'product_uom': server_product.uom_id.id
|
||||
# }))
|
||||
# self.env['purchase.order'].sudo().create({
|
||||
# 'partner_id': server_product.seller_ids.partner_id.id,
|
||||
# 'origin': record.production_id.name,
|
||||
# 'state': 'draft',
|
||||
# 'order_line': order_line_ids,
|
||||
# })
|
||||
|
||||
# 使用super()来调用原始方法(在本例中为'sale.order'模型的'action_confirm'方法)
|
||||
res = super(StatusChange, self).action_confirm()
|
||||
|
||||
|
||||
@@ -272,21 +272,27 @@ class StockRule(models.Model):
|
||||
product_id_to_production_names[product_id] = [production.name for production in all_production]
|
||||
for production_item in productions:
|
||||
if production_item.product_id.id in product_id_to_production_names:
|
||||
for st_item in production_item.product_id.model_process_parameters_ids:
|
||||
purchase_order = self.env['purchase.order'].search([('state','=','draft'),('origin','ilike',production_item.name)])
|
||||
for po in purchase_order.order_line:
|
||||
for pp in po.product_id.model_process_parameters_ids:
|
||||
purchase_order = self.env['purchase.order'].search(
|
||||
[('state', '=', 'draft'), ('origin', 'ilike', production_item.name)])
|
||||
# for po in purchase_order.order_line:
|
||||
for pp in production_item.product_id.model_process_parameters_ids:
|
||||
if pp.gain_way == '外协':
|
||||
purchase_order_line = self.env['purchase.order.line'].search(
|
||||
[('order_id', '=', po.order_id)])
|
||||
if not purchase_order_line:
|
||||
server_product = self.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=', pp.id),
|
||||
('detailed_type', '=', 'service')])
|
||||
production_process = product_id_to_production_names.get(
|
||||
production_item.product_id.id)
|
||||
order_line_ids.append((0, 0, {
|
||||
'product_id': server_product.product_variant_id.id,
|
||||
'product_qty': "同一个产品的制造订单数量",
|
||||
'product_qty': len(production_process),
|
||||
'product_uom': server_product.uom_id.id
|
||||
}))
|
||||
self.env['purchase.order'].sudo().create({
|
||||
'partner_id': server_product.seller_ids.partner_id.id,
|
||||
'origin': "同一个产品的制造订单名称",
|
||||
'origin': ','.join(production_process),
|
||||
'state': 'draft',
|
||||
'order_line': order_line_ids,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user