优化销售订单确认方法
This commit is contained in:
@@ -14,6 +14,25 @@ class StatusChange(models.Model):
|
||||
def action_confirm(self):
|
||||
# 在原有方法执行前记录日志和执行其他操作
|
||||
logging.info('函数已经执行=============')
|
||||
for order in self.order_lines:
|
||||
for item in order.product_template_id.model_process_parameters_ids:
|
||||
server_product = self.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=', item.surface_technics_parameters_id.id),
|
||||
('detailed_type', '=', 'service')])
|
||||
logging.info('server_product:%s' % server_product.name)
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user